
	function clearGridCheckboxes(){
		for (i=0;i<document.gridSearchForm.elements.length;i++)
		{
			if (document.gridSearchForm.elements[i].name == 'cat')
			{
				document.gridSearchForm.elements[i].checked = false;
			}
		}
	}
//Arrays and Functions for Main Navigation Bar
var onArray = new Array("home_on.gif", "wine_country_on.gif", "outdoors_on.gif", "history_on.gif", "trip_on.gif");
var offArray = new Array("home_off.gif", "wine_country_off.gif", "outdoors_off.gif", "history_off.gif", "trip_off.gif");
function showOnButton(index) {
	document.getElementById("image"+index).src = "/images/shell/" + onArray[index];		
}
function showOffButton(index) {
	document.getElementById("image"+index).src = "/images/shell/" + offArray[index];
}
function swapNavBackgroundOn(index) {
	document.getElementById("nav"+index).style.backgroundColor = '#E2663B';
}
function swapNavBackgroundOff(index) {
	document.getElementById("nav"+index).style.backgroundColor = '';
}

//Functions FOR SLIDESHOW
function scrollButtonOn(direction) {
	document.getElementById("scroll"+direction).src = "/images/shell/scroll_"+direction+"_on.gif";	
}
function scrollButtonOff(direction) {
	document.getElementById("scroll"+direction).src = "/images/shell/scroll_"+direction+"_off.gif";	
}

function mapHover(id) {
	document.getElementById(id).style.color = "#E55E1E";	
}
function mapHoverOff(id) {
	document.getElementById(id).style.color = "#666666";	
}

