/* Begin image rollover funtion */
// 0-6 are main navigation rollovers
// 7-13 are footer rollovers
// 14-16 & 41 are header nav images
// 17-24 are secondary nav images
// 25-28 are accepted here button images
// 29-40 are shopping events button images
// 41-42 are Packages button images TEST
var origImg = new Array();
origImg[0] = 'nav_rooms_off.gif';
origImg[1] = 'nav_shows_off.gif';
origImg[2] = 'nav_packages_off.gif';
origImg[3] = 'nav_restaurants_off.gif';
origImg[4] = 'nav_gift_cards_off.gif';
origImg[5] = 'nav_spa_off.gif';
origImg[6] = 'nav_golf_off.gif';
origImg[7] = 'responsible_gambling_off.gif';
origImg[8] = 'investors_off.gif';
origImg[9] = 'about_off.gif';
origImg[10] = 'contact_off.gif';
origImg[11] = 'sitemap_off.gif';
origImg[12] = 'privacy_off.gif';
origImg[13] = 'guest_book_off.gif';
origImg[14] = 'hnav_wlv_off.gif';
origImg[15] = 'hnav_sign_guest_book_off.gif';
origImg[16] = 'hnav_privacy_off.gif';
origImg[17] = 'snav_accepted_here_off.jpg';
origImg[18] = 'snav_gift_guide_off.jpg';
origImg[19] = 'snav_shopping_events_off.jpg';
origImg[20] = 'snav_card_pickup_off.jpg';
origImg[21] = 'snav_shipping_off.jpg';
origImg[22] = 'snav_property_map_off.jpg';
origImg[23] = 'snav_guest_book_off.jpg';
origImg[24] = 'snav_terms_off.jpg';
origImg[25] = 'ah_entertainment_off_btn.gif';
origImg[26] = 'ah_restaurants_bars_off_btn.gif';
origImg[27] = 'ah_shops_off_btn.gif';
origImg[28] = 'ah_resort_amenities_off_btn.gif';
origImg[29] = 'se_january_off_btn.gif';
origImg[30] = 'se_february_off_btn.gif';
origImg[31] = 'se_march_off_btn.gif';
origImg[32] = 'se_april_off_btn.gif';
origImg[33] = 'se_may_off_btn.gif';
origImg[34] = 'se_june_off_btn.gif';
origImg[35] = 'se_july_off_btn.gif';
origImg[36] = 'se_august_off_btn.gif';
origImg[37] = 'se_september_off_btn.gif';
origImg[38] = 'se_october_off_btn.gif';
origImg[39] = 'se_november_off_btn.gif';
origImg[40] = 'se_december_off_btn.gif';
origImg[41] = 'hnav_contact_off.gif';
origImg[42] = 'p2_le_reve_off_btn.gif';
origImg[43] = 'p2_terrace_pointe_off_btn.gif';

var overImg = new Array();
overImg[0] = 'nav_rooms_on.gif';
overImg[1] = 'nav_shows_on.gif';
overImg[2] = 'nav_packages_on.gif';
overImg[3] = 'nav_restaurants_on.gif';
overImg[4] = 'nav_gift_cards_on.gif';
overImg[5] = 'nav_spa_on.gif';
overImg[6] = 'nav_golf_on.gif';
overImg[7] = 'responsible_gambling_on.gif';
overImg[8] = 'investors_on.gif';
overImg[9] = 'about_on.gif';
overImg[10] = 'contact_on.gif';
overImg[11] = 'sitemap_on.gif';
overImg[12] = 'privacy_on.gif';
overImg[13] = 'guest_book_on.gif';
overImg[14] = 'hnav_wlv_on.gif';
overImg[15] = 'hnav_sign_guest_book_on.gif';
overImg[16] = 'hnav_privacy_on.gif';
overImg[17] = 'snav_accepted_here_on.jpg';
overImg[18] = 'snav_gift_guide_on.jpg';
overImg[19] = 'snav_shopping_events_on.jpg';
overImg[20] = 'snav_card_pickup_on.jpg';
overImg[21] = 'snav_shipping_on.jpg';
overImg[22] = 'snav_property_map_on.jpg';
overImg[23] = 'snav_guest_book_on.jpg';
overImg[24] = 'snav_terms_on.jpg';
overImg[25] = 'ah_entertainment_on_btn.gif';
overImg[26] = 'ah_restaurants_bars_on_btn.gif';
overImg[27] = 'ah_shops_on_btn.gif';
overImg[28] = 'ah_resort_amenities_on_btn.gif';
overImg[29] = 'se_january_on_btn.gif';
overImg[30] = 'se_february_on_btn.gif';
overImg[31] = 'se_march_on_btn.gif';
overImg[32] = 'se_april_on_btn.gif';
overImg[33] = 'se_may_on_btn.gif';
overImg[34] = 'se_june_on_btn.gif';
overImg[35] = 'se_july_on_btn.gif';
overImg[36] = 'se_august_on_btn.gif';
overImg[37] = 'se_september_on_btn.gif';
overImg[38] = 'se_october_on_btn.gif';
overImg[39] = 'se_november_on_btn.gif';
overImg[40] = 'se_december_on_btn.gif';
overImg[41] = 'hnav_contact_on.gif';
overImg[42] = 'p2_le_reve_on_btn.gif';
overImg[43] = 'p2_terrace_pointe_on_btn.gif';

