﻿// Jscript

$(document).ready(function(){});

var dotnetprefix = "ctl00_ContentPlaceHolder1_";

function doNav(num, action) {
    if (action == 'highlight') {
        $("#nav" + num).removeClass("nav_inactive");
        $("#nav" + num).addClass("nav_active");
    } else {
        $("#nav" + num).removeClass("nav_active");
        $("#nav" + num).addClass("nav_inactive");
    }
}

function ToggleButton(onoff) {
    //alert('hey');
    if (onoff==1) {
        $("#"+dotnetprefix+"btnSubmit").attr("src","images/get-free-ringtones-now.gif");
    } else {
        $("#"+dotnetprefix+"btnSubmit").attr("src","images/get-free-ringtones.gif");
    }
}

function ConfirmBox(url,msg){
	        var conf = confirm(msg + "\n" + url); 
	        if(conf){
		        window.location.href = url; 
	        }
        }


function ImgSrcToggle(id,opensrc,closesrc) {
    var curr = $("#"+id).attr("src");
    
    if (curr==opensrc) {
        $("#"+id).attr("src",closesrc);
        //$("#naviparent").show();
    } else {
        $("#"+id).attr("src",opensrc);
    }
}

function toggleCheckBoxes(startswith,chktotal) {
    var b;
    var sbool = $("#"+ startswith.toString() + 'All').attr("checked");    
    for (b=1;b<=chktotal;b++) {
        if (sbool==true) {
            $("#"+ startswith.toString() + b.toString()).attr("checked",true);
        } else {
            $("#"+ startswith.toString() + b.toString()).attr("checked",false);
        }
    }
}

function toggleAllOption(startswith,index,chktotal) { 
    // should you select all and then deselect one of the other options
    // the select all check box needs to be deselected
    var that;
    var blAllOptionsChecked = true;
    var isItChecked;
    
    for (b=1;b<=chktotal;b++) {
        isItChecked = $("#"+ startswith.toString() + b.toString()).attr("checked");
        if (isItChecked==false) {
            blAllOptionsChecked = false;
        }
    }
    
    that = $("#"+ startswith.toString() + index.toString()).attr("checked");
    
    if (that==false&&blAllOptionsChecked==false) {
        $("#"+ startswith.toString() + 'All').attr("checked",false);
    
    } else if (blAllOptionsChecked==true) {
        $("#"+ startswith.toString() + 'All').attr("checked",true);  
        toggleCheckBoxes(startswith,chktotal);
        
    }
        
}


function toggleFade(objid) {
    var sty = $("#"+objid).attr("style");
    if (sty==undefined) {
        $("#"+objid).fadeOut();
    } else {
        if (sty.indexOf('none')>0) {
            $("#"+objid).fadeIn();
        } else {
            $("#"+objid).fadeOut();
        }
    }
}

function Highlight(obj) {
    $(obj).attr("style","cursor:hand;background:#cccccc;");
}

function UnHighlight (obj,color) {
    $(obj).attr("style","background:"+color);
}

function scrollWin(scrolltoDivId) {
    $('html, body').animate({
        scrollTop: $("#"+scrolltoDivId).offset().top
    }, 2000);
}
function AnimateDiv(divid,fromNum,toNum,axis) {
    var currheight = $("#"+divid).height();
    var currwidth = $("#"+divid).width();
    
    //alert(navigator.userAgent);
    
    if (axis=='y') { 
        if (currheight==fromNum) {  // minimize height
            if (navigator.userAgent.indexOf("Firefox")>0) {
                $("#"+divid).attr("style","overflow-y:auto;overflow-x:hidden;height:" + toNum.toString() + "px");
            } else {
                $("#"+divid).animate({height: toNum},800); // minimize 
            }
            
        } else {                    // maximize height
            if (navigator.userAgent.indexOf("Firefox")>0) {
                $("#"+divid).attr("style","overflow-y:auto;overflow-x:hidden;height:" + fromNum.toString() + "px");
                if (divid=="navison") {
                    setTimeout("$('#navison').hide();",1300);
                }
            } else {
                $("#"+divid).animate({height: fromNum},800); 
                if (divid=="navison") {
                    setTimeout("$('#navison').fadeOut();",1300);
                }
            }
        }
    } else { 
        if (currwidth==fromNum) {   // maximize width
            if (navigator.userAgent.indexOf("Firefox")>0) { //
                $("#"+divid).attr("style","overflow-y:auto;overflow-x:hidden;width:" + toNum.toString() + "px");
            } else {
                $("#"+divid).animate({width: toNum},800);   
            }
            
        } else {                    // minimize width
            if (navigator.userAgent.indexOf("Firefox")>0) {
                $("#"+divid).attr("style","overflow-y:auto;overflow-x:hidden;width:" + fromNum.toString() + "px");
                if (divid=="navison") {
                    setTimeout("$('#navison').hide();",1300);
                }
            } else {
                $("#"+divid).animate({width: fromNum},800);
                if (divid=="navison") {
                    setTimeout("$('#navison').hide();",1300);
                }
            }
            
            
        }
    }
}

function LoadFrame(Frame,URL){
	$("#"+Frame).attr("src",URL);
}

function LoadFrameParent(Frame,URL){
	if (navigator.userAgent.indexOf("Firefox")>0){
	    parent.document.getElementById(Frame).src=URL;
	} else {
	    parent.document[Frame].location.href=URL;}
}

function RemoveBackground() {$("#overlayBackground").remove();}
function AppendBackground() {
    var background = $('<div/>');
    $(background).attr("id", "overlayBackground").animate({"opacity" : '.8'}, 1000).css({"width" : $(document).width(),"height" : $(document).height()});
    $("body").append(background);
    $("body").append('</div>');
}   