/* ================================ +
   Hoogenraad & Haak advertising-ip
 + ================================ */



/* 
** Made by: Thomas Lievestro
** Email:	info@lstro.com
** Website:	www.lstro.com
*/


/* ================================ +
              Variables
 + ================================ */
 
var TimeOut         = 400;
var TimeOut2        = 1500;
var currentLayer    = null;
var closeTimer      = null;
var content_width = '380';
var content_left = '400';
var content_bar_left = '803';
var content_arrow_left = '801';

/* ================================ +
              MENU FUNC
 + ================================ */

window.onload = function(){
	var body = document.getElementsByTagName("body")[0].id;
	if(document.getElementById("submenu_"+body.slice(5))){
		if(body.slice(5)=='nieuws'){
			document.getElementById("nieuws_items").style.display = 'block';
			document.getElementById("nav_nieuws").style.display = 'block';
		}
		document.getElementById("submenu_"+body.slice(5)).style.display = 'block';
	}	
}
	
function show_submenu(mi) {
    var body = document.getElementsByTagName("body")[0].id;
	if(document.getElementById("submenu_"+body.slice(5))){
		if(body.slice(5)=='nieuws'){
			document.getElementById("nieuws_items").style.display = 'none';
			document.getElementById("nav_nieuws").style.display = 'none';
		}
		document.getElementById("submenu_"+body.slice(5)).style.display = 'none';
	}
	var menu  = document.getElementById("submenu_"+mi);
   if(currentLayer){
     currentLayer.style. display = "none";
   };
   if(closeTimer) {
    window.clearTimeout(closeTimer);
    closeTimer = null;
   };
	menu.style.display = "block";
	currentLayer = menu;
}

function mclosetime() {
  closeTimer = window.setTimeout(hide_submenu, TimeOut);
}

function mcancelclosetime() {
  if(closeTimer) {
    window.clearTimeout(closeTimer);
    closeTimer = null;
  }
}

function mcancelclosetime2() {
  if(closeTimer) {
    window.clearTimeout(closeTimer);
    closeTimer = null;
    closeTimer = window.setTimeout(hide_submenu, TimeOut2);
  }
}

function hide_submenu() {
    if(currentLayer){
   		currentLayer.style.display = "none";
	}
	var body = document.getElementsByTagName("body")[0].id;
	if(document.getElementById("submenu_"+body.slice(5))){
		if(body.slice(5)=='nieuws'){
			document.getElementById("nieuws_items").style.display = 'block';
			document.getElementById("nav_nieuws").style.display = 'block';
		}
		document.getElementById("submenu_"+body.slice(5)).style.display = 'block';
	}
}

document.onclick = hide_submenu; 




/* function to highlight the background of formfield on error */
function HiLite(fieldname) {
	$(fieldname).style.backgroundColor  = "#ff3333";
	
	}
	
/* function to reset the background color formfield  */
function LoLite(fieldname) {
	$(fieldname).style.backgroundColor  = "#ffffff";
	}

/* Email Validation script */
function ValiderEmail(email){
	var pos=email.indexOf("@");
	var pos2=email.indexOf(".");
	var error=0;
	if (email.length == 0) return false;
	if (pos < 1) error++;
	else  if(email.indexOf(".",pos) < pos+2) error++;
	if (pos2==email.length-1)   error++;
	if (email.indexOf(" ") > 0){
    	return false;
	}
	if (error){
		return false;
	}
	return true;
}


