var nav_focus = 0;
var nav_aantal = 7;


function nav_over(item) {
if(item!=nav_focus) {
	itemcel = "navcel_"+item;
	document.getElementById(itemcel).style.backgroundColor = "#FFF2D8";
}
}


function nav_out() {
i=1;
itemcel = "navcel_"+i;
while(document.getElementById(itemcel)) {
	if(i!=nav_focus) {
		document.getElementById(itemcel).style.backgroundColor = "";
	}
	i++;
	itemcel = "navcel_"+i;
}
}


var subnav_focus = 0;


function subnav_over(item) {
if(item!=subnav_focus) {
	itemcel = "subnavcel_"+item;
	document.getElementById(itemcel).style.backgroundColor = "#F9E1C9";
}
}


function subnav_out() {
i = 1;
itemcel = "subnavcel_"+i;
while(document.getElementById(itemcel)) {
	if(i!=subnav_focus) {
		document.getElementById(itemcel).style.backgroundColor = "";
	}
	i++;
	itemcel = "subnavcel_"+i;
}
}


function changecss(theClass,element,value) {
var cssRules;
if (document.all) {
	cssRules = 'rules';
} else if (document.getElementById) {
	cssRules = 'cssRules';
}
var added = false;
for (var S = 0; S < document.styleSheets.length; S++) {
	for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
		if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
			if(document.styleSheets[S][cssRules][R].style[element]){
				document.styleSheets[S][cssRules][R].style[element] = value;
				added=true;
				break;
			}
		}
	}
	if(!added) {
		if(document.styleSheets[S].insertRule) {
			document.styleSheets[S].insertRule(theClass+' { '+element+': '+value+'; }',document.styleSheets[S][cssRules].length);
		} else if (document.styleSheets[S].addRule) {
			document.styleSheets[S].addRule(theClass,element+': '+value+';');
		}
	}
}
}


function maximizeWindow() {
var offset = (navigator.userAgent.indexOf("Mac") != -1 ||
	navigator.userAgent.indexOf("Gecko") != -1 ||
	navigator.appName.indexOf("Netscape") != -1) ? 0 : 4;
window.moveTo(-offset, -offset);
window.resizeTo(window.screen.availWidth + (2 * offset), window.screen.availHeight + (2 * offset));
}


function initiate() {
maximizeWindow();
}


function focusinput(item, area) {
changecss("."+item,"color","#C26100");
if(area) {
	changecss("textarea","background-color","#F3F3F3");
} else {
	changecss("input[name='"+item+"']","background-color","#F3F3F3");
}
}

function outfocusinput(item, area) {
changecss("."+item,"color","#00967E");
if(area) {
	changecss('textarea',"background-color","transparent");
} else {
	changecss("input[name='"+item+"']","background-color","transparent");
}
}

function maxlengte(elem, lengte) {
if(elem.value.length>lengte) {
	elem.value = elem.value.substring(0, lengte);
}
}

var stretched = false;

function stretch(elem, lengte, hoogte) {
l = elem.value.length;
nh = (1+Math.floor(l/lengte))*hoogte;
nhs = nh+"px";
changecss('textarea',"height",nhs);
}


function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if ( 
aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
}


function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}


function meerinformatie() {
var n = getURLParam('n');
var s = getURLParam('s'); if(!s) {s=meerinformatietitel;}
var meerinfo = trim(n+" - "+s,"- ");
location.href = "?n=contact&meerinfo="+meerinfo;
}
