/* 
// @@@
// @@ Author: Kevin Versteeg
// @@ Date: 2007-09-24
// @@ Last change: 2007-09-24
// @@ Version: 1
// @@ Revision: 0
// @@ Copyright: Ecommany B.V.
// @@ Description: 
// @@$
*/
aTimeout = new Array('showMenu', 'setMinimumContentHeight', 'resizeWidth');
aCssRule = new Array();
nCurrentlyOpenedMenu = -1;

function showMenu(nMenu)
{
	// Annuleer verbergen menu als menu weer getoond moet worden
	clearTimeout(aTimeout['showMenu']);
	// Als al een menu geopend, verberg dit (als ander menu dan gevraagd menu is)
	if (nCurrentlyOpenedMenu != -1 && nCurrentlyOpenedMenu != nMenu)
	{
		hideMenu(nCurrentlyOpenedMenu, true);
	}
	// Waar staat de link?
	aPosLink = Position.cumulativeOffset($(('menu_'+nMenu)));
	// Waar header
	aPos = Position.cumulativeOffset($(('header')));
	iY = parseInt(aPos[1]+$(('header')).getHeight()-2);
	iX = parseInt(aPosLink[0]-15);
	
	// Iframe om select te verbergen in IE6
	$(('hideForm')).setStyle({'display': 'inline'});
	$(('hideForm')).setStyle({'top': iY+'px'});
	$(('hideForm')).setStyle({'left': iX+'px'});
	$(('hideForm')).setStyle({'width': $(('submenu_'+nMenu)).getWidth()+'px'});
	$(('hideForm')).setStyle({'height': $(('submenu_'+nMenu)).getHeight()+'px'});

	$(('submenu_'+nMenu)).setStyle({'display': 'inline'});
	$(('submenu_'+nMenu)).setStyle({'top': iY+'px'});
	$(('submenu_'+nMenu)).setStyle({'left': iX+'px'});
	nCurrentlyOpenedMenu = nMenu;
	return;
}
function hideMenu(nMenu, bNow)
{
	bNow = typeof bNow == 'undefined' ? false : true;
	if (bNow)
	{
		$(('submenu_'+nMenu)).setStyle({'display': 'none'});
		$(('hideForm')).setStyle({'display': 'none'});
	} else
	{
		aTimeout['showMenu'] = setTimeout(function(){$(('submenu_'+nMenu)).setStyle({'display': 'none'}); $(('hideForm')).setStyle({'display':'none'}); }, 250);
	}
	return;
}
function openLink(sLink)
{
	window.focus();
	window.location = sLink;
	return;
}
function detectBrowser()
{ 
	var BO = new Object(); 
	BO["ie"]        = false /*@cc_on || true @*/; 
	BO["ie4"]       = BO["ie"] && (document.getElementById == null); 
	BO["ie5"]       = BO["ie"] && (document.namespaces == null) && (!BO["ie4"]); 
	BO["ie6"]       = BO["ie"] && (document.implementation != null) && (document.implementation.hasFeature != null); 
	BO["ie55"]      = BO["ie"] && (document.namespaces != null) && (!BO["ie6"]); 
	/*@cc_on
	BO["ie7"]       = @_jscript_version == '5.7';
	@*/ 
	BO["ns4"]       = !BO["ie"] &&  (document.layers != null) &&  (window.confirm != null) && (document.createElement == null); 
	BO["opera"]     = (self.opera != null); 
	BO["gecko"]     = (document.getBoxObjectFor != null); 
	BO["khtml"]     = (navigator.vendor == "KDE"); 
	BO["konq"]      = ((navigator.vendor == 'KDE') || (document.childNodes) && (!document.all) && (!navigator.taintEnabled)); 
	BO["safari"]    = (document.childNodes) && (!document.all) && (!navigator.taintEnabled) && (!navigator.accentColorName); 
	BO["safari1.2"] = (parseInt(0).toFixed == null) && (BO["safari"] && (window.XMLHttpRequest != null)); 
	BO["safari2.0"] = (parseInt(0).toFixed != null) && BO["safari"] && !BO["safari1.2"]; 
	BO["safari1.1"] = BO["safari"] && !BO["safari1.2"] && !BO["safari2.0"]; 
	return BO; 
} 
var BO = new detectBrowser();
function getInnerHeight(win)
{
	h = 0;
	if (win.innerHeight)
	{
		h = win.innerHeight;
	} else if (win.document.documentElement && win.document.documentElement.clientHeight) 
	{
		h = win.document.documentElement.clientHeight;
	} else if (win.document.body) 
	{
		h = win.document.body.clientHeight;
	}
	return h;
}
function getInnerWidth(win)
{
 	w=0;
 	if (win.innerWidth)
	{
		w = win.innerWidth;
	} else if (win.document.documentElement && win.document.documentElement.clientWidth)
	{
		w = win.document.documentElement.clientWidth;
	} else if (win.document.body)
	{
		w = win.document.body.clientWidth;
	}
	return w;
}
function setMinimumContentHeight()
{
	clearTimeout(aTimeout['setMinimumContentHeight']);
	iInnerHeight = getInnerHeight(window);
	// Waar staat de content container
	iTmp = Position.cumulativeOffset($(('content_content_container')));
	iHeight = iTmp[1];
	// Tel hoogtes van eigen div, en divjes daarna op
	iHeight += $(('content_content_container')).getHeight();
	iHeight += $(('content_bottom_center')).getHeight();
	iHeight += $(('footer_top')).getHeight() + parseInt($(('footer_top')).getStyle('margin-top'));
	iHeight += $(('footer')).getHeight();
	iHeight += $(('footer_bottom')).getHeight() + parseInt($(('footer_bottom')).getStyle('margin-bottom'));
	iNewHeight = parseInt(iInnerHeight - iHeight);
	iNewHeight += $(('content_content_container')).getHeight();
	// Minimumhoogte van 2 banners
	iMinimumHeight = 225;
	iNewHeight = iNewHeight <	iMinimumHeight ? iMinimumHeight : iNewHeight;
	$(('content_content_container')).setStyle({'min-height' : iNewHeight+'px'});
	$(('content_content_container')).setStyle({'height' : iNewHeight+'px'});
	return;
}
function resizeWidth()
{
	w = getInnerWidth(window);
	if (w <= 800)
	{
		aCssRule['container'].style.width = '930px';
		aCssRule['container'].style.left = '0px';
		aCssRule['container'].style.marginLeft = '-50px';

		$(('foto')).setStyle({'width' :'930px'});
		$(('foto_overlay')).setStyle({'width' :'930px'});
		$(('logo_background')).setStyle({'width' :'930px'});
		$(('logo')).setStyle({'width' : '930px'});
		$(('img_foto')).setStyle({'width' : '930px'});
		$(('img_foto')).setStyle({'height' : '350px'});
		document.cookie = 'resize=yes; path=/';
	} else
	{
		aCssRule['container'].style.width = '1000px';
		aCssRule['container'].style.left = '50%';
		aCssRule['container'].style.marginLeft = '-500px';
		
		$(('foto')).setStyle({'width' : '1000px'});
		$(('foto_overlay')).setStyle({'width' :'1000px'});
		$(('logo_background')).setStyle({'width' : '1000px'});
		$(('logo')).setStyle({'width' : '1000px'});
		$(('img_foto')).setStyle({'width' : ''});
		$(('img_foto')).setStyle({'height' : ''}); 
		document.cookie = 'resize=no; path=/';
	}
	return;
}
// Wel met eigen mouseover class
function toggleBannerClass(jsObj, event)
{
	aTmp = $((jsObj)).classNames().toString().split(' ');
	bOdd = aTmp[0] == 'banner_1_container' ? false : true;
	if (event.type == 'mouseover')
	{
		$((jsObj)).addClassName('banner_mo_bg');
		$((jsObj)).removeClassName(aTmp[1]);
	} else
	{
		$((jsObj)).removeClassName(aTmp[1]);
		if (bOdd)
		{
			$((jsObj)).addClassName('banner_2_bg');
		} else
		{
			$((jsObj)).addClassName('banner_1_bg');
		}
	}
	for (i = 0; i < jsObj.childNodes.length; i++)
	{
		if (jsObj.childNodes[i].nodeType != 1) continue;
		aTmp = $((jsObj.childNodes[i])).classNames().toString().split(' ');
		sCurrentClassName = aTmp[1];
		switch (sCurrentClassName)
		{
			case 'b_mo_top_bg':
			case 'banner_1_top_bg':
			case 'banner_2_top_bg':
				if (event.type == 'mouseover')
				{
					sNewClassName = 'b_mo_top b_mo_top_bg';
				} else
				{
					sNewClassName = bOdd ? 'banner_2_top banner_2_top_bg' : 'banner_1_top banner_1_top_bg';
				}
			break;
			case 'b_mo_content_bg':
			case 'banner_1_content_bg':
			case 'banner_2_content_bg':
				if (event.type == 'mouseover')
				{
					sNewClassName = 'b_mo_content b_mo_content_bg';
				} else
				{
					sNewClassName = bOdd ? 'banner_2_content banner_2_content_bg' : 'banner_1_content banner_1_content_bg';
				}
			break;
			case 'b_mo_bottom_bg':
			case 'banner_1_bottom_bg':
			case 'banner_2_bottom_bg':
				if (event.type == 'mouseover')
				{
					sNewClassName = 'b_mo_bottom b_mo_bottom_bg';
				} else
				{
					sNewClassName = bOdd ? 'banner_2_bottom banner_2_bottom_bg' : 'banner_1_bottom banner_1_bottom_bg';
				}
			break;
			default:
				sNewClassName = 'phantom';
		}
		jsObj.childNodes[i].className = sNewClassName;
	}
	return;
}
// Geen eigen mouse over class, maar inverse
function toggleBannerClassNoMo(jsObj)
{
	aTmp = $((jsObj)).classNames().toString().split(' ');
	bOdd = aTmp[1] == 'banner_1_bg' ? true : false;
	if (bOdd)
	{
		$((jsObj)).removeClassName(aTmp[1]);
		$((jsObj)).addClassName('banner_2_bg');
	} else
	{
		$((jsObj)).removeClassName(aTmp[1]);
		$((jsObj)).addClassName('banner_1_bg');
	}
	for (i = 0; i < jsObj.childNodes.length; i++)
	{
		if (jsObj.childNodes[i].nodeType != 1) continue;
		aTmp = $((jsObj.childNodes[i])).classNames().toString().split(' ');
		sCurrentClassName = aTmp[1];
		switch (sCurrentClassName)
		{
			case 'banner_1_top_bg':
			case 'banner_2_top_bg':
				sNewClassName = bOdd ? 'banner_2_top banner_2_top_bg' : 'banner_1_top banner_1_top_bg';
			break;
			case 'banner_1_content_bg':
			case 'banner_2_content_bg':
				sNewClassName = bOdd ? 'banner_2_content banner_2_content_bg' : 'banner_1_content banner_1_content_bg';
			break;
			case 'banner_1_bottom_bg':
			case 'banner_2_bottom_bg':
				sNewClassName = bOdd ? 'banner_2_bottom banner_2_bottom_bg' : 'banner_1_bottom banner_1_bottom_bg';
			break;
			default:
				sNewClassName = 'phantom';
		}
		jsObj.childNodes[i].className = sNewClassName;
	}
	return;
}
function findCssRules()
{
	s = document.styleSheets[0].cssRules ? document.styleSheets[0].cssRules : document.styleSheets[0].rules;
	for (i = 0; i < s.length; i++)
	{
		if (s[i].selectorText == '#container')
		{
			aCssRule['container'] = s[i];
		}
		if (s[i].selectorText == '#content_content_container')
		{
			aCssRule['content_content_container'] = s[i];
		}
	}
	return;
}
function setPrint()
{
	document.getElementById('print').innerHTML = document.getElementById('content_content').innerHTML;
}
function newsSelectSubmit(id, value)
{
	if (id == 'newsmonth')
	{
		sMonth = value;
	} else
	{
		jsObj = document.getElementById('newsmonth');
		sMonth = jsObj != null ? jsObj.options[jsObj.selectedIndex].value : 'januari';
	}
	if (id == 'newsyear')
	{
		sYear = value;
	} else
	{
		jsObj = document.getElementById('newsyear');
		sYear = jsObj != null ? jsObj.options[jsObj.selectedIndex].value : '2007';
	}
	window.location = sSiteURL+sNewsURLPart+'/'+sYear+'/'+sMonth+'.html';
}
function classSelectSubmit(sValue)
{
	window.location = sSiteURL+'/leerlingen/rooster_info/'+sValue+'.htm';
	return;
}
function init()
{
	findCssRules();
	setMinimumContentHeight();
	resizeWidth();
	window.onresize = function() { aTimeout['setMinimumContentHeight'] = setTimeout("setMinimumContentHeight()", 40); aTimeout['resizeWidth'] = setTimeout("resizeWidth()", 40); };
	setPrint();
	return;
}