function sendAanvraagNieuwsbrief(language) {

	var goodToGo 		= "yes";
	var goodToGocheck 	= "yes";
	
	var FieldArray = new Array();
		
	FieldArray[0]="voornaam"
	FieldArray[1]="achternaam"
	FieldArray[2]="email"

	/* emailadres valideren */
	if (!ValiderEmail($F('email'))) {
		goodToGo = "no";
		HiLite('email');
		}
		
	/* Walkthru Array of formfields and check value */
	FieldArray.each(function(i) {
		
		if (!$F(i)) {
	 		HiLite(i);
	 		goodToGo = "no";
	 		}
		
		});

	/* emailadres valideren */
	if ($('akkoord').checked == false) {
		goodToGocheck = "no";
		if (language == "NL") {
			alert("U gaat niet akkoord met de voorwaarden.");
		} else {
			alert("You did not agree with our conditions.");
		}
	}
		
	if (goodToGo == "no") {
		if (language == "NL") {
			alert("Niet alle velden zijn juist ingevuld, controleer de gemarkeerde velden.");
		} else {
			alert("Please complete the form and check the required fields marked red.");
		}
		
	} else if (goodToGocheck == "yes") {
		document.nieuwsbrief_inschrijven.submit();
	}

	}

/* check form velden stap 2*/
function startSearch() {
	if ($F('trefwoord').length < 2) {
		 		HiLite('trefwoord');
		 		goodToGo = "no";
  }	else 	{
			$('zoekform').submit();
		}
}

function checkbelmij() {
	
	var goodToGo = "yes";
	 
	if ($F('naam') == '') {
		 		HiLite('naam');
		 		goodToGo = "no";
	}
	
	if ($F('bedrijf') == '') {
		 		HiLite('bedrijf');
		 		goodToGo = "no";
	}
	
	if ($F('telefoon') == '') {
		 		HiLite('telefoon');
		 		goodToGo = "no";
	}
  
  if(goodToGo != "no") {
			//$('bel_mij_form').submit();
		}
	
}

function showWindow(elementid) {
 	if ($(elementid).visible()) {
 		Effect.BlindUp(elementid,{ duration: 0.2 });
 	} else {
		Effect.BlindDown(elementid,{ duration: 0.2 });
	}
}

/* Toggle van het CallmeBack formulier */
function toggleCallMe() {
 	if ($('bel_mij_bg').visible()) {
 		Effect.BlindUp('bel_mij_bg',{ duration: 0.2 });
 		Effect.BlindUp('bel_mij',{ duration: 0.2 });
 	} else {
 		Effect.BlindDown('bel_mij_bg',{ duration: 0.2 });
 		Effect.BlindDown('bel_mij',{ duration: 0.2 });
	}
}


/* Toggle van het nieuwsbrief aanvraag formulier */
function toggleNieuwsbriefAanvraag() {
 	if ($('nieuwsbrief_aanvraag_container').visible()) {
 		$('nieuwsbrief_aanvraag_container').hide();
 		Effect.BlindUp('nieuwsbrief_aanvraag_bg',{ duration: 0.2 });
 		Effect.BlindUp('nieuwsbrief_aanvraag',{ duration: 0.2 });
 	} else {
 		$('nieuwsbrief_aanvraag_container').show();
 		Effect.BlindDown('nieuwsbrief_aanvraag_bg',{ duration: 0.2 });
 		Effect.BlindDown('nieuwsbrief_aanvraag',{ duration: 0.2 });
	}
}



/* Script voor het selecteren van filters bij overzichten */
function selectFilter(pageid) {
 	var filterid = $('filterSelector').options[$('filterSelector').selectedIndex].value;
 	if ($('filterSelector')) {
 		var filterid = $('filterSelector').options[$('filterSelector').selectedIndex].value;
 	} else {
 		var filterid = "0";
 	}
	location.href = "index.php?pageid="+pageid+"&id="+filterid+"&language="+$F('language');
}

/* functie bij mouseover van groepsfoto de menu items te toggelen */
function PersoonHighlight(id) {

  /* Alle opties uit zetten */
  $('nav0_wieiswie').removeClassName('active');
  $('nav1_wieiswie').removeClassName('active');
  $('nav2_wieiswie').removeClassName('active');
  $('nav3_wieiswie').removeClassName('active');
  $('nav4_wieiswie').removeClassName('active');
  $('nav5_wieiswie').removeClassName('active');
  $('nav6_wieiswie').removeClassName('active');
  $('nav7_wieiswie').removeClassName('active');

  /* De menuoptie welke uit flash word doorggeven actief zetten */
  if (id != '0') {
    $$('.persoon_' + id).each( function (s) { s.addClassName('active'); })
    }
  }



