//valid replacment for onLoad in body tag
//via : http://simonwillison.net/2004/May/26/addLoadEvent/

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
	window.onload = func;
    } else {
	window.onload = function() {
	    if (oldonload) {
	        oldonload();
	    }
	    func();
	}
    }
    
    //jon added on resize function
    var oldonresize = window.onresize;
    if (typeof window.onresize != 'function') {
	window.onresize = func;
    } else {
	window.onresize = function() {
	    if (oldonresize) {
	        oldonresize();
	    }
	    func();
	}
    }
}

//seperate js file for other pages, otherwise js error occurs when it cant find the div id - in the long run should merge these scripts

addLoadEvent(function() {
	
		//new function to put overflow scroll in correct position on si pages esp in ie6
	var sWidth = ( (document.viewport.getWidth())); 
	Element.setStyle('textContentLarge', {width:sWidth+'px'} );
	
	if (document.viewport.getWidth() > 400) {
		var newContentSize = ( (document.viewport.getHeight())-161);  //this works best across all browsers 
		Element.setStyle('textContentLarge', {height:newContentSize+'px'} );//both used to be set on PrimaryContent - now set on text so that menu doesnt scroll
		if (newContentSize < document.viewport.getHeight()){ 
			Element.setStyle('textContentLarge', {overflow:'scroll'} );  /*added here, rathr than in css, as we only want it to work if js is working*/
			//Element.setStyle('primaryContent', {overflowY:'scroll'} );  
			//Element.setStyle('primaryContent', {overflowX:'overflow'} );  /*caused (major) ie js bug - as overflowX is not level 2 - see http://www.prototypejs.org/api/element/setStyle and http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-ElementCSSInlineStyle
			

		}
		return false; 
	}
})

