/*

	standard javascript functions
	query reader, cookie handling
*/

function setCookie(c_name,value,expiredays)
{
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return ""
}
function getQueryVariable(variable)
{
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i = 0; i < vars.length; i++)
	{
		var pair = vars[i].split("=");
		if (pair[0] == variable)
		{
			return pair[1];
		}
	} 
}


/*
	made in holiday autos javascript functions

*/

function countryselected(url) // this function is called once the user has selected a country. It create a cookie if user want his choice to be remembered and redirect the visitor to the desired website.
{
	if (document.form1.remember.checked)
	{
		setCookie("hapreferredurl",url,365);
	}
	location.href=url;
}





if (getCookie("hapreferredurl").length>0) // this script controls auto-redirection if "remember my choice" was selected in the past
{
	if (getQueryVariable('redirect')!='no')
	{
		var url=getCookie("hapreferredurl");
		setCookie("hapreferredurl",url,365);
		location.href=url;
	}
	else setCookie("hapreferredurl","",365);
}
