var the_imageoff = new Image();
var the_imageon = new Image();

var array_manufacturer = new Array("Acura","Audi","BMW","Buick");
var array_Acura = new Array("CL","Integra","MDX","NSX","RL","SLX","TL","Other");
var array_Audi = new Array("A4","A6","A8","Allroad","S4","TT","Other");
var array_BMW = new Array("3 Series","5 Series","6 Series","7 Series","M3","M5","X5","Z3","Z8","Other");
var array_Buick = new Array("Century","Le Sabre","Park Ave","Regal","Other");
var array_modelname = new Array();
var i;


function img_act(imgName){ 

if (document.images){ 
the_imageoff[imgName] = new Image();
the_imageon[imgName] = new Image();
the_imageoff[imgName].src = "http://img.xmradio.com/images/" + imgName + ".gif"
the_imageon[imgName].src = "http://img.xmradio.com/images/" + imgName + "_on.gif";
document.images[imgName].src = the_imageon[imgName].src;
}
}

function img_inact(imgName){ 

if (document.images){ 
the_imageoff[imgName] = new Image();
the_imageon[imgName] = new Image();
the_imageoff[imgName].src = "http://img.xmradio.com/images/" + imgName + ".gif"
the_imageon[imgName].src = "http://img.xmradio.com/images/" + imgName + "_on.gif";
document.images[imgName].src = the_imageoff[imgName].src;
}
}
   
function img_act2(imgName){ 

if (document.images){ 
the_imageoff[imgName] = new Image();
the_imageon[imgName] = new Image();
the_imageoff[imgName].src = "http://img.xmradio.com/images/programming/subnav/" + imgName + "_off.gif"
the_imageon[imgName].src = "http://img.xmradio.com/images/programming/subnav/" + imgName + "_on.gif";
document.images[imgName].src = the_imageon[imgName].src;
}
}

function img_inact2(imgName){ 

if (document.images){ 
the_imageoff[imgName] = new Image();
the_imageon[imgName] = new Image();
the_imageoff[imgName].src = "http://img.xmradio.com/images/programming/subnav/" + imgName + "_off.gif"
the_imageon[imgName].src = "http://img.xmradio.com/images/programming/subnav/" + imgName + "_on.gif";
document.images[imgName].src = the_imageoff[imgName].src;
}
}

function getManufacturer(){
	
	// Fills in options within manufacturer
	for(i=0; i<array_manufacturer.length; i++){	 			
		document.sign_up_step02.carmanufacturer.options[i] = new Option(array_manufacturer[i],array_manufacturer[i],false,false);
	}
	//
	str_init_manufacturer = ("array_" + array_manufacturer[0]);
	array_init_manufacturer = str_init_manufacturer.toString().split(',');
	default_manufacturer = eval(array_init_manufacturer[0]);
	
	// After page loaded, fills in options for models of Acura
	for(i=0; i < default_manufacturer.length; i++){
		document.sign_up_step02.carmodel.options[i] = new Option(default_manufacturer[i],default_manufacturer[i],false,false);
	}
	// Displays the first content within the options
	document.sign_up_step02.carmanufacturer.options[0].selected = true;
	document.sign_up_step02.carmodel.options[0].selected = true;
}

//var sign_up_step02;

function changeModel(modelname) {

	clearModels();
	str_modelname = eval("array_"+modelname);
	array_modelname = str_modelname.toString().split(',');

	//alert(sign_up_step02.model.options.length);
	
	for (i=0; i < array_modelname.length; i++){
		document.sign_up_step02.carmodel.options[i] = new Option(array_modelname[i],array_modelname[i],false,false);
	}
	document.sign_up_step02.carmodel.options[0].selected = true;
}

function clearModels(){
/*
	//Initializes array
	for (i=0; i < array_modelname.length; i++){
		document.sign_up_step02.model.options[i] = new Option('','',false,false);		
		//alert(array_modelname[i]);
	}
	
	for (i=0; i < default_manufacturer.length; i++){
		//alert(array_modelname[i]);
		document.sign_up_step02.model.options[i] = new Option('','',false,false);
	}
*/
	// Removes empty options
	document.sign_up_step02.carmodel.options.length=0;
	
}


function helpPopUp(){

	var w = window.open("/contextual_help/contextual_help.html", "contextual_help","width=392,height=300,status=yes,resizable=no" );

}

function launchplayer(StreamType, StreamChannel) {

		var agt = navigator.userAgent.toLowerCase();
		var is_mac = (agt.indexOf("mac")!=-1);

		if (is_mac != true) {
		var options = "width=490,height=190,resizable=no";
		var thehref = "/wmp_skin/wmp_skin.jsp?type=" + StreamType + "&channel=" + StreamChannel;
		}
		else { 
		var options = "width=310,height=80,resizable=no,screenX=0,screenY=0";
	 	var thehref = "/wmp_skin/mac_wmp.jsp?type=" + StreamType + "&channel=" + StreamChannel;
		}	
		
		
		var remote = window.open(thehref,"wmp",options);
 
        if (!remote.opener) remote.opener = self; // For JS1.0
        if (remote.focus) remote.focus();
        // Netscape 6.0 complains when focusing on newly opend window, saying
        // "uncaught exception". This exception cannot be caught even if it's in try block.
        // This is a known N6 bug, and no workaround is made here.
}

