﻿// Jscript

$(document).ready(function(){});

var ogch = 0; // original content height

function ShowProductID(ProductID) {
    currwinstyle = $("#divProductWindow").attr("style");
    if (currwinstyle.indexOf("ISPLAY: block") > 0 || currwinstyle.indexOf("ISPLAY: inline") > 0) { // close window
        $("#frmProductDetails").attr("src", "_blank.htm");
        $("#divProductWindow").fadeOut()
        RemoveBackground();
    } else { // open window
        $("#frmProductDetails").attr("src", "productdetails.asp?id=" + ProductID);
        AppendBackground();
        setTimeout("$('#divProductWindow').fixedBox().show();",500);
        
    }
}
        
function doWhite() {
    
    var wh = WindowHeight();
    var ch; // content height
    if (ogch==0) {
        ch = $("#site_contentheight").height()-6;
        ogch = ch;
    } else {
        ch = ogch;
        ogch = 0;
    }
    
    var check;
    if (ch<wh) {
        //alert('content is shorter than window ch = ' + ch + ', win = ' + wh);
        check = wh-ch;
        if (check<=30) {
            ch = wh-240;
        } else {
            ch = wh-240;
        }
    } else if (ch>wh) {
        //alert('content is taller than window = ' + ch + ', win = ' + wh);
        ch = ch;
    }else {
//        browser adjustments for white background on body content
        alert('con = ' + cf + ', win = ' + wh);
//        if ($.browser.safari) {
//            ch = 552;
//        } else if ($.browser.msie) {
//            ch = 547;
//        } else if ($.browser.mozilla) {
//            ch = 552;
//        } else if ($.browser.opera) {
//            ch = 548;
//        }
    }
    $("#WhiteHeight").attr("style","height:"+ch+"px;background:url('../images/white-opacity-50.png');background-repeat:repeat-y;background-position:center top;");
}

function WindowHeight() {
    var winY = $(document.window).height();
    return winY;
    
}

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>');
	    }   

var dotnetprefix = "ctl00_ContentPlaceHolder1_";

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.indexOf('none')>0) {
        $("#"+objid).fadeIn();
    } else {
        $("#"+objid).fadeOut();
    }
    
    //alert($("#"+objid).attr("style"));
    
}

function Highlight(obj) {
    $(obj).attr("style","cursor:hand;background:#cccccc;");
}

function UnHighlight (obj,color) {
    $(obj).attr("style","background:"+color);
}

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;}
}
