// JavaScript Document


// --------------------------------------------------------
//  Preloads images for the random inn on front page
// --------------------------------------------------------

// This script and many more are available free online at -->
// The JavaScript Source!! http://javascript.internet.com -->

// Set up the image files to be used.
var theImages = new Array() // do not change this
// URLs that go with each image
var theURLs = new Array()
// To add more image files, continue with the
// pattern below, adding to the array.

theImages[0] = 'featured-abbett.jpg'
theURLs[0] = 'www.abbettplacer.com'
theImages[1] = 'featured-allaire.jpg'
theURLs[1] = 'www.allairetimbers.com'
theImages[2] = 'featured-barn.jpg'
theURLs[2] = 'breckenridge-inn.com'
theImages[3] = 'featured-evanshouse.jpg'
theURLs[3] = 'coloradoevanshouse.com'
theImages[4] = 'featured-fireside.jpg'
theURLs[4] = 'firesideinn.com'
//theImages[5] = 'featured-fourpeaks.jpg'
//theURLs[5] = 'www.fourpeaksinn.com'
theImages[6] = 'featured-galenast.jpg'
theURLs[6] = 'www.galenastreet.com'
theImages[7] = 'featured-high_country.jpg'
theURLs[7] = 'www.ahighcountrylodge.com'
theImages[8] = 'featured-ski_tip.jpg'
theURLs[8] = 'www.skitiplodge.com'
theImages[9] = 'featured-snowberryhill.jpg'
theURLs[9] = 'www.snowberryhill.com'
theImages[5] = 'featured-westernskies.jpg'
theURLs[5] = 'www.westernskies-keystone-cabins.com'
//theImages[11] = 'featured-hpi.jpg'
//theURLs[11] = 'www.huntplacerinn.com'


// do not edit anything below this line

var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}

// --------------------------------------------------------
//  Prints the img tag for the random image
// --------------------------------------------------------

function showImage(){
	var whichImage = Math.round(Math.random()*(p-1));
	document.write('<a href="http://' + theURLs[whichImage]+'" target="_blank"><img src="'+theImages[whichImage]+'" border="0"></a>');
}


// Preloads the maps
//map1 = new Image();
//map1.src = "pic-map-area.jpg";

//map2 = new Image();
//map2.src = "pic-map-inset.jpg";

function open_window(file,w,h) {
	
	var win2 = window.open(file,"map","width=" + w + ",height=" + h + ",scrollbars=yes,resizable=yes");
	//win2.focus();
	
}

var old_map = "inset";
function moveArrow(x,y,map) {
   
   if(map != "" && map != old_map) {
		toggleMaps(map);
		old_map = map;
   }
   
   document.map_holder.focus();
   
   // first get the object's stylesheet
    var styleObject = getStyleObject("arrow");
	    // then if we find a stylesheet, set its visibility
    // as requested
    //
    if (styleObject) {
		styleObject.visibility= "visible";
		styleObject.left = x + "px";
		styleObject.top = y + "px";
		return true;
    } else {
		return false;
    }
}

function toggleMaps(map) {
	var img_src = "pic-map-" + map + ".jpg";
	document['map_holder'].src=img_src;
	
}

function toggleMaps() {
	
	var styleObject = getStyleObject("arrow");
	if (styleObject) {
		styleObject.visibility= "hidden";
    }
	
	if (old_map == "area") {
		document['map_holder'].src="pic-map-inset.jpg";
		old_map = "inset"
	} else {
		document['map_holder'].src="pic-map-area.jpg";
		old_map = "area"
	}
	
}

function getStyleObject(objectId) {
  // checkW3C DOM, then MSIE 4, then NN 4.
  //
  if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId).style;
   }
   else if (document.all && document.all(objectId)) {  
	return document.all(objectId).style;
   } 
   else if (document.layers && document.layers[objectId]) { 
	return document.layers[objectId];
   } else {
	return false;
   }
}

<!-- ********************************************** -->
<!--      Functions drive the expanding content		-->
<!--				in a BnB's listing				-->
<!-- ********************************************** -->
var visible = 1;

function switchDiv(div_id)
{
  if(document.images) {
	  var style_sheet = getStyleObject(div_id);
	  if (style_sheet)
	  {
		if (style_sheet.display != "none") {
			changeObjectVisibility(div_id, "none");
			//visible = 0;
		} else {
			changeObjectVisibility(div_id, "block");
			//visible = 1;
		}
	  }
	  else 
	  {
		//alert("sorry, this only works in browsers that do Dynamic HTML");
	  }
  }
}

function changeObjectVisibility(objectId, newVisibility) {
    // first get the object's stylesheet
    var styleObject = getStyleObject(objectId);

    // then if we find a stylesheet, set its visibility
    // as requested
    //
    if (styleObject) {
	styleObject.display = newVisibility;
	return true;
    } else {
	return false;
    }
}

