var pic = new Array()
var preLoad = new Array()
	pic[0] = '/images/header/nav01on.gif';
	pic[1] = '/images/header/nav02on.gif';
	pic[2] = '/images/header/nav03on.gif';
	pic[3] = '/images/header/nav04on.gif';
	pic[4] = '/images/header/nav05on.gif';
	pic[5] = '/images/header/nav06on.gif';
	pic[6] = '/images/header/nav07on.gif';
	
	pic[7] = '/images/header/txtaccommodations.gif';
	pic[8] = '/images/header/txtattractions.gif';
	pic[9] = '/images/header/txtdiningent.gif';
	pic[10] = '/images/header/txtshopping.gif';
	pic[11] = '/images/header/txttourstrans.gif';
	pic[12] = '/images/header/txtvisitorserv.gif';

	var p=pic.length;
				
	for (x=0;x<p;x++) {
		preLoad[x] = new Image()
		preLoad[x].src = pic[x]
	}
var CityNameText = '...or enter a city';
var MaxWords = 30;
var MaxChars = 250;

function ImageExists(i) {
	var x;
	var d=document;
	if (document.getElementById)
		x=document.getElementById(i);
		if (x==null) x=document.images[i];
	else
		x=document.images[i];
	return x;
}

function SwapImageBack() {
	var x,t;
	var s=document.SavedImages;
	for (i=0;s&&i<s.length;i++) document.SavedImages[i].src = document.SavedImages[i].oSrc;
}
		
function SwapImage() {
	var i;
	var j=0;
	var x;
	var a=SwapImage.arguments;
	document.SavedImages = new Array;
	for (x=0;x<(a.length);x+=2) {
		if ((i=ImageExists(a[x])) != null) {
			document.SavedImages[j++] = i;
			if (!i.oSrc) i.oSrc = i.src;
			i.src=a[x+1];
		}
	}
}


function SelectCity(formobject,cityid,clearcity) {
	if (!clearcity) 
		clearcity = 'Yes'
	if (clearcity == 'Yes')
		ClearCityName();
	if ((cityid != '') && (cityid != 'dummy')) {
		/*document.destinations.submit();*/
		formobject.submit();
	}
}		
function CategoryClick(urlpath) {
	var CountryValue = parent.document.destinations.countryid.options[parent.document.destinations.countryid.options.selectedIndex].value;
	/* var CountryValue = parent.document.destinations.zipcode.value; */
	if (CountryValue == '0') {
		alert("Please select a country before continuing");
	} else {
		document.destinations.ReturnPath.value = urlpath;
		document.destinations.submit();
	}
}

function Country(c_id, c_name) {
	this.id = c_id;
	this.name = c_name;
}

function State(s_id, s_name, s_countryid) {
	this.id = s_id;
	this.countryid = s_countryid;
	this.name = s_name;
}

function City(c_id, c_name, c_stateid) {
	this.id = c_id;
	this.stateid = c_stateid;
	this.name = c_name;
}

var NS4 = parseInt('0');
var IE4 = parseInt('1');
<!-- Detect the client browser -->
function detectBrowser() {
	if (parseInt(navigator.appVersion)>=4) {
		if (navigator.appName=="Netscape")
			return NS4;
		else
			return IE4;
	}
	else
		return NS4;
}

function ClearZip(zipcode) {
	zipcode.value = "";
}

function ClearCityName() {
	var CityNameField = parent.document.destinations.CityName;
	CityNameField.value = "...or enter a city";
}

function PopulateStates(parent,child,child2,start,cityphrase) {
	var statephrase;
	if (parent.options[parent.options.selectedIndex].value == 319) {
		statephrase = "Then a Province";
	} else {
		statephrase = "Then a State";
	}
	
	<!-- Remove all the items first -->
	if (IE4 == detectBrowser()) {
		var y = child.options.length;
		var b = child2.options.length;
		for (var x=start; x<y; x++) 
			child.options.remove(start);
		for (var a=start; a<b; a++)
			child2.options.remove(start);
	} else {
		child.options.length = start;
		child2.options.length = start;
	}
		
	if (parent.selectedIndex >= start) {
		<!-- Now populate the child list box -->
		var id = parent.options[parent.options.selectedIndex].value;
		var StateResults = false;

		if (id!="0") {
			<!-- Extract the id to use during comparison process -->
			// arrayOfStrings = id.split("@");
			//	id = arrayOfStrings[1]

			for (var i=0; i < num_StateArray; i++) {
				if (StateArray[i].countryid == id) {
					newopt = new Option;
					newopt.value = StateArray[i].id;
					newopt.text = StateArray[i].name;
					child.options[child.options.length] = newopt;
					StateResults = true;
				}
	   		 }
			 if (StateResults == false) {
			 	newopt = new Option;
				newopt.value = "0";
				newopt.text = "Click to continue -->";
			 	child.options[0] = newopt;
				<!-- child.options[child.options.length] = newopt; -->
			 } else {
			 	newopt = new Option;
				newopt.value ="0";
				newopt.text = statephrase;
				child.options[0] = newopt;
			 }
			newopt2 = new Option;
			newopt2.value = "0";
			newopt2.text = cityphrase;
			child2.options[0] = newopt2;
			
			 <!-- Enable the State control -->
			 child.options[0].selected = true;
			 child.disabled = false;
			 
			 child2.options[0].selected = true;
			 child2.disabled = true;
		}
	}
	else {
		child.options[0].selected = true;
		child.disabled = true;
		
		child2.options[0].selected = true;
		child2.disabled = true;
	}
}