//Mouse-over for Homepage Map Link
function mapExtendOn(id) {
	document.getElementById(id).src = "/images/shell/extend_map_over.gif";	
}
function mapExtendOff(id) {
	document.getElementById(id).src = "/images/shell/extend_map.gif";	
}
function imageOn(img) {
	image = document.getElementById(img);
	image.src = "/images/shell/"+img+"_over.gif";
}
function imageOff(img) {
	image = document.getElementById(img);
	image.src = "/images/shell/"+img+".gif";
}
function imageOnGrids(img) {
	image = document.getElementById(img);
	image.src = "/images/grids/"+img+"_over.gif";
}
function imageOffGrids(img) {
	image = document.getElementById(img);
	image.src = "/images/grids/"+img+".gif";
}
function imageOnMap(img) {
	image = document.getElementById(img);
	image.src = "/images/emap/"+img+"_over.gif";
}
function imageOffMap(img) {
	image = document.getElementById(img);
	image.src = "/images/emap/"+img+".gif";
}
//Right Column Functions
function columnImageOn(img) {
	image = document.getElementById(img);
	if(image.name == "closed")
	{
		image.src = "/images/shell/"+img+"closed_over.gif";
		image.name = "closed";
	}
	else
	{
		image.src = "/images/shell/"+img+"open_over.gif";
		image.name = "open";
	}
}
function columnImageOff(img) {
	image = document.getElementById(img);
	if(image.name == "closed")
	{
		image.src = "/images/shell/"+img+"closed.gif";
		image.name = "closed";
	}
	else
	{
		image.src = "/images/shell/"+img+"open.gif";
		image.name = "open";
	}	
}
function columnImageSwap(img)
{
	image = document.getElementById(img);
	if(image.name == "closed")
	{
		image.src = "/images/shell/"+img+"open.gif";
		image.name = "open";
	}
	else
	{
		image.src = "/images/shell/"+img+"closed.gif";
		image.name = "closed";
	}
}
function gridClassImageSwap(img,bg)
{
	image = document.getElementById(img);
	bg = document.getElementById(bg);
	if(image.name == "closed")
	{
		image.src = "/images/grids/gridClass_button_open.gif";
		image.name = "open";
		bg.style.background = "url('/images/grids/gridClass_verticalLine.gif') repeat-y";
	}
	else
	{
		image.src = "/images/grids/gridClass_button_closed.gif";
		image.name = "closed";
		bg.style.background = '';
	}
}
function homeMapSwitch(id)
{
	itm = document.getElementById(id);
	if(!itm)
	return false;
	if(itm.style.display == 'none')
	itm.style.display = '';
	else
	itm.style.display = 'none';
	if(id == 'mapOpenBodyTop')
	{	
		itm1 = document.getElementById('mapClosedBodyTop');
		if(itm1.style.display == 'none')
		itm1.style.display = '';
		else
		itm1.style.display = 'none';
	}
	if(id == 'mapClosedBodyTop')
	{	
		itm1 = document.getElementById('mapOpenBodyTop');
		if(itm1.style.display == 'none')
		itm1.style.display = '';
		else
		itm1.style.display = 'none';
	}
	
	itm3 = document.getElementById('mapClosedBodyTopContainer');
	if(itm3.style.display == 'none')
	itm3.style.display = '';
	else
	itm3.style.display = 'none';
	
	itm5 = document.getElementById('mapOpenBodyTopContainer');
	if(itm5.style.display == 'none')
	itm5.style.display = '';
	else
	itm5.style.display = 'none';
	
	return false;
}
function homeGoogleExpand()
{
	home_Left = document.getElementById('homeLeft');
	home_Right = document.getElementById('homeRight');
	googleMap = document.getElementById('map_canvas');
	home_Map_Button = document.getElementById('home_map_button_');
	map_Header = document.getElementById('mapHeader');
	if(home_Map_Button.name == "closed")
	{
		home_Map_Button.src = '/images/shell/home_map_button_open.gif';
		home_Left.style.display = 'none';
		home_Right.style.width = '558px';
		
		home_Map_Button.name = 'open';
		map_Header.style.display = '';
		
		document.getElementById('map_canvas').style.display = 'none';
		/*document.getElementById('mapClosedBodyTopContainer').style.height = '50px';*/
		document.getElementById('mapClosedBodyTopContainer').style.height = '50px';
		document.getElementById('homeMapContainer').style.visibility = '';
		document.getElementById('homeMapContainer').style.display = '';
		document.getElementById('homeMapContainer').style.height = '400px';
		if(document.getElementById('homeMapContainer').name != "loaded")
		{
			pageload();
		}
		document.getElementById('homeMapContainer').name = "loaded";
		/*document.getElementById('map_content').style.visibility = 'visible';*/
		/*document.getElementById('interactiveMapContainer').style.visibility = '';*/
		/*document.getElementById('interactiveMapContainer').style.display = '';*/
	}
	else
	{
		document.getElementById('homeMapContainer').style.height = '0px';
		document.getElementById('homeMapContainer').style.visibility = 'hidden';
		document.getElementById('homeMapContainer').style.display = 'none';
		map_Header.style.display = 'none';
		
		document.getElementById('map_canvas').style.display = '';
		/*document.getElementById('mapClosedBodyTopContainer').style.height = '340px';*/
		document.getElementById('mapClosedBodyTopContainer').style.height = '';
		home_Map_Button.src = '/images/shell/home_map_button_closed.gif';
		home_Left.style.display = '';
		home_Right.style.width = '246px';
		googleMap.style.width = '246px';
		home_Map_Button.name = 'closed';
		
		initialize();
		
		
		
		/*document.getElementById('interactiveMapContainer').style.visibility = 'hidden';*/
		/*document.getElementById('interactiveMapContainer').style.display = 'none';*/
		/*document.getElementById('map_content').style.visibility = 'hidden';*/
	}
}

function weatherSwap()
{
	image = document.getElementById('weather');
	if(image.name == "closed")
	{
		image.src = "/images/shell/weather_open.gif";
		image.name = "open";
	}
	else
	{
		image.src = "/images/shell/weather_closed.gif";
		image.name = "closed";
	}
}
function toggleItem(id)
{
	itm = document.getElementById(id);
	if(!itm)
	return false;
	
	if(itm.style.display == 'none')
	itm.style.display = '';
	else
	itm.style.display = 'none';
	
	return false;
}

function cmsZoom(pageSource, pageName, theHeight, theWidth)
{
	showScrollbars = '';
	leWindow = window.open(pageSource, pageName, 'width='+theWidth+',height='+theHeight+','+showScrollbars+'resizable'); 
	leWindow.resizeTo(theWidth,theHeight);
	leWindow.focus();
}

function listingContainerSwitch(id,state)
{
	if (document.getElementById('listingContainerClosed'+id))
	{		
		objOpen=document.getElementById('listingContainerOpen'+id);
		objClosed=document.getElementById('listingContainerClosed'+id);
		if(objOpen.style.display == 'none')
		{
			objOpen.style.display="";
			objClosed.style.display="none";
		}
		else
		{
			objOpen.style.display="none";
			objClosed.style.display="";
		}

	}
	return false;		
}

//Begin Evgeni
var nScrolledOffset2 = 0;
//whats the Width of the video strip on the client browser
var visibleStripWidth = 549;  