<!-- ********************************************** -->
<!--      		  Amenity descriptions				-->
<!-- ********************************************** -->
// Use this one. Uses an Image instead of form field as the descriptor.
// Uses src from preloadDescriptions()
function amenityDescription2(bnb_id,amenity) {

	if (amenity_preload_flag) {
		img_object = "amenities_" + bnb_id;
		//img_name = img_path + "/icon_descriptions/" + amenity + ".gif";
		
		document.images[img_object].src = eval(amenity).src;

		//document.images[img_object].src= img_name;
		//var keywords = new Array ('bike_storage','ski_storage','horse_boarding','sack_lunches','special_diet','highspeed_internet','videos','library','shuttle','kitchenette','dvd','tv','dataport','fitness_center','business_center','child_care','handicap','breakfast_cont','breakfast_full','fireplace_private','pool_outdoor','pool_indoor','steam','sauna','hottub_community','hottub_private','whirlpool','bath_shared','bath_private','wedding_catering','wedding');
		//var linkElement = keywords.grep();
		//alert(linkElement);
	}
}

<!-- ********************************************** -->
<!--      	Preload Amenity Icon Descriptions		-->
<!-- ********************************************** -->
var amenity_preload_flag = false;
function preloadDescriptions() {

	var icon_path = "icon_descriptions/";
		
	blank = new Image();
	blank.src = icon_path + "blank.gif";
	
	bath_private = new Image();
	bath_private.src = icon_path + "bath_private.gif";

	bath_shared = new Image();
	bath_shared.src = icon_path + "bath_shared.gif";

	whirlpool = new Image();
	whirlpool.src = icon_path + "whirlpool.gif";

	hottub_private = new Image();
	hottub_private.src = icon_path + "hottub_private.gif";

	hottub_community = new Image();
	hottub_community.src = icon_path + "hottub_community.gif";

	sauna = new Image();
	sauna.src = icon_path + "sauna.gif";

	steam = new Image();
	steam.src = icon_path + "steam.gif";

	pool_indoor = new Image();
	pool_indoor.src = icon_path + "pool_indoor.gif";

	pool_outdoor = new Image();
	pool_outdoor.src = icon_path + "pool_outdoor.gif";

	fireplace_private = new Image();
	fireplace_private.src = icon_path + "fireplace_private.gif";

	kitchenette = new Image();
	kitchenette.src = icon_path + "kitchenette.gif";
	
	cabins = new Image();
	cabins.src = icon_path + "cabins.gif";

	dvd = new Image();
	dvd.src = icon_path + "dvd.gif";

	tv = new Image();
	tv.src = icon_path + "tv.gif";

	library = new Image();
	library.src = icon_path + "library.gif";

	videos = new Image();
	videos.src = icon_path + "videos.gif";

	dataport = new Image();
	dataport.src = icon_path + "dataport.gif";

	highspeed_internet = new Image();
	highspeed_internet.src = icon_path + "highspeed_internet.gif";

	breakfast_full = new Image();
	breakfast_full.src = icon_path + "breakfast_full.gif";
	
	credit_cards = new Image();
	credit_cards.src = icon_path + "credit_cards.gif";

	breakfast_cont = new Image();
	breakfast_cont.src = icon_path + "breakfast_cont.gif";

	special_diet = new Image();
	special_diet.src = icon_path + "special_diet.gif";

	sack_lunches = new Image();
	sack_lunches.src = icon_path + "sack_lunches.gif";

	wedding = new Image();
	wedding.src = icon_path + "wedding.gif";

	wedding_catering = new Image();
	wedding_catering.src = icon_path + "wedding_catering.gif";

	handicap = new Image();
	handicap.src = icon_path + "handicap.gif";

	child_care = new Image();
	child_care.src = icon_path + "child_care.gif";

	horse_boarding = new Image();
	horse_boarding.src = icon_path + "horse_boarding.gif";

	ski_storage = new Image();
	ski_storage.src = icon_path + "ski_storage.gif";

	bike_storage = new Image();
	bike_storage.src = icon_path + "bike_storage.gif";

	business_center = new Image();
	business_center.src = icon_path + "business_center.gif";

	fitness_center = new Image();
	fitness_center.src = icon_path + "fitness_center.gif";

	shuttle = new Image();
	shuttle.src = icon_path + "shuttle.gif";
	
	amenity_preload_flag = true;
}

<!-- ********************************************** -->
<!--      			Moves the Map Arrow				-->
<!-- ********************************************** -->

function moveArrow(x,y,other) {
   document.map_holder.focus();
   
   // first get the object's stylesheet
    var styleObject = getStyleObject("arrow");
	var styleObject2 = getStyleObject("wskies");
	// then if we find a stylesheet, set its visibility
    // as requested
    //
	if(other == "wskies") {
		
		if (styleObject) {
			styleObject.visibility= "hidden";
		}
		
		if(styleObject2) {
			styleObject2.visibility= "visible";
			styleObject2.left = x + "px";
			styleObject2.top = y + "px";
			return true;
		} else {
			return false;
		}		
	} else {
		if (styleObject2) {
			styleObject2.visibility= "hidden";
		}
		
		if (styleObject) {
			styleObject.visibility= "visible";
			styleObject.left = x + "px";
			styleObject.top = y + "px";
	
			return true;
		} else {
			return false;
		}
	}
	
}
