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);

	myWidth=1280;
	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.width = "100%";
		document.getElementById("share").style.marginLeft="10px";
		document.getElementById("share").style.marginBottom="10px";
		document.getElementById("share").style.paddingTop="5px";
		document.getElementById("share").style.paddingBottom="0";
		document.getElementById("share").style.cssFloat="right";
		document.getElementById("share").style.position="static";
		document.getElementById("share").style.width="100%";
		document.getElementById("share").style.textAlign="left";
		document.getElementById("share1").style.width="1px";
		document.getElementById("share2").style.width="6px";
		document.getElementById("share3").style.width="8px";
		document.getElementById("share4").style.margin="0 8px";
		document.getElementById("share5").style.marginRight="8px";
	} else if (myWidth > 1500) {
		document.getElementById("mybody").style.fontSize="1.1em";
		document.getElementById("mybody").style.lineHeight="1.4em";
		dp.style.width = "1180px";
		document.getElementById("content").style.width="650px";
		document.getElementById("sidebar").style.marginLeft="700px";
	}
}
