Array.prototype.remove=function(s){
    for(i=0;i<this.length;i++)
    {
        if(s==this[i]) this.splice(i, 1);
    }
}
Array.prototype.clear=function()
{
    this.length = 0;
};
Array.prototype.pushVal=function(element, defaultVal)
{
    if(element)
    {
        this.push(element);
    }
    else
    {
        if(defaultVal)
            this.push(defaultVal);
        else
            this.push("&nbsp;");
    }
};
Array.prototype.contains=function(element)
{
    for (var i = 0; i < this.length; i++)
    {
        if (this[i] == element)
        {
            return true;
        }
    }
    return false;
};
Array.prototype.containsSongName=function(element)
{
    for (var i = 0; i < this.length; i++)
    {
        if (this[i].songName == element)
        {
            return true;
        }
    }
    return false;
};

$(document).ready(function() {   

    //--------------------------------------------    
    slideShow();

    //--------------------------------------------
    $('.themedDropDown').each(
        function(i)
        {
            var ext = "";
            ext = ($(this).hasClass("Light")) ? "Light" : "";
            $(this).combobox(
            {
                comboboxContainerClass: "comboboxContainer" + ext,
                comboboxValueContainerClass: "comboboxValueContainer",
                comboboxValueContentClass: "comboboxValueContent",
                comboboxDropDownClass: "comboboxDropDownContainer",
                comboboxDropDownButtonClass: "comboboxDropDownButton" + ext,
                comboboxDropDownItemClass: "comboboxItem",
                comboboxDropDownItemHoverClass: "comboboxItemHover",
                comboboxDropDownGroupItemHeaderClass: "comboboxGroupItemHeader",
                comboboxDropDownGroupItemContainerClass: "comboboxGroupItemContainer",
                animationType: "slide",
                width: $('.themedDropDown')[i].offsetWidth
            });
        }
    );
    
    //--------------------------------------------
    $(".otherExtraItem").click(
        function()
        {
            if(!$(this).hasClass('fakechecked'))
            {
                $(".otherExtrasText")[0].disabled = false;
            }
            else
            {
                $(".otherExtrasText")[0].disabled = true;
                //$(".otherExtrasText").val("");
            }
        }
    );
    
    //$("INPUT:checkbox", $(".musicTable")).eq(0).click(
    $(".fakecheck", $(".musicTable")).eq(0).click(
        function()
        {
            selectedSongs.clear();
            //toggleFakeCheck($(this));
            var chkBoxes = $(".fakecheck", $(".musicTable"));
            if(!chkBoxes.eq(0).attr("checked"))
            {
                chkBoxes.each(
                    function(i)
                    {
                        if(i>0)
                        {
                            //this.checked = false;
                            $(this).attr("checked", false);
                            $(this).removeClass('fakechecked')
                            //$(this).trigger("click");
                            $(this).trigger("click");
                        }
                    }
                );
            }
            else
            {
                chkBoxes.each(
                    function(i)
                    {
                        if(i>0)
                        {
                            //this.checked = true;
                            $(this).attr("checked", true);
                            $(this).addClass('fakechecked');
                            //$(this).trigger("click");
                            $(this).trigger("click");
                        }
                    }
                );
            }
        }
    );
    
    //$(".chkSong").click(selectSong);
    
    $(".fakecheck").click(function(){
		//$("INPUT:first", $(this).parent()).trigger("click");
		toggleFakeCheck($(this));
		if($(this).hasClass("songFakeCheck"))
		    selectSong(this);
		return false;
	});
	
	$("ul.menuList").children("li").children("img").fadeTo("Fast", 0.0, function() {
	    $("ul.menuList").children("li").children("img").show();
	});
	
	$("ul.menuList").children("li").hover(
	    function() {
	        $(this).children("img").stop();
	        $(this).children("img").fadeTo("Slow", 1.0);
	    },
	    function() {
	        $(this).children("img").stop();
	        $(this).children("img").fadeTo("Slow", 0.0);
	    }
	);
}); 

