function showPopup(){
	var img = this.src;
	window.open(img,'id','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=800');
}

function showPopup2(img){
  window.open(img,'id','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=800');
}
 

function assigndate(date)
{
	var vanaf = document.getElementById('vanaf');
	var tot   = document.getElementById('tot');
	if(vanaf.value == 'Selecteer een datum' || vanaf.value == '')
	{
		vanaf.style.color = 'black';
		vanaf.value = date;
	}else
	{
		//if(tot.value == 'Selecteer een datum' || tot.value == '')
		//{
			tot.style.color = 'black';
			tot.value = date;
		//}
	}
}

function highlight(id)
{
	if(id)
	{
		document.getElementById(id+'_1').style.oldbackground = document.getElementById(id+'_1').style.background;
		document.getElementById(id+'_1').style.background = '#e9ea74';

		document.getElementById(id+'_2').style.oldbackground = document.getElementById(id+'_2').style.background;
		document.getElementById(id+'_2').style.background = '#e9ea74';

		document.getElementById(id+'_3').style.oldbackground = document.getElementById(id+'_3').style.background;
		document.getElementById(id+'_3').style.background = '#e9ea74';

		document.getElementById(id+'_4').style.oldbackground = document.getElementById(id+'_4').style.background;
		document.getElementById(id+'_4').style.background = '#e9ea74';

		document.getElementById(id+'_5').style.oldbackground = document.getElementById(id+'_5').style.background;
		document.getElementById(id+'_5').style.background = '#e9ea74';

		document.getElementById(id+'_6').style.oldbackground = document.getElementById(id+'_6').style.background;
		document.getElementById(id+'_6').style.background = '#e9ea74';

		document.getElementById(id+'_7').style.oldbackground = document.getElementById(id+'_7').style.background;
		document.getElementById(id+'_7').style.background = '#e9ea74';
	}
}

function weekhighlight(id,van,tot)
{
	if(id)
	{
		var vanaf = document.getElementById('vanaf');
		if(vanaf.value == 'Selecteer een datum' || vanaf.value == '')
		{
			assigndate(van);
			assigndate(tot);
		}else
		{
			assigndate(tot);
		}
		document.getElementById(id+'_1').style.oldbackground = document.getElementById(id+'_1').style.background;
		document.getElementById(id+'_1').style.background = '#e9ea74';

		document.getElementById(id+'_2').style.oldbackground = document.getElementById(id+'_2').style.background;
		document.getElementById(id+'_2').style.background = '#e9ea74';

		document.getElementById(id+'_3').style.oldbackground = document.getElementById(id+'_3').style.background;
		document.getElementById(id+'_3').style.background = '#e9ea74';

		document.getElementById(id+'_4').style.oldbackground = document.getElementById(id+'_4').style.background;
		document.getElementById(id+'_4').style.background = '#e9ea74';

		document.getElementById(id+'_5').style.oldbackground = document.getElementById(id+'_5').style.background;
		document.getElementById(id+'_5').style.background = '#e9ea74';

		document.getElementById(id+'_6').style.oldbackground = document.getElementById(id+'_6').style.background;
		document.getElementById(id+'_6').style.background = '#e9ea74';

		document.getElementById(id+'_7').style.oldbackground = document.getElementById(id+'_7').style.background;
		document.getElementById(id+'_7').style.background = '#e9ea74';

		document.getElementById((id+1)+'_1').style.oldbackground = document.getElementById(id+'_7').style.background;
		document.getElementById((id+1)+'_1').style.background = '#e9ea74';
	}
}

function delight(id)
{
	if(id)
	{
		document.getElementById(id+'_1').style.background = document.getElementById(id+'_1').style.oldbackground;
		document.getElementById(id+'_2').style.background = document.getElementById(id+'_2').style.oldbackground;
		document.getElementById(id+'_3').style.background = document.getElementById(id+'_3').style.oldbackground;
		document.getElementById(id+'_4').style.background = document.getElementById(id+'_4').style.oldbackground;
		document.getElementById(id+'_5').style.background = document.getElementById(id+'_5').style.oldbackground;
		document.getElementById(id+'_6').style.background = document.getElementById(id+'_6').style.oldbackground;
		document.getElementById(id+'_7').style.background = document.getElementById(id+'_7').style.oldbackground;
	}
}

