// this function switches the tabs by doing style changes on the fly
// it unwrites all the list items' styles first, then applies the style to the numbered item

function resorttabs(tabon){
	tab_list = top.document.getElementById('tablist');
	tab_on = top.document.getElementById('tab_' + tabon);
	if (!(tab_list && tab_on)) return;

	for (var i=0; i<tab_list.childNodes.length; i++) {
		if (tab_list.childNodes[i].tagName == 'LI') {
			tab_list.childNodes[i].className = '';
		}
	}
	if (tab_on.tagName == 'LI') {
		tab_on.className = 'overstate';
	}
}

//this script puts the overwrite CSS file onto the page for PCIE/NS
//If you make the NS version higher than 5, it will apply the ns_styles to Safari
//and we don't want that.

if(navigator.appName == "Microsoft Internet Explorer" && navigator.platform != "MacPPC"){

document.write('<link rel="stylesheet" href="/css/ie_classes.css" type="text/css" />');

}else if(navigator.appName == "Netscape" && navigator.platform != "MacPPC"){

document.write('<link rel="stylesheet" href="/css/ns_classes.css" type="text/css" />');

}


function popupwindow(theurl,windowname,features){
window.open(theurl,windowname,features);
void 0;
}

function popup(theurl,windowname,features){
window.open(theurl,windowname,features);
void 0;
}



function choose05bike(){

	if(document.bikeselection.my05[document.bikeselection.my05.selectedIndex].value=='@'){
	
	}
	
	else{

		document.location = document.bikeselection.my05[document.bikeselection.my05.selectedIndex].value;

	}
	
	
	document.bikeselection.my05.options[0].selected=true

}

function choose04bike(){

	if(document.bikeselection.my04[document.bikeselection.my04.selectedIndex].value=='@'){
	
	}
	
	else{// In this section we set up the content to be placed dynamically on the page.
// Customize movie tags and alternate html content below.



		document.location = document.bikeselection.my04[document.bikeselection.my04.selectedIndex].value;

	}
	
	
	document.bikeselection.my04.options[0].selected=true

}


//Taken from O'Reilly Cookbook

function adjustiFrameSize(id){
	var myiframe = top.document.getElementById(id);

	if (myiframe){
	
		if (myiframe.contentDocument && myiframe.contentDocument.body.offsetHeight){
			//W3C DOM (and Mozilla) syntax
			myiframe.height = myiframe.contentDocument.body.offsetHeight;
		}
		else if (myiframe.Document && myiframe.Document.body.scrollHeight){
			//IE DOM syntax
			myiframe.height = myiframe.Document.body.scrollHeight;
		}
		// bind onload events to iframe
		if (myiframe.addEventListener){
		
			myiframe.addEventListener('load', resizeIframe, false);
		
		}else{
		
			myiframe.attachEvent('onload', resizeIframe);
		
		}
	}
}

function resizeIframe(evt){
	evt = (evt) ? evt : event;
	var target = (evt.target) ? evt.target : evt.srcElement;
	// take care of W3C event processing from iframe's root document
	
	if (target && target.nodeType && target.nodeType == 9){
		if (evt.currentTarget && evt.currentTarget.tagname.toLowerCase() == "iframe"){
	
			target = evt.currentTarget;
		
		}
	}
	if(target){
	
		adjustiFrameSize(target.id);
	
	}
}

function flashcall(flashsrc,flashwidth,flashheight){
	// Optionally add a bgcolor parameter
	bgcolor = "#FFFFFF";
	if (arguments.length > 3)
	  bgcolor = arguments[3];
	
	if (!useRedirect) {    // if dynamic embedding is turned on
	  if(hasRightVersion) {  // if we've detected an acceptable version
	    var oeTags = '<OBJECT CLASSID="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'
	    + 'WIDTH="' + flashwidth + '" ' + 'HEIGHT="' + flashheight + '"'
	    + 'CODEBASE="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0">'
	    + '<param name="allowScriptAccess" value="sameDomain" />'
	    + '<PARAM NAME="MOVIE" VALUE="' + flashsrc + '">'
	    + '<PARAM NAME="PLAY" VALUE="true">'
	    + '<PARAM NAME="LOOP" VALUE="false">'
	    + '<PARAM NAME="QUALITY" VALUE="high">'
		+ '<PARAM NAME="bgcolor" VALUE="' + bgcolor + '">'
	    + '<param name=FlashVars value="langType=us">'
	    + '<PARAM NAME="MENU" VALUE="false">'
	    + '<EMBED SRC="' + flashsrc + '"'
	    + 'WIDTH="' + flashwidth + '" ' + 'HEIGHT="' + flashheight + '"'
	    + 'name="index"'
	    + 'align="middle"'
	    + 'allowScriptAccess="sameDomain"'
	    + 'PLAY="true"'
	    + 'LOOP="false"'
	    + 'flashVars="langType=us"'   
	    + 'bgcolor="' + bgcolor + '"'
	    + 'QUALITY="high"'
	    + 'MENU="false"'
	    + 'TYPE="application/x-shockwave-flash"'
	    + 'PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">'
	    + '<\/EMBED>'
	    + '<\/OBJECT>';
	
	    document.write(oeTags);   // embed the flash movie
	  } else {  // flash is too old or we can't detect the plugin
	    // NOTE: height, width are required!
	    var alternateContent = '<a href="http://www.macromedia.com/go/getflash"><img src="/images/shared/non_flash_image.jpg" alt="Bike Menu" border="0" width="750" height="376" /></a>';
	
	    document.write(alternateContent);  // insert non-flash content
	  }
	}
}

function randomString() {
	if (arguments.length == 0)
		str_len = 8;
	else
		str_len = arguments[0];

	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var str = '';
	for (var i=0; i < str_len; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		str += chars.substring(rnum,rnum+1);
	}
	return str;
}
