
sfHover = function() {
	var sfEls = document.getElementById("hoofdnavigatie").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

// Open de infopopup
function OpenInfoPopup(strHREF)
{
	//var strSeperator = (strHREF.indexOf('?')>0)?'&':'?';
	// + strSeperator 
	window.open(strHREF + '','Information','location=no, status=no, toolbar=no,width=727, height=680'); 
	return false;
}

// Check if window focus is lost()
function focusLost(strEl, strElValue)
{
	var oEl = document.getElementById(strEl);
	if(oEl != undefined){
		if(oEl.value == ""){
			oEl.value = strElValue;
		}
	}
}

//openen popup window
function OpenAWindow(AURL,AAttr) {
  AWindow=window.open(AURL,window.name+"X",AAttr);
  if(parseInt(navigator.appVersion)>=3) AWindow.focus();
  return false;
}

//submenu tonen en verbergen
function toggleSubmenu(strSubmenu) {
	var elems = document.getElementById('groep_subnavigatie').getElementsByTagName("UL");

	for (var j=0; j<elems.length; j++) {
		if (elems[j].id == strSubmenu) {		
			if (elems[j].style.display == 'block')
				elems[j].style.display = 'none';
			else
				elems[j].style.display = 'block';
		} else {
			elems[j].style.display = 'none';
		}
	}
}

//tonen van een foto bij een product
function showFoto(strFotoNr, intNr, intTabNr, intProductID, strTypeFoto) {
	var elemFoto = document.getElementById('foto_visual');
	var elemTabs = document.getElementById('productfotos').getElementsByTagName('A');
	var elemFilmpje = document.getElementById('filmpje');

	// Variabelen instellen
	strType	=	strTypeFoto;
	intWaarde = intProductID;
	intFotoNr = intNr;
	
	// Foto tabjes bijwerken
	for (var i = 0; i < elemTabs.length; i++) {
		if (elemTabs[i].id == 'foto_tab_'+intTabNr) {
			elemTabs[i].className = 'ACTIVE';
		} else {
			elemTabs[i].className = '';
		}
	}
	
	// Foto source instellen
	if(elemFoto!=undefined){
			elemFoto.style.visibility = "visible";
			elemFoto.style.display = "block";
	}

	//instellen filmpje layer
	if(elemFilmpje!=undefined){
			elemFilmpje.style.visibility = "hidden";
			elemFilmpje.style.display = "none";
	}

	if(elemFoto!=undefined){
		if (strType == 'families') {
			elemFoto.src = '/data/families/normaal/' + strFotoNr + '_' + intNr + '.jpg';
		} else if (strType == 'producten') {
			elemFoto.src = '/data/producten/normaal/' + strFotoNr + '_' + intNr + '.jpg';
		}
	}
}

//tonen van een filmpje bij een product
function showFilmpje(strFilmID, intNr, intTabNr) {
	var elemFoto		= document.getElementById('foto_visual');
	var elemTabs		= document.getElementById('productfotos').getElementsByTagName('A');
	var elemFilmpje = document.getElementById('filmpje');

	// Variabelen instellen
	intWaarde = strFilmID;
	intFotoNr = intNr;
	
	// Foto tabjes bijwerken
	for (var i = 0; i < elemTabs.length; i++) {
		if (elemTabs[i].id == 'foto_tab_'+intTabNr) {
			elemTabs[i].className = 'ACTIVE';
		} else {
			elemTabs[i].className = '';
		}
	}
	
	// Foto source instellen
	if(elemFoto!=undefined){
			elemFoto.style.visibility = "hidden";
			elemFoto.style.display = "none";
	}

	//Show filmpje layer
	if(elemFilmpje!=undefined){
			elemFilmpje.style.visibility = "visible";
			elemFilmpje.style.display = "block";
	}
}

//tonen van een grote foto popup
function showGroteFoto() {
	if (strType == 'producten') {
		return OpenAWindow('/popup/grote-foto.asp?intProductID='+intWaarde+'&intFotoNr='+intFotoNr, 'width=640,height=520,status=no');
	} else if (strType == 'families') {
		return OpenAWindow('/popup/grote-foto.asp?intFamilieID='+intWaarde+'&intFotoNr='+intFotoNr, 'width=640,height=520,status=no');
	}
}

/* -- FUNCTION -------------
* tonen verbergen element -- */
function showHideElement(strEl){
	var oEl = document.getElementById(strEl);
	if(oEl != undefined){
		if(oEl.style.visibility == "hidden"){
			oEl.style.visibility = "visible";
			oEl.style.display = "block";
		}
		else if(oEl.style.visibility == "visible"){
			oEl.style.visibility = "hidden";
			oEl.style.display = "none";
		}
		else{
			oEl.style.visibility = "hidden";
			oEl.style.display = "none";
		}
	}
	else{
		alert(oEl + " is undefined");
	}
}

function zetVeldDoeActie(strForm, strVeld, strVeldWaarde, blnDoeAktie)
{	
	var oVeld  = document.getElementById(strVeld);
	if(oVeld!=undefined){
		oVeld.value = strVeldWaarde;
		if(blnDoeAktie==true){
			document.getElementById(strForm).submit();
		}
	}
	return false;
}


/* -- VIDEO POPUP -- */
function ShowPopUp(strPopUp, strConfig, oPlayer )
{
	setMaskSize("popupMask");
	toggleVisibility('popupMask', true);
	toggleVisibility(strPopUp, true);

	var oSWFObject = new SWFObject("/flash/flowplayer/FlowPlayer.swf", "flashHighResPlayer", "100%", "575", "9", "#ffffff");
	oSWFObject.addParam("wmode", "opaque");
	oSWFObject.addParam("allowScriptAccess", "always");
	oSWFObject.addVariable("config", "{hideControls:true, playList: [ { url: '"+strConfig+"' } ], initialScale: 'scale', autoPlay:true }");
	oSWFObject.write("flashVideoPlayer");

	return false;
}	
/* -- // VIDEO POPUP -- */

/* -- VOORRAAD REMINDER POPUP -- */
function showVoorraadReminderInvoer(strPopup, strFrm, intProductNr){

	setMaskSize("popupMask");
	toggleVisibility('popupMask', true);
	toggleVisibility(strPopup, true);
	zetVeldDoeActie(strFrm, 'intProductNr', intProductNr, false);
	zetVeldDoeActie(strFrm, 'strActie', 'init', false);
	getVoorraadReminderForm(strFrm);

	return false;
}

function getVoorraadReminderForm(strFrm){
		new AJAX.Request("/ajax/voorraad-reminder-handler.asp"
		, {parameters:FORM.toString(strFrm)
		,	responseEl:"elVoorraadReminderContent"
		, preloader:false
		, responseType:"html"
	});

	var oEl = document.getElementById('elVoorraadReminderContent');
	if(oEl!=undefined){oEl.innerHTML="";}
}

function opslaanVoorraadReminder(strFrm){

	new AJAX.Request("/ajax/voorraad-reminder-handler.asp"
		, {parameters:FORM.toString(strFrm)
		,	responseEl:"elVoorraadReminderContent"
		, preloader:false
		, responseType:"html"
	});

}

/* -- // VOORRAAD REMINDER POPUP -- */


/* -- POPUP-ALGEMEEN -- */
function hidePopUp(strPopUp)
{
	setMaskSize("popupMask");
	toggleVisibility('popupMask', false);
	toggleVisibility(strPopUp, false);						
	return false;
}	

// Element zichtbaarheid switchen
function toggleVisibility(elemName, blnVisible) {
	var elem = document.getElementById(elemName);
	if (elem != undefined) {
		if (blnVisible == true) {
			elem.style.display = 'block';
		} else {
			elem.style.display = 'none';
		}
	}
	return false;
}

function setMaskSize(divMaskName)
{
	var theBody = document.getElementsByTagName("BODY")[0];
			
	var fullHeight = getViewportHeight();
	var fullWidth = 0; //getViewportWidth();
	
	// Determine what's bigger, scrollHeight or fullHeight / width
	if (fullHeight > theBody.scrollHeight) {
		popHeight = fullHeight;
	} else {
		popHeight = theBody.scrollHeight;
	}
	
	if (fullWidth > theBody.scrollWidth) {
		popWidth = fullWidth;
	} else {
		popWidth = theBody.scrollWidth;
	}
	
	var gPopupMask = document.getElementById(divMaskName);
	
	gPopupMask.style.height = (popHeight+20) + "px";
	gPopupMask.style.width = "100%";
	//gPopupMask.style.width = popWidth + "px";
}

function getViewportHeight()
{
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 

	return window.undefined; 
}
/* -- POPUP-ALGEMEEN -- */



/* -- popup catalogus 2008 -- */

var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}

