<!--

function clearSubnav(elementNumber)
{
	for (var x=0;x<8;x++)
	{
		document.getElementById('mms-subnav-'+x).style.display='none';
		if (x != elementNumber && 'active' != document.getElementById('nav'+x).childNodes[0].className)
		{
			document.getElementById('nav'+x).childNodes[0].className='';
		}
	}
	
	if (document.getElementById('nav'+elementNumber).childNodes[0].className != 'active')
	{
		document.getElementById('nav'+elementNumber).childNodes[0].className='activehover';
	}
	document.getElementById('mms-subnav-'+elementNumber).style.display='block';
			
}

var activeNav = false;



Event.observe(window, 'load', function()
{
	activeNav = $('subnav-collections');
	// $$('#xwd-main-nav li ul').each(Element.hide);

	$$('#xwd-main-nav>li').each(
		function(anchor)
		{
			Event.observe(anchor, 'mouseover', function()
			{
				if(anchor != activeNav)
				{
					showSubNav(anchor);
					activeNav = anchor.down().next();
				}	
			});
		}
	);
})

function showSubNav(nav)
{
	var home = '';
	var members = '\
<ul id="subnav-members" class="xwd-subnav">\
	<li class="first"><a href="/members-login">Login</a></li>\
	<li>| <a href="/login">Become a member</a></li>\
	<li>| <a href="/register-card">Register card</a></li>\
	<li>| <a href="/members">Upgrade your membership</a></li>\
</ul>';
	var destinations = '';
	var collections = '';
	var offers = '\
<ul id="subnav-offers" class="xwd-subnav">\
	<li class="first"><a href="/hotel-offers/united-kingdom">UK &amp; Ireland</a></li>\
	<li>| <a href="/hotel-offers/europe">Europe</a></li>\
	<li>| <a href="/hotel-offers/usa">USA</a></li>\
	<li>| <a href="/hotel-offers/asia">Asia</a></li>\
	<li>| <a href="/hotel-offers/rest-of-world">Rest of the world</a></li>\
</ul>';
	var shop = '\
<ul id="subnav-shop" class="xwd-subnav">\
	<li class="first"><a href="/shop/category/books">Books</a></li>\
	<li>| <a href="/shop/category/music">CDs</a></li>\
	<li>| <a href="/mr-and-mrs-smith-get-a-room-gift-vouchers/product-view">Vouchers</a></li>\
	<li>| <a href="/shop/category/special-offers">Special offers</a></li>\
</ul>';
	var maps = '\
<ul id="subnav-maps" class="xwd-subnav">\
	<li class="first"><a href="/smith-maps?name=United%20Kingdom&lat=53.3309&lng=-1.05469&zoom=5">United Kingdom</a></li>\
	<li>| <a href="/smith-maps?name=United%20States&lat=39.3683&lng=-100.547&zoom=4">United States</a></li>\
	<li>| <a href="/smith-maps?name=Germany&lat=51.5087&lng=10.1953&zoom=4">Europe</a></li>\
	<li>| <a href="/smith-maps?name=South%20Africa&lat=-1.6001&lng=23.3789&zoom=3">Africa</a></li>\
	<li>| <a href="/smith-maps?name=Thailand&lat=15.9613&lng=100.898&zoom=3">Asia</a></li>\
	<li>| <a href="/smith-maps?name=Brazil&lat=-9.79568&lng=-54.1406&zoom=3">South America</a></li>\
	<li>| <a href="/smith-maps?name=Indian%20Ocean&lat=10.67957&lng=75.492&zoom=3">Indian Ocean</a></li>\
	<li>| <a href="/smith-maps?name=Australia&lat=-24.3671&lng=132.363&zoom=4">Australasia</a></li>\
	<li>| <a href="/smith-maps?name=Caribbean&lat=17.0778&lng=-81.8091&zoom=4">Caribbean</a></li>\
</ul>';
	var search = '\
<ul id="subnav-search" class="xwd-subnav">\
	<li class="first"><a href="/hotel-search">I know my hotel\'s name</a></li>\
	<li>| <a href="/hotel-search">I know my destination</a></li>\
	<li>| <a href="/hotel-search">Need ideas?</a></li>\
	<li>| <a href="/late-availability/united-kingdom">Late availability</a></li>\
</ul>';
	
	// $$('#xwd-main-nav li ul').each(Element.hide);
	if(activeNav)
	{
		activeNav.hide();
	}
	ulId = nav.identify().substring(4);
	if(!$('subnav-'+ulId) && eval(ulId) != '')
	{
		nav.innerHTML += eval(ulId);
	}
	if(nav.down().next())
	{
		nav.down().next().show();
		activeNav = nav.down().next();
	}
	else
	{
		activeNav = false;
	}
}

function submitSearch()
{
	if ($('country_select').value != '')
	{
		 return true;
	}
	else 
	{
		alert('Please select a country to continue'); 
		return false;
	}
}

var smith_offer_active = false;

function toggle_smith_offer_box(layer) 
{
	if (layer == null)
		layer = 'popup-content';
	if (smith_offer_active)
	{
		Effect.Fade(layer, {duration:0.4, queue:'end'});
		//Effect.Fade('popup-bg', {duration:0.2, from:0.5, to:0, queue:'end'});
		smith_offer_active = false;
	}
	else
	{
		//Effect.Appear('popup-bg', {duration:0.2, from:0, to:0.5, queue:'end'});
		Effect.Appear(layer, {duration:0.4, queue:'end'});
		smith_offer_active = true;
	}

	return false
}