function swapImage(mouseevent,id,arrayNum) {
	if (mouseevent == 'over'){
		document.getElementById(id).setAttribute('src','images/'+ overImg[arrayNum]);
	}
	
	else if (mouseevent == 'out') {
		document.getElementById(id).setAttribute('src','images/'+ origImg[arrayNum]);
	}
	
	else {
		return;
	}
}

function preloadImages() {
	for (i=0; i<overImg.length; i++) {
		var images = new Array();
		images[i] = new Image;
		images[i].src = 'images/' + overImg[i];
	}
}
/* End image rollover function */

/* Begin content swapping functions */
function contentSwap(id,id2){	
	var activeDiv = document.getElementById(id);				// div that was clicked in the tertiary navigation.
	var setID = new Array();									// Array to hold all the div tag id's for the tertiary navigation.
	
	var buttonsDiv = document.getElementById(id2+'_buttons');		// div that wraps the tertiary navigation div tags.
	var indButtonsDivs = buttonsDiv.getElementsByTagName('div');	// Used to grab all div elements within buttonsDiv.
	
	var copyDiv = document.getElementById(id2+'_copy'); 		// div that wraps the different copy div tags.
	var showCopy = document.getElementById(id + '_copy');		// Copy div to be displayed.
	var indCopyDivs = copyDiv.getElementsByTagName('div');		// Used to grab all div elements within copyDiv.
	var indCopyDivCount = indCopyDivs.length;					// Used to hold the total number of different content elements.
	
	var showImage = document.getElementById(id + '_widget_image'); // Right side image (above the widget) to be displayed.
	
	
	for (var i=0;i<indCopyDivCount;i++){ // Loops through and hides all the content divs and right side image divs. As well, it builds the img tags for the tertiary navigation.
		setID[i] = indButtonsDivs[i].getAttribute('id'); 		// Gets the div ids for the tertiary navigation
		
		var page = setID[i].split('_')[0];						// Parses the div id to determine the current page. It uses the beginning of the id to determine the page, because the naming convention varries per page.
		
		// Variables for alt and title attributes for the button images.
		var position1 = setID[i].indexOf('_') + 1;				// Used to determine where to slice the id.
		var sliceID1 = setID[i].slice(position1);				// Slices the part of the id starting at the first _ forward
		var alt1 = sliceID1.replace(/_/, " ");					// Holds what will become the alt and title attribute values. The naming convention for the id's lends itself to being used as alt and title tag information.
		
		indCopyDivs[i].style.display = "none";					// Hides all the divs within copyDiv
		
		if ((page == 'p') || (page == 'si') || (page == 'ah')) {	// If the page is "packages" or "shows info" or "accepted here" (Pages that change the right side image.)
			//Variables for the right side images
			var imageDiv = document.getElementById(page + '_widget_image');  //div that wraps all the right side images.
			var imgs = imageDiv.getElementsByTagName('img');		// Used to grab all img tags within imageDiv.
			
			imgs[i].style.display = "none"; 	// Hides all the right side images.
		}
		
		// Builds the img tag for all tertiary navigation buttons and sets it as the HTML for the appropriate div element.
		document.getElementById(setID[i]).innerHTML = "<img src=\""+csImgOff+setID[i]+"_off_btn.gif\" id=\""+setID[i]+"_image\" width=\"126\" height=\"18\" alt=\""+alt1+"\" title=\""+alt1+"\" onmouseover=\"swapImage2('over',this.getAttribute('id'));\" onmouseout=\"swapImage2('out',this.getAttribute('id'));\" />";
	}
	
	showCopy.style.display = "block";		// Displays the appropriate copy div
	
	if ((page == 'p') || (page == 'si') || (page == 'ah')) {	// If the page is "packages" or "shows info" or "accepted here" (Pages that change the right side image.)
		showImage.style.display = "block";	// Displays the appropriate right side image
	}
	
	if (showCopy.style.display == "block") {	// Based on the copy that is displayed, do the following.
		var position2 = id.indexOf('_') + 1;
		var sliceID2 = id.slice(position2);
		var alt2 = sliceID2.replace(/_/, " ");
		
		// Rebuild the img tag for the clicked div and set it as the HTML for that div. To make sure the clicked div button is in the on state.
		activeDiv.innerHTML = "<img src=\""+csImgOn+id+"_on_btn.gif\" id=\""+id+"_image\" width=\"126\" height=\"18\" alt=\""+alt2+"\" title=\""+alt2+"\" />";	
	}
}

