/*================================*/
/* Process Information            */
/*================================*/

var fadetimer = new Array();
fadetimer['steps_up'] = 4;
fadetimer['speed_up'] = 20;
fadetimer['steps_down'] = 3;
fadetimer['speed_down'] = 20;
var today = new Date();

var activeFloater = new Object;
var prev = new Object();
var blinked = false;

//STANDARD WIPE EFFECTS CONTROLS
var slider = new Array();
var slstep = 24; //number of steps to animate
var slwait = 15; //milliseconds between states


/*================================*/
/* My Junk                        */
/*================================*/

//browsercheck code by Javier Peletier (peletier.com) with adaptations
//Creates an "is" array with browser information for various functions
function BrowserCheck() {
  var b = navigator.appName
  if (b=="Netscape") this.b = "ns"
  else if (b=="Microsoft Internet Explorer") this.b = "ie"
  else this.b = b
  this.a = navigator.userAgent
  this.version = navigator.appVersion
  this.v = parseInt(this.version)
  this.ns = (this.b=="ns" && this.v>=4)
  this.ns4 = (this.b=="ns" && this.v==4)
  this.ns5 = (this.b=="ns" && this.v==5)
  this.ns6 = (this.b=="ns" && this.v>=6)
  this.ie = (this.b=="ie" && this.v>=4)
  this.ie4 = (this.version.indexOf('MSIE 4')>0)
  this.ie5 = (this.version.indexOf('MSIE 5')>0)
  this.ie6 = (this.version.indexOf('MSIE 6')>0)
  this.opera = (this.a.indexOf('Opera')>0) 
  this.min = (this.ns||this.ie)
}
is = new BrowserCheck();

//Corrects PNG transparency rendering
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
   {
   for(var i=0; i<document.images.length; i++)
      {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }
   }
window.attachEvent("onload", correctPNG);


//ANIMATION: Reveals a hidden object, usually a <div> element
function showup(obj) {
  clearTimeout(slider[obj.id]);
  if (!obj.sldpos) { obj.sldpos = 0; }
  obj.width = obj.offsetWidth;
  obj.height = obj.offsetHeight;
  if (obj.sldpos<slstep) {
    d = Math.sin(Math.PI*obj.sldpos++/slstep/2);
    obj.style.clip="rect(0 "+(obj.width*d)+" "+(obj.height*d)+" 0)";
    slider[obj.id] = setTimeout("showup("+obj.id+");",slwait);
    obj.style.visibility = "visible";
  } else {
    obj.style.clip="rect(0 auto auto 0)";
    obj.sldpos = 0;
  }
}

//ANIMATION: Hides an object, usually a <div> element
function wipeout(obj) {
  clearTimeout(slider[obj.id]);
  if (!obj.sldpos) { obj.sldpos = 0; }
  obj.width = obj.offsetWidth;
  obj.height = obj.offsetHeight;
  if (obj.sldpos<slstep) {
    d = (-1*Math.sin(Math.PI*obj.sldpos++/slstep/2))+1;
    obj.style.clip="rect(0 "+(obj.width*d)+" "+(obj.height*d)+" 0)";
    slider[obj.id] = setTimeout("wipeout("+obj.id+");",slwait);
  } else {
    obj.style.visibility = "hidden";
    obj.style.clip="rect(0 auto auto 0)";
    obj.sldpos = 0;
  }
}

//ANIMATION: Slides an object to a target, usually a <div> element
function slideto(obj, tgt) {
  clearTimeout(slider[obj.id]);
  if (!obj.sldpos) { obj.sldpos = 0; obj.start = obj.offsetTop; }
  obj.topat = obj.offsetTop;
  if (obj.sldpos<slstep) {
    d = Math.sin(Math.PI*obj.sldpos++/slstep/2);
    obj.style.top = obj.start+(tgt-obj.start)*d;
    //alert(obj.style.top);
    slider[obj.id] = setTimeout("slideto("+obj.id+","+tgt+");",slwait);
  } else {
    obj.style.top = tgt;
    obj.sldpos = 0;
  }
}

//POPUP: Opens a reference in a popup window
function view(ref) {
  Viewer = window.open(ref,"Viewer","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700,height=500,screenX=10,screenY=10")
/*
  self.Viewer.document.open()
  self.Viewer.document.write(baseHTML)
  self.Viewer.document.close() */
}

//ANIMATION: Follows a list of dynamic anchors with thumbnails
function chase(prey) {
  t = document.body.scrollTop + 200;
  if (prey) {
    chase_img.src = prey;
    chase_txt.innerText = event.srcElement.innerText;
    
  }
  t = (t<400?t=400:t);
  clearTimeout(slider[chaser.id]);
  slider[chaser.id] = setTimeout("slideto(chaser,"+t+");",200);
}
