
//Screen detection
if (screen.width < 1024) {
	document.write('<link href="/html/postbus51/styles/style_800.css" type="text/css" rel="stylesheet" media="Screen" />');
}

// Attach an event handler function to the searchbox .onfocus event trigger.
// When the user sets the focus to this field (e.g. puts his cursor into the field,
// and the value of the field still contains a default value, clear the field.
//
function clearField(){
	// Search the DOM for the searchbox...
	if(document.getElementById('field_search')){
		// Attach an event handler to the .onfocus event...
		document.getElementById('field_search').onfocus = function(){
			// Check whether the field still contains a default value...
			if (document.getElementById('field_search').value == "Vul trefwoord(en) in"){
				// Clear the box...
				this.value = "";	
			}
		}
	}
}

// To prevent the readspeaker control to load in the current window, add a blank target
// to the onclick event. Since XHTML doesn't support blank target parameter directly, 
// this is loaded lazy.
function readspeakerWin(){
	if(document.getElementById('control-readspeaker-link')){	
		document.getElementById('control-readspeaker-link').onclick = function(){
			document.getElementById('control-readspeaker-link').target = "_blank";
		}
	}
}


// hide summary
function hideSummaryInit(){
	if(document.getElementById('hideSummary')){
	document.getElementById('hideSummary').onclick = function(){
		if (!document.getElementsByTagName) return; 
	 		var para = document.getElementsByTagName("p"); 	
			 for (var i=0; i<para.length; i++) { 
			 	
				if(para[i].style.display == "none"){
					para[i].style.display = "block";
					document.getElementById('hideSummary').innerHTML = "Samenvattingen verbergen";
				}else{
					para[i].style.display = "none";
					document.getElementById('hideSummary').innerHTML = "Samenvattingen tonen";
				}
				
			 }
		}
	}
}


function printFunction() {
		
	
		
		var writeroot = document.getElementById('printlink');
		if (!writeroot) return;
		
		var link = document.createElement('a');
		link.href = '#';
		link.appendChild(document.createTextNode('Print'));
		
		link.onclick = function () {
			window.print();
			return false;
		}
		writeroot.appendChild(link);
	}



 var check = false;

function init() {
    // quit if this function has already been called
    if (arguments.callee.done) return;
    
    // flag this function so we don't do the same thing twice
    arguments.callee.done = true;
    
    // kill the timer
    if (_timer) {
        clearInterval(_timer);
        _timer = null;
    }
    
    GetSANAProductAmount();
};

// Attach our init function to the document loader.
// Different techniques for different browser families.

// For Mozille...
if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", init, false);
}

// For Internet Explorer...
/*@cc_on @*/
/*@if (@_win32)
    document.write("<script id=__ie_onload defer src=\"\"><\/script>");
    var script = document.getElementById("__ie_onload");
    script.onreadystatechange = function() {
        if (this.readyState == "complete") {
            init(); // call the onload handler
        }
    };
/*@end @*/

// for Safari 
if (/WebKit/i.test(navigator.userAgent)) { // sniff
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            init(); // call the onload handler
        }
    }, 10);
}



function GetSANAProductAmount() {
 var cookieName = 'BasketProductCount';
 var theCookie=''+document.cookie;
 var ind=theCookie.indexOf(cookieName);

if (ind==-1 || cookieName=='') return ''; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 var itemsAmount = unescape(theCookie.substring(ind+cookieName.length+1,ind1))
 if (itemsAmount > 0) 
	{
		divText='Bestel (' + itemsAmount + ')';
		document.getElementById('divSANAProductAmount').innerHTML = divText;
	}
}


// Onload functions
window.onload = function(){ 
	clearField(); 
	hideSummaryInit(); 
	printFunction(); 
	init(); 
	readspeakerWin(); 
}