var alreadyrunflag=0 //flag to indicate whether target function has already been run

if (document.addEventListener)
  document.addEventListener('DOMContentLoaded', function(){alreadyrunflag=1; sizeall()}, false)
else if (document.all && !window.opera){
  document.write('<script type="text/javascript" id="contentloadtag" defer="defer" src="javascript:void(0)"><\/script>')
  var contentloadtag=document.getElementById('contentloadtag')
  contentloadtag.onreadystatechange=function(){
    if (this.readyState=='complete'){
      alreadyrunflag=1
      sizeall()
    }
  }
}

window.onload=function(){
  setTimeout('if (!alreadyrunflag) sizeall()', 0)
}

window.onresize=sizeall;

function sizeall(){
	padsize('wrapper');
}

function size(id) { 
	var dp = document.getElementById(id);
	
	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;
  }
	
	if (myWidth < 1100) {
   		dp.style.marginLeft = "1%";
   		dp.style.marginRight = "1%";
	} else if (myWidth < 1400) {
  		dp.style.marginLeft = "2%";
   		dp.style.marginRight = "2%";
  	} else if (myWidth < 1600) {
  		dp.style.marginLeft = "10%";
   		dp.style.marginRight = "10%";
	} else {
  		dp.style.marginLeft = "15%";
   		dp.style.marginRight = "15%";
  	}
}

function padsize(id) { 
	var dp = document.getElementById(id);

	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;
  }
	
	if (myWidth < 1024) {
		dp.style.width = "100%";
	} else if (myWidth > 1400) {
		document.getElementById("mybody").style.fontSize="1em";
		document.getElementById("mybody").style.lineHeight="1.5em";
		dp.style.width = "1050px";
	}
}
