	function getBrowserWidth(){
		if (window.innerWidth){
	//	alert("Hi");
			return window.innerWidth;}	
		else if (document.documentElement && document.documentElement.clientWidth != 0){
	//	alert("Something DIfferent");
			return document.documentElement.clientWidth + 12;	}
		else if (document.body){return document.body.clientWidth;}		
	//	alert("and again some other");
			return 0;
	}

function dynamicLayout(){
	var browserWidth = getBrowserWidth();
	//This loads styles.css (the one for smaller screen sizes) 
	if (browserWidth <= 1010){
	//	alert(browserWidth);
		changeLayout("thin");
	}
	//This loads large.css (the one for bigger resolutions)
	if (browserWidth >= 1011){
	//	alert(browserWidth);
		changeLayout("wide");
	}
}

// changeLayout is based on setActiveStyleSheet function by Paul Sowdon 
// http://www.alistapart.com/articles/alternate/
function changeLayout(description){
   var i, a;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++){
	   if(a.getAttribute("title") == description){a.disabled = false;}
	   else if(a.getAttribute("title") != "default"){a.disabled = true;}
   }
}

	//addEvent() by John Resig
	function addEvent( obj, type, fn ){ 
	   if (obj.addEventListener){ 
	      obj.addEventListener( type, fn, false );
	   }
	   else if (obj.attachEvent){ 
	      obj["e"+type+fn] = fn; 
	      obj[type+fn] = function(){ obj["e"+type+fn]( window.event ); } 
	      obj.attachEvent( "on"+type, obj[type+fn] ); 
	   } 
	} 
	
	//Run dynamicLayout function when page loads and when it resizes.
	addEvent(window, 'load', dynamicLayout);
	addEvent(window, 'resize', dynamicLayout);
