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 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 eraseCookie(name) {
        createCookie(name,"",-1);
}

function select_skigebied()
{
        http = create_http();
        var date = new Date();
        var url = "/ajax/wintersport-vakanties.nl/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/wintersport-vakanties.nl/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);
}

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){ alert('Het formulier is niet correct ingevuld!.\nControleer aub de rode velden.'); return false; } else { return true;}
}
