//
// VARIABLES
//

// Updated
var vis, invis;
var pageWidth = 0;
var bodyWidth;
var marginWidth;

//
// FUNCTIONS
//

function objChangeClass(id,newclass)
{
  document.getElementById(id).className = newclass;
}

// Open a window
function openWindow(href,name)
{
  window.open(href,name,'toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,resizable=no,width=500,height=400');
}

function openWindowSize(href,name,w,h)
{
  window.open(href,name,'toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,resizable=no,width='+w+',height='+h);
}

// Load an image
function loadImage (name,path)
{
  eval(name+"= new Image();");
  eval(name+".src = '"+path+"';");
}

function changeImage(layer,name,obj)
{
  if (document.images)
  {
    if (document.layers && layer!=null)
      eval('document.'+layer+'.document.images["'+name+'"].src = '+obj+'.src');
    else
      document.images[name].src = eval(obj+".src");
  }
}

// Netscape resize bug fix
function NSresize() 
{
  if (document.FIX.NSfix.initWindowWidth != window.innerWidth || document.FIX.NSfix.initWindowHeight != window.innerHeight)
    document.location = document.location;
}

function NSCheck()
{
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4))
  {
    if (typeof document.FIX == 'undefined')
      document.FIX = new Object;
    if (typeof document.FIX.FIX_scaleFont == 'undefined')
    {
      document.FIX.NSfix = new Object;
      document.FIX.NSfix.initWindowWidth = window.innerWidth;
      document.FIX.NSfix.initWindowHeight = window.innerHeight;
    }
    window.onresize = NSresize;
  }
}

function getWidth()
{
  if (is.NS) pageWidth = window.innerWidth;
  if (is.IE) pageWidth = document.body.clientWidth;
}

function getMarginWidth()
{
  getWidth();
  if (pageWidth <= 0) marginWidth = 0;
  else marginWidth = (pageWidth-bodyWidth)/2;
  if (marginWidth < 0) marginWidth = 0;
}

function setMarginWidth(w)
{
  marginWidth=w;
}

function setBodyWidth(w)
{
  bodyWidth=w;
}

function onResize()
{
  //if (!is.IE) location.reload();
  winResize();
}	

// Check browser and set up layer call
function getBrowser ()
{ 
  this.NS = false;
  this.NS6 = false;
  this.IE = false;
  this.DOM = false;

  this.agent = navigator.userAgent.toLowerCase();
  this.major = parseInt(navigator.appVersion);
  this.minor = parseFloat(navigator.appVersion);
  this.opera = (this.agent.indexOf('opera') != -1);
  
  if (document.all) 
  {
    this.IE=true;
    vis="visible";
    invis="hidden";
  }
  
  if (document.layers)
  {
    this.NS=true;
    this.IE=false;
    vis="show";
    invis="hide";
  }

  if (document.getElementById) 
  {
	if (!this.opera)
      this.DOM=true;
    invis ="hidden";
    vis = "visible";
  }

  if (this.DOM == true && navigator.appName =="Netscape")
  {
    this.NS = true;
    this.NS6 = true;
  }
}

//
// NEW FUNCTIONS
//

// Utility function to trim spaces from both ends of a string
function Trim(inString) {
  var retVal = "";
  var start = 0;
  while ((start < inString.length) && (inString.charAt(start) == ' ')) {
    ++start;
  }
  var end = inString.length;
  while ((end > 0) && (inString.charAt(end - 1) == ' ')) {
    --end;
  }
  retVal = inString.substring(start, end);
  return retVal;
}

function Is() {
agent = navigator.userAgent.toLowerCase();
this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);
this.ns = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer')
== -1)
     && (agent.indexOf('compatible') ==  -1)));
this.ns2 = (this.ns && (this.major == 3));
this.ns3 = (this.ns && (this.major == 3));
this.ns4b = (this.ns && (this.major == 4) && (this.minor <= 4.03));
this.ns4 = (this.ns && (this.major == 4));
this.ns6 = (this.ns && (this.major >= 5));
this.opera = (agent.indexOf("opera") != -1);
this.ie = (agent.indexOf("msie") != -1 && !this.opera);
this.ie3 = (this.ie && (this.major < 4));
this.ie4 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0")
 == -1));
this.ie5 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0")
 != -1));
this.ie55 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.5")
 != -1));
this.ie6 = (this.ie && (agent.indexOf("msie 6.0")!=-1) );
this.aol = (agent.indexOf("aol") != -1);
this.aol3 = (this.aol && this.ie3);
this.aol4 = (this.aol && this.ie4);
this.aol5 = (this.aol && this.ie5);
}

var is2 = new Is();

function displayBrowser()
{
  document.write("agent = ",agent,"<br>");
  document.write(".major = ",is2.major,"<br>");
  document.write(".minor = ",is2.minor,"<br>");
  document.write(".ns = ",is2.ns,"<br>");
  document.write(".ns2 = ",is2.ns2,"<br>");
  document.write(".ns3 = ",is2.ns3,"<br>");
  document.write(".ns4b = ",is2.n4b,"<br>");
  document.write(".ns4 = ",is2.ns4,"<br>");
  document.write(".ns6 = ",is2.ns6,"<br>");
  document.write(".opera = ",is2.opera,"<br>");
  document.write(".ie = ",is2.ie,"<br>");
  document.write(".ie3 = ",is2.ie3,"<br>");
  document.write(".ie4 = ",is2.ie4,"<br>");
  document.write(".ie5 = ",is2.ie5,"<br>");
  document.write(".ie55 = ",is2.ie55,"<br>");
  document.write(".ie6 = ",is2.ie6,"<br>");
  document.write(".aol = ",is2.aol,"<br>");
  document.write(".aol3 = ",is2.aol3,"<br>");
  document.write(".aol4 = ",is2.aol4,"<br>");
  document.write(".aol5 = ",is2.aol5,"<br>");
}

function winResize() {
if(is2.ns4 ||is2.ns6||is2.ie4||is2.ie5||is2.ie55||is2.ie6) {
history.go(0);
}
}

//
// MAIN
//

// get browser
is = new getBrowser();

// Fix Netscape Resize Bug
NSCheck();

// End

