function get_object(id) 
{
	var object = null;
	if (document.layers) 
	{   
		object = document.layers[id];
	} else if (document.all)
	{
		object = document.all[id];
	}else if (document.getElementById) 
	{
		object = document.getElementById(id);
	}
    return object;
}

function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}

function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}
function validate(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = email;
   if(reg.test(address) == false) {
      return false;
   }
   return true;
}

var active_home_info = "div_info_knop1";
var active_hotel_info = new Array();
var active_slide = 1;
$(document).ready(function() {
	$('.div_info_knop').click(function() {
		$('#' + active_home_info).removeClass(active_home_info + "_act");
		$('#' + active_home_info).addClass(active_home_info);
		$('#' + active_home_info + "_content").addClass("hidden");
		
		active_home_info = $(this).attr('id');
		
		$('#' + active_home_info).removeClass(active_home_info);
		$('#' + active_home_info).addClass(active_home_info + "_act");
		$('#' + active_home_info + "_content").removeClass("hidden");
	});
	
	$('.div_slider_bol').click(function() {
		$('#slider_info_' + active_slide).addClass("hidden");
		$('#slider_center_' + active_slide).addClass("hidden");
		$('#div_slider_nav_' + active_slide).addClass("inactive");
		
		active_slide = $(this).attr('title');
		
		$('#slider_info_' + active_slide).removeClass("hidden");
		$('#slider_center_' + active_slide).removeClass("hidden");
		$('#div_slider_nav_' + active_slide).removeClass("inactive");
	});	
	http://s3.amazonaws.com/ld48/index.html
	$('.div_reis_right_nav_knop').click(function() {
		$('#' + active_hotel_info[$(this).attr('title')]).removeClass(active_hotel_info[$(this).attr('title')].substr(0,24) + "_act");
		$('#' + active_hotel_info[$(this).attr('title')]).addClass(active_hotel_info[$(this).attr('title')].substr(0,24));
		$('#' + active_hotel_info[$(this).attr('title')] + '_content').addClass('hidden');
		
		active_hotel_info[$(this).attr('title')] = $(this).attr('id');
		
		$('#' + active_hotel_info[$(this).attr('title')]).removeClass(active_hotel_info[$(this).attr('title')].substr(0,24));
		$('#' + active_hotel_info[$(this).attr('title')]).addClass(active_hotel_info[$(this).attr('title')].substr(0,24) + "_act");
		$('#' + active_hotel_info[$(this).attr('title')] + '_content').removeClass('hidden');
	});
});

function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}

function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}

function makeTip(id, tip_value)
{
	$(id).qtip({
		content: tip_value,
		show: { ready: true, when: false },
		hide: 'unfocus',
		position:	{
					  corner: {
								 target: 'bottomMiddle',
								 tooltip: 'topMiddle'
							  }
					},
		style: 	{ 
					background: '#018BD3',
					color: '#FFF',
					tip: 'topMiddle',
					border: {
							 width: 1,
							 radius: 2,
							 color: '#0174B1'
							}
				}
	})
}

// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strDay=dtStr.substring(0,pos1)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		//alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		//alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		//alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		//alert("Please enter a valid date")
		return false
	}
return true
}

function ValidateForm(){
	var dt=document.frmSample.txtDate
	if (isDate(dt.value)==false){
		dt.focus()
		return false
	}
    return true
 }
 
 function xhrRequest(type) { 
		type = type ||  "html"; 
		xhrSend =  !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest(); 
		if (xhrSend.overrideMimeType) {   xhrSend.overrideMimeType("text/" + type); } 
	return xhrSend; 
} 

function gotoContact(website,taal)
{
	url = website + "/contact_content.php?taal=" + taal + "&txt_naam=" + encodeURIComponent(get_object("txt_naam").value) +
	"&txt_adres=" + encodeURIComponent(get_object("txt_adres").value) + "&txt_postcode=" + encodeURIComponent(get_object("txt_postcode").value) +
	"&txt_telefoon=" + encodeURIComponent(get_object("txt_telefoon").value) + "&txt_email=" + encodeURIComponent(get_object("txt_email").value) +
	"&txt_vraag=" + encodeURIComponent(get_object("txt_vraag").value) + "&randNR=" + Math.floor(Math.random()*11) + "&valid=yes";
	//location.href=url;
	var reqType = "text"; 
	var xhrRec = xhrRequest(reqType); 
	xhrRec.open("GET", url, true); 
	var xhrRecB = xhrRequest(reqType); 
	
	
	xhrRec.onreadystatechange =    function () 
	{ 
		if (xhrRec.readyState == 4 && xhrRec.status == 200) 
		{ 
			var rt= xhrRec.responseText; 
			
			get_object("contact_form").innerHTML =  rt; 
		
			xhrRec = null;         
		} 
	} 
	xhrRec.send(null); 
}
function gotoBrochure(website,taal)
{
	url = website + "/brochureaanvraag_content.php?taal=" + taal + "&txt_naam=" + encodeURIComponent(get_object("txt_naam").value) +
	"&txt_adres=" + encodeURIComponent(get_object("txt_adres").value) + "&txt_postcode=" + encodeURIComponent(get_object("txt_postcode").value) +
	"&txt_telefoon=" + encodeURIComponent(get_object("txt_telefoon").value) + "&txt_email=" + encodeURIComponent(get_object("txt_email").value) +
	"&txt_gemeente=" + encodeURIComponent(get_object("txt_gemeente").value) + "&randNR=" + Math.floor(Math.random()*11) + "&valid=yes";
	//location.href=url;
	var reqType = "text"; 
	var xhrRec = xhrRequest(reqType); 
	xhrRec.open("GET", url, true); 
	var xhrRecB = xhrRequest(reqType); 
	
	
	xhrRec.onreadystatechange =    function () 
	{ 
		if (xhrRec.readyState == 4 && xhrRec.status == 200) 
		{ 
			var rt= xhrRec.responseText; 
			
			get_object("brochureaanvraag").innerHTML =  rt; 
		
			xhrRec = null;         
		} 
	} 
	xhrRec.send(null); 
}