function launchplayer2(StreamChannel) {
	
		var options = "width=490,height=190,resizable=no";
		var thehref = "/wmp_skin/traffic_wmp_skin.jsp?streamURL=/metafiles/" + StreamChannel + ".asx";	
		
		var remote = window.open(thehref,"wmp",options);
 
        if (!remote.opener) remote.opener = self; // For JS1.0
        if (remote.focus) remote.focus();
        // Netscape 6.0 complains when focusing on newly opend window, saying
        // "uncaught exception". This exception cannot be caught even if it's in try block.
        // This is a known N6 bug, and no workaround is made here.
}

function checkpassword(){

if ((document.pressroom_login.pass.value)=="Entertainment") location.href="/newsroom-secure/press_room_main.html"
else alert("Please enter the correct password");

}


function newWin(theURL){
var confirmWin = window.open(theURL,'','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');

	//give a reference between the opener
	//and the popup for backwards compatibility
	if(confirmWin.opener==null){
		confirmWin.opener = self;
	}
	return false;
}

function imagepop(bg, image, width, height) { //maDprogrAMiNsklz 2003 (c)
	
	window.open('/generic/pop_up.jsp?bgColor=' + bg + '&image=' + image + '', 'xtWin', 'left=10,top=10,width=' + width + ',height=' + height + ',scrollbars=no,status=no');
	
}

	
function popTriviaWindow(window_url){ //mwiest 05/14/2004

	window.open(window_url, '', 'left=10,top=10,width=450,height=500,scrollbars=yes,status=no');
	
}

function launchXMRO() {
	
		var options = "width=760,height=448,resizable=no,scrollbars=no,status=no,top=10,left=10";
		var thehref = "/xstream/service/player/wmp/index.jsp";	
		
		var agt=navigator.userAgent.toLowerCase();
		if (agt.indexOf("msie") == -1){
		
		options = "width=760,height=478,resizable=no,scrollbars=no,status=no,top=10,left=10";
		
		}
		
		
		var remote = window.open(thehref,"wmp",options);
 
        if (!remote.opener) remote.opener = self; // For JS1.0
        if (remote.focus) remote.focus();
        // Netscape 6.0 complains when focusing on newly opend window, saying
        // "uncaught exception". This exception cannot be caught even if it's in try block.
        // This is a known N6 bug, and no workaround is made here.
}

function why_login() {
	
		var options = "width=400,height=150,resizable=no,scrollbars=yes,status=no,top=10,left=10";
		var thehref = "/xstream/registration/why_login.jsp";	
		
		var remote = window.open(thehref,"why",options);
 
        if (!remote.opener) remote.opener = self; // For JS1.0
        if (remote.focus) remote.focus();
        // Netscape 6.0 complains when focusing on newly opend window, saying
        // "uncaught exception". This exception cannot be caught even if it's in try block.
        // This is a known N6 bug, and no workaround is made here.
}


function find_radio() {
	
		var options = "width=400,height=150,resizable=no,scrollbars=yes,status=no,top=10,left=10";
		var thehref = "/xstream/registration/find_radio.jsp";	
		
		var remote = window.open(thehref,"why",options);
 
        if (!remote.opener) remote.opener = self; // For JS1.0
        if (remote.focus) remote.focus();
        // Netscape 6.0 complains when focusing on newly opend window, saying
        // "uncaught exception". This exception cannot be caught even if it's in try block.
        // This is a known N6 bug, and no workaround is made here.
}

	function isBeatlesFormReady(form)
	{		
	// returns true/false depending on success of validating form
		var errorMsg = "";
		var tmpMsg = "";
			
		// check for empty field entries
		if (!hasLetter(form.fullname.value)) {
			tmpMsg = tmpMsg + "     Your Name\n";
		}
		if (!hasLetter(form.address.value)) {
			tmpMsg = tmpMsg + "     Mailing Address\n";
		}
		if (!hasLetter(form.city.value)) {
			tmpMsg = tmpMsg + "     City\n";
		}
		if (!hasLetter(form.state.value)) {
			tmpMsg = tmpMsg + "     State\n";
		}
		var hasEmail = hasLetter(form.email.value);
		if (!hasEmail) {
			tmpMsg = tmpMsg + "     Email Address\n";
		}
		if (!hasLetter(form.q1.value)) {
			tmpMsg = tmpMsg + "     Question #1\n";
		}
		if (!hasLetter(form.q2.value)) {
			tmpMsg = tmpMsg + "     Question #2\n";
		}
		if (!hasLetter(form.q3.value)) {
			tmpMsg = tmpMsg + "     Question #3\n";
		}
		if (!hasLetter(form.q4.value)) {
			tmpMsg = tmpMsg + "     Question #4\n";
		}
		if (!hasLetter(form.q5.value)) {
			tmpMsg = tmpMsg + "     Question #5\n";
		}
		if (!hasLetter(form.q6.value)) {
			tmpMsg = tmpMsg + "     Question #6\n";
		}
		if (!hasLetter(form.q1.value)) {
			tmpMsg = tmpMsg + "     Question #1\n";
		}

		if (tmpMsg.length>0) {
			errorMsg = "Please fill out the following:\n" + tmpMsg + "\n";
		}
			
		// if there was an email entry, check for valid email address
		if (hasEmail) {
				if (!isValidEmail(form.email.value)) {
					errorMsg = errorMsg + "Please enter a valid email address.\n";
				}
		}
		
		if (errorMsg.length>0) {
			alert (errorMsg);
			return false; 
		} else {
			return true;
		}
	}
	
	function jsfBeatlesSubmit(form) {
		 if (isBeatlesFormReady(form))
			form.submit();
	} 
