function getWindowWidth() {
	var myWidth = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}
	return myWidth;
}


var widthSet = -1;

function setPageWidth() {
	var myWidth = getWindowWidth();
	
	//window.status = "current width: " + myWidth;
		
	/*if ((myWidth < 800) && (widthSet != 1)) {
		setSessionCookie('page_width', '1280');
		changeStyleSheet('ngi_width_', '1280');
		widthSet = 1;
	}*/
	
	//if (((myWidth < 1200) && (myWidth > 800)) && (widthSet != 1)) {
	if ((myWidth < 1200) && (widthSet != 1)) {
		strLayoutSheet = '1024';
		setSessionCookie('wi_ss', '1024');
		widthSet = 1;
		setStyleSheet(strLayoutSheet);
	}
	
	if ((myWidth >= 1200) && (widthSet != 2)) {
		strLayoutSheet = '1280'; 
		setSessionCookie('wi_ss', '1280');
		widthSet = 2;
		setStyleSheet(strLayoutSheet);
	}
	
	/*if ((myWidth <= 800) && (widthSet != 3)) {
		strLayoutSheet = '800'; 
		setSessionCookie('wi_ss', '800');
		widthSet = 3;
		setRefajaStyleSheet(strLayoutSheet);
	}*/
	
	
	
}

/*
function setFontSize(intSize) {
	switch(intSize) {
		case 2:
			setSessionCookie('CSS_FONT_SIZE', 'large');
			changeStyleSheet('style_font_', 'large');
			break;
		case 1:
			setSessionCookie('CSS_FONT_SIZE', 'medium');
			changeStyleSheet('style_font_', 'medium');
			break;
		default:
			setSessionCookie('CSS_FONT_SIZE', 'normal');
			changeStyleSheet('style_font_', 'normal');
			break;
	}
	fixHeightElements()
}
*/
			
function changeStyleSheet(title, layoutsheet) {
	var i, a, main;
	
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if (a.getAttribute('href').indexOf(title) != -1 ) {
			if (a.getAttribute('href').indexOf(layoutsheet) != -1 ) {
				a.disabled = false;
			} else {
				a.disabled = true;
			}
		}
	}
}

function setPageSheets() {
	setPageWidth();
	/* zou niet hoeven omdat css al aan server kant goed gezet word
	switch(setSessionCookie('CSS_FONT_SIZE')) {
		case 'large':
			setFontSize(2);
			break;
		case 'medium':
			setFontSize(1);
			break;
		default:
			setFontSize(0);
			break;
	}*/
}

if (window.addEventListener) 
		window.addEventListener("load", setPageSheets, false) 
	else if (window.attachEvent) 
		window.attachEvent("onload", setPageSheets)
	else
		window.onload=setPageSheets

/*if (window.addEventListener) 
		window.addEventListener("resize", setPageSheets, false) 
	else if (window.attachEvent) 
		window.attachEvent("onresize", setPageSheets)
	else
		window.onresize=setPageSheets
*/

	
//var bolsetSifrOnResize = false;
function setStyleSheet(layoutsheet) {

	var i, a, main;
	
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			//if ((a.getAttribute("title") == contentsheet) || (a.getAttribute("title") == layoutsheet))
			//window.status += ' ' + a.getAttribute("title");
			if (a.getAttribute("title") == layoutsheet) {
				a.disabled = false;
			} else{ 
				a.disabled = true;
			}
		}
	}
	
	//if (bolsetSifrOnResize) setSifrOnResize();
}

var strLayoutSheet;

switch (getSessionCookie('wi_ss')) {
	case '1024': strLayoutSheet = '1024'; break
	default: strLayoutSheet = '1280'; break;
}

setStyleSheet(strLayoutSheet);