/* core.js file */

function setNavItems(gNav,secNav){
//	if(gNav == "onXM" || gNav == "whatIs" || gNav == "shopXM"){
	if(gNav == "whatIs" || gNav == "shopXM"){
		document.getElementById(gNav + "_A").className = "current";
	}
	if(secNav != "" && secNav != gNav){
		document.getElementById("subnav_" + secNav + "_A").className = "current";
	}
}

function recallFlashDate(date){
	var urlStr = "/onxm/this-week-on-xm.xmc?day=" + date;
	window.location = urlStr;
}

// Embed Flash Simplify

function embedFlash(width,height,allowScriptAccess,movie,bgcolor,flashvars)
{
	document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="'+width+'" HEIGHT="'+height+'">\n');
	document.write('<param name="allowScriptAccess" value="'+allowScriptAccess+'" />\n');
	document.write('<param name="movie" value="'+movie+'" />\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<param name="bgcolor" value="'+bgcolor+'" />\n');
	document.write('<PARAM NAME="menu" VALUE="false"/>\n');	
	document.write('<PARAM NAME="FlashVars" VALUE="'+flashvars+'"/>\n');	
	document.write('<embed src="'+movie+'" quality="high" bgcolor="'+bgcolor+'" width="'+width+'" height="'+height+'" align="middle" allowScriptAccess="'+allowScriptAccess+'" menu="false" FlashVars="'+flashvars+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/>\n');
    document.write('</object>\n');
}

// function to match heights to two divs that are next to each other
function matchHeights(arr) {
	var maxHeight = 0;
	var curHeight = 0;
	for(i=0;i<arr.length;i++) {
		curHeight = document.getElementById(arr[i]).offsetHeight;
		if(curHeight > maxHeight) {
			maxHeight = curHeight;
		}
	}
	maxHeight = maxHeight - 10;
	for(i=0;i<arr.length;i++) {
		document.getElementById(arr[i]).style.height = maxHeight + "px";
	}
}

var lastDiv = "";
function showDiv(divName) {
	// hide last div
	if (lastDiv) {
		document.getElementById(lastDiv).className = "displayNone";
	}
	//if value of the box is not nothing and an object with that name exists, then change the class
	if (divName && document.getElementById(divName)) {
		document.getElementById(divName).className = "displayBlock";
		lastDiv = divName;
	}
}



try{
	document.execCommand("BackgroundImageCache",false,true);
}catch(err){}



/* ****************************************************
 * Opens new window 
 * ****************************************************/
function pop(url,name,h,w,s,t,m,r){

	var wWin = null;
	//if(uBN=="MSIE" && uOS=="Macintosh"){r = "no"};
	if(document.location.href.substring(0,5) == "https"){
		name="https";
	}

		x=(screen.availWidth-w);
		y=(screen.availHeight-h);
		if (name.document) {
			name.document.location.href=url;
		} else {
			wWin=window.open(url,name,"height="+h+",width="+w+",scrollbars="+s+",toolbar="+t+",menubar="+m+",resizable="+r+",status=yes,location=no,screenX="+x/2+",screenY="+y/2+",left="+x/2+",top="+y/2);
			//wWin.resizeTo(w,h);
			wWin.focus();

	}
}

function launchPlayer(playerURL){
	pop(playerURL,'player',550,750,'no','no','no','no');
}


function showStatus(sMsg) {
    window.status = sMsg ;
    return true ;
}

function activate(lang){
	if(lang == "en"){
		window.open("https://activate.xmradio.ca/online-activation/en/");
	}else if(lang == "fr"){
		window.open("https://activate.xmradio.ca/online-activation/fr/");	
	}
}


