///////////////////////////////////////////////////////////////////////
//     This fade library was designed by Erik Arvidsson for WebFX    //
//                                                                   //
//     For more info and examples see: http://webfx.eae.net          //
//     or contact Erik at http://webfx.eae.net/contact.html#erik     //
//                                                                   //
//     Feel free to use this code as long as this disclaimer is      //
//     intact.                                                       //
//                                                                   //
//     Last updated: 2000-11-22                                      //
///////////////////////////////////////////////////////////////////////

window.status = "Loading fade package...";

var fadeSteps = 4;
var fademsec = 75;


var fadeArray = new Array();

function fade(el, fadeIn, steps, msec) {

	if (steps == null) steps = fadeSteps;
	if (msec == null) msec = fademsec;
	
	if (el.fadeIndex == null)
		el.fadeIndex = fadeArray.length;
	fadeArray[el.fadeIndex] = el;
	
	if (el.fadeStepNumber == null) {
		if (el.style.visibility == "hidden")
			el.fadeStepNumber = 0;
		else
			el.fadeStepNumber = steps;
		if (fadeIn) {
			el.style.filter = "Alpha(Opacity=0)";
			el.style.MozOpacity = 0;
		}
		else {
			el.style.filter = "Alpha(Opacity=70)";
			el.style.MozOpacity = 0.7;
		}
	}
			
	window.setTimeout("repeatFade(" + fadeIn + "," + el.fadeIndex + "," + steps + "," + msec + ")", msec);
}

function repeatFade(fadeIn, index, steps, msec) {	
	el = fadeArray[index];
	
	c = el.fadeStepNumber;
	if (el.fadeTimer != null)
		window.clearTimeout(el.fadeTimer);
	if ((c == 0) && (!fadeIn)) {
		el.style.visibility = "hidden";
//		el.style.filter = "";
		return;
	}
	else if ((c==steps) && (fadeIn)) {	//Done fading in!
		el.style.filter = "Alpha(Opacity=70)";
		el.style.MozOpacity = 0.7;
		el.style.visibility = "visible";
		return;
	}
	else {
		(fadeIn) ? 	c++ : c--;
		el.style.visibility = "visible";
		el.style.filter = "Alpha(Opacity=" + 70*c/steps + ")";
		el.style.MozOpacity = c / 8;

		el.fadeStepNumber = c;
		el.fadeTimer = window.setTimeout("repeatFade(" + fadeIn + "," + index + "," + steps + "," + msec + ")", msec);
	}
}


function SetImageSize (curImg, viewWidth, viewHeight)
{
     var scale = 1.0;
     var width, height;

     width = curImg.width;
     height = curImg.height;

     var xscale=viewWidth/width;
     var yscale=viewHeight/height;
     if (parseFloat(xscale) > parseFloat(yscale))
     {
          scale = yscale;
      width = parseInt(width*scale);
      height = parseInt(height*scale);
      }
      else
      {
         scale = xscale;
      width = width*scale;
      height = height*scale;
      }
      curImg.width = width;
      curImg.height = height;
}
var myWidth=800;
var myHeight=600;
function WindowSize()
{
	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;
	}
}

function GetWindowHeight () {
    WindowSize();
	return (myHeight-20);
}
function GetWindowWidth () {
    WindowSize();
	return (myWidth);
}

window.status = window.defaultStatus;
