

var indMenuDown = false;
var timerId = 0;

var activesubmenu = '';
var activemenu = '';
var activesidemenu = 'divSideMenuItemWonen';

// Top menu
function initMenu() {
  pageHeight = document.getElementById('divPage').offsetHeight;
  document.getElementById('divOverlay').style.height=(pageHeight-101)+'px';
}

function menuOver(elem, css) {
  if (elem.id != activemenu) { 
    elem.className=css+'_over';
  }
}

function menuOut(elem, css) {
  if (elem.id != activemenu) { 
    elem.className=css;
  }
}

function showSubmenu(elem, id, url) {
  document.getElementById('divOverlay').style.visibility='visible';
  if (activemenu > '') {
    document.getElementById(activemenu).className=activemenu;
  }
  activemenu = elem.id;
  elem.className=activemenu+'_active';
  if (id != activesubmenu) {
    if (activesubmenu > '') {
      Effect.BlindUp(activesubmenu, {duration:0.1,queue:'front'});
    } 

    Effect.Appear(id, {duration:0.2, queue:'end'});
    activesubmenu = id;

//    new Ajax.Updater(id, url, {asynchronous: true,evalScripts:true});  
    document.getElementById(id).innerHTML = document.getElementById(id+'Temp').innerHTML;
    indMenuDown = false;
  }  
}

function showSubmenu2(elem, id, url) {
  document.getElementById('divOverlay').style.visibility='visible';
  if (activemenu > '') {
    document.getElementById(activemenu).className=activemenu;
  }
  activemenu = elem.id;
  elem.className=activemenu+'_active';
  if (id != activesubmenu) {
    if (activesubmenu > '') {
      Effect.BlindUp(activesubmenu, {duration:0.1,queue:'front'});
    } 

    Effect.Appear(id, {duration:0.2, queue:'end'});
    activesubmenu = id;

    new Ajax.Updater(id, url, {asynchronous: true,evalScripts:true});  
//    document.getElementById(id).innerHTML = document.getElementById(id+'Temp').innerHTML;
    indMenuDown = false;
  }  
}

function loadFooter() {
    new Ajax.Updater("Footer", "public/include/footer.php", {asynchronous: true,evalScripts:true});  
}


function hideSubmenu() {
  if (indMenuDown) {
    if (activesubmenu > '') {
      document.getElementById(activemenu).className=activemenu;
      Effect.BlindUp(activesubmenu, {duration:0.1,queue:'front'});
      document.getElementById('divOverlay').style.visibility='hidden';
      activesubmenu = '';
      activemenu = '';
      indMenuDown = false;
    }
  }
}

function startTimer() {
  timerId = setTimeout('hideSubmenu()', 500);
}

function stopTimer() {
  clearTimeout(timerId);
}

// Side menu
function sideMenuOver(elem) {
    elem.className='divSideMenu_over';
}

function sideMenuOut(elem) {
    elem.className='divSideMenu';
}

function slideSubMenu(id) {
  if (id != activesidemenu) {
    if (activesidemenu > '') {
      Effect.BlindUp(activesidemenu, {duration:0.4});
    } 
    Effect.BlindDown(id, {duration:0.6});
    activesidemenu = id;
  }
}

function checkFieldsContactForm(){
    if ((document.getElementById('naam').value != "") && (document.getElementById('email').value != "")) {
        return true;            
    } else {
        alert("Niet alle velden zijn correct ingevuld !");
        return false;
    }
}

function checkFieldsInfoForm(){
    if ((document.getElementById('naam').value != "") && (document.getElementById('email').value != "")) {
        return true;            
    } else {
        alert("Niet alle velden zijn correct ingevuld !");
        return false;
    }
}

function OpenWin(mypage,myname,w,h,features) {
    if(screen.width){
    var winl = (screen.width-w)/2;
    var wint = (screen.height-h)/2;
    }else{winl = 0;wint =0;}
    if (winl < 0) winl = 0;
    if (wint < 0) wint = 0;
    var settings = 'height=' + h + ',';
    settings += 'width=' + w + ',';
    settings += 'top=' + wint + ',';
    settings += 'left=' + winl + ',';
    settings += features;
    win = window.open(mypage,myname,settings);
    win.window.focus();
}      

function checkNieuwsbrief() {
	var sOut = "De volgende velden zijn incorrect:\n";
	var bResult = true;
	if (document.getElementById('email').value == '') {
		sOut += 'E-mail adres\n';
		bResult = false;
	}
	if (!bResult) {
		alert(sOut);
	}
	return bResult;	
}

function changePage() {
	if (self.parent.frames.length != 0) {
		self.parent.location=document.location;
	}
}

