self.name = "vh1";

// browser detection code for legacy pages
var NS = (navigator.appName == "Netscape");
var IE4 = document.all;
var NS4 = document.layers;
mac = navigator.appVersion.indexOf("Mac");
if (mac>=0) {mac=1} else {mac=0}
var compliant = document.getElementById;
var initialized = false;
 
function imgFlip(imageName,imageSrc) {
  if (document.images && document.images[imageName])
    document.images[imageName].src = eval(imageSrc + ".src");
}
// FORM HANDLER CODE ----------------------------------------------------------
var win = null;
function formHandle(formname, listname) {
  var l = document.forms[formname][listname];
  var i = l.selectedIndex;
  var url = l.options[i].value;
  var firstChar = url.charAt(0);
  var secondChar = url.charAt(1);
  
  var windowprops = new Array;
  windowprops[0] = "width=400,height=300,scrollbars=yes,resizable=yes";
  windowprops[1] = "width=320,height=180,screenX=30,screenY=30";
 // add new window properties here and call them by using '$' followed by the next array number and place in front of url 
 // windowprops[1] = " ";
 // windowprops[2] = " ";
  
  // do nothing if no url is selected
  if (url=='none') l.selectedIndex = 0;
  
  // open the link in a new browser window
  else if (firstChar=='+') open(url.substring(1), '_blank');
  
  // open as popup with attributes defined in the array windowprops[]
  else if (firstChar=='$') window.open(url.substring(2),"MenuPopup",windowprops[secondChar]);
  
  // just go to the URL
  else location.href = url;
}
// REGULAR EXPRESSION STRIPPER ------------------------------------------------
function valueStrip(regSearch,features)
{
	var results =  features.match(regSearch);
	if (results != null) return results[2];
	else return 0;
}
// POSITIONED POP UP WINDOW CODE ----------------------------------------------
function popper(theURL,winName,features,purl) {
	var posWin = null;
	var gotIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;	
	var gotNS = (navigator.appName == 'Netscape') ? true : false;
	var gotNN6 = (gotNS && (parseInt(navigator.appVersion) >= 5)) ? true : false;
// REGULAR EXPRESSIONS TO STRIP OUT THE WIDTH AND HEIGHT VARS -----------------
	var widthMatch = /(width=)(\d+)/i;
	var heightMatch = /(height=)(\d+)/i;
	var scrollMatch = /(scrollbars=)([a-zA-Z0-9])/i;
	var numMatch = /\d+/;
	
	var width = valueStrip(widthMatch,features);
	var height = valueStrip(heightMatch,features);
	var scrollbars = valueStrip(scrollMatch,features);
	
	if (posWin!=null && !posWin.closed) posWin.close();
	
   if (gotIE) {
      var left = (screen.Width/2) - width/2;
      var top = (screen.Height/2) - height/2;
      posWin = window.open(theURL,winName,"scrollbars=0,left="+left+",top="+top+",width="+width+",height="+height+",scrollbars="+scrollbars);
      if((typeof posWin != "undefined") && (posWin != null)){
         posWin.focus();
      }
   }
	else if (gotNS && !gotNN6) {
	var left = (screen.availWidth/2) - width/2;
	var top = (screen.availHeight/2) - height/2;
	posWin = window.open(theURL,winName,"screenX="+left+",screenY="+top+",innerWidth="+width+",innerHeight="+height+",scrollbars="+scrollbars);
	posWin.focus();
	}
	else if (gotNN6) {
	var left = (screen.availWidth/2) - width/2;
	var top = (screen.availHeight/2) - height/2;
	posWin = window.open(theURL,winName,"screenX="+left+",screenY="+top+",width="+width+",height="+height+",scrollbars="+scrollbars);
	posWin.focus();
	}
	else {
	posWin = window.open(theURL,winName,"scrollbars=0,width="+width+",height="+height+",scrollbars="+scrollbars);
	posWin.focus();
	}
	
	
	if (purl != null) window.location.href = purl;
	
	
	
}
// RELOADER CODE --------------------------------------------------------------
function load(){
  if (parseFloat(navigator.appVersion) == 4.08) return;
  location.reload();
}
// OPEN UP PREFERENCES WINDOW -------------------------------------------------
function pref(arg) {
  var url;

  if (!arg) url = "/my_account/util/direct.jhtml?dir=popup&linkTextID=toPrefs&messageID=loginRequired&welcome=false&postLoginURL=/my_account/prefs/framey.jhtml";
  else if (arg=="newsletters") url = "/my_account/util/direct.jhtml?dir=popup&linkTextID=toNewsletters&messageID=loginRequired&welcome=false&postLoginURL=/my_account/prefs/framey.jhtml%3Fsrc%3Dnewsletters";
  else if (arg=="fanclubs") url = "/my_account/util/direct.jhtml?dir=popup&linkTextID=toFanClubs&messageID=loginRequired&welcome=false&postLoginURL=/my_account/prefs/framey.jhtml%3Fsrc%3Dfanclubs";
  else url = arg;

  popper(url, "prefs", "width=640,height=500,scrollbars=1");
}

