
function getContent(url, method, dest, cursr) {	// url = page you want to call, method = GET or POST, dest = id of element you want the response to be in
	var ajaxPost;
	if (dest=='OtherVersionLayout'){
		displayTab('OtherVersionLayout',1,0)
		//document.getElementById("OtherVersionLayout").style.display="block";	
	}
	if(method == null || method == "") {
		method = "GET";
	}
	
	if(dest == "") {
		dest = null;
	}
	
	try	{
		// Initialize all current browsers
		ajaxPost = new XMLHttpRequest();
	}
	catch(tryms) {
		try	{
			// Initialize Internet Explorer
			ajaxPost = new ActiveXObject('msxml2.XMLHTTP');
		}
		catch(tryotherms) {
			try {
				// Initialize older Internet Explorer
				ajaxPost = new ActiveXObject('Microsoft.XMLHTTP');
			}
			catch(failed){
				alert('XmlHttp not supported');
				return false;
			}
		}
	}
	
	if (url.indexOf("?") >= 0) {
		url = url + "&rand=" + getRandom();
	} else {
		url = url + "?rand=" + getRandom();
	}
	
	var ReqParams = new String("");
	
	if (url.indexOf("?") >= 0 && method.toUpperCase() == "POST") {
		ReqParams = url.substring(url.indexOf("?") + 1, url.length);
		url = url.substring(0, url.indexOf("?"));
	}
	
	ajaxPost.onreadystatechange=function(){
		if(ajaxPost.readyState == 4){
			if(ajaxPost.status == 200){
				if(dest != null) {
					document.getElementById(dest).innerHTML = unescape(ajaxPost.responseText);
					if(dest == "LightBox") {
						showLightBox();	
					}
				} else {
					eval(ajaxPost.responseText);
				}
				if(cursr != null && cursr != "") {
					document.body.style.cursor = cursr;
				}
			} else {
				if(dest != null) {
					alert("Ajax Error!");
				}
			}
		}
	}
	
	ajaxPost.open(method.toUpperCase(), url, true);
	if (method.toUpperCase() == "POST") {
		ajaxPost.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	}
	ajaxPost.send(ReqParams);
	
	return true;
}

function getRandom() {	// this is used to break the caching issues in IE
   	var minutes = 1000*60;
	var hours = minutes*60;
	var days = hours*24;
	var years = days*365;
	var date = new Date();
	var t = date.getTime();
	var myrandom = Math.round(t/years);

	var d = new Date()
	var ranNum= (Math.round((Math.random()* myrandom)+1)) + d.getTime();
    return ranNum;
}

function displayTab(pagetab,showing,tablink,isSub){	
	if (showing ==1){
		document.getElementById(pagetab).style.display="block";
		if (tablink !=0){			
			OffOnTab(tablink,isSub);
		}		
	}
	else{
		document.getElementById(pagetab).style.display="none";
	}			
}
function OffOnTab2(myObj,isHover){
	if (isHover == 0){/* do this if the user click in order to change the tab background */
		for (x=1; x<=3;x++){
			var tempvar = "feattab" + x;		
			document.getElementById(tempvar).style.backgroundImage="url(http://images.ez-tracks.com/v2/feattabbg_off.png)";
		}
		document.getElementById(myObj).style.backgroundImage="url()";
	}
	else if (isHover == 1){/* ONMOUSEOVER - do this if the user hover the tab in order to change the tab background to OnState */
		//if (document.getElementById(myObj).style.backgroundImage !="none" && document.getElementById(myObj).style.backgroundImage != "url()" && document.getElementById(myObj).style.backgroundImage != "url(http://images.ez-tracks.com/)" && document.getElementById(myObj).style.backgroundImage != "url(http://dev.ez-tracks.com/)" && document.getElementById(myObj).style.backgroundImage != "url(http://www.ez-tracks.com/)"){		
		if (document.getElementById(myObj).style.backgroundImage =="url(http://images.ez-tracks.com/v2/feattabbg_off.png)"){
			document.getElementById(myObj).style.backgroundImage="url(http://images.ez-tracks.com/v2/feattabbg_on.png)";
		}		
	}	
	else if (isHover == 2){/* ONMOUSEOUT - do this if the user hover the tab in order to change the tab background to OnState */		
		//if (document.getElementById(myObj).style.backgroundImage !="none" && document.getElementById(myObj).style.backgroundImage != "url()"){	
		if (document.getElementById(myObj).style.backgroundImage =="url(http://images.ez-tracks.com/v2/feattabbg_on.png)"){
			document.getElementById(myObj).style.backgroundImage="url(http://images.ez-tracks.com/v2/feattabbg_off.png)";
		}
	}		
}

