addEvent(window, 'load', init, false);

var sBrowser = navigator.userAgent;  
if ((sBrowser.indexOf("IE") > -1) && (navigator.platform == "Win32")) {
	sBrowser="IE";
} else {
	sBrowser = "nonIE";
}

function addEvent(element, eventType, lamdaFunction, useCapture) {
    if (element.addEventListener) {
        element.addEventListener(eventType, lamdaFunction, useCapture);
        return true;
    } else if (element.attachEvent) {
        var r = element.attachEvent('on' + eventType, lamdaFunction);
        return r;
    } else {
        return false;
    }
}

function init() {
    var formInputs = document.getElementsByTagName('input');
    for (var i = 0; i < formInputs.length; i++) {
        var theInput = formInputs[i];        
        if (theInput.type == 'text' && theInput.className.match(/\bcleardefault\b/)) {  
            addEvent(theInput, 'focus', clearDefaultText, false);
            addEvent(theInput, 'blur', replaceDefaultText, false);
            if (theInput.value != '') {
                theInput.defaultText = theInput.value;
            }
        }
    }
}

function clearDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;    
    if (target.value == target.defaultText) {
        target.value = '';
    }
}

function replaceDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    if (target.value == '' && target.defaultText) {
        target.value = target.defaultText;
    }
}

function clickButton(e, buttonid) {
	var evt = e ? e:window.event;
	var bt = document.getElementById(buttonid);
	if (bt) {
		if (evt.keyCode == 13) {
			bt.click();
			return false;
		}
	}
}

function popupWindow(url,name,w,h) {

	l=(screen.width-w)/2;
	t=(screen.height-h)/2;
	window.open(url,name,'width='+w+',height='+h+',left='+l+',top='+t+',location=no,menubar=no,status=no,toolbar=no,scrollbars=no,resizable=yes');
}


function clearinputs() {
	a = document.getElementsByTagName('input');
	for(i = 0; i < a.length; i++) {
		if(a[i].type=='text') {
			a[i].value = "";
		}
	}

	a = document.getElementsByTagName('select');
	for(i = 0; i < a.length; i++) {
		a[i].value = "";
	}
}

function DoPrint()
{
	self.print();
}

function Printpage() {
	if (sBrowser == "IE") {
		PrintpageIE("print_content");
	}
	else {
		PrintpageFirefox("print_content");
	}
}

function Printcao() {
	if (sBrowser == "IE") {
		PrintpageIE("print_content_cao");
	}
	else {
		PrintpageFirefox("print_content_cao");
	}
}

function PrintpageIE(printid) {
	var content_value = document.getElementById(printid).innerHTML;
	var disp_setting = "toolbar=yes,location=no,directories=yes,menubar=yes,scrollbars=yes,width=780,height=600,left=100,top=25";
	var docprint = window.open("", "", disp_setting);
	docprint.document.open();
	docprint.document.write('<html><head><title>Uitgeverijbedrijf</title>');
	docprint.document.write('<link rel="stylesheet" type="text/css" href="/_layouts/images/UB/Includes/style.css"/>');
	docprint.document.write('<link rel="stylesheet" type="text/css" href="/_layouts/images/UB/Includes/print.css"/>');
	docprint.document.write('</head><body onLoad="self.print()" style="background: #FFF!important;">');
	docprint.document.write('<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">');
	docprint.document.write('<tr><td align="center"><img src="/_layouts/images/UB/Images/logo.gif" vspace="50" /></td></tr>');
	docprint.document.write('<tr><td valign="top" height="100%" style="padding:0 50px 0 50px;">');
	docprint.document.write(content_value); 	
	docprint.document.write('</td></tr>');
	docprint.document.write('<tr><td align="center" style="font-size:75%;padding-bottom:50px;">Bron: www.Uitgeverijbedrijf.nl</td></tr></table>');
	docprint.document.write('</body></html>');
	docprint.document.close();
	docprint.focus();
}

function PrintpageFirefox(printid) {
	var node = document.getElementById(printid).cloneNode(true);
	
	var tab = document.createElement('table'); 
	tab.setAttribute('width','100%'); 
	tab.setAttribute('height','100%'); 
	tab.setAttribute('border','0'); 
	tab.setAttribute('cellspacing','0'); 
	tab.setAttribute('cellpadding','0'); 

	var headerrow=document.createElement('tr'); 
	tab.appendChild(headerrow); 	
	var headercell=document.createElement('td'); 
	headercell.setAttribute('align','center'); 
	var headerimg=document.createElement('img'); 
	headerimg.setAttribute('src','/_layouts/images/UB/Images/logo.gif'); 
	headerimg.setAttribute('vspace','50'); 
	headerrow.appendChild(headercell); 
	headercell.appendChild(headerimg); 	

	var bodyrow=document.createElement('tr'); 
	tab.appendChild(bodyrow);
	var bodycell=document.createElement('td'); 
	bodycell.setAttribute('valign','top'); 
	bodycell.setAttribute('height','100%'); 
	bodycell.setAttribute('style','padding:0 50px 0 50px;'); 
	bodyrow.appendChild(bodycell); 
	bodycell.appendChild(node); 	

	var footerrow=document.createElement('tr'); 
	tab.appendChild(footerrow); 	
	var footercell=document.createElement('td'); 
	footercell.setAttribute('align','center'); 
	footercell.setAttribute('style','font-size:75%;padding-bottom:50px;'); 
	var footertext = document.createTextNode("Bron: www.Uitgeverijbedrijf.nl");
	footerrow.appendChild(footercell); 
	footercell.appendChild(footertext); 	

	var disp_setting = "toolbar=yes,location=no,directories=yes,menubar=yes,scrollbars=yes,width=780,height=600,left=100,top=25";
	var docprint = window.open("", "", disp_setting);
	docprint.document.open();
	docprint.document.write('<html><head><title>Uitgeverijbedrijf</title>');
	docprint.document.write('<link rel="stylesheet" type="text/css" href="/_layouts/images/UB/Includes/default.css"/>');
	docprint.document.write('<link rel="stylesheet" type="text/css" href="/_layouts/images/UB/Includes/print.css"/>');
	docprint.document.write('</head><body onLoad="self.print()" style="background: #FFF!important;">');
	docprint.document.body.appendChild(tab); 	
	docprint.document.write('</body></html>');
	docprint.document.close();
	docprint.focus();
}
