var currPl = "";
// Globals
// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 28;


function roll(el, img) {

    eval(el).childNodes[0].src = img;
}

function changeClass(checkbox, elementToChange, class1, class2) {
    document.getElementById(elementToChange).className = checkbox.checked ? class1 : class2;
}



function PlaySong(songId){
    StopAllSounds();
    document.getElementById(songId).play();
}

function StopAllSounds()
{
    for (var i=0; i < document.forms[0].elements.length; i++) {
        var element = eval(document.forms[0].elements[i]);
        var prefix = element.id.substring(10,0);          
        if(prefix == "yl_player_"){
            element.stop();
        }
    }
}

function songPlayed(songId, playerId) {
    //alert(playerId);
}

function showPlayer(pl, songId) {

    var notIE = navigator.userAgent.indexOf('MSIE') == -1;
    document.getElementById("playerDiv").style.height = "60px";
    if (notIE){
        document.getElementById("playerDiv").style.visibility = "visible";
    }
    if (currPl == pl) {
        document.getElementById('YouLicensePlayerBig').playById(songId);
    }
	else
    {
        document.getElementById('YouLicensePlayerBig').loadAndPlayById(pl, songId);
        currPl = pl;
    }
}

function closePlayer() {
    var notIE = navigator.userAgent.indexOf('MSIE') == -1;

    document.getElementById('YouLicensePlayerBig').stopYLPlayer();
    document.getElementById("playerDiv").style.height = "1px";
    if (notIE) {
        document.getElementById("playerDiv").style.visibility = "hidden";
    }
}


function RegisterSearchPlayer(file){
    window["player"] = new Object();
    var flashvars = {};
    flashvars.XmlFile = file;
    flashvars.AutoPlay = "true";
	flashvars.id = "player"; 
	flashvars.name = "player"; 
	flashvars.CompactMode = "false";
	flashvars.Embedded = "false";
    var params = {};
    params.id = "player";
    params.name = "player";
    var attributes = {};
    attributes.id = "player";
    attributes.name = "player";
    swfobject.embedSWF("fullplayer.swf", "player", "430", "281", "9.0.0","expressInstall.swf", flashvars, params,attributes);

}

function SongPlayed(id){
    document.getElementById("frmRating").src = "RatingPage.aspx?PID=" + id;
    document.getElementById("frmArtistDesc").src = "ArtistDescription.aspx?ID=" + id;
}

function openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

function center(objectId)
 {
     var object = eval(document.getElementById(objectId));
     object.style.marginLeft = "-" + parseInt(object.offsetWidth / 2) + "px";
     object.style.marginTop = "-" + parseInt(object.offsetHeight / 2) + "px";
 }
 
  function ratingCallback(rating, widget) {
          var itemURL = widget.env.url;
         
          var ratingInStarsCount = (Math.floor(rating / 25) + 1);
          var from = itemURL.indexOf('ID=');
          var to = itemURL.indexOf('#');
            var param1 = itemURL.substring(from+3,to);
            var param2 = widget.env.contentType;
            var callBackUrl = 'RatingHandler.aspx';
            var c = window.location.toString()
            if (c.indexOf("www.") < 0)
            {
                callBackUrl = 'RatingHandler.aspx';
            }
            
            var callback = function(response) {
      
}

       new SB.Ajax.Request(callBackUrl, 'Ajax', 'RatingDone', 'no').invoke(callback,null,param1,param2,ratingInStarsCount);
}
 
function showProgress()
{
    Effect.BlindDown('divRate',{duration:0.5});
} 
function showUploadProgress()
{
    Effect.BlindDown('divPop',{duration:0.5});
}
function closeUploadProgress()
{
    Effect.BlindUp('divPop',{duration:0.5});
}

function setClassName(el, name)
{
	el.className = name;
}
function doClick(buttonName,e)
    {
    
//the purpose of this function is to allow the enter key to 
//point to the correct button to click.
        var key;

         if(window.event)
              key = window.event.keyCode;     //IE
         else
              key = e.which;     //firefox
    
        if (key == 13)
        {
       
            //Get the button the user wants to have clicked
            var btn = document.getElementById(buttonName);
            if (btn != null)
            { //If we find the button click it
             
             WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$LoginBox1$Login1$LoginLinkButton", "", true, "ctl00$Login1", "", false, true));
                //btn.click();
                event.keyCode = 0
            }
        }
   }
   
   function doSearch(buttonName,e)
    {
    
//the purpose of this function is to allow the enter key to 
//point to the correct button to click.
        var key;

         if(window.event)
              key = window.event.keyCode;     //IE
         else
              key = e.which;     //firefox
    
        if (key == 13)
        {
       
            //Get the button the user wants to have clicked
            var btn = document.getElementById(buttonName);
            if (btn != null)
            { //If we find the button click it
             
           WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$SearchRedirector1$lnkGo", "", true, "", "", false, true))
                //btn.click();
                event.keyCode = 0
            }
        }
   }
   
   function doQuickSearch(e){
    var key;

         if(window.event)
              key = window.event.keyCode;     //IE
         else
              key = event.which;     //firefox
    
        if (key == 13)
        {
                alert('enter');
                try{
            __doPostBack('ctl00$SearchRedirector1$lnkGo','');
            }
            catch(err){
           WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$SearchRedirector1$lnkGo", "", true, "", "", false, true));
           }
             event.keyCode = 0
         }
    }
   
       

   
   function RedirectFromSelect(select){
		var index= select.selectedIndex
		if (select.options[index].value != "0") 
		{
			location = select.options[index].value;
		}
   }

