function knippertekst() {
	// settings
	var timeout = 100;
	var step = 30;
	// groen = 64AD45 = 100;173;69;
	// wit = FFFFFF = 255;255;255;
	// paars = 793E8B = 121;62;139;

	// code
	var els = document.getElementById ('knipper');
	if (!els)
		return false;
	
	var reverse = color = 0;
	window.setInterval (function () {

		var one = color.toString(16);
		var col = '#'+one+one+one;

		els.style.color = col;

		if (reverse) {
			if (color - step < 0)
				reverse = false;
			else
				color = color-step;
		} else {
			if (color + step > 255)
				reverse = true;
			else
				color = color+step;
		}

	}, timeout);
}

// show or hide the hidden menu items
function showhiddenmenu (el) {
	
	var nextsib = dom.getNextSibling (el);
	if (nextsib && nextsib.className =='hiddennav') {
		nextsib.style.display="block";
		nextsib.onclick = function (e) {
			e = e || window.event;
			
			if (e.stopPropagation)
				e.stopPropagation ();
			else
				e.cancelBubble = true;
		}
		
		nextsib.onmouseover = function (e) {
			if (showhiddenmenu.timer)
				window.clearTimeout (showhiddenmenu.timer);
		}
		
		nextsib.onmouseout = function (e) {
			e = e || window.event;
			var target = e.target || e.srcElement;
			showhiddenmenu.timer = window.setTimeout (function () {
				nextsib.style.display="none";
			}, 2)
		};
		
		el.onmouseout = function (e) {
			e = e || window.event;
			var target = e.target || e.srcElement;
			showhiddenmenu.timer = window.setTimeout (function () {
				nextsib.style.display="none";
			}, 2)
		};
		
		showhiddenmenu.submenu [showhiddenmenu.submenu.length] = nextsib;
		
		
		window.document.body.onclick = function () {
			for(var el in showhiddenmenu.submenu ) {
				showhiddenmenu.submenu[el].style.display='none';
			}
			showhiddenmenu.submenu = [];
		
		}
		
	}
}
showhiddenmenu.submenu = [];



// end og show or hide the hidden menu items

// Print functie (haalt bepaalde TD uit de maintable en gooit deze in een popup)
function printPage(td) {
	if (document.getElementById(td)) {
		var print = document.getElementById(td).innerHTML;
		window.printgedeelte = '<table><tr><td>'+print+'</td></tr></table>';
	
		//open popup en vul deze 
		var w =  window.open('/print.html');
	}
}


//Popup voor inboedelmeter en overige informatie

//voer aantal handelingen uit voor correcte weergave formulier
function settingCorrectPDF() {
	document.getElementById('divHeelFormulier').style.display='block';
	setValue('actiontype','premieberekening');
	if (document.getElementById('knoppenNaPremieBoven')) 
		document.getElementById('knoppenNaPremieBoven').style.display = 'none';
	if (document.getElementById('tr_PP.PP.ALGVWD')) 
		document.getElementById('tr_PP.PP.ALGVWD').style.display = 'none';
	
	verbergAanvraagvelden();
	if (typeof Waarden == "object") {
		for (keycode in Waarden) {
			if (Waarden[keycode] == "") {
				if (document.all.item( "tr_" + keycode ))
					hideInput(keycode,true);
			}
		}
	}
	//specifiek autoformulier
	if (Waarden['PP.CA.CA_CODE'] == "") {
		if (document.getElementById('lbl_PP.CA.CA_CODE'))
			document.getElementById('lbl_PP.CA.CA_CODE').style.display = 'block';
	}
	ShoworHide('PP.RI.RI_BONAUTO','show');
	ShoworHide('PP.CA.CA_CODE','show');
	ShoworHide('PROM.PROM_PO_PAKKET','show');
}

// Print functie (haalt bepaalde TD uit de maintable en stopt deze in de PDF writer)
function setPDFinput(tdid,formuliernaam) {
	if (document.getElementById(tdid)) {
		if (document.createpdf.pdf_submap.value) {
			var pdfdisplay = "<script>settingCorrectPDF();</script>";
			var pdfinput = '<html><head><link rel="STYLESHEET" type="text/css" href="/css/weergave.css"><link rel="STYLESHEET" type="text/css" href="/css/navigatie.css"><link rel="STYLESHEET" type="text/css" href="/css/formulieren.css"><link rel="STYLESHEET" type="text/css" href="/css/bouwstenen.css"><link rel="STYLESHEET" type="text/css" href="/css/print.css"><script language="JavaScript" src="/js/weergave.js"></script><script language="JavaScript" src="/clientjs/nodes.js"></script><script language="JavaScript" src="/clientjs/global.js"></script><script language="JavaScript" src="/clientjs/validation.js"></script><script language="JavaScript" src="/clientjs/errorhandling.js"></script><script language="JavaScript" src="/clientjs/help.js"></script><script language="JavaScript" src="/js/validationrules.js"></script><script language="JavaScript" src="/clientjs/bouwstenen.js"></script></head><table><tr><td><img src="/images/formulieren/logo_pdf.gif">' + document.getElementById(tdid).innerHTML + '</td></tr></table>' + pdfdisplay + '</html>';
		}

		//var postcode = getValue("PP.VP.VP_PCODE");
		//var geboortedatum = getValue("PP.VP.VP_GEBDAT");
		var kenteken = getValue("PP.OB.OB_KENTEKE");
		//geboortedatum = geboortedatum.replace("-","");
		
		//if (postcode == '' || geboortedatum == '') 
		if(kenteken==''){
			alert('U heeft geen kenteken ingevuld');
			return false;
		} else {
			var pdfunieknr = kenteken;
			
			if (document.getElementById('pdfcontent')){
			//	alert(pdfinput);
				document.getElementById('pdfcontent').innerText = pdfinput;
			//	alert(pdfinput);
			}
			if (document.getElementById('pdf_unieknr'))
				document.createpdf.pdf_unieknr.value = pdfunieknr;
			
			document.forms[formuliernaam].submit();
		}
	}
}

