/*#############################################################
Name: AT
Version: 1.0
//No-JS HighContrast TextNormal
#############################################################*/
/* fix img backgrounds on links in IE6 */
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}


// add hideFromJS to the onload
// code found in sifr.js
if(window.addEventListener) 
{
	window.addEventListener("load", hideFromJS, false)
	window.addEventListener("load", toggleAdminMode, false)
} 
else 
{
	window.attachEvent("onload", hideFromJS)
	window.attachEvent("onload", toggleAdminMode)
}


function toggleAdminMode() {
	var bodyEl = document.getElementsByTagName('body')[0];
	var Dom = YAHOO.util.Dom;

	if(Dom.get("mpLeftBackPadding")) 
	{
		Dom.addClass(bodyEl ,"EditMode");
	}
	else 
	{
		Dom.addClass(bodyEl ,"ViewMode");
		//DoSifrStuff();
	}
}

// change No-JS class in the body tag to JS
function hideFromJS() {
	var bodyEl = document.getElementsByTagName('body')[0];
	var Dom = YAHOO.util.Dom;
	Dom.replaceClass(bodyEl ,"No-JS", "JS");
	//change HighContrast if no cookie
	var x = readCookie('HighContrast');
	if (!x) {
		Dom.replaceClass(bodyEl ,"HighContrast", "LowContrast");
	}
	else {
		if (x=="on") {
			Dom.replaceClass(bodyEl ,"LowContrast", "HighContrast");
		} else {
			Dom.replaceClass(bodyEl ,"HighContrast", "LowContrast");
		}
	}
	var x = readCookie('TextSize');
	if (x) {
		Dom.replaceClass(bodyEl ,"TextMedium", x);
	} else {
		//always create a cookie so webparts can check for javascript
		createCookie('TextSize', "TextMedium", 60);
	}

}

function ChangeContrast() {
	var bodyEl = document.getElementsByTagName('body')[0];
	var Dom = YAHOO.util.Dom;
	var x = readCookie('HighContrast');
	if (x) {
		if (x=="on") {
			//eraseCookie('HighContrast');
			createCookie('HighContrast', "off", 60);
			Dom.replaceClass(bodyEl ,"HighContrast", "LowContrast");
		} else {
			createCookie('HighContrast', "on", 60);
			Dom.replaceClass(bodyEl ,"LowContrast", "HighContrast");
		}
	} else {
		createCookie('HighContrast', "on", 60);
		Dom.replaceClass(bodyEl ,"HighContrast", "LowContrast");
	}
}

function changeText(className) {
	var bodyEl = document.getElementsByTagName('body')[0];
	var Dom = YAHOO.util.Dom;
	Dom.removeClass(bodyEl, "TextMedium");
	Dom.removeClass(bodyEl, "TextBig");
	Dom.removeClass(bodyEl, "TextBigger");
	Dom.addClass(bodyEl, className);
	
	createCookie('TextSize', className, 60);
}

/*#############################################################
	COOKIES
	see http://www.quirksmode.org/js/cookies.html
#############################################################*/

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

/*#############################################################
	PRINTING
#############################################################*/

function printPage() {
		window.print();return false

}

/*################################################
				 time based background 
################################################*/


var currentTime = new Date()
var hours = currentTime.getHours()
var link;
if (document.createElement && (link = document.createElement('link')) && hours > 20 || hours < 7)
{
link.href = '/Style%20Library/css/backgroundstadnacht.css';
link.rel = 'stylesheet';
link.type = 'text/css';
var head = document.getElementsByTagName('head')[0];
	if (head) {
	head.appendChild(link);
	}
}
/*################################################
			detect 800 x 600 or less
################################################*/

if (window.screen.height <= 640) {
link.href = '/Style%20Library/css/smallresolution.css';
link.rel = 'stylesheet';
link.type = 'text/css';
var head = document.getElementsByTagName('head')[0];
	if (head) {
	head.appendChild(link);
	}
}

/*#####*/

function getElementsByClassName(classname, node) {
 if(!node) node = document.getElementsByTagName("body")[0];
 var a = [];
 var re = new RegExp('\\b' + classname + '\\b');
 var els = node.getElementsByTagName("*");
 for(var i=0,j=els.length; i<j; i++)
 if(re.test(els[i].className))a.push(els[i]);
 return a;
  }


/*################################################
			paginahoogte voor klikbare 
			tekst en footer
################################################*/

function WrapperSize() {
   if(document.getElementById('contentcontainer') != undefined ) { 
  var theWrapper = document.getElementById('fullWrapper');
    var theContentHeight = document.getElementById('content').offsetHeight;
  var myHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight + window.scrollMaxY;
  } else if( document.documentElement && (document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    if ((theContentHeight + 320) > document.documentElement.clientHeight ) {
    myHeight = (theContentHeight + 320); 
    }
    else {
    myHeight = (document.documentElement.clientHeight - 26);
    }
    
  } 
  theWrapper.style.height = myHeight  + "px";
 
}
	else if(document.getElementById('communicationComponent') != undefined ) {
	 var theWrapper = document.getElementById('fullWrapper');
    var theContentHeight = document.getElementById('communicationComponent').offsetHeight;
  var myHeight = 0;
if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight + window.scrollMaxY;
  } else if( document.documentElement && (document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = (document.documentElement.clientHeight - 46);    
  } 
  
   theWrapper.style.height = myHeight  + "px";

	}
}  
  





/*################################################
			lightboxprintstijl
################################################*/

function lightboxprintstyle() {
var bodyPl = document.getElementsByTagName('body')[0];
	var Dom = YAHOO.util.Dom;
	Dom.addClass(bodyPl ,"lightbox");

}

function endlightboxprintstyle() {
var bodyPl = document.getElementsByTagName('body')[0];
	var Dom = YAHOO.util.Dom;
	Dom.removeClass(bodyPl ,"lightbox");

}

function printPartOfPage()
{
			window.print();
}