var why_book_active = false;

function toggle_why_book()
{
	if (why_book_active)
	{
		Effect.BlindUp('why-book-detail', {duration:0.4, queue:'end'});
		Effect.Fade('why-book-bg', {duration:0.2, from:0.5, to:0, queue:'end'});
		why_book_active = false;
	}
	else
	{
		Effect.Appear('why-book-bg', {duration:0.2, from:0, to:0.5, queue:'end'});
		Effect.BlindDown('why-book-detail', {duration:0.4, queue:'end'});
		why_book_active = true;
	}

	return false;
}



function bookmarker22() 
{
title = "Mr and Mrs Smith - Boutique Hotels"; 
url = "http://www.mrandmrssmith.com";
if (window.sidebar) { // Mozilla Firefox Bookmark
window.sidebar.addPanel(title, url,"");
} else if( window.external ) { // IE Favorite
window.external.AddFavorite( url, title); }
else if(window.opera && window.print) { // Opera Hotlist
return true; }
}





function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}


function getref (obj)
{	
    var ref;
    
    if (obj.contentDocument) // For NS6
    {
        ref = obj.contentDocument;
    } 
    
    else if (obj.contentWindow) // For IE5.5 and IE6
    {
        ref = obj.contentWindow.document;
    } 
    
    else if (obj.document) // For IE5
    {
        ref = obj.document;
    }
    else ref = 'error';
    
    return ref;
}


function get_object(id)
{
	if(document.getElementById) 
	{
		return document.getElementById(id);
	}
	else 
	{
		return document.all[id];	
	}
}

function start_late_search()
{
		var indicator_div = get_object('search_indicator'); 
		indicator_div.style.display = 'block';
}

function start_date_search(link)
{
	start_late_search();
	location.href = link;
	return false;
}

function bookmarksite(title,url)
{
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
	} 
	else if(document.all)// ie
		window.external.AddFavorite(url, title);
}

/*
function textCounter(field, maxlimit) 
{
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
}
*/

function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
	countfield.value = maxlimit - field.value.length;
}

function check_delete(msg) 
{
	var ok=confirm(msg);
	if (ok)
	  return true;
	else
	  return false;
}

function hotelGalPostBack()
{
// window.opener.document.getElementById("date15_date").value=document.getElementById("date15_date").value;
// window.opener.document.getElementById("date15_month").value=document.getElementById("date15_month").value;
// window.opener.document.getElementById("date15_year").value=document.getElementById("date15_year").value;
window.opener.document.getElementById("date_from").value=document.getElementById("date_from").value;
window.opener.document.getElementById("nights").value=document.getElementById("nights").value;
window.opener.document.getElementById("adults").value=document.getElementById("adults").value;
window.opener.document.getElementById("children").value=document.getElementById("children").value;
window.opener.document.forms['right-bar-booking'].submit();
window.close();
return false;
}

function reviewSetIds(id)
{
	var ids = id.split('~');
	$('review_id').value = ids[0];
	$('review_hotel_id').value = ids[1];
}


function state_to_us(formname, usstate)
{
	if (usstate != "")
		document.forms[formname].country.value = "US";
		
}

function check_country(formname, country)
{
	if (country != "US")
		document.forms[formname].state.value = "";
		
}

function show_field(selected_value,test,show)
{
	if (selected_value == test)
		document.getElementById(show).style.display = "block";
	else
		document.getElementById(show).style.display = "none";					
}



function checkboxAsRadio(FormName, FieldName, CheckValue)
{
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		for(var i = 0; i < countCheckBoxes; i++)
		{
			if ( CheckValue.value == objCheckBoxes[i].value )
				objCheckBoxes[i].checked = CheckValue;
			else
				objCheckBoxes[i].checked = false;	
		}	
}

var activeNav = false;

// move the selected options up one location in the select list

function moveOptionsUp(selectId) {
 var selectList = document.getElementById(selectId);
 var selectOptions = selectList.getElementsByTagName('option');
 for (var i = 1; i < selectOptions.length; i++) {
  var opt = selectOptions[i];
  if (opt.selected) {
   selectList.removeChild(opt);
   selectList.insertBefore(opt, selectOptions[i - 1]);
     }
    }
}

// move the selected options down one location in the select list

function moveOptionsDown(selectId) {
 var selectList = document.getElementById(selectId);
 var selectOptions = selectList.getElementsByTagName('option');
 for (var i = selectOptions.length - 2; i >= 0; i--) {
  var opt = selectOptions[i];
  if (opt.selected) {
   var nextOpt = selectOptions[i + 1];
   opt = selectList.removeChild(opt);
   nextOpt = selectList.replaceChild(opt, nextOpt);
   selectList.insertBefore(nextOpt, opt);
     }
    }
}


function selAll(obj) {
	obj = (typeof obj == "string") ? document.getElementById(obj) : obj;
	if (obj.tagName.toLowerCase() != "select")
		return;
	for (var i=0; i<obj.length; i++) {
		obj[i].selected = true;
	}
}


//-->