// 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 WrapperHt()
{
  var y = myHeight();
 
  WrapperHeight = Math.max(Math.round(0.94 * y),560);
  return(WrapperHeight);
}


function ElasticWrapper()
{

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

var x = myWidth();
var WrapperHeight = WrapperHt();

WrapperWidth = Math.max(Math.round(1.5 * WrapperHeight),980);
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.4 * WrapperHt);
FontSz = WrapperHt / 8.5;
SideMargin = (myWidth - 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";
 

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

function CommonInit()
{
var AvailHt = window.screen.availHeight;
var AvailWdth = window.screen.availWidth;
var ScreenHt = window.screen.height;
var ScreenWdth = window.screen.width;

Aspect = ScreenWdth / ScreenHt;
window.moveTo(0,0);
window.resizeTo(ScreenWdth,ScreenHt);

if (ScreenWdth > 1024)
{
  Aspect = 1.3333;
  myWidth = 1150;
  myHeight = 847;
  FontSz = myHeight / 9;
}
else
{
  Aspect = 1.3333;
  myWidth = 944;
  myHeight = 591;
  FontSz = myHeight / 8;
}

window.document.getElementById("wrapper").style.width = myWidth + "px";
window.document.getElementById("wrapper").style.fontSize = FontSz + "%";
window.document.getElementById("wrapper").style.lineHeight = 1.6 * FontSz + "%";
  
}