var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var popupscherm=0;

function openPopup(filename, fileid, width, height, scrollbars, resizable, menubar, toolbar, status, location) {
	if (!fileid || fileid=="")					fileid="Het Groene Hart verzekeringen";
	if (!width || width=="")					width="655";
	if (!height || height=="")					height="490";
	if (!scrollbars || scrollbars=="")			scrollbars="no";
	if (!resizable || resizable=="")			resizable="no";
	if (!menubar || menubar=="")				menubar="no";
	if (!toolbar || toolbar=="")				toolbar="no";
	if (!status || status=="")					status="no";
	if (!location || location=="")				location="no";
	popupscherm=0;
	var args = "height=" + height + ", width=" + width + ", scrollbars=" + scrollbars + ", resizable=" + resizable +  ", menubar=" + menubar + ", toolbar=" +toolbar + ", status=" + status + " ,location=" + location;
	popupscherm = window.open(filename,'', args);
	if (!InternetExplorer) 						popupscherm.focus();
}

var resize = function () {
	//return false;
	var maindiv = document.getElementById('maindiv');
	if (maindiv !== null) {
		var bsize = getBrowserSize();
		bheight = bsize[1] - 180;
		//FX only....
		maindiv.style.overflow=self.innerWidth?'hidden':'auto';
		//
		maindiv.style.height = bheight < 20? 20: bheight;
		window.onresize = resize;
	}
}

var getBrowserSize = function ()  {
	if (self.innerWidth) {
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	} else if (document.documentElement &&	document.documentElement.clientWidth) {
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}
	return [frameWidth,frameHeight];
}
if (typeof dom!='undefined') dom.onload (this,'resize');

//deze functie geeft de invoer velden bij brochure aanvraag per post weer
function checkbrochure(){
	if(document.formulier.brochurecheck.checked == true){
		document.getElementById('brochuregegevens').style.display="block";
	}else{
		document.getElementById('brochuregegevens').style.display="none";
	}
}


var offsetxpoint=-60; //Customize x offset of tooltip
var offsetypoint=20; //Customize y offset of tooltip
var ie=document.all;
var ns6=document.getElementById && !document.all;
var enabletip=false;
if (ie||ns6)
	var tipobj=document.all? document.all["tooltip"] : document.getElementById? document.getElementById("tooltip") : "";
var ifrobj =document.all? document.all["HelpShim"] : document.getElementById? document.getElementById("HelpShim") : "";

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showtip(thetext, thecolor, thewidth){
	if (ns6||ie){
		tipobj=document.all? document.all["tooltip"] : document.getElementById? document.getElementById("tooltip") : "";
		ifrobj =document.all? document.all["HelpShim"] : document.getElementById? document.getElementById("HelpShim") : "";
		if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
		if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
		tipobj.innerHTML=thetext
		enabletip=true
		return false
	}
}

function positiontip(e){
	if (enabletip){
		tipobj=document.all? document.all["tooltip"] : document.getElementById? document.getElementById("tooltip") : "";
		ifrobj =document.all? document.all["HelpShim"] : document.getElementById? document.getElementById("HelpShim") : "";
		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
		var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
		var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
		
		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<tipobj.offsetWidth)
			//move the horizontal position of the menu to the left by it's width
			tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
		else if (curX<leftedge)
			tipobj.style.left="5px"
		else
			//position the horizontal position of the menu where the mouse is positioned
			tipobj.style.left=curX+offsetxpoint+"px"
			
		//same concept with the vertical position
		if (bottomedge<tipobj.offsetHeight)
			tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
		else
			tipobj.style.top=curY+offsetypoint+"px"
		tipobj.style.visibility="visible"
		
		ifrobj.style.top = tipobj.style.top;
		ifrobj.style.left = tipobj.style.left;
		ifrobj.style.width = tipobj.offsetWidth;
		ifrobj.style.height = tipobj.offsetHeight;
		ifrobj.style.display='block';
	}
}

function hidetip(){
	if (ns6||ie){
		enabletip=false
		tipobj.style.visibility="hidden"
		tipobj.style.left="-1000px"
		tipobj.style.backgroundColor=''
		tipobj.style.width=''
		ifrobj.style.display='none';
	}
}

function trackMailtoLinks() {
	//add onclick event to all mailto hyperlinks
	var links = document.getElementsByTagName("a");
	if (typeof links == "object") {
		for (key in links) {
			if (typeof links[key] == "object") {
				var href = links[key].href;
				if (href.substring(0,7) == 'mailto:') {
					links[key].onclick = function() { 
						pageTracker._trackPageview(href);
					};
				}
			}
		}
	}
}

document.onmousemove=positiontip
