function create_http() {
try
  {
        // Firefox, Opera 8.0+, Safari
         http=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    http=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      http=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  return http;
}


function createCookie(name,value,days) {
        if (days) {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000));
                var expires = "; expires="+date.toGMTString();
        }
        else var expires = "";
        document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for(var i=0;i < ca.length;i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length);
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        }
        return null;
}

function eraseCookie(name) {
        createCookie(name,"",-1);
}

function select_skigebied()
{
        http = create_http();
        var date = new Date();
        var url = "/ajax/select_skigebied.php?time="+date.getTime();
	var params;

        http.open("GET", url, true);
        //Send the proper header information along with the request
        http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        http.setRequestHeader("Connection", "close");
        http.onreadystatechange = function() {//Call a function when the state changes.
                if(http.readyState == 4) {
                        document.getElementById('select_skigebied').innerHTML = http.responseText;
			select_plaats();
                }
        }
        http.send(params);
}

function select_plaats()
{
        http = create_http();
	var date = new Date();
        var url = "/ajax/select_plaats.php?time="+date.getTime();
	var params;

        http.open("GET", url, true);
        //Send the proper header information along with the request
        http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        http.setRequestHeader("Connection", "close");
        http.onreadystatechange = function() {//Call a function when the state changes.
                if(http.readyState == 4) {
                        document.getElementById('select_plaats').innerHTML = http.responseText;
                }
        }
        http.send(params);
}


// Popup Function
function popup (mylink, windowname, width, height) {
                if (! window.focus) { return true; }
                var href;
                if (typeof(mylink) == 'string') {
                        href=mylink;
                } else {
                        href=mylink.href;
                }
                window.open(href, windowname, 'width='+width+',height='+height+',scrollbars=yes');
                return false;
}

function uitklappen(id){
	document.getElementById(id).style.display = "inline";
	document.getElementById('beschrijvingkop').innerHTML = "<a onclick=\"inklappen('bijzonderhedeninklap')\" style=\"cursor: pointer;\"><b>Lees de reisinformatie voordat u een reis boekt! klik hier  -</b></a><br>";
}

function inklappen(id){
	document.getElementById(id).style.display = "none";
	document.getElementById('beschrijvingkop').innerHTML = "<a onclick=\"uitklappen('bijzonderhedeninklap')\" style=\"cursor: pointer;\"><b>Lees de reisinformatie voordat u een reis boekt! klik hier +</b></a><br>";
}

function checkvalidation(theform,array,security)
{
var falsearray;
	for(i=0;i<array.length;i++) 
	{
		var string = "var obj = document.forms['"+theform+"']."+array[i];
		eval(string);
		if(obj[0] && !obj.value)
		{	
			var chosen = ""
			var filled = false;
			len = obj.length
			for (b = 0; b <len; b++)
			{
				if (obj[b].checked)
				{
					filled = true;
				}
			}
			if(!filled)
			{
				document.getElementById(array[i]).style.color = 'red';
				falsearray=1;
			}else
			{
				document.getElementById(array[i]).style.color = 'black';
			}
		}else
		{
			var tmp = obj.value;
			if(!tmp)
			{
				var string = "document.forms['"+theform+"']."+array[i]+".style.border = '1px solid red';";
				eval(string);
				falsearray=1;
			}else
			{
		               	if(tmp!="")
				{
					var string = "document.forms['"+theform+"']."+array[i]+".style.border = '0px';";
			               	eval(string);
				}
			}
		}
	} 
	if(security)
	{
		var string = "var sec_code = document.forms['"+theform+"'].security";
		eval(string);
		var string = "var sec_gen = document.forms['"+theform+"'].sec_code_gen";
		eval(string);
		if(sec_code.value != sec_gen.value)
		{
			sec_code.style.border='1px solid red'; return false; 
		}else
		{
			sec_code.style.border='0px solid black';
		}
	}
	if(falsearray==1){ return false; } else { return true;}
}
