function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function ProceedShopping( url )
{
  /* go back */
  parent.location = url;
}

function goToUrl( url )
{
  /* go to the specified url */
  parent.location = url;
}

function NextOrderStep( url )
{
  /* go to the next step */
  parent.location = url;
}

function askConfirmation( msg, url )
{
  if ( confirm( msg ) )
    parent.location = url;
}

function ChangeLayerVisibility( id, visible )
{
  /* load the layer */
  lay = MM_findObj( id );
  
  /* change the visibitily of the layer */
  if ( visible )
    lay.style.display = "block";
  else
    lay.style.display = "none";
}


function changePrice(elm,val) {
	obj = MM_findObj(elm);
	if ( obj )
		obj.innerHTML = val;
}

function setElmValue(id,val) {
	vObj = MM_findObj(id);
	if ( vObj ) 
		vObj.value = val;
}

function validateAddArticleForm() {

	/* check variation */
	vObj = MM_findObj('variation');
	if ( !vObj || vObj.value == '' || vObj.value == 0 ) {
		alert('Foutmelding: u heeft geen geldige variant geselecteerd!');
		return false;
	}
	
	/* check count */
	cObj = MM_findObj('count');
	if ( !(/^\d+$/.test(cObj.value) ) || parseInt(cObj.value) > 100) {
		alert('Foutmelding: voer een geldig aantal in (max. 100)!');
		return false;
	}
	
	/* check count against the current stock */
	sObj = MM_findObj('stock');
	if ( !sObj || sObj.value == '' || sObj.value == 0 ) {
		alert('Foutmelding: dit product is tijdelijk niet op voorraad!');
		return false;
	} else if ( parseInt(sObj.value) < parseInt(cObj.value) ) {
		alert('Foutmelding: u kunt maximaal ' + parseInt(sObj.value) + ' stuk(s) bestellen!');
		return false;
	}
	
	/* default value */
	return true;

}

function activateA(cur) {
	var t = cur;
	if (t) {
		t=t.firstChild;
		if (t) {
			var pos = t.className.indexOf('nav_item_level_1');
			if (pos>=0) { t.className += ' hoveratag'; }
		}
	}
}

function deActivateA(cur) {
	var t = cur;
	if (t) {
		t=t.firstChild;
		if (t) {
			var pos = t.className.indexOf('nav_item_level_1');
			if (pos>=0) { t.className=t.className.replace(" hoveratag", ""); }
		}
	}
}


activateMenu = function(nav) {
	var navroot = document.getElementById(nav);
	var lis=navroot.getElementsByTagName("LI");  
	for (i=0; i<lis.length; i++) {
		if(lis[i].lastChild.tagName=="UL"){
			lis[i].onmouseover=function() {	
				this.lastChild.style.display="block";
				activateA(this);
			}
			lis[i].onmouseout=function() {                       
				this.lastChild.style.display="none";
				deActivateA(this);
			}
		}
	}
}

window.onload= function(){
	activateMenu('nav'); 
}
