var isNav, isIE, isN6;
var coll = "";
var styleObj = "";
var currSub = "none"
var name = "none"

if( navigator.appName == "Netscape"){
	if ( parseInt( navigator.appVersion ) >= 5 ){
		isN6 = true;
		//styleObj = ".style";
		//coll = "getElementById(";
		//styleObj = ").style";
	}
	else
		isNav = true;
	
}
else{
	isIE = true;
	coll = "all.";
	styleObj = ".style";
}



function getObject( obj ){
	var theObj, temp;
	//if( isN6 ){
		//theObj = document.getElementById( obj )
		//alert( theObj );
	//}
	if(typeof obj == "string"){
		if( isN6 ){
			theObj = document.getElementById( obj ).style;
			//theObj = eval("document."+obj+".style");
			//alert( theObj );
		}
		else
			theObj = eval("document."+coll+obj+styleObj);
	}else{
		theObj = obj;
	}
	return theObj;
}


function rollOver( imageName, imageSrc, layer ){
	
		if( isNav ){
			if( layer != "" ){
				var obj = eval("document."+layer+".document");
				obj.images[imageName].src = imageSrc;
			}
			else
				document.images[imageName].src = imageSrc;
		}
		else{
			document[imageName].src = imageSrc;
		}
}


function hide( obj ){
		var theObj = getObject(obj);
		theObj.visibility = "hidden";

}



function show( obj ){
		var theObj = getObject(obj);
		theObj.visibility = "visible";
}


function openWin( URL ) { 
  var newWin = window.open(URL,"newWin","toolbar,scrollbars,width=450,height=470");
  newWin.focus();
}


var defimg, timer,currentSub,DefaultSub,tempimg,tempsrc,DefaultImg;



pauselength = 750;

function init( str ){

	//preload all images
	preloadImgs();
	
	currentSub = str;
	tempSub = currentSub; 

}

function showsub(){
	if( currentSub != '' ){	

		show( currentSub );
		
	}

}

function mover( imageName, imageSrc, targSub ){

	
	//clear timeout
	window.clearTimeout(timer);
	
	//mosueover the menu item
	rollOver( imageName, imageSrc, "" );

	//hide the current submenu
	if( tempSub != "" ){
		hide( tempSub );
	}
	
	if( currentSub != "" ){
		hide( currentSub );
	}
	//mouseout of the open menu image if there is one
	//and its not the current image
	if( tempimg  != "" ){
		if( document[ tempimg ] ){
			if(tempimg != imageName){//dont mouseout if its the current image
				rollOver( tempimg, tempsrc, "" );	
			}
		}
	}

	//show submenu if there is one
	if( targSub != "" ){
		show( targSub );
		//capture the name so you know what to shut off
		tempSub = targSub;
	}



}

function mout( imageName, imageSrc ){

	tempimg = imageName;
	tempsrc = imageSrc;
	
	
	//rollOver( imageName, imageSrc, "" );
	//start timer - the timer will expire and close the submenu if not selected first
	timer = setTimeout( "closeTemp()", pauselength );


}


function sover(){

	
	//clear timeout
	clearTimeout(timer);
	
	
}

function sout(){

	
	//set timeout
	timer = setTimeout( "closeTemp()", pauselength );
	
	

}


function closeTemp(){
	
	if( tempSub != "" ){
		hide(tempSub);
	}
	
	//show the current sub - the default sub
	if( currentSub != '' ){	

		show( currentSub );
		
	}
	
	//mouse out of current image if there is one
	if( tempimg != "" ){
		rollOver( tempimg, tempsrc, "" );
	}
	tempimg = "";
	tempsrc = "";
}

function preloadImgs() { 

		
		//img1 = new Image; 
		//img1.src = "images/menu/contacton.gif";

}

function reloadWin(){
	document.location = document.location;
}


function isEmpty( str ){


	if(( str == "") || (str == " ")){
	
		return true;
	}


}

function openwin( URL ){
	
		winwidth = 550;
		winheight = 550;
		var newWin = window.open(URL,"presswin","toolbar,scrollbars,width=" + winwidth + ",height=" + winheight );
	  	//alert("width=" + winwidth + ",height=" + winheight);
		newWin.focus();


}

function previewImg( URL ){
	winwidth = 550;
	winheight = 300;
	var newWin = window.open(URL,"presswin","toolbar,resizeable,scrollbars,width=" + winwidth + ",height=" + winheight );
	//alert("width=" + winwidth + ",height=" + winheight);
	newWin.focus();


}

function previewselectedpic(){
	d = document.mainform.picture;
	src = d.options[d.selectedIndex].value;
	if( d.selectedIndex > 0 ){
		URL = "http://www.cochraneventilation.com/previewimage.php?img=" + src;
		previewImg( URL );
	}

}

function previewselectedpdf(){

	d = document.mainform.pdf;
	src = d.options[d.selectedIndex].value;
	if( d.selectedIndex > 0 ){
		URL = "previewpdf.php?img=" + src;
		previewPDF( URL );
	}
}

function previewPDF( URL ){
	winwidth = 600;
	winheight = 400;
	var newWin = window.open(URL,"presswin","toolbar,resizeable,scrollbars,width=" + winwidth + ",height=" + winheight );
	//alert("width=" + winwidth + ",height=" + winheight);
	newWin.focus();


}