function swapImage2(mouseevent,id) {
	img = id.split('_image')[0];
	
	if (mouseevent == 'over'){
		document.getElementById(id).setAttribute('src',csImgOn+img + "_on_btn.gif");
	}
	
	else if (mouseevent == 'out') {
		document.getElementById(id).setAttribute('src',csImgOff+img + "_off_btn.gif");
	}
	
	else {
		return;
	}
}
/* End content swapping functions */

/* Begin dynamic drop-down functions */
var t = null;															// this is used for the timeout for the search to add slight delay
var us_states = new Array("select a state","Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","West Virginia","Wisconsin","Wyoming","Washington","Washington, D.C.");
var us_statecodes = 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","WV","WI","WY","WA","DC");
var au_states = new Array("select a state","Australian Capital Territory","New South Wales","Northern Territory","Queensland","South Australia","Tasmania","Victoria","Western Australia");
var au_statecodes = new Array("","ACT","NSW","NT","QLD","SA","TAS","VIC","WA");
var ca_states = new Array("select a state","Alberta","British Columbia","Manitoba","New Brunswick","Newfoundland","Northwest Territories","Nova Scotia","Nunavut","Ontario","Prince Edward Island","Quebec","Saskatchewan","Yukon Territory");
var ca_statecodes = new Array("","AB","BC","MB","NB","NF","NT","NS","NV","ON","PE","QC","SK","YT");
var jp_states = new Array("select a state","Aichi","Akita","Aomori","Chiba","Ehime","Fukui","Fukuoka","Fukushima","Gifu","Gunma","Hiroshima","Hokkaido","Hyogo","Ibaraki","Ishikawa","Iwate","Kagawa","Kagoshima","Kanagawa","Kochi","Kumamoto","Kyoto","Miyagi");
var jp_statecodes = new Array("","Aichi","Akita","Aomori","Chiba","Ehime","Fukui","Fukuoka","Fukushima","Gifu","Gunma","Hiroshima","Hokkaido","Hyogo","Ibaraki","Ishikawa","Iwate","Kagawa","Kagoshima","Kanagawa","Kochi","Kumamoto","Kyoto","Miyagi");
var de_states = new Array("select a state","Baden-Wuerttemberg","Baravia","Berlin","Brandenburg","Bremen","Hamburg","Hessen","Mecklenburg-Vorpommern","Niedersachsen","Nordrhein-Westfalen","Rheinland-Pfalz","Saarland","Sachsen","Sachsen-Anhalt","Schleswig-Holstein","Thueringen");
var de_statecodes = new Array("","Baden-Wuerttemberg","Baravia","Berlin","Brandenburg","Bremen","Hamburg","Hessen","Mecklenburg-Vorpommern","Niedersachsen","Nordrhein-Westfalen","Rheinland-Pfalz","Saarland","Sachsen","Sachsen-Anhalt","Schleswig-Holstein","Thueringen");
var default_states = new Array("N/A");
var default_statecodes = new Array("NULL");
var liveSearchFieldID = null;

// init function ran when page loads.
function dynamicDropDownInit() {
	addEvent($("country"),'change',livesearchFetch);					// add "onchange" function to the country drop-down
	livesearchFetch();
}

