function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}
var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		nav_buildings = newImage("/gsa/images/nav_buildings-over.gif");
		nav_products = newImage("/gsa/mages/nav_products-over.gif");
		nav_services = newImage("/gsa/images/nav_services-over.gif");
		nav_technology = newImage("/gsa/images/nav_technology-over.gif");
		nav_policy = newImage("/gsa/images/nav_policy-over.gif");
		nav_about = newImage("/gsa/images/nav_about-over.gif");
		preloadFlag = true;
	}
}

var strVisible='';
var timer;
var blnActivated=0;
var homepage=0;
var hasCustomize=0;
var hasHideMe=0;

function makeObj(div,nest){
	if(document.layers){
		return false;
	}
	else if(document.all){
		obj=div
		this.css=eval(obj+".style");
	}
	else{
		this.css=eval("document.getElementById(\""+div+"\").style");
	}
	this.show=show;
	this.hide=hide;
	this.delay=delay;
	hidden=(document.layers)?"hide":"hidden"
	visible=(document.layers)?"show":"visible"
}

function show(otherLayer){
	if (document.layers){
		return false;
	}
	
	clearTimeout(timer)

	if(strVisible!=this)
		hide();
	this.css.visibility=visible
	strVisible=this;

	if ((this==divProducts ||this==divServices) && hasCustomize) {
		divCustomizeRegion.css.visibility=hidden; 
	}
	else if ((this==divPolicy	|| this==divAbout) && hasHideMe) {
		divHideMe.css.visibility=hidden;
	}
	else	{
		return false;
	}
}

function hide(){
	if(strVisible!="")
	{
		strVisible.css.visibility=hidden;
		if(hasCustomize)
			divCustomizeRegion.css.visibility=visible;
		if(hasHideMe)
			divHideMe.css.visibility=visible;
	}
}

function delay(){
	if(document.layers)
		return false;
	timer=setTimeout('hide()',200);
}


function homeInit()
{
	divCustomizeRegion=new makeObj('customizeRegion');
}

function hideInit()
{
	divHideMe=new makeObj('hideMe');
}

function init(){
	if (document.layers)
		return false;
	divBuildings=new makeObj('buildings');
	divProducts=new makeObj('products');
	divServices=new makeObj('services');
	divTechnology=new makeObj('technology');
	divPolicy=new makeObj('policy');
	divAbout=new makeObj('about');
	blnActivated=1;
	preloadImages();
	if(document.getElementById("customizeRegion")){
		homeInit();
		hasCustomize=1;
	}
	if(document.getElementById("hideMe")){
		hideInit();
		hasHideMe=1;
	}
}

function popupPictures(imgName,repo,h,w){
	SB="no"
	if(h)
		WinHeight=parseInt(h)+35;
	else
		WinHeight=600;
	if(w)
		WinWidth=parseInt(w);
	if(WinHeight>600){
		WinHeight=600;
		WinWidth+=25;
		SB="yes";
	}
	newWin = window.open("/gsa/popup_picture_"+repo+".html",imgName,"height="+WinHeight+",width="+WinWidth+",scrollbars="+SB+"");
}

//This script ensures that if the popup is opened, then *not* closed,
//then another popup link is selected or the same link is clicked,
//the popup window will gain focus. It's also generic enough to be used anywhere.
//The best implementation would be to call the script in an onclick event,
//and have the anchor's href attibute link to the file meant to be included in the pop-up,
//as below, ensuring that users with Javascript disabled will still be able
//to access the content.

function windowOpener(url, name, args) {
	if (typeof(popupWin) != "object"){
		popupWin = window.open(url,name,args);
	} 
	else {
		if (!popupWin.closed){ 
			popupWin.location.href = url;
		} 
		else {
			popupWin = window.open(url, name,args);
		}
	}
	popupWin.focus();
}



function setAction(st) {
	document.form.queryState.value = st;
    document.form.submit(); 
}


function submitState(stateObj) {
  var selectedIndex = stateObj.selectedIndex;
  var value = stateObj.options[selectedIndex].value;  
  if (value!="") 
	document.perDiemFeedBackForm.submit();  	
  return false;  
} 
function setFbAction(){
	document.getElementById("actionType").value= "sendemail";        	
}
function setActionAdd(){
	document.getElementById("actionType").value= "addhotel";        	
}