var ajax = new sack();
var allowload = true;
var mainmenu = '';
var previousmenu='';
var menutimerdata = new Array();
var menutimerlist = new Array();

var menutimer='';
var menu_enabled = true;

var menucolors = new Array();
var poppar = '';
var ia = new Array();

function preLoadDd(a)
{
	for(i in a)
	{
		c = ia.length;
		ia[c] = new Image();
		ia[c].src= a[i];

		
	}
}

function postInteresse(u,args,el)
{
	if(checkInteresseForm())
	{
		var ajax = new sack();
		for(i in args)
		{
			ajax.setVar(args[i], document.getElementById(args[i]).value);			
		}
		ajax.requestFile = u
		ajax.method = "POST";
		ajax.element = el;
		ajax.runAJAX();
	}
	else
	{
			
	}
}

function loadNws(u,args,el)
{
	
	var ajax = new sack();
	for(i in args)
	{
		ajax.setVar(args[i][0],args[i][1]);			
	}
	ajax.requestFile = u
	ajax.method = "GET";
	ajax.element = el;
	ajax.runAJAX();
	
}

function checkInteresseForm()
{
	e='';
	
	if(document.getElementById('frm_bericht').value=='')
	{
		e+="- Voert u a.u.b. een boodschap in.\n";
	}
	if(!checkEmail(document.getElementById('frm_email').value) && document.getElementById('frm_telefoon').value.length<10)
	{
		e+="- Voert u a.u.b. een geldig e-mail adres of telefoonnummer in";
	}
		
	if(e!='')
	{
		alert(e);
		return false;
	}
	else
	{
		return true;
	}
}


function loadPopPage(id,par)
{
	var so_pop = new SWFObject("/popup.swf?parText="+par, "popupswf_player", "550", "350", "8", "");
	so_pop.addParam("menu", "false");
	so_pop.addParam("wmode", "transparent");
	so_pop.addParam("allowScriptAccess", "always");
	so_pop.addParam("NAME", "popupswf_player");
	so_pop.write("popupswf");
	var ajax = new sack();

	poppar = par;
	
	ajax.requestFile = id
	ajax.method = "GET";
	ajax.element = 'popupcontentscontainer';
	ajax.onCompletion = showPop;
	ajax.runAJAX();
	
	
}
function closePop()
{
	showSelects();
	document.getElementById('popup').style.display='none';		
	
}
function showPop()
{
	hideSelects();
	document.getElementById('popup').style.display='';
}

function changeLayout()
{
	// lines
	if(previousmenu!='')
	{
		document.getElementById("menuline_top_"+previousmenu).style.visibility="hidden";
		document.getElementById("menuline_bottom_"+previousmenu).style.visibility="hidden";
		document.getElementById("main_"+previousmenu).style.backgroundColor="#FFFFFF";
		document.getElementById("menusubtitle_"+previousmenu).style.color="#000000";
		document.getElementById("menutitle_"+previousmenu).style.color="#4864ae";
		
	}
	document.getElementById("menuline_top_"+mainmenu).style.visibility="hidden";
	document.getElementById("menuline_bottom_"+mainmenu).style.visibility="hidden";
	document.getElementById("menusubtitle_"+mainmenu).style.color="#FFFFFF";
	document.getElementById("menutitle_"+mainmenu).style.color="#FFFFFF";
	// set layer top color
	document.getElementById("headercolorline-left").style.backgroundColor="#"+menucolors[mainmenu][0];
	document.getElementById("headercolorline-right").style.backgroundColor="#"+menucolors[mainmenu][2];
	// set bg 
	document.getElementById("main_"+mainmenu).style.backgroundColor="#"+menucolors[mainmenu][0];
	
}
function onLoadingPage()
{
	allowload = false;
}
function onCompletedPage()
{
	changeLayout();
	allowload = true;
}