function prefs(arg) {
  var url;
  var id = null;
 if (!id) {
 
  //if (!arg) url = "/my_account/util/direct.jhtml?dir=popup&linkTextID=toPrefs&messageID=loginRequired&welcome=false&postLoginURL=/my_account/prefs/framey_new.jhtml";
  if (!arg) url = "/interact/my_account/my_account.jhtml";
  else if (arg=="newsletters") url = "/interact/my_account/newsletter_list.jhtml";
  //else if (arg=="fanclubs") url = "/my_account/util/direct.jhtml?dir=popup&linkTextID=toFanClubs&messageID=loginRequired&welcome=false&postLoginURL=/my_account/prefs/framey_new.jhtml%3Fsrc%3Dfanclubs";
  else url = arg;
  }
  
  else  url = "/my_account/util/direct.jhtml?dir=popup&linkTextID=toArtistPage&messageID=loginRequired&welcome=false&postLoginURL=/my_account/prefs/framey_new.jhtml%3Fpaid%3D" + id;
  
  spawnOrLink(url);
  //popper(url, "prefs", "width=640,height=500,scrollbars=1");
}


function checkIfRap(rid) {

switch (parseInt(rid)) {
			case -138 : 
			return true;
			case -194 : 
			return true;
			case 9 : 
			return true;
			case 130 : 
			return true;
			case -196 : 
			return true;
			case -180 : 
			return true;
			case 15 : 
			return true;
			default :
			return false;
		
		}

}
function checkIfHH(rid) {

switch (parseInt(rid)) {
			case -138 : 
			return true;
			default :
			return false;
		
		}

}



// coBrand v.2.1 - VH1 --------------
//function launchRSN(varStationID)
//{
	
	//	var domainN = window.location.hostname.toLowerCase();
	//	if ((domainN.indexOf("dev") != -1) || (domainN.indexOf("qa") != -1) || (domainN.indexOf(".mtvi.com") != -1)) domainN = 'http://smdev.sonicnet.com';
	//	else domainN = 'http://radio.sonicnet.com';
		
		
		
		//	var face = 'VH1DOTCOM';
		//	var tuner;
			//if (checkIfRap(varStationID)) tuner = window.open('/asm/ads/advertisers/fs/ad.jhtml?rid=' + varStationID,'TUNER','width=682,height=381,toolbar=no,resizable=no,scrollbars=no');
			//else tuner = window.open(domainN + '/player/launchplayer.asp?A='+varStationID+'&face='+face,'TUNER','width=682,height=381,toolbar=no,resizable=no,scrollbars=no');
		//	if (checkIfHH(varStationID)) tuner = window.open('/asm/ads/advertisers/cingular/ad.jhtml?rid=' + varStationID,'TUNER','width=682,height=381,toolbar=no,resizable=no,scrollbars=no');
		//	else if (varStationID == -268) tuner = window.open('/asm/ads/advertisers/sprint/ad.jhtml?rid=' + varStationID,'TUNER','width=682,height=381,toolbar=no,resizable=no,scrollbars=no');
		//	else if (varStationID == -209) tuner = window.open('/asm/ads/advertisers/konami/ad.jhtml?rid=' + varStationID,'TUNER','width=682,height=381,toolbar=no,resizable=no,scrollbars=no');
		//	else if (varStationID == -254) tuner = window.open('/asm/ads/advertisers/chilis/ad.jhtml?rid=' + varStationID,'TUNER','width=682,height=381,toolbar=no,resizable=no,scrollbars=no');
		//	else tuner = window.open(domainN + '/player/launchplayer.asp?A='+varStationID+'&face='+face,'TUNER','width=682,height=381,toolbar=no,resizable=no,scrollbars=no');
		
//}



