function openAndSubmitReserve(hotelid) {
		
		windowWidth = 800;
		windowHeight = 750;
		
		var centerWidth = (window.screen.width - windowWidth) / 2;
    	var centerHeight = (window.screen.height - windowHeight) / 2;
		
		reservewindow = window.open('','reservewindow','menubar=1,toolbar=1,location=1,scrollbars=1,width=' + windowWidth + ',height=' + windowHeight + ',top=' + centerHeight + ',left=' + centerWidth);
		document.getElementById('reservationform_' + hotelid).target = 'reservewindow';
		document.getElementById('reservationform_' + hotelid).submit();
}

function openReserve(hotelid) {
	
	windowWidth = 800;
	windowHeight = 750; 
	
	var centerWidth = (window.screen.width - windowWidth) / 2;
	var centerHeight = (window.screen.height - windowHeight) / 2;
	
	var reserveUrl = 'https://' + secureServer + '/reservationPopup/' + hotelid + '?ref=' + serverName + '&lang=' + currentLanguage;
	 
	reservewindow = window.open(reserveUrl,'reservewindow','menubar=1,toolbar=1,location=1,scrollbars=1,width=' + windowWidth + ',height=' + windowHeight + ',left=' + centerWidth + ',top=' + centerHeight);
	
}

function openReserveWithPost() {

	windowWidth = 800;
	windowHeight = 750;
	
	var centerWidth = (window.screen.width - windowWidth) / 2;
	var centerHeight = (window.screen.height - windowHeight) / 2;

	reservewindow = window.open('','reservewindow','menubar=1,toolbar=1,location=1,scrollbars=1,width=' + windowWidth + ',height=' + windowHeight + ',top=' + centerHeight + ',left=' + centerWidth);
	document.getElementById('reserveformpopup').target = 'reservewindow';
	document.getElementById('reserveformpopup').submit();
}

function tabsChange(tabId) {
	otab1 = window.document.getElementById('tab1');
	otab2 = window.document.getElementById('tab2');
	otabOuter1 = window.document.getElementById('tabOuter1');
	otabOuter2 = window.document.getElementById('tabOuter2');
	osearchLocationsBox = document.getElementById('findLocationTable');
	osearchHotelsBox = document.getElementById('findHotelTable');

	if(tabId == 3 || tabId == 4) {
		box = 'box3';
	} else {
		box = 'box2'; 
	}
	
	if(tabId == 2 || tabId == 4) {
		otab1.className = box + '-tab1-inactive';
		otabOuter1.className = box + 'outterTabBox-inactive';
		otab2.className = box + '-tab2';
		otabOuter2.className = box + 'outterTabBox';

		osearchHotelsBox.style.display = 'block';
		osearchLocationsBox.style.display = 'none';
		
	}

	if(tabId == 1 || tabId == 3) {
		otab2.className = box + '-tab2-inactive';
		otab1.className = box + '-tab1';
		otabOuter1.className = box + 'outterTabBox';
		otabOuter2.className = box + 'outterTabBox-inactive';

		osearchHotelsBox.style.display = 'none';
		osearchLocationsBox.style.display = 'block';
	}	 
}

function checksearchlocations() {
	
	sBox = document.getElementById('searchStringLocation');
	if(sBox.value == '' || sBox.value == null || searchInitialized == false) {
		document.getElementById('searchLocationsError').style.display = 'block';
		document.getElementById('searchLocationsError').innerHTML = lexicon['PLEASE_TYPE_DESTINATION'];
		sBox.focus();
		return false;
	}

	sdBox = document.getElementById('startdate');
	if(sdBox.value == '' || sdBox.value == null) {
		alert(lexicon['PLEASE_SELECT_CHECKIN_DATE']);
		sdBox.focus();
		return false;
	}

	edBox = document.getElementById('enddate');
	if(edBox.value == '' || edBox.value == null) {
		alert(lexicon['PLEASE_SELECT_CHECKOUT_DATE']);
		edBox.focus();
		return false;
	}
}

function checksearchhotel() {
	sBox = document.getElementById('searchStringHotel');
	if(sBox.value == '' || sBox.value == null) {
		document.getElementById('searchHotelsError').innerHTML = lexicon['TYPE_THE_NAME_OF_THE_HOTEL'];
		setTimeout('document.getElementById("searchHotelsError").innerHTML = "";', 10000);
		sBox.focus();
		return false;
	}
}

function validateForm() {
		
	if (document.getElementById('username').value == '') {
		alert(lexicon['PLEASE_FILL_USERNAME']);
		document.getElementById('username').focus();
		return false;
	}
	
	if (document.getElementById('password').value == '') {
		alert(lexicon['PLEASE_FILL_PASSWORD']);
		document.getElementById('password').focus();
			return false;
	}
}

function checkcancellationform() {
	if(document.getElementById('reason').value == '') {
		alert(lexicon['PLEASE_PROVIDE_THE_CANCELLATION_REASON']);
		return false;
	}
}