/***** this function is to display tabs on the genre page / top charts and new songs ******/
function OffOnTab(tablink,isSub){
	document.getElementById(tablink).style.backgroundImage="url()";
	if (tablink == "FeaturedTabLink1"){
		if (isSub == 0){				
			document.getElementById("FeaturedTabLink2").style.backgroundImage="url(http://images.ez-tracks.com/v2/tabbg_off.png)";			
		}
		else {
			document.getElementById("tabdivider").innerHTML="";
			document.getElementById("tabdivider2").innerHTML='<img src="http://images.ez-tracks.com/v2/tabdivider4.png" width="7" height="46" alt="" />';
		}
		document.getElementById("FeaturedTabLink3").style.backgroundImage="url(http://images.ez-tracks.com/v2/tabbg_off.png)";
	}
	else if (tablink == "FeaturedTabLink2") {
		document.getElementById("FeaturedTabLink1").style.backgroundImage="url(http://images.ez-tracks.com/v2/tabbg_off.png)";
		document.getElementById("FeaturedTabLink3").style.backgroundImage="url(http://images.ez-tracks.com/v2/tabbg_off.png)";
	}
	else {		
		if (isSub == 0){			
			document.getElementById("FeaturedTabLink2").style.backgroundImage="url(http://images.ez-tracks.com/v2/tabbg_off.png)";			
		}
		else {
			document.getElementById("tabdivider").innerHTML='<img src="http://images.ez-tracks.com/v2/tabdivider4.png" width="7" height="46" alt="" />';
			document.getElementById("tabdivider2").innerHTML="";
		}
		document.getElementById("FeaturedTabLink1").style.backgroundImage="url(http://images.ez-tracks.com/v2/tabbg_off.png)";		
	}	
}


// SeViR Simple Horizontal Accordion @2007
// http://letmehaveblog.blogspot.com
jQuery.fn.extend({
  haccordion: function(params){	  
	var jQ = jQuery;
	var params = jQ.extend({
	  speed: 500,
	  contentclass: "tempcontent",
	  contentwidth: 561
	},params);
	return this.each(function(){							 
		jQ(".hacc_mblog, .hacc_mnews, .hacc_headlines",this).click(function(){			
		$(".tempcontent").animate({width: "0px"},params.speed);/* Close Every Opened tempcontent - Cause one if opened by default and needs to be close */	
		var myClassName = $(this).attr('class'); /* set var - get class name of the selector */
		var mystart=myClassName.length - 5;
		var myend=myClassName.length;
		if (myClassName.substring(mystart,myend) != "_temp"){
			var p = jQ(this).parent()[0];
			if (p.opened != "undefined"){
			  jQ(p.opened).next("div."+params.contentclass).animate({
				width: "0px"
			  },params.speed);
			}
			p.opened = this;
			jQ(this).next("div."+params.contentclass).animate({
			  width: params.contentwidth + "px"
			}, params.speed);
			jQ(this).attr('class')
			// reset class to original state
			$("#mblog").removeClass("hacc_mblog_temp").addClass("hacc_mblog");	
			$("#mnews").removeClass("hacc_mnews_temp").addClass("hacc_mnews");	
			$("#headlines").removeClass("hacc_headlines_temp").addClass("hacc_headlines");	
			// set class to active state
			$("."+ myClassName).removeClass(myClassName).addClass(myClassName+"_temp");			
		}		
	  });
	});
  }
});


function hideElement(el) {
	document.getElementById(el).style.display = "none";
	return false;
}


function PopupSong(ProductId,TrackId,doit,songurl){
	var myWidth = 0, myHeight = 0;
	if (songurl == null) {
		songurl = "http://billboard.puretracks.com";
	}
	self.moveTo(screen.availLeft,screen.availTop);
	self.resizeTo(screen.availWidth,screen.availHeight);
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	
	var InstructionHeight = (screen.availHeight -myHeight) + 270;//height of the instruction
	myHeight = screen.availHeight - InstructionHeight;
	var left2 = screen.availLeft;
	if (left2 == undefined)
		left2 = 0;
	
	var Attri2 = "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + myWidth + ",height=" + myHeight + ",left=" + screen.availLeft + ",top = " + InstructionHeight;
	var url = songurl + "/catalog/details.aspx?pid=" + ProductId;
	window.open(url, 'topPop', Attri2);

	self.resizeTo(screen.availWidth,InstructionHeight);
	if(doit)
		window.location = '/billboard_instruction.html?trackid=' + TrackId;
}

function callEmbedCode(songID){
	$(document).ready(function(){
		tb_show("Embed Code","/includesV2/light_embedcode.cfm?songID=" + songID +"&modal=true&width=700&height=630",null,null);
	});
}

function callPreview(songID){
	$(document).ready(function(){
		tb_show("Song Preview","/includesV2/previewsong.cfm?songID=" + songID +"&modal=true&width=700&height=400",null,null);
	});
}
function Social_Load() { 
var d=document; if(d.images){ if(!d.Social) d.Social=new Array();
var i,j=d.Social.length,a=Social_Load.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("##")!=0){ d.Social[j]=new Image; d.Social[j++].src=a[i];}}
}
Social_Load('http://www.social-bookmark-script.de/img/bookmarks/digg_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/del_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/reddit_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/stumbleupon_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/furl_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/spurl_trans_ani.gif','http://www.social-bookmark-script.de/img/bookmarks/technorati_trans_ani.gif','http://www.social-bookmark-script.de/load.gif')
function schnipp() { 
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function schnupp(n, d) { 
  var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=schnupp(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
  }
function schnapp() { 
  var i,j=0,x,a=schnapp.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=schnupp(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
  }