function moveVideoStripLeft2()
{
	var whereToMove = "";
	var stripWidth = document.getElementById("related_images2").clientWidth;

	if(parseInt(nScrolledOffset2) <= (parseInt(stripWidth)-parseInt(visibleStripWidth)))
	{
		var cPadding = document.getElementById("image_content2").style.left;
		var cPaddingEx = cPadding.split("px");
		
		nScrolledOffset2 += 549;
		whereToMove = cPaddingEx[0]-549+"px";
		document.getElementById("image_content2").style.left = whereToMove;
	}
	else
	{
		document.getElementById("move_left2").onclick = "";
	}
}

function moveVideoStripRight2()
{
	var whereToMove = "";
	var stripWidth = document.getElementById("related_images2").clientWidth;

	if(parseInt(nScrolledOffset2) > 0 )
	{
		var cPadding = document.getElementById("image_content2").style.left;
		var cPaddingEx = cPadding.split("px");
		
		nScrolledOffset2 -= 549; 
		whereToMove = parseInt(cPaddingEx[0])+549+"px";
		document.getElementById("image_content2").style.left = whereToMove;										
	}
	else
	{
		document.getElementById("move_right2").onclick = "";
	}
}

function moveVideoStripUp()
{
	var whereToMove = "";
	var stripWidth = document.getElementById("related_images").clientHeight;

	if(parseInt(nScrolledOffset2) <= (parseInt(stripWidth)-parseInt(visibleStripWidth)))
	{
		var cPadding = document.getElementById("image_content").style.top;
		var cPaddingEx = cPadding.split("px");
		
		nScrolledOffset2 += 300;
		whereToMove = cPaddingEx[0]-300+"px";
		document.getElementById("image_content").style.top = whereToMove;
	}
	else
	{
		document.getElementById("move_up").onclick = "";
	}
}

function moveVideoStripDown()
{
	var whereToMove = "";
	var stripWidth = document.getElementById("related_images").clientHeight;

	if(parseInt(nScrolledOffset2) > 0 )
	{
		var cPadding = document.getElementById("image_content").style.top;
		var cPaddingEx = cPadding.split("px");
		
		nScrolledOffset2 -= 300; 
		whereToMove = parseInt(cPaddingEx[0])+300+"px";
		document.getElementById("image_content").style.top = whereToMove;										
	}
	else
	{
		document.getElementById("move_down").onclick = "";
	}
}



function addCartListings(x)
{
	//if(document.getElementById(
	x_addCartListings_php(x,addCartListings_callback);
}

function addCartListings_callback(z){}

function removeCartListings(element,ListingID)
{
	x_removeCartListings_php(element,ListingID,removeCartListings_callback);	
}

function removeCartListings_callback(z){}		
		
function newAddCart(ListingID)
{
		addCartListings(ListingID);
		document.getElementById("thisAddCart"+ListingID).style.display="none";
		document.getElementById("thisAddMessage"+ListingID).style.display="none";
		document.getElementById("thisRemoveCart"+ListingID).style.display="";
		document.getElementById("thisRemoveMessage"+ListingID).style.display="";
		document.getElementById("thisCart"+ListingID).src='/images/grids/i_cart_remove.jpg';
		listing_count();
		
}

function newRemoveCart(ListingID)
{
		removeCartListings("thisCart"+ListingID,ListingID);		
		document.getElementById("thisAddCart"+ListingID).style.display="";
		document.getElementById("thisAddMessage"+ListingID).style.display="";
		document.getElementById("thisRemoveCart"+ListingID).style.display="none";
		document.getElementById("thisRemoveMessage"+ListingID).style.display="none";
		document.getElementById("thisCart"+ListingID).src='/images/grids/i_cart_add.jpg';
		listing_count();
		
}

