function init() {
	var objMyImage = new OpacityObject('contentvlak','/img/wit');
	objMyImage.setBackground();
}


function set_selected(ele,value) {
   var select = document.getElementById(ele);
   
   var options = select.getElementsByTagName('option');
   
   for ( var i=0; i<options.length; i++ ) {
      if ( value == options[i].value ) {
         select.selectedIndex = i;
         return
      }
   }  
}

function openwindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function fotoPopUp(villaid) {
//   openwindow('/zoek/details/fotos/index2.asp?villaid='+villaid,'','width=710,height=490, top=100, left=100')
//	popupWindow('/zoek/details/fotos/index.asp?villaid='+villaid,'fotovilla'+villaid,710,490)
	/* bigger */
	popupWindow('/zoek/details/fotos/index.asp?villaid='+villaid,'fotovilla'+villaid,873,490)
}


function popupWindow( url, name, width, height, scrollbars, resizable ) { 

	if ( scrollbars == null ) scrollbars = "0" 
	if ( resizable == null )  resizable = "0"

	str  = ""; 
	str += "resizable=" + resizable + ","; 
	str += "scrollbars=" + scrollbars + ","; 
	str += "width=" + width + ","; 
	str += "height=" + height + ","; 

	if ( window.screen ) { 
		var ah = screen.availHeight - 30; 
		var aw = screen.availWidth - 10; 

		var xc = ( aw - width ) / 2; 
		var yc = ( ah - height ) / 2; 

		str += ",left=" + xc + ",screenX=" + xc; 
		str += ",top=" + yc + ",screenY=" + yc; 
	} 
	var popup = window.open( url, name, str ); 
	popup.focus();
	return popup
   
}

/* reserveren.asp ---------------------------------------------------------- */
function changeDiv(target, txt)
{
	if(document.layers)
	{
		with(document.layers[target].document)
		{
			open();write(txt);close();
		}
	}
	else if(document.getElementById) 
	{
		if (document.getElementById(target))
		{
			document.getElementById(target).innerHTML=txt;
		}
	}
	else if (document.all) 
	{
		if (document.all[target])
		{
			document.all[target].innerHTML=txt;
		}
	}
}


function setStart(index)
{
	week = index;
	document.uform.week.value=index;
	document.uform.startdate.value=enddates[index][0];
	document.uform.enddate.value=enddates[index][document.uform.numweeks.options[document.uform.numweeks.selectedIndex].value];
	changeDiv('aankomstdatum', 'za. ' + enddates[index][0]);
	changeDiv('vertrekdatum', 'za. ' + enddates[index][document.uform.numweeks.options[document.uform.numweeks.selectedIndex].value]);
	calculatePrice();
}

function updateEnd()
{
	setStart(week);
	calculatePrice();
}

function calculatePrice()
{
	var numweeks = document.uform.numweeks.options[document.uform.numweeks.selectedIndex].value;
	var price = 0;
	for (var i=0; i < numweeks; i++)
	{
		price = price + prices[week + i];
	}
	price = price.toString();
	document.uform.theprice.value=price;
	price = price.split('.');
	var pf;
	if (price.length > 1)
	{
		pf = price[0] + ',' + price[1];
		if (price[1].length == 0)
		{
			pf = pf + "00";
		}
		if (price[1].length == 1)
		{
			pf = pf + "0";
		}
	}
	else
	{
		pf = price[0];
	}
	changeDiv('price','&euro; ' + pf);
}

function check_reserveren_1()
{
   var pers = document.getElementById('numguests').value;
   
   if ( ( pers == null ) || ( pers == 0 ) || ( pers == '' ) )
   {
	   if ( lang == 'nl' ) {
		   alert('selecteer het aantal personen')
	   } else {
		   alert('select the number of guests')
	   }
      return false;
   }

   if ( document.uform.theprice.value == '0' ) {
	   if ( lang == 'nl' ) {
		   alert("Voor deze periode is geen prijs beschikbaar, kies een andere periode")
	   } else {
		   alert("There is no price available for this period, choose another period")
	   }
	   return false;
   }
   
   return true;
}

function check_reserveren_2()
{
	var missing = 0;
	for (var i = 0; i < document.uform.elements.length; i++)
	{
		var formname = document.uform.elements[i].name.split('_');
		if (formname.length > 2)
		{
			if (formname[1] == 'M')
			{
				if (document.uform.elements[i].value.length <= 0)
				{
				        blink_field(document.uform.elements[i])
					missing = 1;
				} else {
				   document.uform.elements[i].style.backgroundColor = 'white'

				}
			}
		}
	}
	if (!document.uform.voorwaarden.checked)
	{
		alert("U dient de algemene voorwaarden te accepteren");
		return false;
	}
	if (missing)
	{
		alert("Niet alle verplichte velden zijn ingevuld");
		return false;
	}

	return true;
}

/* -------------------------------------------------------------------------- */
function blink_field(field) {
   $(field).style.backgroundColor = '#ebcacb';
   $(field).onclick = function() { this.style.backgroundColor = 'white' };
   new Effect.Appear(field);
}
/* -------------------------------------------------------------------------- */

function email_check(lang) {
   if ( ( document.getElementById('nieuwsbriefemail').value == '' ) || 
        ( document.getElementById('nieuwsbriefemail').value == your_email ) ||
          ! document.getElementById('nieuwsbriefemail').value.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/) ) {
           alert( lang == 'nl' ? 'Vul een geldig email adres in' : 'Provide a valid email address' );
           return false
        }
   return true;
}
