function initPage()
{
		//clearFormFields({
		//clearInputs: true,
		//clearTextareas: true,
		//passwordFieldText: true,
		//addClassFocus: "focus",
		//filterClass: "default"
	//});
}
/* deze functie
function clearFormFields(o)
{
	if (o.clearInputs == null) o.clearInputs = true;
	if (o.clearTextareas == null) o.clearTextareas = true;
	if (o.passwordFieldText == null) o.passwordFieldText = false;
	if (o.addClassFocus == null) o.addClassFocus = false;
	if (!o.filter) o.filter = "default";
	if(o.clearInputs) {
		var inputs = document.getElementsByTagName("input");
		for (var i = 0; i < inputs.length; i++ ) {
			if((inputs[i].type == "text" || inputs[i].type == "password") && inputs[i].className.indexOf(o.filterClass)) {
				inputs[i].valueHtml = inputs[i].value;
				inputs[i].onfocus = function ()	{
					if(this.valueHtml == this.value) this.value = "";
					if(this.fake) {
						inputsSwap(this, this.previousSibling);
						this.previousSibling.focus();
					}
					if(o.addClassFocus && !this.fake) {
						this.className += " " + o.addClassFocus;
						this.parentNode.className += " parent-" + o.addClassFocus;
					}
				}
				inputs[i].onblur = function () {
					if(this.value == "") {
						this.value = this.valueHtml;
						if(o.passwordFieldText && this.type == "password") inputsSwap(this, this.nextSibling);
					}
					if(o.addClassFocus) {
						this.className = this.className.replace(o.addClassFocus, "");
						this.parentNode.className = this.parentNode.className.replace("parent-"+o.addClassFocus, "");
					}
				}
				if(o.passwordFieldText && inputs[i].type == "password") {
					var fakeInput = document.createElement("input");
					fakeInput.type = "text";
					fakeInput.value = inputs[i].value;
					fakeInput.className = inputs[i].className;
					fakeInput.fake = true;
					inputs[i].parentNode.insertBefore(fakeInput, inputs[i].nextSibling);
					inputsSwap(inputs[i], null);
				}
			}
		}
	}
	if(o.clearTextareas) {
		var textareas = document.getElementsByTagName("textarea");
		for(var i=0; i<textareas.length; i++) {
			if(textareas[i].className.indexOf(o.filterClass)) {
				textareas[i].valueHtml = textareas[i].value;
				textareas[i].onfocus = function() {
					if(this.value == this.valueHtml) this.value = "";
					if(o.addClassFocus) {
						this.className += " " + o.addClassFocus;
						this.parentNode.className += " parent-" + o.addClassFocus;
					}
				}
				textareas[i].onblur = function() {
					if(this.value == "") this.value = this.valueHtml;
					if(o.addClassFocus) {
						this.className = this.className.replace(o.addClassFocus, "");
						this.parentNode.className = this.parentNode.className.replace("parent-"+o.addClassFocus, "");
					}
				}
			}
		}
	}
	function inputsSwap(el, el2) {
		if(el) el.style.display = "none";
		if(el2) el2.style.display = "inline";
	}
}
*/
// **** K13 *****
function favorites(bookmarkurl, bookmarktitel) {
		if (window.sidebar) { // firefox
              window.sidebar.addPanel(bookmarktitel, bookmarkurl,"");
        } else if( document.all ) { //MSIE
                window.external.AddFavorite( bookmarkurl, bookmarktitel);
        } else {
               alert("Sorry, your browser doesn't support this");
        }
}

// **** functies voor checken invoer forms
var regex_postcode = /^[1-9][0-9]{3}(?:[ ]?[a-z]{2})?$/i;
function CheckPlaatsnaamResult(originalRequest,jsonobject)
{
	validplaatsnaam = false;
	
  if (originalRequest.responseText=="1")
	validplaatsnaam = true;
}
	