function showClientContent(objectid, position, title, description, url, logo, verhoudingid){

	if (description == "<br />") {var description = ""};

	
	/* Het vullen en tonen van de tekstballon */

    $('client-balloon-logo').removeClassName('normal-bottom');
    $('client-balloon-logo').removeClassName('normal-top');
    $('client-balloon-logo').removeClassName('portrait-bottom');
		$('client-balloon-logo').removeClassName('portrait-top');

  /* wanneer een van de eerste 12, dan ballon naar boven */
	if (position > 12) {

  	$('client-balloon-text').removeClassName('text-top');
  	$('client-balloon-text').addClassName('text-bottom');
  	$('client-balloon-text').clonePosition(objectid, {
  		setWidth: false,
  		setHeight: false,
  		offsetLeft: 80,
  		offsetTop: 20
  	});
  	
  	if (verhoudingid == 21) {
  		$('client-balloon-logo').addClassName('portrait-bottom');
  		$('client-balloon-logo').clonePosition(objectid, {
  			setWidth: false,
  			setHeight: false,
  			offsetLeft: -130,
  			offsetTop: 10
  		});
  	}
  	else {
  		$('client-balloon-logo').addClassName('normal-bottom');
  		$('client-balloon-logo').clonePosition(objectid, {
  			setWidth: false,
  			setHeight: false,
  			offsetLeft: -160,
  			offsetTop: 20
  		});
  	}
  	
	/* wanneer een van de eerste 12, dan ballon naar onder */
  } else {
  

  	$('client-balloon-text').removeClassName('text-bottom');
  	$('client-balloon-text').addClassName('text-top');
  	$('client-balloon-text').clonePosition(objectid, {
  		setWidth: false,
  		setHeight: false,
  		offsetLeft: 80,
  		offsetTop: -190
  	});
  	
		if (verhoudingid == 21) {

      $('client-balloon-logo').addClassName('portrait-top');
      $('client-balloon-logo').clonePosition(objectid, {
        setWidth: false,
        setHeight: false,
        offsetLeft: -130,
        offsetTop: -200
      });
    }
    else {
	    $('client-balloon-logo').addClassName('normal-top');
	    $('client-balloon-logo').clonePosition(objectid, {
	      setWidth: false,
	      setHeight: false,
	      offsetLeft: -160,
	      offsetTop: -130
	    });
    }
		

  	
  } 
	
	 

    if (verhoudingid == 21) {
		  var tmpLogo = '<div class="logo"><img src="' + logo + '" width="90"/></div>' + title;
	  } else {
      var tmpLogo = '<div class="logo"><img src="' + logo + '" width="120"/></div>' + title;
	  }


	$('textcontent').update('');

    if (description) {
      $('textcontent').update(description);
      $('client-balloon-text').show();
     }   
     if (!description) {
     	 $('client-balloon-text').hide();
     }
    	$('client-balloon-logo').update(tmpLogo);
		$('client-balloon-logo').show();
		$$('div.masker').each(Element.show);
		$('clienten-info-layer-grey').show();


   $$('div.masker').each(function(element) { element.observe('mouseout', function() {

    $('client-balloon-text').hide();

    $('client-balloon-logo').hide();
    $$('div.masker').each(Element.hide);
    $('clienten-info-layer-grey').hide();
   })});


	/* Verwijderen van text box bij mouse out  */
	$('client-balloon-text').observe('mouseout', function() {
    $('client-balloon-text').hide();

		$('client-balloon-logo').hide();
		$$('div.masker').each(Element.hide);
		$('clienten-info-layer-grey').hide();
  });
	



}




  


/* ================================ +
              SCROLLFUNC
 + ================================ */



