if (typeof(prependDomain) == "undefined") {
	prependDomain = "";
}

function nullit() {
	return true;
}
//window.onerror = nullit;


function MakeArray(n){
   this.length = n
   for (var i = 1; i<=n; i++) {
      this[i] = new Image()
   }
   return this;
}

function omOver(name,number){
	if (document.images){
      name.src = over[number].src;
   }
}

function omOut(name,number){
	if (document.images){
    	name.src = out[number].src;
   }
}

if (document.images) {
	braille_out = new MakeArray(12);
	braille_over = new MakeArray(12);
	imgLoc = new Array ("","lyl_1","lyl_2","lyl_3","lyl_4","dyl_1","dyl_2","dyl_3","dyl_4","dyl_1","dyl_2","dyl_3","dyl_4")
	imgLoc2 = new Array ("","lyl_a1","lyl_a1","lyl_a1","lyl_a1","dyl_a1","dyl_a1","dyl_a1","dyl_a1","dyl_a1","dyl_a1","dyl_a1","dyl_a1")
	for (imgX=1;imgX<13;imgX++){
	braille_out[imgX].src = "/sitewide/images/icn_braille_" + imgLoc[imgX] + ".gif";
	braille_over[imgX].src = "/sitewide/images/icn_braille_" +imgLoc2[imgX] + ".gif";
	}
}

function brailleOver(name,number){
	if (document.images){
    	name.src = braille_over[number].src;
	}
}
function brailleOut(name,number){
	if (document.images){
    	name.src = braille_out[number].src;
	}
}



function launchRSN(varStationID){
	var tuner = false;
	tuner = window.open('/mtvradio/radiolaunch.jhtml?oparam=radio&serviceSubjectID='+ varStationID + '&A='+ varStationID ,'TUNERLogin','width=700,height=312,toolbar=no,resizable=no,scrollbars=no');
	tuner.focus;
	popCheck(tuner);
}


function popCheck(obj){
	if (!obj) {
		alert("Some content on MTV.com is displayed using pop-ups.  \n\nIf you're using a Pop-up Blocker, you'll need to permit pop-ups \nfrom MTV.com in order to view Videos, photos and other content on our site.");
	}
}

/*
 * @description	Opens the sitewide flipbook player.
 * @param fbKey Flipbook ID or URL.
 * @param obj, Object, used to customize the flipbook skin and values.
 */
function popFlip(fbKey, obj){
	var fbArgs = "";
	for (var p in obj){
		fbArgs += "&" + p + "=" + obj[p];
	}

	var pWin = false;
	if (fbKey.indexOf("fid=")>=0) {
		// new flip pop, old w=556, h=486
		pWin = window.open('/sitewide/flipbook/index.jhtml?'+fbKey+fbArgs,'flipbook','width=720,height=540,scrollbars=no');
	}
	else {
		var flipLoc  = fbKey.split("?");
		flipLocPath  = flipLoc[0].split("index.jhtml");
		var flipLocFull  =  flipLocPath[0];
		if (flipLoc[1] != "" && flipLoc[1] != null) flipLocFull += "&" + flipLoc[1];

		pWin = window.open('/sitewide/flipbook/index.jhtml?pf='+flipLocFull+fbArgs+'','flipbook','width=720,height=540,scrollbars=no');
	}
	popCheck(pWin);

}

function popFlipById(fid){
	popFlip('fid=' + fid);
}

function dropIt(layername,layerstatus){
	return true;
}

function genPop(loc,wName,attr){
	var pWin = false;
	pWin = window.open(loc,wName,attr);
	popCheck(pWin);
}

function touppPop(pp){
	var pWin = false;
	if (arguments.length == 1) {
		pWin = window.open(prependDomain + '/sitewide/mtvinfo/privacy.jhtml','Privacy','width=605,height=400,resizable,scrollbars');
	}
	else {
		pWin = window.open(prependDomain + '/sitewide/mtvinfo/terms.jhtml','TOS','width=605,height=400,resizable,scrollbars');
	}
	popCheck(pWin);
}

function adspecsPop(pp){
	var pWin = false;
	pWin = window.open('/asm/adspecs/contact.jhtml','AdSpecs','width=605,height=400,resizable,scrollbars');
	popCheck(pWin);
}

function popQT(url){
	url = "/sitewide/videoplayer/qtplayer.jhtml?" + url;

	var pWin = false;
	window.open(url,"qtplayer","width=320, height=240");
	popCheck(pWin);
}


function MakeArray(n){
   this.length = n
   for (var i = 1; i<=n; i++) {
	  this[i] = new Image()
   }
   return this;
}


function imgFlip(imageName,imageSrc) {
  if (document.images)
    document.images[imageName].src = eval(imageSrc + ".src");
}


function toggleFlash(show) {
	if (IE4){
		document.all.flashLayer.style.visibility = show;
	}
	if (NS4){
		document.flashLayer.visibility=show;
	}
	if (NS4 && (show=="visible")){
		document.flashLayer.top = "0";
	}
	if (NS6 && (show=="hidden")){
		document.getElementById("flashLayer").style.top = "-1000px";
	}
	if (NS6 && (show=="visible")){
		document.getElementById("flashLayer").style.top = "0px";
	}
}

function launchEssentials()
{
    var url;
    var win;
    var winWidth = 952;
    var winHeight = 600;
    var msg = "A PopUp blocker has blocked the Essentials window from launching.\nPlease add MTV.com to your safe list.";

    if (screen.width <= 800) {
        winWidth = 780;
        winHeight = 500;
    }

    url = "/partners/essentials/popflash.jhtml?width=" + winWidth + "&height=" + winHeight;

    win = window.open(url, "essentials", "width=" + winWidth + ",height=" + winHeight);
    if (win) {
        win.focus();
    } else {
        alert(msg);
    }

    self.location.href = "/partners/essentials/";
}