function CheckAanbodForm($formName)
  {
	if ($formName == '') $formName = 'zoekform';
	frmCheck = document.forms[$formName];
    frmCheck.citypc.value = frmCheck.citypc.value.replace(/^\s*|\s*$/g,"");
	//alert(frmCheck.citypc.value);
	if (frmCheck.citypc.value == '') {
		  window.alert("Vul een plaatsnaam of postcode in");
			frmCheck.citypc.focus();
			frmCheck.citypc.select();
		  return false
	} 

	if (parseInt(frmCheck.minprice.options[frmCheck.minprice.selectedIndex].value) >= parseInt(frmCheck.maxprice.options[frmCheck.maxprice.selectedIndex].value))
    {
      window.alert("De minimumprijs moet kleiner zijn dan de maximumprijs");
      frmCheck.minprice.focus();
      return false;
    } else if (!frmCheck.chkbestaandebouw.checked && !frmCheck.chknieuwbouw.checked)
    {
      window.alert("U moet minimaal 1 keuze maken uit 'bestaande bouw' of 'nieuwbouw'");
      return false;
    }

	var element = document.createElement("input");
    //Assign different attributes to the element.
    element.setAttribute("type", "hidden");
    element.setAttribute("value",frmCheck.citypc.value);
    element.setAttribute("name", "citypc");
    element.setAttribute("id", "citypc");
	element.setAttribute("class", "textbox");
	element.setAttribute("style", "width:260px");
	frmCheck.appendChild(element);	
  }

function CheckAdresForm($formName) {
	if ($formName == '') $formName = 'zoekformadres';
	frmCheck = document.forms[$formName];
	if (frmCheck.address_streetname.value == ''){ 
	    window.alert("U moet een straatnaam invullen");
		return false;
	}	
	else if (!CheckPlaatsnaam(frmCheck.address_city.value)){ 
	    window.alert("U moet een geldige plaatsnaam invullen");
		return false;
	}  	else {
		return true;
	}
	
}

function CheckAanbodFormUitgebreid($formName) {
	if ($formName == '') $formName = 'zoekform';
	frmCheck = document.forms[$formName];

	var aantalingevuld = 0;
	for (i=0; i<=4; i++)
	{
		if ($('citypc'+i).value != '') {
			aantalingevuld++;
			if (!regex_postcode.test($('citypc'+i).value))
			{
				//geen valid postcode dan plaatsnaam checken
				validplaatsnaam = false;
				//if ($('citypc'+i).value != ''){validplaatsnaam = true;}
				if (CheckPlaatsnaam($('citypc'+i).value)) {validplaatsnaam = true;}
				if (!validplaatsnaam)
				{
				  window.alert("Dit is geen geldige plaatsnaam of postcode");
					$('citypc'+i).focus();
					$('citypc'+i).select();
				  return false
				}
			} else {
				validpostcode = regex_postcode.test($('citypc'+i).value);
				if (!validpostcode)
				{
				  window.alert("Dit is geen geldige postcode");
					$('citypc'+i).focus();
					$('citypc'+i).select();
				  return false
				}

			}
		}
	}
		
	// minimaal 1 plaats moet ingevuld zijn
	if (aantalingevuld==0)
	{
		alert('Wilt u minimaal 1 plaatsnaam of postcode invullen?');
		$('citypc0').focus();
	  return false;
	} 
	if (parseInt(frmCheck.minprice.options[frmCheck.minprice.selectedIndex].value) >= parseInt(frmCheck.maxprice.options[frmCheck.maxprice.selectedIndex].value))
    {
      window.alert("De minimumprijs moet kleiner zijn dan de maximumprijs");
      frmCheck.minprice.focus();
      return false;
    } else if (!frmCheck.chkbestaandebouw.checked && !frmCheck.chknieuwbouw.checked)
    {
      window.alert("U moet minimaal 1 keuze maken uit 'bestaande bouw' of 'nieuwbouw'");
      return false;
    }


	return true;
	
}

function showThumb($imgUrl, $imgId, $imgUrlMoviq, $imgIdMoviq, $bottomLinkMoviq) {
	bigImg = document.getElementById($imgId);
	bigImg.src = $imgUrl;
	//alert(bigImg);
	
	bigImgMoviq = document.getElementById($imgIdMoviq);
	bigImgMoviq.href = $imgUrlMoviq;
	
	bottomLinkMoviq = document.getElementById($bottomLinkMoviq);
	bottomLinkMoviq.href = $imgUrlMoviq;
	
}

