/******************************
*
* Javascript for www.scootersfriends.com
*
* @date: 2007-0606
*
* some code may be borrowed or heavily inspired by Jeremy Keith's DOM Scripting (2005) from Friends of Ed.
*
*********************************/


/* custom stuff */



/* this function drives the main navigation */
function prep_mainNavRO(){
	if(!document.getElementsByTagName || !document.getElementById){
		return false;
	}
	if(document.getElementById("L1nav")){
		var myHeader = document.getElementById("L1nav");
		var links = myHeader.getElementsByTagName("a");
		for(var i=0; i<links.length; i++){
			links[i].onmouseover = function(){
				this.firstChild.src = this.firstChild.src.substring(0, this.firstChild.src.lastIndexOf(".")) + "_f2.gif";
			}
			links[i].onmouseout = function() {
				this.firstChild.src = this.firstChild.src.substring(0, this.firstChild.src.lastIndexOf("_")) + ".gif";
			}
		}
	}
}
addLoadEvent(prep_mainNavRO);


//function to resize container on the /portfolio/index.php page 
function resizeContainer(){
	if(document.getElementById("productNav")){
		var frame = document.getElementById("productNav");
		var maxHeight = frame.height;
		maxHeight = maxHeight + 20; // extra height to make all browsers happy
		//var maxHeight = document.body.parentNode.scrollHeight;
		//var frame2 = document.getElementById("container");
		//frame2.style.height = maxHeight + "px";
		frame.style.height = maxHeight + 20 + "px";
	}
}
addLoadEvent(resizeContainer);



/* global resources */

/* function to simply multiple functions in window.onload
* DOM Scripting (103) :: Simon Willison (http://simon.incution.com) */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if(typeof window.onload != 'function'){
		window.onload = func;
	}
	else {
		window.onload = function(){
			oldonload();
			func();
		}
	}
}


/* generic popup window function to act as an interface to window.open() 
* DOM Scripting (88) */
function popUp(winURL, title, w, h){
	d = "width=" + w + ",height=" + h;
	window.open(winURL, title, d);
}


/* javascript to preload the full-size images on the portfolio/project.php pages * takes 4 image arguments to correspond to the 4 possible images in the portfolio */
function portfolioPreloader(img1, img2, img3, img4, img5, img6, img7) {
	var i = 0;
	
	imageObj = new Image();
	
	//set image list
	images = new Array();
	images[0] = img1;
	images[1] = img2;
	images[2] = img3;
	images[3] = img4;
	images[4] = img5;
	images[5] = img6;
	images[6] = img7;
	
	// start preloading
	for(i = 0; i<=6; i++) {
		imageObj.src=images[i];
	}
}



