//Browser Detection

var bType;
function BDetect () {
	if (document.layers) {
	bType = "ns4";
	}
	else if (document.getElementById) {
	bType = "dom"
	}
	else if (document.all && !document.getElementById) {
	bType = "ie4";
	}
	else {
	bType = "other";
	}
}
BDetect();

//Mac ?
isMac = 0;
if (navigator.appVersion.indexOf("Mac") > -1)	{
	isMac	= 1;
	//alert("isMac");
}

function setElementProperty(elm, property, value){
	var thisElm = null;
	if(typeof(elm) == "object"){
		thisElm = elm;
	} else {
		thisElm = document.getElementById(elm);
	}
	if((thisElm != null) && (thisElm.style != null)){
		thisElm = thisElm.style;
		thisElm[property] = value;
	}
}

// Popup Window
function popWin(url,wd,ht,scroll) {
	useScroll = 0;
	if (scroll == 1)	{
		useScroll = 1;
	}
	height = ht;
	width = wd;
	thisURL = url;
	popupWin=window.open(thisURL,"","width=" + width + ",height=" + height + ", scrollbars=" + useScroll + ", resizable")
}

function goToMetro() {
	if(document.searchProperties.metroList.selectedIndex != 0) {
		thisMetro = document.searchProperties.metroList.value;
		thisURL = "http://www.intownsuites.com/detail_metro.asp?city=" + thisMetro;
		changeLocation(thisURL);
	} else {
		if(document.searchProperties.states.selectedIndex != 0) {
			thisState = document.searchProperties.states.value;
			thisURL = "http://www.intownsuites.com/detail_state.asp?state=" + thisState;
			changeLocation(thisURL);
		}
	}
}

function changeLocation(url){
	window.location=url
}
function imgOn(imgName) {
	ActiveImage = eval(imgName + "_on.src");
	document[imgName].src = ActiveImage;		
}	

function imgOff(imgName) {
	ActiveImage = eval(imgName + "_off.src");
	document[imgName].src = ActiveImage;		
}	

if (document.images){
	navAbout_on = new Image;                             
	navAbout_on.src = "images/nav_main_about_our_hotels_on.gif";                     

	navAbout_off = new Image;                             
	navAbout_off.src = "images/nav_main_about_our_hotels.gif";                     

	navFind_on = new Image;                             
	navFind_on.src = "images/nav_main_find_reserve_on.gif";                     

	navFind_off = new Image;                             
	navFind_off.src = "images/nav_main_find_reserve.gif";                     

	navCorp_on = new Image;                             
	navCorp_on.src = "images/nav_main_corporate_clients_on.gif";                     

	navCorp_off = new Image;                             
	navCorp_off.src = "images/nav_main_corporate_clients.gif";                     

	navNew_on = new Image;                             
	navNew_on.src = "images/nav_main_whats_new_on.gif";                     

	navNew_off = new Image;                             
	navNew_off.src = "images/nav_main_whats_new.gif";

	navWhy_on = new Image;                             
	navWhy_on.src = "images/nav_main_why_intown_on.gif";                     

	navWhy_off = new Image;                             
	navWhy_off.src = "images/nav_main_why_intown.gif";

	navContact_on = new Image;                             
	navContact_on.src = "images/nav_main_contact_us_on.gif";                     

	navContact_off = new Image;                             
	navContact_off.src = "images/nav_main_contact_us.gif";                     

}

function clearMetros() {
	var elm = document.getElementById('metroList');
	for(i=elm.options.length; i>0; i--){
		elm.options[i] = null;
	}
}

function addMetros(thisState) {
	clearMetros();
	var elm = document.getElementById('metroList');
	for(i=0; i<thisState.length; i++){
		opt = document.createElement('option');
		opt.text = thisState[i];
		opt.value = thisState[i]
		try {
			elm.add(opt, null);
		}
		catch(ex) {
			elm.add(opt);
		}
	}
}