var resizet;
window.onload = function() {
	pageResAdjust();
}

window.onresize = pageResAdjust;

function pageResAdjust() {
	var pageSize;
	pageSize = getPageSize()[0];
	if(pageSize<=770) {
		disableStyleSheet('baseRes800');
		switchStyleSheet('baseResLowest');
		//$("headflash").width = pageSize;
		//$("headflash").height = pageSize*0.188;
	} else if(pageSize<=971) {
		disableStyleSheet('baseResLowest');
		switchStyleSheet('baseRes800');
		//$("headflash").width = 770;
		//$("headflash").height = 145;
	} else {
		disableStyleSheet('baseResLowest');
		disableStyleSheet('baseRes800');
		//$("headflash").width = 950;
		//$("headflash").height = 179;
	}
}
function getStyleAttr(id, attr) {
	attr = (attr == null) ? 'width' : attr;
	if(attr=='width') {
		return $(id).offsetWidth;
	}
	return null;
}
function switchStyleSheet(id) {
  var i, sheet;
  for(i=0; (sheet = document.getElementsByTagName('link')[i]); i++) {
    if(sheet.getAttribute('rel').indexOf('style') != -1 && sheet.getAttribute('id')) {
      sheet.disabled = true;
      if(sheet.getAttribute('id') == id) sheet.disabled = false;
    }
  }
}
function disableStyleSheet(id) {
	if($(id) && $(id).disabled == false) { $(id).disabled = true; }
}
function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // Browser: All but IE-Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Browser: IE-Mac, Also Work in IE6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// Browser: All but IE
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Browser: IE6 Strict
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // Browser: IE (Other then IE6 Strict)
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// Short Pages (height)
	var pageWidth, pageHeight;
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// Short Pages (width)
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	var arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
function $(id) { return document.getElementById(id); }