function ChangeLanguage(url)
{
	window.location = ReverseString(url);
}

function ReverseString(value)
{
	if (value == null)
		return null;
	
	var output = "";	
	for (i = 0; i < value.length; i++)
	{
		output = value.charAt(i) + output;
	}
	return output;
}

function Tabs() { //v3.0
  var i, args=Tabs.arguments; document.Tabs_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}



function getDate(dateString) {
    var year = dateString.substr(0,4)
    var month = dateString.substr(5,2) - 1 // 0 - 11
    var day = dateString.substr(8,2)
    return new Date(year,month,day)
}


// validate dates
function ValidateSearch() {

    var inDate = getDate(document.getElementById("f_date_a").value)
    var outDate = getDate(document.getElementById("f_calcdate").value)
	var currentDate = new Date();
	var Destination = document.getElementById("subcategories_id").value;

	//validate checkin - checkout difference (date range too big)
	if ((outDate - inDate) / 86400000 >= 31) {  //86400000 is one days in milliseconds
		alert('Your period of stay should be no longer than 30 nights.')
		return false
	}

    // validate checkout <= checkin
	if (outDate - inDate <= 0) {
		alert('Please ensure that the check-out date is after the check-in date.')
		
		return false
	}
	
	    //validate checkin/checkout is less than one year in advance
    if ((outDate - currentDate) / 86400000 >= 363) {
        alert('You cannot book 1 year in advance.')
        return false;
    }
	
	if (Destination <= 0) {
		alert('Please select a City!')
		
		return false
	}

	document.SearchBoxCityBigForm.submit()
}

// validate dates
function ValidateDates() {

    var inDate = getDate(document.getElementById("f_date_a").value)
    var outDate = getDate(document.getElementById("f_calcdate").value)
	var currentDate = new Date();

	//validate checkin - checkout difference (date range too big)
	if ((outDate - inDate) / 86400000 >= 31) {  //86400000 is one days in milliseconds
		alert('Your period of stay should be no longer than 30 nights.')
		return false
	}

    // validate checkout <= checkin
	if (outDate - inDate <= 0) {
		alert('Please ensure that the check-out date is after the check-in date.')
		
		return false
	}
	
	    //validate checkin/checkout is less than one year in advance
    if ((outDate - currentDate) / 86400000 >= 363) {
        alert('You cannot book 1 year in advance.')
        return false;
    }

	document.SearchBoxCityBigForm.submit()
}

//unencode url-encoded string
function URLDecode(urlStr) {
	return unescape(urlStr.replace(/\+/g, " "))
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

function SetBookmark()
{
	var url = document.location;
	var title = document.title;
	if (window.sidebar)
	{
		window.sidebar.addPanel(title, url,"");
	}
	else
	{
		window.external.AddFavorite(url, title);
	}
}

function showDiv(hotelId) {
	if (document.getElementById) {	
	document.getElementById('fileName').value = hotelId;
			var layer =  document.getElementById('hideshow')
			if(layer){
				layer.style.visibility = 'visible';
			}
	}	
}
 
 
function hideDiv(){
	if (document.getElementById) {
		var layer =  document.getElementById('hideshow')
		if(layer){
			layer.style.visibility = 'hidden';
		}
	}	
}