function CheckHypotheekgesprek4Form(form)
{
//aanhef
	 if (!form.aanhef[0].checked && !form.aanhef[1].checked)
	  {
	  	window.alert("Wilt u uw aanhef invullen?");
	    return false;
	  }
//naam
	if (form.naam.value=='')
  {
    window.alert("Wilt u uw naam invullen?");
    form.naam.focus();
    return false;
  }
  
  
//geboortedatum
//geboortedag
if (form.GebDag.value=='')
  {
    window.alert("Wilt u uw geboortedag invullen?");
    form.GebDag.focus();
    return false;
  }
//geboortemaand
  if (form.GebMaand.value=='')
  {
    window.alert("Wilt u uw geboortemaand invullen?");
    form.GebMaand.focus();
    return false;
  }
 //geboortejaar
  if (form.GebJaar.value=='')
  {
    window.alert("Wilt u uw geboortejaar invullen?");
    form.GebJaar.focus();
    return false;
  }
//postcode
if (form.postcode.value=='')
	{
	  window.alert("Wilt u uw postcode invullen?");
	  form.postcode.focus();
	  
	  return false;
	}
	// controleren of het een geldige postcode is
	else if (!regex_postcode.test(form.postcode.value))
  {
    alert('Dit is geen geldige postcode');
    form.postcode.focus();
    return false;
  }
//huisnummer
  if (form.huisnr.value=='')
	{
	  window.alert("Wilt u uw huisnummer invullen?");
	  form.huisnr.focus();
	  return false;
	}
//telefoonnummer	
  if (form.telefoon_bereikbaar.value=='')
  {
    window.alert("Wilt u uw telefoonnummer invullen?");
    form.telefoon_bereikbaar.focus();
    return false;
  }
  if (form.telefoon_bereikbaar.value!='' && form.telefoon_bereikbaar.value.substr(0,1) != "0")
  {
    window.alert("Wilt u bij uw telefoonnummer ook het netnummer invullen?");
    form.telefoon_bereikbaar.focus();
    return false;
  }
  
  form.telefoon_bereikbaar.value = form.telefoon_bereikbaar.value.replace(/-/,"")
  
  return true; // kennelijk zijn alle testen ok, formulier verzenden dus.
}
function CheckAfmeldForm($formName) {
	//checken ingevulde zoekopties
	if ($formName == '') $formName = 'frmAfmelden';
	frmCheck = document.forms[$formName];
	
		//checken naam/telefoonnummer/emailadres/controle email
	if (frmCheck.email.value=='')
	{
		window.alert("Wilt u een e-mailadres invullen?");
		frmCheck.naam.focus();
		return false;
	}
	return true;

	
}
function CheckAanmeldForm($formName)
{
	//checken ingevulde zoekopties
	if ($formName == '') $formName = 'zoekform';
	frmCheck = document.forms[$formName];

	var aantalingevuld = 0;
	for (i=0; i<=4; i++)
	{
		if ($('plaatspostcode'+i).value != '') {
			aantalingevuld++;
			if (!regex_postcode.test($('plaatspostcode'+i).value))
			{
				//geen valid postcode dan plaatsnaam checken
				validplaatsnaam = false;
				//if ($('citypc'+i).value != ''){validplaatsnaam = true;}
				if (CheckPlaatsnaam($('plaatspostcode'+i).value)) {validplaatsnaam = true;}
				if (!validplaatsnaam)
				{
				  window.alert("Dit is geen geldige plaatsnaam of postcode");
					$('plaatspostcode'+i).focus();
					$('plaatspostcode'+i).select();
				  return false
				}
			} else {
				validpostcode = regex_postcode.test($('plaatspostcode'+i).value);
				if (!validpostcode)
				{
				  window.alert("Dit is geen geldige postcode");
					$('plaatspostcode'+i).focus();
					$('plaatspostcode'+i).select();
				  return false
				}

			}
		}
	}
		
	// minimaal 1 plaats moet ingevuld zijn
	if (aantalingevuld==0)
	{
		alert('Wilt u minimaal 1 plaatsnaam of postcode invullen?');
		$('plaatspostcode0').focus();
	  return false;
	} 
	if (parseInt(frmCheck.minprice.options[frmCheck.minprice.selectedIndex].value) >= parseInt(frmCheck.maxprice.options[frmCheck.maxprice.selectedIndex].value))
    {
      window.alert("De minimumprijs moet kleiner zijn dan de maximumprijs");
      frmCheck.minprice.focus();
      return false;
    } 
	
	if (!frmCheck.chkbestaandebouw.checked && !frmCheck.chknieuwbouw.checked)
    {
      window.alert("U moet minimaal 1 keuze maken uit 'bestaande bouw' of 'nieuwbouw'");
      return false;
    }
	

	//checken naam/telefoonnummer/emailadres/controle email
	if (frmCheck.naam.value=='')
	{
		window.alert("Wilt u uw naam invullen?");
		frmCheck.naam.focus();
		return false;
	}

	if (!ValidateEmail(frmCheck.email.value))
	{
		window.alert("Wilt u een geldig e-mailadres invullen?");
		frmCheck.email.focus();
		return false;
	}

	// controleer of de e-mailadressen gelijk zijn, ingeval er emailadressen in het formulier zijn
	if ( frmCheck.email.value != null &&  frmCheck.emailControle.value != frmCheck.email.value)	
	{
		alert("De e-mailadressen komen niet overeen");
		return false;
	}

	//privacy check
	if (!frmCheck.optin.checked)
	{
		alert('Selecteer dat u akkoord gaat met het privacy statement');
		return false;
	}
	
	return true; // kennelijk zijn alle testen ok, formulier verzenden dus.

}

