function hasClass(objElement,strClass) {if (objElement.className) {var arrList = objElement.className.split(' ');var strClassUpper = strClass.toUpperCase();for(var i= 0;i<arrList.length;i++) if(arrList[i].toUpperCase() == strClassUpper) return true;}return false;}
function addClass(objElement,strClass,blnMayAlreadyExist) {if(objElement.className) {var arrList = objElement.className.split(' ');if(blnMayAlreadyExist) {var strClassUpper = strClass.toUpperCase();for(var i=0;i<arrList.length;i++) {if (arrList[i].toUpperCase() == strClassUpper) {arrList.splice(i, 1);i--;}}}arrList[arrList.length] = strClass;objElement.className = arrList.join(' ');} else objElement.className = strClass;}
function removeClass(objElement,strClass) {if(objElement.className) {var arrList = objElement.className.split(' ');var strClassUpper = strClass.toUpperCase();for(var i=0;i<arrList.length;i++) {if(arrList[i].toUpperCase() == strClassUpper) {arrList.splice(i, 1);i--;}}objElement.className = arrList.join(' ');}}
addDOMLoadEvent=(function(){var load_events=[],load_timer,script,done,exec,old_onload,init=function(){done=true;clearInterval(load_timer);while(exec=load_events.shift())exec();if(script)script.onreadystatechange = '';};return function(func){if (done) return func(); if(!load_events[0]){if(document.addEventListener)document.addEventListener("DOMContentLoaded",init,false);/*@cc_on @*//*@if (@_win32)document.write("<script id=__ie_onload defer src=//0><\/scr"+"ipt>");script = document.getElementById("__ie_onload");script.onreadystatechange = function(){if(this.readyState=="complete")init();};@end @*/if(/WebKit/i.test(navigator.userAgent)){load_timer=setInterval(function(){if(/loaded|complete/.test(document.readyState))init();}, 10);}old_onload=window.onload;window.onload=function(){init();if(old_onload) old_onload();};}load_events.push(func);}})();

function showForm() {
	if (document.getElementById('showform_button') && document.getElementById('showform_button').className != 'none') {
		var button = document.getElementById('showform_button');
		var button2 = document.getElementById('showform_button2');
		button.onclick = function(){
			if (button.className == 'hidden') {
				button.className = '';
				if (document.getElementById('showform_button2')) button2.className = '';
				button.firstChild.src = 'images/button-ShowForm.png';
				document.getElementById('findhotelform').className = '';
				removeClass(document.getElementById('findahotel'),'noimage');
				document.getElementById('extended_img').style.display = '';
			} else {
				button.className = 'hidden';
				if (document.getElementById('showform_button2')) button2.className = 'hidden';
				button.firstChild.src = 'images/button-HideForm.png';
				document.getElementById('findhotelform').className = 'visible';
				addClass(document.getElementById('findahotel'),'noimage','');
				document.getElementById('extended_img').style.display = 'none';
			}
		}
		if (document.getElementById('showform_button2')) button2.onclick = button.onclick;
	}
}

function hideDateFormat() {
	if(document.getElementById('checkInDate')) {
		hideFormat(document.getElementById('checkInDate'));
	}
	if(document.getElementById('checkOutDate')) {
		hideFormat(document.getElementById('checkOutDate'));
	}
}

function hideFormat(id) {
	id.onfocus = function() {
		if(id.value=='mm/dd/yyyy') id.value='';
		displayCalendar(id,'mm/dd/yyyy',this);
	}
	id.onblur = function() {
		if(id.value=='') id.value='mm/dd/yyyy';
	}
}

function showStates(load,default_state,strState,strProvince) {
	if(document.getElementById('country') && document.getElementById('state') && !load) {
		var country = document.getElementById('country');
		var state = document.getElementById('state');
		country.onchange = function() {
				state.options.length = '0';
			if(country.value ==  '0001') {
				for(var i=0; i < US_States.length; i++) {
					state.options[i] = new Option(US_States[i],US_States[i]);
					document.getElementById('stateitem').style.visibility = 'visible';
					document.getElementById('statelabel').innerHTML = 'State:';
				}
			} else if(country.value == '0260') {
				for(var i=0; i < CA_States.length; i++) {
					state.options[i] = new Option(CA_States[i],CA_States[i]);
					document.getElementById('stateitem').style.visibility = 'visible';
					document.getElementById('statelabel').innerHTML = 'Province:';
				}
			}
		}
	} else if(document.getElementById('country')) {
		var country = document.getElementById('country');
		var state = document.getElementById('state');
		var selected = false;
		if(country.value ==  '0001') {
			for(var i=0; i < US_States.length; i++) {
				selected=false;
				if (default_state == US_States[i]) selected = true;
				state.options[i] = new Option(US_States[i],US_States[i],selected);
				document.getElementById('stateitem').style.visibility = 'visible';
				document.getElementById('statelabel').innerHTML = 'State:';
			}
		} else if(country.value == '0260') {
			for(var i=0; i < CA_States.length; i++) {
				selected=false;
				if (default_state == CA_States[i]) selected = true;
				state.options[i] = new Option(CA_States[i],CA_States[i],selected);
				document.getElementById('stateitem').style.visibility = 'visible';
				document.getElementById('statelabel').innerHTML = 'Province:';
			}
		}
	}
}

function showTooltips() {
	if(!document.getElementById('notes1')) return false;
	document.getElementById('notes1').style.display = 'none';
	document.getElementById('notes2').style.display = 'none';
	document.getElementById('notes3').style.display = 'none';
	var links = document.getElementsByTagName('a');
	for(var i=0;i<links.length;i++) {
		if(links[i].rel == 'tooltip') {
			var link = links[i];
			var href = link.href.split('#');
			if(document.getElementById(href[1])) {
				link.onmouseover = function(){
					var href = this.href.split('#');
					var content = document.getElementById(href[1]).innerHTML;
					tooltip.show(content);
				};
				link.onmouseout = function(){tooltip.hide();};
				link.onclick = function(){return false;};
			}
		}
	}
}

function clearInput(e) {
	e = document.getElementById(e);
	e.value = '';
}

addDOMLoadEvent(showForm);
addDOMLoadEvent(hideDateFormat);
addDOMLoadEvent(showStates);
addDOMLoadEvent(showTooltips);

var US_States = new Array('','AL','AK','AZ','AR','CA','CO','CT','DE','FL','GA','HI','ID','IL','IN','IA','KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE','NV','NH','NJ','NM','NY','NC','ND','OH','OK','OR','PA','RI','SC','SD','TN','TX','UT','VT','VA','WA','WV','WI','WY');
var CA_States = new Array('','AB','BC','MB','NL','NS','ON','PE','QC','SK','YT');
	
