
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
  MM_reloadPage(true);
}
	function initPrimary( formObj )
	{
		// Fill up primary selector with labels/values
		if ( loading )
			getQueryVals();
		
		formObj.primary.length = 0;
		formObj.primary.options[0] = new Option( selData[0][1], selData[0][0], 1, 1 );
		for ( var i=1; i<selData.length; i++ )
		{
			formObj.primary.options[i] = new Option( selData[i][1], selData[i][0] );
		}
		
		if ( loading && initPri != null ) {
			idx = getSelectorIndex( selData, initPri );
			if ( idx != null ) {
				formObj.primary.selectedIndex = idx;
			}
		}
		
		initSecondary( formObj );
	}
	
	function initSecondary( formObj )
	{
		//This happens when the page is first loaded or when an item in the Primary Menu is selected 
		// Fill up secondary selector with labels/values
		var priIndex = formObj.primary.selectedIndex;
		formObj.secondary.length = 0;

		if ( selData[ priIndex ][2].length > 0 )
		{
			formObj.secondary.options[0] = new Option( selData[ priIndex ][2][0][1], selData[ priIndex ][2][0][0], 1, 1 );
			for ( var i=1; i<selData[ priIndex ][2].length; i++ )
			{
				formObj.secondary.options[i] = new Option( selData[ priIndex ][2][i][1], selData[ priIndex ][2][i][0] );
			}
			if ( loading && initSec != null )
				formObj.secondary.selectedIndex = initSec;

			if ( loading && initSec != null ) {
				idx = getSelectorIndex( selData[ priIndex ][2], initSec );
				if ( idx != null ) {
					formObj.secondary.selectedIndex = idx;
				}
			}

			secondaryVisibility( formObj, "visible" );
		} else {
			secondaryVisibility( formObj, "hidden" );
			if ( !loading ) {
				selectorGo( formObj );
			}
		}
		loading = false;
	}
	
	function getQueryVals() {
		qStr = location.href.split("?")[1];
		if ( qStr != null ) {
			var props = qStr.split("&");
			var vals = new Array();
			for ( i=0; i<props.length; i++ ){
				vals[i] = props[i].split("=");
				switch( vals[i][0] ) {
					case pri:
						initPri = vals[i][1];
						break;
					case sec:
						initSec = vals[i][1];
						break;
				}
			}
			//alert( pri + "=" + initPri + "\n" + sec + "=" + initSec );
		} else {
			alert( "no query string" );
		}
	}
	
	function secondaryVisibility( frm, state ) {
		secondaryState = state;
		frm.secondary.style.visibility = secondaryState;
	}

	function primaryChanged( formObj ) {
		//This happens when an item in the Secondary Menu is selected
		if ( formObj.primary.options[ formObj.primary.selectedIndex ].value != noAction ) {
			initSecondary( formObj );
		}
	}
	
	function secondaryChanged( formObj ) {
		//This happens when an item in the Secondary Menu is selected
		if ( formObj.secondary.options[ formObj.secondary.selectedIndex ].value != noAction ) {
			selectorGo( formObj );
		}
	}
	
	function goOver( formObj ) {
		window.status = 'Go to ' + formObj.secondary.options[ formObj.secondary.selectedIndex ].text;
	}
	
	function goOut( formObj ) {
		window.status = '';
	}
	
	function selectorGo( formObj ) {
		queryStr = "?" + pri + "=" + formObj.primary.options[ formObj.primary.selectedIndex ].value + 
		  (secondaryState == "visible" ? "&" + sec + "=" + 
		  formObj.secondary.options[ formObj.secondary.selectedIndex ].value : "" );
		queryStr += "&brand=" + brand;
		window.location.href = page + queryStr;
		//alert( page + queryStr );
	}

	function getSelectorIndex( ar, val ) {
		for ( i=0; i<ar.length; i++ ) {
			if ( ar[i][0] == val ) {
				return i;
				break;
			}
		}
		return null;
	}