function activatePage()
{
	closePop();
	for(id in menutimerlist)
	{
		break;
	}	
	
	if(typeof(menutimerlist[id])!='undefined' && typeof(menutimerlist[id][2])!='undefined')
	{

		menutimerdata = menutimerlist[id];
		if(allowload && mainmenu != menutimerdata[1])
		{
			
			if(typeof(menutimerdata[1])!='undefined')
			{
				previousmenu = mainmenu;
				mainmenu = menutimerdata[1];
				
				
				
				
				ajax = new  sack();
				if(menutimerdata[1]== navigationLock)
				{
					ajax.requestFile = menutimerdata[3];
				}
				else
				{
					ajax.requestFile = menutimerdata[0];
				}
				// lock navigation?
				
				handleNavigationLock(menutimerdata[1]);
				ajax.method = "GET";
				ajax.element = 'contentsmiddle';
				ajax.onLoading = onLoadingPage;
				ajax.onCompletion = onCompletedPage;
				ajax.runAJAX();
			
				delete menutimerlist[menutimerdata[1]];
				clearTimeout(menutimer);
			}
		}
	}
}
function unloadTimer(id)
{
	
	if(typeof(menutimerlist[id])!='undefined' && typeof(menutimerlist[id][2])!='undefined')
	{
		clearTimeout(menutimerlist[id][2]);
		delete menutimerlist[menutimerdata[1]];
	}
}
function loadPage(uri,id,currentpage)
{
	if(menu_enabled)
	{
		menutimer = setTimeout("activatePage()",350);
		if(allowload)
		{
			menutimerdata[0] = uri;
			menutimerdata[1] = id;
			menutimerdata[2] = menutimer;
			menutimerdata[3] = currentpage;
			menutimerlist[id] = menutimerdata;
		}
	}
	
}


// product details menu popup
var allowparenthide = false;
var hideParentTimer = '';
var showParentTimer = '';

function showParentMenu()
{
	if(document.getElementById('parentMenu').style.display=='none')
	{
		document.getElementById('parentMenu').style.display='';
	}
}
function hideParentMenu()
{
	if(document.getElementById('parentMenu').style.display=='')
	{
		document.getElementById('parentMenu').style.display='none';
	}
}
function clearHideParentTimer()
{
	if(typeof(hideParentTimer)!='undefined' && hideParentTimer!='')
	{
		clearTimeout(hideParentTimer);
		hideParentTimer='';
	}
}
function clearShowParentTimer()
{
	if(typeof(showParentTimer)!='undefined' && showParentTimer!='')
	{
		clearTimeout(showParentTimer);
		showParentTimer='';
	}
}
function setShowParentTimer()
{
	if(typeof(showParentTimer)!='undefined' && showParentTimer!='')
	{
	}
	else
	{
		showParentTimer = setTimeout("showParentMenu()",350);
		clearHideParentTimer();
	}
}

function setHideParentTimer()
{
	if(typeof(hideParentTimer)!='undefined' && hideParentTimer!='')
	{
	}
	else
	{
		clearShowParentTimer();
		hideParentTimer = setTimeout("hideParentMenu()",350);
	}
}

var navigationLock='';
function handleNavigationLock(m)
{
	if(m != navigationLock && navigationLock!='')
	{
		lockNavigation(true);
	}
	else
	{
		lockNavigation(false);
	}
}

function lockNavigation(st)
{
	if(st)
	{
		document.getElementById('rightcontentslock').className= 'rightcontents-locked';
	}
	else
	{
		document.getElementById('rightcontentslock').className= 'rightcontents';
	}
}

function setNavigationLock(m)
{
	navigationLock = m;
}
var lockonscroll = false;
function dDinit()
{
  if(lockonscroll)
  {
	document.body.onscroll = scrollMenLock;
	document.body.onmousewheel = scrollMenLock;
	document.body.onresizestart = scrollMenLock;
  }
}

var scrolllock = '';
function scrollMenLock()
{
	
	if(scrolllock =='')
	{
		disableMainMenu();
		scrolllock = setTimeout("scrollMenLock(false)",1000);
	}
	else
	{
		scrollMenUnlock
	}
}
function scrollMenUnlock()
{
	enableMainMenu();
	clearTimeout(scrolllock);
	scrolllock='';
}

function disableMainMenu()
{
	menu_enabled = false;
}
function enableMainMenu()
{
	menu_enabled = true;
}

preLoadDd(['/images/silverline_1004.jpg','/images/colorline_1004.jpg','/images/fauxcontent_black_1004.jpg','/images/footerbg_black_2_1004.jpg','/images/logo.jpg','/images/blockbg_r.jpg']);