//<script language='JavaScript' type="text/javascript">
<!--
//alert('sharedscripts up')

function preloadImages(imageList) { 
	//alert('preloading images')
	var doc=document; //put the document object into a variable for abbreviated handling
	if(doc.images){ //if this browser is capable of finding document images, then proceed
		if(!doc.loadedImages) doc.loadedImages=new Array(); //if the loadedimages array doesn't yet exist, create it & attach it to the document object
		var i,len=doc.loadedImages.length; //set up variables
		for(i=0; i<imageList.length; i++){//cycle through the image paths passed as arguments and preload them
  			doc.loadedImages[len]=new Image(); 
			doc.loadedImages[len++].src=imageList[i];//note that putting the ++ after "len" increments "len" AFTER the current expression is evaluated!
    		//alert(doc.loadedImages.length + ' images have been preloaded');
		}
	}
}

function goURL(url,target,popWidth,popHeight,resize,scrollbars) {
	if(!resize){
		resize=1;
	}
	if(!scrollbars){
		scrollbars=0;
	}
	//alert('goURL, url= ' + url + ' target= ' + target)
	switch (target) {
		case 'top':
			window.location=url;
			break;
		case 'popup':
			if (!popWidth) {
				popWidth=410;
			}
			if (!popHeight) {
				popHeight=420;
			}
			var winLeft=(screen.width - popWidth)/2;
			var winTop=(screen.height - popHeight)/2;
			popWin=window.open('','','width=' + popWidth + ',height=' + popHeight + ',left=' + winLeft + ',top=' + winTop + ',resizable=' + resize +',scrollbars=' + scrollbars);
			popWin.location=url;
			popWin.focus();
			break;
	}
}

//controls images swaping for both mouseEnter & mouseLeave actions
function imageSwap(mouseDir,objID) { 
	//alert('in imageSwap')
	imageInfo=null;
	if ((imgObjPath=findObjectPath(objID))!=null){
  		switch (mouseDir) {
			case'enter':
  				newImgPath=stringReplace(imgObjPath.src,'_norm','_over');
				imgObjPath.src = newImgPath;
				break;
			case'leave':
  				newImgPath=stringReplace(imgObjPath.src,'_over','_norm');
				imgObjPath.src = newImgPath;
				break;
		}
	}
}

//controls images swaping for both mouseEnter & mouseLeave actions on models
function modelimageSwap(mouseDir,objID,model) { 
	//alert('in imageSwap')
	imageInfo=null;
	if ((imgObjPath=findObjectPath(objID))!=null){
  		switch (mouseDir) {
			case'enter':
  				newImgPath=stringReplace(imgObjPath.src,'_norm','_'+model);
				imgObjPath.src = newImgPath;
				//alert('enter path:'+newImgPath);
				break;
			case'leave':
  				newImgPath=stringReplace(imgObjPath.src, '_'+model,'_norm');
				imgObjPath.src = newImgPath;
				//alert('leave path:'+newImgPath);
				break;
		}
	}
}

function findObjectPath(objID,popWin) {
	//alert('finding object path')
	//return the appropriate object path depending on what browser we are using.
	//Note that if the browser doesn't support one of these object models, null is returned
	var pathInfo;
	if (!popWin) {
		//alert('not using popWin')
		if (document.getElementById) {
			//alert('found getElementByID, objID= ' + objID)
			pathInfo=document.getElementById(objID);
		} else if (document.all) {
			//alert('found all, objID= ' + objID)
			pathInfo=document.all[objID];
		} else if (document.layers) {
			//alert('found layers, objID= ' + objID)
			pathInfo=document.images[objID];
		} else { 
			//alert('unable to process DHTML on this browser')
			pathInfo=null;
		}
	}else{
		//alert('using popWin')
		if (popWin.document.getElementById) {
			//alert('found getElementByID, objID= ' + objID)
			pathInfo=popWin.document.getElementById(objID);
		} else if (popWin.document.all) {
			//alert('found all, objID= ' + objID)
			pathInfo=popWin.document.all[objID];
		} else if (popWin.document.layers) {
			//alert('found layers, objID= ' + objID)
			pathInfo=popWin.document.images[objID];
		} else { 
			//alert('unable to process DHTML on this browser')
			pathInfo=null;
		}
	}
	//alert('pathInfo=' + pathInfo)
	return pathInfo;
}

//this is a script to modify a given string with the given new string info
function stringReplace(modifyString,findString,replaceString) {
	//alert('in stringReplace')
	var pos=0,len=findString.length;
	pos=modifyString.indexOf(findString);
	//using the 'while(pos != -1)' here allows us to escape if the 'findString' we are sending isn't found in the 'modifyString' at all
	while(pos != -1) {
		preString=modifyString.substring(0,pos);
		postString=modifyString.substring(pos+len,modifyString.length);
		modifyString=preString+replaceString+postString;
		pos=modifyString.indexOf(findString);
	}
	return modifyString;
}
	
//-->