function livesearchFetch() {
	var field = "state";	
	liveSearchFieldID =  field;
	clean($(field));													// remove all previous items in drop-down
	livesearchStart();
}

// adds a slight delay to the search
function livesearchStart() {
	if (t)	window.clearTimeout(t);
	t = window.setTimeout("livesearchSearch()",200);
}
// function which starts the dropdown process
function livesearchSearch() {
	var country = $('country').options[$('country').selectedIndex].value;	// set variable to what country has been selected
	
	populateSearch(country);												// function to populate the dropdown with the appropriate list of states based on the selected country
}

// function to actually add items (from array of items supplied) to dropdown
function populateSearch(country) {
	var field = liveSearchFieldID;			
	
	switch(country){												// switch the country to choose the appropriate state arrays
		case "US":
			stateName = us_states;
			stateCode = us_statecodes;
			break
		case "AU":
			stateName = au_states;
			stateCode = au_statecodes;
			break
		case "CA":
			stateName = ca_states;
			stateCode = ca_statecodes;
			break
		case "JP":
			stateName = jp_states;
			stateCode = jp_statecodes;
			break
		case "DE":
			stateName = de_states;
			stateCode = de_statecodes;
			break
		default:
			stateName = default_states;
			stateCode = default_statecodes;
	}
	
	var len = stateName.length;										// get the total number of select options to create
	for (var i=0; i<len; i++) {										// for each item
		var option = document.createElement('option');				// create an <option> element to store the info
		option.appendChild(document.createTextNode(stateName[i]));	// create the text of the state to be put in option
		option.setAttribute("value",stateCode[i]);					// add a value attribute and populate with the corresponding state code
		document.getElementById(field).appendChild(option);			// add the item to the dropdown
	}
}
/* End dynamic drop-down functions */

/* Begin dynamic drop-down helper functions */
/* Extracted from Prototype JS Library, http://prototype.conio.net/
 Written by Sam Stephenson, http://conio.net/ */
function $() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string') element = (document.getElementById) ? document.getElementById(element) : eval("document.all."+element) ;
    if (arguments.length == 1) return element;
    elements.push(element);
  }
  return elements;
}
/* Function to remove all child nodes of an element. */
function clean(elm) {
	while($(elm).hasChildNodes()) {
		$(elm).removeChild($(elm).childNodes[0]);
	}
	return true;
}

/* Function to grab all elements with a specific class name.
 Original written by Jonathan Snook, http://www.snook.ca/jonathan
 Add-ons by Robert Nyman, http://www.robertnyman.com 	
 Re-written by Zack Gilbert of Seen Creative, http://www.weareseencreative.com */
function getElementsByClass(className, elm, tag){
	if(elm == null) elm = document;
	if(tag == null) tag = '*';
	var elems = (tag == "*" && document.all)? document.all : elm.getElementsByTagName(tag);
	var returnElems = new Array();
	className = className.replace(/\-/g, "\\-");
	var pattern = new RegExp("(^|\\s)" + className + "(\\s|$)");
	for(var i=0; i<elems.length; i++){
		if(pattern.test(elems[i].className)) returnElems.push(elems[i]);
	}
	return returnElems
}
/* Functions to add/remove event listeners to objects
	Written by John Resig, http://ejohn.org */
function addEvent( obj, type, fn ) {
	if (obj.addEventListener) obj.addEventListener( type, fn, false );
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}

function removeEvent( obj, type, fn ) {
	if (obj.removeEventListener) obj.removeEventListener( type, fn, false );
	else if (obj.detachEvent) {
		obj.detachEvent( "on"+type, obj[type+fn] );
		obj[type+fn] = null;
		obj["e"+type+fn] = null;
	}
}
/* Functions to handle cross-browser events.
 Written by Zack Gilbert of Seen Creative, http://www.weareseencreative.com. */
/* get the target of an event object */
function getTarget(e) {
	return (e.target) ? e.target : e.srcElement;
}
// this function is used to stop events from acting normally. 
// NOTE: Safari supports these functions, but does not work properly!
function killKey(e) {
	(e.preventDefault) ? e.preventDefault() : window.event.returnValue = false;
	(e.stopPropagation) ? e.stopPropagation() : window.event.cancelBubble = true;	
	return false;
}
/* End dynamic drop-down helper functions */