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( imageName != ""){
		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 openWin( URL ) { 
  var newWin = window.open(URL,"newWin","toolbar,scrollbars,width=450,height=470");
  newWin.focus();
}


var defimg, timer,currentSub,tempSub,tempimg,tempsrc;



pauselength = 750;

function init( str,str2){
	//the main default
	
	//preload all images
	preloadImgs();
	
	defimg = str;
	defsrc = str2;

}


function mover( imageName, imageSrc, targSub ){

	//rollout the default image
	defsrc = "images/menu/" + defimg + ".gif";
	rollOver( defimg, defsrc, "" );
	
	//clear timeout
	window.clearTimeout(timer);
	
	//mosueover the menu item
	rollOver( imageName, imageSrc, "" );

	
	//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, "" );	
			}
		}
	}



}

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);
	
	//mosueover the menu item
	//rollOver( imageName, imageSrc, layer );

}

function sout(){

	
	//set timeout
	timer = setTimeout( "closeTemp()", pauselength );
	
	//mosueover the menu item
	//rollOver( imageName, imageSrc, layer );

}


function closeTemp(){
	


	//mouse out of current image if there is one
	if( tempimg != "" ){
		rollOver( tempimg, tempsrc, "" );
	}
	//restore the default image
	defsrc = "images/menu/" + defimg + "on.gif";
	rollOver( defimg, defsrc, "" );
	
	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 = "previewimage.php?img=" + src;
		previewImg( URL );
	}

}

function previewthumpic(){
	d = document.mainform.thumbnail;
	src = d.options[d.selectedIndex].value;
	if( d.selectedIndex > 0 ){
		URL = "previewimage.php?img=" + src;
		previewImg( URL );
	}

}

function previewhomepic(){
	d = document.mainform.homepic;
	src = d.options[d.selectedIndex].value;
	if( d.selectedIndex > 0 ){
		URL = "previewimage.php?img=" + src;
		previewImg( URL );
	}

}

function previewfilepic(){
	d = document.mainform.filepath;
	src = d.options[d.selectedIndex].value;
	if( d.selectedIndex > 0 ){
		URL = "previewimage.php?img=" + src;
		previewImg( URL );
	}

}

function directions( URL ){
	winwidth = 550;
	winheight = 500;
	URL = "http://www.amsolutions.net/directions_" + URL + ".php";
	var newWin = window.open(URL,"dirwin","toolbar,resizeable,scrollbars,width=" + winwidth + ",height=" + winheight );
	//alert("width=" + winwidth + ",height=" + winheight);
	newWin.focus();


}