function CheckWijzigZoekForm($formName)
{
	//checken ingevulde zoekopties
	if ($formName == '') $formName = 'frmWijzigen';
	frmCheck = document.forms[$formName];

	var aantalingevuld = 0;
	for (i=0; i<=4; i++)
	{
		if ($('plaatspostcode'+i).value != '') {
			aantalingevuld++;
			if (!regex_postcode.test($('plaatspostcode'+i).value))
			{
				//geen valid postcode dan plaatsnaam checken
				validplaatsnaam = false;
				//if ($('citypc'+i).value != ''){validplaatsnaam = true;}
				//if (($('plaatspostcode'+i).value)) {validplaatsnaam = true;}
				if (CheckPlaatsnaam($('plaatspostcode'+i).value)) {validplaatsnaam = true;}
				if (!validplaatsnaam)
				{
				  window.alert("DDit is geen geldige plaatsnaam of postcode");
					$('plaatspostcode'+i).focus();
					$('plaatspostcode'+i).select();
				  return false
				}
			} else {
				validpostcode = regex_postcode.test($('plaatspostcode'+i).value);
				if (!validpostcode)
				{
				  window.alert("Dit is geen geldige postcode");
					$('plaatspostcode'+i).focus();
					$('plaatspostcode'+i).select();
				  return false
				}

			}
		}
	}
		
	// minimaal 1 plaats moet ingevuld zijn
	if (aantalingevuld==0)
	{
		alert('Wilt u minimaal 1 plaatsnaam of postcode invullen?');
		$('plaatspostcode0').focus();
	  return false;
	} 
	if (parseInt(frmCheck.minprice.options[frmCheck.minprice.selectedIndex].value) >= parseInt(frmCheck.maxprice.options[frmCheck.maxprice.selectedIndex].value))
    {
      window.alert("De minimumprijs moet kleiner zijn dan de maximumprijs");
      frmCheck.minprice.focus();
      return false;
    } 
	
	if (!frmCheck.chkbestaandebouw.checked && !frmCheck.chknieuwbouw.checked)
    {
      window.alert("U moet minimaal 1 keuze maken uit 'bestaande bouw' of 'nieuwbouw'");
      return false;
    }
	

	//checken naam/telefoonnummer/emailadres/controle email
	if (frmCheck.naam.value=='')
	{
		window.alert("Wilt u uw naam invullen?");
		frmCheck.naam.focus();
		return false;
	}

	
	return true; // kennelijk zijn alle testen ok, formulier verzenden dus.
	frmCheck.submit();

	
}

function ValidateEmail(emailad)
{ var re = /^[_a-zA-Z0-9\-\_\.\+&]+(\.[_a-zA-A0-9\-\_\.\+&]+)*@[a-zA-Z0-9-\.]+(\.[a-zA-Z-9\-\.]+)*(\.[a-zA-Z]{2,4})$/;
if (re.test(emailad)) {return true;} else {return false;}
}

function replaceText(fullString, replaceText, newText) {
	return fullString.replace(replaceText, newText);
}
function setMoviqRoomplannerLink() {
	roomplanner = new Array();
	roomplanner['href'] = 'http://www.moviq.nl/hom3decorator/?f=zah&img=';
	roomplanner['linkText'] = 'Richt deze ruimte zelf opnieuw in met <span style="color:#E1104A;">Moviq</span> en <span style="color:#1a1818;">Hom3decorator</span>';
	return roomplanner;
}

//Resume
if (window.addEventListener)
	window.addEventListener("load", initPage, false);
else if (window.attachEvent)
	window.attachEvent("onload", initPage);
	
	