function prijsberekening()
{
	var obj_tot		= document.getElementById('tot');
	var obj_vanaf	= document.getElementById('vanaf');
	var tot			= obj_tot.value;
	var vanaf		= obj_vanaf.value;
	var tot_array	= tot.split('-');
	var vanaf_array = vanaf.split('-');
	var time_vanaf	= mktime(0,0,0,vanaf_array[1],vanaf_array[0],vanaf_array[2]);
	var time_tot	= mktime(0,0,0,tot_array[1],tot_array[0],tot_array[2]);
	var total_time	= time_tot - time_vanaf;
	var week		= Math.ceil(total_time / (24*3600*7));
	document.getElementById('nr_weken').innerHTML = week;

	var var_array = new Array();
	var_array['nr_week']= week;
	var_array['camper']	= document.getElementById('camper').value;
	var_array['vanaf']	= time_vanaf;
	var_array['tot']	= time_tot;
	ajax("prijsberekening",var_array,'weekprijs');
}

function mktime() {

    var no, ma = 0, mb = 0, i = 0, d = new Date(), argv = arguments, argc = argv.length;

    if (argc > 0){
        d.setHours(0,0,0); d.setDate(1); d.setMonth(1); d.setYear(1972);
    }

    var dateManip = {
        0: function(tt){ return d.setHours(tt); },
        1: function(tt){ return d.setMinutes(tt); },
        2: function(tt){ var set = d.setSeconds(tt); mb = d.getDate() - 1; return set; },
        3: function(tt){ var set = d.setMonth(parseInt(tt)-1); ma = d.getFullYear() - 1972; return set; },
        4: function(tt){ return d.setDate(tt+mb); },
        5: function(tt){ return d.setYear(tt+ma); }
    };

    for( i = 0; i < argc; i++ ){
        no = parseInt(argv[i]*1);
        if (isNaN(no)) {
            return false;
        } else {
            // arg is number, let's manipulate date object
            if(!dateManip[i](no)){
                // failed
                return false;
            }
        }
    }

    return Math.floor(d.getTime()/1000);
}


function check_reserveren()
{
	return true;
}

function calendar(year,month)
{
      	var array = new Array;
      	array['year'] = year;
      	if(month)
      	{
      		array['month'] = month;
      	}
      	ajax('calendar',array,'calendar');
      	if(month)
      	{
      		if((month+1)>12)
      		{
      			var month_plus = 1;
      			var year_plus = (year+1);
      			var year_min = year;
      			var month_min = (month-1);
      		}else
      		{
       		if((month-1)<1)
       		{
       			var month_plus = (month+1);
       			var year_plus = year;
       			var month_min = 12;
       			var year_min = (year-1);
       		}else
       		{
       			var month_plus = (month+1);
       			var month_min = (month-1);
       			var year_plus = (year);
       			var year_min = (year);
       		}
      		}

      		document.getElementById('prev').href = "javascript:calendar("+year_min+","+month_min+");";
      		document.getElementById('next').href = "javascript:calendar("+year_plus+","+month_plus+");";
      	}else
      	{
      		document.getElementById('prev').href = "javascript:calendar("+(year-1)+");";
      		document.getElementById('next').href = "javascript:calendar("+(year+1)+");";
      	}
}

function set_product_amount(i){
	obj = document.getElementById('product_amount');
	if(i == 'up'){
		obj.value = parseFloat(obj.value) + 1;
	}else{
		if(parseFloat(obj.value)!=1){
			obj.value = parseFloat(obj.value) - 1;
		}
	}
}

function checkSubmitNawForm(){

	var form = document.nawform;
	var response ='';
	var fields = new Array();
    var count =0;
	for(i=0; i<document.nawform.elements.length; i++)
	{
		if(document.nawform.elements[i].value == ''){
			response += " - " + document.nawform.elements[i].id + "\n";
			count++;
		}
	}
    if(count == 2 && document.nawform.mobieletelefoon.value=='' && document.nawform.phonenumber.value =='')
    {
		response = ' - Vul ten minste een telefoonnummer/mobiel nummer in.' + "\n";	}
    if(count == 1 && (document.nawform.mobieletelefoon.value=='' || document.nawform.phonenumber.value ==''))
    {
		response = '';
	}
	if(document.nawform.av.checked != true){		response += " - " + 'U dient akkoord te gaan met onze algemene voorwaarden.' + "\n";
	}
	//alert(document.nawform.av.checked);
	if(response !=''){
	alert("U heeft de volgende velden nog niet ingevuld: \n\n" + response);
	return false;
	}else{
		document.nawform.submit();
		return true;
	}
}