function selectionCriteriaChange() {
	
	sBox = document.getElementById('criteriaSelectionSubmit');
	sForm = document.getElementById('criteriaForm');
	sForm.submit();
	
}

var cvccodepopuplink = '/help/3digits.html';

	function changeguestname() {
		tboxGuestTick = document.getElementById('guestnames_tick');
		tboxGuestnames = document.getElementById('guestnames');
		if(tboxGuestTick.checked == false) {
			tboxGuestnames.disabled = false;
			tboxGuestnames.className = "";
		} else {
			tboxGuestnames.className = "inputdisabled";
			tboxGuestnames.disabled = true;
		}
	}

function checkAmEx()
{
  if(document.getElementById('CardType').value == "AmEx")
  {
	document.getElementById('CCCVC').maxLength = 4;
	cvccodepopuplink = '/help/4digits.html';
  }
  else
  {
	document.getElementById('CCCVC').maxLength = 3;
	cvccodepopuplink = '/help/3digits.html';
  }
}

function checkstep4reservationform(pressedbutton) {
	switch(pressedbutton) {
		case  'Finish':
			setTimeout( "ShowAnimatedPleasewait();", 50 ); 
			document.getElementById('step4').submit();
			document.getElementById('Finish').disabled = true;
			document.getElementById('stepBack').disabled = true;
			return true;
		break;
		case 'stepBack':
			document.getElementById('Finish').disabled = true;
			return true;
		break;
		default:
			return false;
	}
}

function ShowAnimatedPleasewait() {
	document.getElementById('pleasewaitspan').style.display = 'block';
}

function grayOut(elem, vis, options, extra) {
  var options = options || {};
  var zindex = options.zindex || 50;
  var opacity = options.opacity || 70;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#000000';
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');           // Create the layer.
        tnode.style.position='absolute';                 // Position absolutely
        tnode.style.top='0px';                           // In the top
        tnode.style.left='0px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later

	var msgnode = document.createElement('div');           // Create the box layer.
		msgnode.style.position='absolute';                 // Position absolutely
        msgnode.style.top= screen.height/3+'px';                           // In the top
        msgnode.style.left=screen.width/3+'px';                          // Left corner of the page
        msgnode.style.overflow='hidden';                   // Try to avoid making scroll bars
        msgnode.style.display='none';                      // Start out Hidden
        msgnode.id='box';                   				// Name it so we can find it later
	tbody.appendChild(msgnode);                            // Add it to the grey screen
    tbody.appendChild(tnode);                            // Add it to the web page
    dark=document.getElementById('darkenScreenObject');  // Get the object.
  }
  if (vis) {
    // Calculate the page width and height
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    }
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;
    dark.style.MozOpacity=opaque;
    dark.style.filter='alpha(opacity='+opacity+')';
    dark.style.zIndex=zindex;
    dark.style.backgroundColor=bgcolor;
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display='block';
	if (extra == 'Y') {
		document.body.style.overflow = 'hidden';
	}
	
	elem.style.zIndex = zindex + 10;
	
  } else {
     dark.style.display='none';
  }
}
  
function hideMap() {
 		
	document.getElementById('mapPop').style.display = "none";
	//document.getElementById('mapDiv').style.display = "block";
	
	popped = false;
	
	//terminateMap();
	
	grayOut(document.getElementById("mapPop"), false, '', '');
}
  
window.center = function()
{
	var hWnd = (arguments[0] != null) ? arguments[0] : {width:0,height:0};

	var _x = 0;
	var _y = 0;
	var offsetX = 0;
	var offsetY = 0;

	//IE
	if(!window.pageYOffset)
	{
		//strict mode
		if(!(document.documentElement.scrollTop == 0))
		{
			offsetY = document.documentElement.scrollTop;
			offsetX = document.documentElement.scrollLeft;
		}
		//quirks mode
		else
		{
			offsetY = document.body.scrollTop;
			offsetX = document.body.scrollLeft;
		}
	}
	//w3c
	else
	{
		offsetX = window.pageXOffset;
		offsetY = window.pageYOffset;
	}

	_x = ((this.size().width-hWnd.width)/2)+offsetX;
	_y = ((this.size().height-hWnd.height)/2)+offsetY;

	return{x:_x,y:_y};
}

window.size = function()
{
	var w = 0;
	var h = 0;

	//IE
	if(!window.innerWidth)
	{
		//strict mode
		if(!(document.documentElement.clientWidth == 0))
		{
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		}
		//quirks mode
		else
		{
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	}
	//w3c
	else
	{
		w = window.innerWidth;
		h = window.innerHeight;
	}
	return {width:w,height:h};
}

function popMap(s) {

	point = window.center({width: 600, height: 350});
	
	document.getElementById('mapPop').style.left = point.x + "px";
	document.getElementById('mapPop').style.top = point.y + "px";
	document.getElementById('mapPop').style.display = "block";
	
	if(iframemapLoaded == false) {
		document.getElementById('iframemap').src = iframeSrc;
		iframemapLoaded = true;
	} 
	popped = true;
	grayOut(document.getElementById("mapPop"), true, '', '');
}