function listing_count()
{
var listings;
try
  {
  // Firefox, Opera 8.0+, Safari
  listings=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    listings=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      listings=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  listings.onreadystatechange=function()
    {
    if(listings.readyState==4)
      {
      document.getElementById("listing_count").innerHTML=listings.responseText+" Listing(s) in My Trip";
      }
    }
  listings.open("POST","/js_css/count_listings.php",true);
  listings.send(null);
}

var sajax_debug_mode = false;
var sajax_request_type = "GET";
var sajax_target_id = "";
var sajax_failure_redirect = "";

function sajax_debug(text) {
	if (sajax_debug_mode)
		alert(text);
}

	function sajax_init_object() {
		sajax_debug("sajax_init_object() called..")
		
		var A;
		
		var msxmlhttp = new Array(
		'Msxml2.XMLHTTP.5.0',
		'Msxml2.XMLHTTP.4.0',
		'Msxml2.XMLHTTP.3.0',
		'Msxml2.XMLHTTP',
		'Microsoft.XMLHTTP');
	for (var i = 0; i < msxmlhttp.length; i++) {
		try {
			A = new ActiveXObject(msxmlhttp[i]);
		} catch (e) {
			A = null;
		}
	}
		
	if(!A && typeof XMLHttpRequest != "undefined")
		A = new XMLHttpRequest();
	if (!A)
		sajax_debug("Could not create connection object.");
	return A;
}

var sajax_requests = new Array();

function sajax_cancel() {
	for (var i = 0; i < sajax_requests.length; i++) 
		sajax_requests[i].abort();
}

function sajax_do_call(func_name, args) {
	var i, x, n;
	var uri;
	var post_data;
	var target_id;
	
	sajax_debug("in sajax_do_call().." + sajax_request_type + "/" + sajax_target_id);
	target_id = sajax_target_id;
	if (typeof(sajax_request_type) == "undefined" || sajax_request_type == "") 
		sajax_request_type = "GET";
	
	uri = "/accommodations/";
	if (sajax_request_type == "GET") {
	
		if (uri.indexOf("?") == -1) 
			uri += "?rs=" + escape(func_name);
		else
			uri += "&rs=" + escape(func_name);
		uri += "&rst=" + escape(sajax_target_id);
		uri += "&rsrnd=" + new Date().getTime();
		
		for (i = 0; i < args.length-1; i++) 
			uri += "&rsargs[]=" + escape(args[i]);

		post_data = null;
	} 
	else if (sajax_request_type == "POST") {
		post_data = "rs=" + escape(func_name);
		post_data += "&rst=" + escape(sajax_target_id);
		post_data += "&rsrnd=" + new Date().getTime();
		
		for (i = 0; i < args.length-1; i++) 
			post_data = post_data + "&rsargs[]=" + escape(args[i]);
	}
	else {
		alert("Illegal request type: " + sajax_request_type);
	}
	
	x = sajax_init_object();
	if (x == null) {
		if (sajax_failure_redirect != "") {
			location.href = sajax_failure_redirect;
			return false;
		} else {
			sajax_debug("NULL sajax object for user agent:\n" + navigator.userAgent);
			return false;
		}
	} else {
		x.open(sajax_request_type, uri, true);
		// window.open(uri);
		
		sajax_requests[sajax_requests.length] = x;
		
		if (sajax_request_type == "POST") {
			x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
			x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		}
	
		x.onreadystatechange = function() {
			if (x.readyState != 4) 
				return;

			sajax_debug("received " + x.responseText);
		
			var status;
			var data;
			var txt = x.responseText.replace(/^\s*|\s*$/g,"");
			status = txt.charAt(0);
			data = txt.substring(2);

			if (status == "") {
				// let's just assume this is a pre-response bailout and let it slide for now
			} else if (status == "-") 
				alert("Error: " + data);
			else {
				if (target_id != "") 
					document.getElementById(target_id).innerHTML = eval(data);
				else {
					try {
						var callback;
						var extra_data = false;
						if (typeof args[args.length-1] == "object") {
							callback = args[args.length-1].callback;
							extra_data = args[args.length-1].extra_data;
						} else {
							callback = args[args.length-1];
						}
						callback(eval(data), extra_data);
					} catch (e) {
						sajax_debug("Caught error " + e + ": Could not eval " + data );
					}
				}
			}
		}
	}
	
	sajax_debug(func_name + " uri = " + uri + "/post = " + post_data);
	x.send(post_data);
	sajax_debug(func_name + " waiting..");
	delete x;
	return true;
}


// wrapper for addCartListings_php		
function x_addCartListings_php() {
	sajax_do_call("addCartListings_php",
		x_addCartListings_php.arguments);
}

		
// wrapper for removeCartListings_php		
function x_removeCartListings_php() {
	sajax_do_call("removeCartListings_php",
		x_removeCartListings_php.arguments);
}

// wrapper for addCartArticles_php		
function x_addCartArticles_php() {
	sajax_do_call("addCartArticles_php",
		x_addCartArticles_php.arguments);
}

		
// wrapper for removeCartArticles_php		
function x_removeCartArticles_php() {
	sajax_do_call("removeCartArticles_php",
		x_removeCartArticles_php.arguments);
}