function init() {
//		params = 'affid=gh01&c=VRZK_GHD';
	new Ajax.Updater('offertForm', 'public/form.php', {asynchronous: true,evalScripts:true});  
}


function showContact() {
//   new Effect.Fade('dvText', {from: 1, to: 0});
//	  new Effect.SlideUp('dvSlideBlock', {duration: 0.0});
  new Effect.Appear('dvBlock', {from: 0, to: 1});
  new Effect.SlideDown('dvBlock', {duration: 0.8});
}

function hideContact() {
  //new Effect.SlideUp('dvSlideBlock', {duration: 0.0});
 // new Effect.Fade('dvText', {from: 0, to: 1});
  new Effect.SlideUp('dvBlock', {duration: 0.8});
  new Effect.Appear('dvBlock', {from: 1, to: 0});
}        

function showOfferteForm() {
  new Effect.Appear('dvOfferteBlock', {from: 0, to: 1});
  new Effect.SlideDown('dvOfferteBlock', {duration: 0.8});
}

function hideOfferteForm() {
  new Effect.SlideUp('dvOfferteBlock', {duration: 0.8});
  new Effect.Appear('dvOfferteBlock', {from: 1, to: 0});
}        

function OpenWin(mypage,myname,w,h,features) {
	if(screen.width){
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	}else{winl = 0;wint =0;}
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;
	var settings = 'height=' + h + ',';
	settings += 'width=' + w + ',';
	settings += 'top=' + wint + ',';
	settings += 'left=' + winl + ',';
	settings += features;
	win = window.open(mypage,myname,settings);
	win.window.focus();
}

function logOff() {
document.location='/beheer/index.php?logout=true';
}

var indMenuDown = false;

function dropmenu() {
  document.getElementById('dropdownMenu').style.display='block';
  indMenuDown = false; 
}

function dropmenuUp() {
  if (indMenuDown) {
      document.getElementById('dropdownMenu').style.display='none';
      indMenuDown = false; 
  }
}

function loadFrame() {
	location.href="#top";
}

function checkEmail() {
  var tmp = "";
  var bResult = true;
  
  if (!checkValidEmailAddress("emailadres")) {
    tmp += "Uw E-mailadres is niet correct ingevuld !";
    bResult = false;
  }
  
  if (bResult) {
    return true;
  } else {
    alert(tmp);
    return false;
  }
}

function checkValidEmailAddress(obj) {
	var myEMailIsValid = true;
	var myAtSymbolAt = document.getElementById(obj).value.indexOf('@');
	var myLastDotAt = document.getElementById(obj).value.lastIndexOf('.');
	var mySpaceAt = document.getElementById(obj).value.indexOf(' ');
	var myLength = document.getElementById(obj).length;
	
	if (myAtSymbolAt < 1 ) 
	 {myEMailIsValid = false}
	
	if (myLastDotAt < myAtSymbolAt) 
	 {myEMailIsValid = false}
	
	if (myLength - myLastDotAt <= 2) 
	 {myEMailIsValid = false}
	
	
	// no empty space " " is permitted (one may trim the email)
	// x.y@yell ow.com : NOT valid
	
	if (mySpaceAt != -1) 
	 {myEMailIsValid = false}
	
	
	if (myEMailIsValid == true) {
		document.getElementById(obj).style.backgroundColor = "#FFFFFF";
		return true;
	} else {
    	//alert("email is not correct");
    	document.getElementById(obj).style.backgroundColor = "#FFCCCC";
		//document.getElementById(obj).focus();
		return false;
	}
}
function changePage() {
  if (self.parent.frames.length != 0)
  	self.parent.location=document.location;
}
  
function PrintContent() {
  if(screen.width){
  var winl = (screen.width-600)/2;
  var wint = (screen.height-550)/2;
  }else{winl = 0;wint =0;}
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + 550 + ',';
  settings += 'width=' + 600 + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += "scrollbars=yes";
  win = window.open("print.php","Print",settings);
  win.window.focus();
}

function showPopUp(url) {
  document.getElementById('divPopupBody').innerHTML = '';

  new Effect.Appear('divLoader', {from: 0, to: 1, duration: 0.1});
 	new Ajax.Updater('divPopupBody', url, {asynchronous: true,evalScripts:true});  
}

function closePopUp() {
  document.getElementById('divLoader').style.display='none';
//  new Effect.Appear('divLoader', {from: 1, to: 0, duration: 0.1});
}

function checkFAQQuestion() {
  if (($('question').value > '') && ($('question_desc').value > '')&& ($('question_desc').value > '')) {
    return true;
  } else {
    alert("Niet alle gegevens zijn correct ingevuld !");
    return false;
  }
}