// RADIO LAUNCH SCRIPTS - New Radio Skin , Urge Conversion --  Jayesh Patel
function depricatedStationAlert() {
	alert('This Station Is No Longer Available');
	return true;
}
function launchRSN(varStationID) {
	var depricatedStation = false;	
	switch (parseInt(varStationID)) {
		case 17 : varStationID = 16372;
			break;
		case 141 : varStationID = 16383;
			break;
		case 59 : varStationID = 16393;
			break;
		case 174 : varStationID = 16458;
			break;
		case 22 : varStationID = 16398;
			break;
		case -147 : varStationID = 16591;
			break;
		case 2 : varStationID = 16437;
			break;
		case -174 : varStationID = 16409;
			break;
		case 14 : varStationID = 16527;
			break;
		case 224 : varStationID = 16370;
			break;
		case 12 : varStationID = 16427;
			break;
		case 231 : varStationID = 16493;
			break;
		case 52 : varStationID = 16367;
			break;
		case 26 : varStationID = 16369;
			break;
			
		case 24 : varStationID = 16385;
			break;
		case 37 : varStationID = 16381;
			break;
		case -179 : varStationID = 16530;
			break;
			
			
		case -221 : varStationID = 16569;
			break;
		case -34 : varStationID = 16406;
			break;
		case -234 : varStationID = 16650;
			break;
			
		case -247 : varStationID = 16888;
			break;
		case 117 : varStationID = 16430;
			break;
		case 145 : varStationID = 16436;
			break;
		case 28 : varStationID = 16438;
			break;
		case 84 : varStationID = 16439;
			break;
		case 146 : varStationID = 16399;
			break;
			
		case 27 : varStationID = 47850;
			break;
		case 202: varStationID = 16366;
			break;
		case 204 : varStationID = 16482;
			break;
		case -240 : varStationID = 16583;
			break;
		case 31 : varStationID = 16391;
			break;
		case 79 : varStationID = 16395;
			break;
		case -132 : varStationID = 16587;
			break;
		case -167 : varStationID = 16518;
			break;
		case 215 : varStationID = 16485;
			break;
			
			
		case 65 : varStationID = 16425;
			break;
		case 49 : varStationID = 16432;
			break;
		case -166 : varStationID = 16517;
			break;
	
		case -218 : varStationID = 16566;
			break;
		case -168 : varStationID = 16519;
			break;
		case 38: varStationID = 16460;
			break;
		case -172 : varStationID = 16523;
			break;	
		case 143: varStationID = 16386;
			break;	
		case 81 : varStationID = 16407;
			break;	
		case 50 : varStationID = 16499;
			break;		
		case 36 : varStationID = 16380;
			break;
		case -191 : varStationID = 16541;
			break;
		
			break;
		case -194 : varStationID = 16544;
			break;
		case 9 : varStationID = 16390;
			break;		
		case 130 : varStationID = 16401;
			break;
		case 15 : varStationID = 16455;
			break;
		case 136 : varStationID = 16394;
			break;
		case -72 : varStationID = 16408;
			break;		
		case -225 : varStationID = 16572;
			break;
		case 19 : varStationID = 16426;
			break;
		case 11 : varStationID = 16442;
			break;
		case -241 : varStationID = 16584;
			break;		
		case 82 : varStationID = 16450;
			break;
		case 58 : varStationID = 16373;
			break;
		case 34 : varStationID = 16389;
			break;
		case 4 : varStationID = 16654;
			break;		
		case 97 : varStationID = 16403;
			break;
		case 10 : varStationID = 16825;
			break;
		case 68 : varStationID =  16365;
			break;
		case 7 : varStationID = 16371;
			break;
		case 85 : varStationID = 16376;
			break;		
		case -196 : varStationID = 16546;
			break;
		case 20 : varStationID = 16422;
			break;
		case 33 : varStationID = 16435;
			break;
		case 61 : varStationID = 16449;
			break;
		case 1205 : varStationID = 16483;
			break;
		case 6 : varStationID = 16388;
			break;		
		case 102 : varStationID = 16375;
			break;
		case 5 : varStationID = 16405;
			break;
		case 126 : varStationID = 16443;
			break;
		case -239 : varStationID = 16582;
			break;		
		case 35 : varStationID = 16428;
			break;
		case -222 : varStationID = 16570;
			break;
		case 203 : varStationID = 16489;
			break;	
			
	   case -270 : varStationID = 96704;
			break;
		case -94 : varStationID = 96710;
			break;
		case -209 : varStationID = 16557;
			break;	
		case 162 : varStationID = 96712;
			break;
		case -215 : varStationID = 16564;
			break;
		case 201 : varStationID = 16480;
			break;	
		case -158 : varStationID = 19716;
			break;
		case -138 : varStationID = 96717;
			break;
		case -193 : varStationID = 96718;
			break;	
		case -180 : varStationID = 96719;
			break;
		case -145 : varStationID = 96723;
			break;	
		case 13 : varStationID = 16423;
			break;	
    	case 500 : depricatedStation = depricatedStationAlert();
			break;

	}
	
  if(!depricatedStation) {
	tuner = window.open('/sitewide/apps/radio/tuner/?stationId='+varStationID,'TUNER','width=688,height=320,toolbar=no,resizable=no,scrollbars=no');
  }
}



//Intro for Media Players
//function launchIntroVideo(videoID,time) {

//popper("/sitewide/apps/mediaplayer/intro.jhtml?vID=" + videoID + "&time=" + time, "liveVideos", "width=698,height=496,scrollbars=0");

//}  
// VARIABLE FOR THE MY MUSIC RANDOM PICTURE -----------------------------------
RandNum = null;

var reef = false;

function btmVideo(){
	launchVideo('vid=17861');
	window.location.href='/shows/dyn/behind_the_music/series.jhtml';
	return true;
}

function btmGame(){
	popper('/shows/series/behind_the_music/trivia_flash/index.jhtml','popUP','width=570,height=502,scrollbars=0');
	window.location.href='/shows/dyn/behind_the_music/series.jhtml';
	return true;
}

function fashionSweeps(){
	popper('/interact/sweepstakes/fashion_game/player.jhtml','popUP','width=715,height=505,scrollbars=0');
	window.location.href='/shows/dyn/fashion_awards_2002/series.jhtml';
	return true;
}

function hotOrNot(url) {
	popper(url,'popUp','width=728,height=595,scrollbars=0');
}

function spawnOrLink(theURL) {


window.location.href = theURL;


}

function targetBrow(theURL,winName) {
	window.open(theURL,winName);
}
