﻿// Jscript
$(document).ready(function() { });

// site & myaccount navigation 
var navpersist = 1;
function doHover(curr) {
    for (i = 1; i <= 7; i++) {
        if (curr == i) {
            $("#nav" + i).removeClass("inactive");
            $("#nav" + i).addClass("active");
        } else {
            $("#nav" + i).addClass("inactive");
        }
    }
}

function doOut(curr) {
    for (i = 1; i <= 7; i++) {
        $("#nav" + i).removeClass("active");
    }
    $("#nav" + navpersist).addClass("active");
}


// general functions
var dotnetprefix = "ctl00_ContentPlaceHolder1_";

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>');
}

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;
    }
}

function ShowEditWelcome() {
    $("#HIDDENIFRAME").attr("src", "../../../frame1.htm");
    $("#HIDDENIFRAME").attr("src", "EditWelcome.asp");
    //return overlay(that, 'DIVHIDDENFRAME', 'bottomright');

    AppendBackground();

    $("#DIVHIDDENFRAME").fadeIn().fixedBox();
}
function overlayclose(subobj) {
    document.getElementById(subobj).style.display = "none"
    RemoveBackground();
    document.getElementById(subobj).setAttribute("src", "/frame1.htm")
}