function PopulateCities(parent,child,start,cityphrase) {
	if (parent.selectedIndex >= start) {
		<!-- Remove all the items first -->
		if (IE4 == detectBrowser()) {
			var j = child.options.length;
			for (var i=start; i<j; i++) 
				child.options.remove(start);
		}
		else child.options.length = start;
		<!-- Now populate the child list box -->
		var id = parent.options[parent.options.selectedIndex].value;
		var CityResults = false;
		if (id!="") {
			<!-- Extract the id to use during comparison process -->
			// arrayOfStrings = id.split("@");
			//	id = arrayOfStrings[1]

			for (var i=0; i < num_CityArray; i++) {
				if (CityArray[i].stateid == id) {
					newopt = new Option;
					newopt.value = CityArray[i].id;
					newopt.text = CityArray[i].name;
					child.options[child.options.length] = newopt;
					CityResults = true;
				}
	   		 }
			 if (CityResults == false) {
			 	newopt = new Option;
				newopt.value = "";
				newopt.text = "Click to continue -->";
			 	child.options[0] = newopt;
				<!-- child.options[child.options.length] = newopt; -->
			 } else {
			 	newopt = new Option;
				newopt.value ="";
				newopt.text = "Then a City";
				child.options[0] = newopt;
			 }
			 <!-- Enable the control -->
			 child.options[0].selected = true;
			 child.disabled = false;
		}
	}
	else {
		child.options[0].selected = true;
		child.disabled = true;
	}
}

function OpenCertDetails() {
	thewindow = window.open('https://www.thawte.com/cgi/server/certdetails.exe?code=USCERT33', 'anew', config='height=400,width=450,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
}

function OnLengthMove(checkfield,movetofield,len) {
	if (checkfield.value.length == len) {
		movetofield.focus();
	}
}

function RemoveText(checkfield, originaltext) {
	if (checkfield.value == originaltext)
		checkfield.value = "";
}

function NoTextFill(checkfield, originaltext) {
	if (checkfield.value == '')
		checkfield.value = originaltext;
}

function EmailValid(FormName, ElemName) {
	// -----------------------------------------------------------------
	// Description : Checks if given email address is of valid syntax
	// Copyright   : (c) 1998 Shawn Dorman
	// http://www.goodnet.com/~sdorman/web/IsEmailValid.html
	// onChange="IsEmailValid('FormName','FieldName')"
	// -----------------------------------------------------------------
	var EmailOk	= true
	var Temp	= document.forms[FormName].elements[ElemName]
	var AtSym	= Temp.value.indexOf('@')
	var Period	= Temp.value.lastIndexOf('.')
	var Space	= Temp.value.indexOf(' ')
	var Length	= Temp.value.length - 1   // Array is from 0 to length-1
	
	if (Length > -1) {
		if (Temp.value != '') {
			if ((AtSym < 1) ||                     // '@' cannot be in first position
			    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
			    (Period == Length ) ||             // Must be atleast one valid char after '.'
			    (Space  != -1))                    // No empty spaces permitted
			   {  
			      EmailOk = false
			   }
		}
	} else {
		EmailOk = false;
	}
	return EmailOk
}

function IsEmailValid(FormName,ElemName) {
	var EmailOk	= true
	var Temp	= document.forms[FormName].elements[ElemName]
	if (!EmailValid(FormName,ElemName)) {
	      EmailOk = false
	      alert('Please enter a valid e-mail address!')
	      Temp.focus()
	}
	return EmailOk
}

function IsWebAddressValid(FormName,ElemName,OnlyIf) {
	var AddressOk	= true;
	var Temp		= document.forms[FormName].elements[ElemName];
	var Http		= Temp.value.indexOf('http://');
	var Period		= Temp.value.indexOf('.');
	var ErrorMsg	= '';
	var valid		= false;

	if (Temp.value != '' && Temp.value != 'http://') valid = true;
	
	if (OnlyIf) {
		var Temp2	= document.forms[FormName].elements[OnlyIf];
		if (Temp2[0].checked) valid = true
		else valid = false;
	}
	
	if (valid) {
		if (Http < 0) {
			AddressOk = false;
			ErrorMsg = 'A web address must include the http://';
		}
		if (Period < 1) {
			AddressOk = false;
			ErrorMsg = 'Please enter a valid web address';
		}
		if (!AddressOk) {
			alert(ErrorMsg);
			Temp.focus();
		}
	}
	return AddressOk
}

function CheckWords(FieldName, CounterFieldName) {
	var WordCounter = 0;
	if (FieldName.value.length > 0) WordCounter++;
	for (x=0; x < FieldName.value.length;x++) {
		if ((FieldName.value.charAt(x) == " " && FieldName.value.charAt(x-1) != " " && FieldName.value.charAt(x-1) != "," && FieldName.value.charAt(x+1) != ",") || (FieldName.value.charAt(x)==",")) {WordCounter++}  // Counts the spaces while ignoring double spaces, usually one in between each word.
		if (WordCounter > 250) {FieldName.value = FieldName.value.substring(0, x);}
		else {CounterFieldName.value = WordCounter;}
	}
}

function CheckChars(FieldName, CountFieldName) {
	if (FieldName.value.length > MaxChars)
		{FieldName.value = FieldName.value.substring(0, MaxChars);}
	else {
		CountFieldName.value = FieldName.value.length;
	}
}
