// copied from html/js library

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 ;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return ""
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
}

function DetectBrowser()
{
var Browser = navigator.appName;
var Version = navigator.appVersion;

if (Browser.search(/Microsoft/i) != -1)
{
 if ( Version.search(/MSIE 6/i) != -1)
  alert('Your browser is too old for this website. Please upgrade your browser. ');
}
}

function OldBrowser()
{
var Browser = navigator.appName;
var Version = navigator.appVersion;

if (Browser.search(/Microsoft/i) != -1)
{
 if ( Version.search(/MSIE 6/i) != -1)
   return(true);
 else
   return(false); 
}
else
  return(false);
}

function myHeight()
{
	
  var Height = 0;
  
  if( typeof( window.innerWidth ) == 'number' ) 
  {
    //Non-IE
    Height = window.innerHeight;
  } 
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
  {
    //IE 6+ in 'standards compliant mode'
    Height = document.documentElement.clientHeight;
  } 
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
  {
    //IE 4 compatible
    Height = document.body.clientHeight;
  }
  return(Height);
  
  
}

function myWidth()
{
	
  var Width = 0;
  
  if( typeof( window.innerWidth ) == 'number' ) 
  {
    //Non-IE
    Width = window.innerWidth;
  } 
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
  {
    //IE 6+ in 'standards compliant mode'
    Width = document.documentElement.clientWidth;
  }
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
  {
    //IE 4 compatible
    Width = document.body.clientWidth;
  }
 
  return(Width);
}

function myAspect()
{
  var Aspect = window.screen.width / window.screen.height;
  return(Aspect);
}

function ElasticWrapper()
{

window.moveTo(0,0);
window.resizeTo(window.screen.width,window.screen.height);

var x = myWidth();
var y = myHeight();
 
WrapperHeight = Math.max(Math.round(y - (y * ( (1.2 * 2)/100))),599);
WrapperWidth = Math.round(1.33 * WrapperHeight);
FontSz = WrapperHeight / 8.5;
SideMargin = (x - WrapperWidth)/2;

window.document.getElementById("wrapper").style.left =  SideMargin + "px";
window.document.getElementById("wrapper").style.width =  WrapperWidth + "px";
window.document.getElementById("wrapper").style.height =  WrapperHeight + "px";
window.document.getElementById("wrapper").style.fontSize = FontSz + "%";
window.document.getElementById("wrapper").style.lineHeight = "1.3em";

}

// end of common code

function ElasticPage()
{

ElasticWrapper(); 

if (navigator.appName.search(/Microsoft/i) != -1)
{
 if ( navigator.appVersion.search(/MSIE 6/i) != -1)
 {
  window.document.getElementById("main").style.paddingTop =  "2%";
 }
 else
 {
   window.document.getElementById("main").style.paddingTop =  "2%";
 }
}
else
{
   window.document.getElementById("main").style.paddingTop =  "0%";
}
}
 
function FixedPage(WrapperHeight)
{
var AvailHt = window.screen.availHeight;
var AvailWdth = window.screen.availWidth;
var ScreenHt = window.screen.height;
var ScreenWdth = window.screen.width;

 ScreenAspect = ScreenWdth / ScreenHt; 

  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

window.moveTo(0,0);
window.resizeTo(ScreenWdth,ScreenHt);

WrapperHt = Math.max(Math.round(myHeight - (myHeight * ( (1.2 * 2)/100))),599);
WrapperWidth = Math.round(1.33 * WrapperHt);
FontSz = WrapperHt / 8.5;
SideMargin = (myWidth - WrapperWidth)/2;
MainX = SideMargin + 0.18 * WrapperWidth;
setCookie('MainX',MainX,null);
window.document.getElementById("wrapper").style.left =  SideMargin + "px";
window.document.getElementById("wrapper").style.width =  WrapperWidth + "px";
window.document.getElementById("wrapper").style.height =  WrapperHeight + "px";
window.document.getElementById("wrapper").style.fontSize = FontSz + "%";
window.document.getElementById("wrapper").style.lineHeight = "1.3em";
 

if (navigator.appName.search(/Microsoft/i) != -1)
{
 if ( navigator.appVersion.search(/MSIE 6/i) != -1)
 {
  window.document.getElementById("main").style.paddingTop =  "2%";
 }
 else
 {
   window.document.getElementById("main").style.paddingTop =  "2%";
 }
}
else
{
   window.document.getElementById("main").style.paddingTop =  "0%";
}

return(WrapperHt);
}
