window.onload = init;


function init() {
setItemVal();
externalLinks();
}


var photoWin = null;

function viewPhoto( imgSrc, imgTitle ) {

	if( photoWin ) {
		photoWin.close();
	}
	photoWin = window.open( '', 'photoWin', 'width=150,height=150' );

	var htm = '<html>' +
	'<head>' +
	'<title>' + imgTitle + '</title>' +
	'<meta http-equiv="imagetoolbar" content="false" />' +
	'</head>' +
	'<body style="margin: auto; padding: auto; overflow: hidden;" onload="document.getElementById(\'theDiv\').style.visibility=\'visible\';document.getElementById(\'closeWin\').style.visibility=\'visible\';window.resizeTo(document.images[ \'theImage\' ].width+30,document.images[ \'theImage\' ].height+70);">' +
	'<p style="font: 11px Verdana,sans-serif; position: absolute; top: 10px; left: 10px;">Image Loading<br /><blink>Please wait...</blink></p>' +
	'<div id="theDiv" style="visibility: hidden; position: absolute; top: 10px; left: 10px; text-align: center;"><img src="' + imgSrc + '" border="0" id="theImage" alt="' + imgTitle + '" /></div>' +
	'<div id="closeWin" style="visibility: hidden; position: absolute; top: 5px; left: 0; width: 100%; z-index: 100; text-align: right; display: block;"><form><input type="button" style="background: #fff; border: 1px solid #000000; color: #000000; font: bold 11px Verdana, sans-serif; margin-right: 5px; display: inline;" onclick="window.close();" value="Close Window" /></form></div>' +
	'</body>' +
	'</html>';

	photoWin.document.write( htm );
	photoWin.document.close();
}

var popUpWin = null;

function openWindow( winUrl, winWidth, winHeight ) {

    if( popUpWin ) {
		popUpWin.close();
	}
	popUpWin = window.open( winUrl, 'popUpWin', 'width=' + winWidth + ',height=' + winHeight + ',status=yes,scrollbars=yes,resizable=yes' );
}


function externalLinks() { 

if (!document.getElementsByTagName) return; 
var anchors = document.getElementsByTagName("a"); 
for (var i=0; i<anchors.length; i++) { 
var anchor = anchors[i]; 
if (anchor.getAttribute("href") && 
anchor.getAttribute("rel") == "external") 
anchor.target = "_blank"; 
} 
}

function setItemVal() {

	// get value passed from url - in this case ?subject=1
	var val = getVal( 'subject' );

	// target item
	var item = document.getElementById( 'vehicle' );

	// loop through menu and select
	if( val && item ) {
		for( var i = 0; i < item.length; i ++ ) {
			var vals = item.options[ i ];
			if( vals.value == unescape( val ) ) {
				vals.selected = true;
			}
		}
	}
}

function getVal( var_name ) {

	// return matching value for var_name in url string
	var query = window.location.search.substring( 1 );
	// loop through all parameteres on url
	var values = query.split( '&' );
	for( var i = 0; i < values.length; i ++ ) {
		var pair = values[ i ].split( '=' );
		if( pair[ 0 ] == var_name ) {
			return pair[ 1 ];
		}
	}
	return;
}




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];}
}