//ROLLOVER RELATED
///////////////////////////
var over = new Object();
var out = new Object();
function addRollovers(idArr) {
	var imgs, a;

	if (!document.images) return;

	for (i = 0; i < idArr.length; i++) {
		imgs = getObj(idArr[i]);
		if (!imgs) continue;
		a = imgs.parentNode;
		if (a && a.tagName == 'A'){
			over[ idArr[i] ] = new Image();
			out[ idArr[i] ] = new Image();
			over[ idArr[i] ].src = getRollSrc(imgs.src,"gif",1);
			out[ idArr[i] ].src = imgs.src;
			a.onmouseover = function() { this.childNodes[0].src = over[this.childNodes[0].id].src; }
			a.onfocus = function() { this.childNodes[0].src = over[this.childNodes[0].id].src; }
			a.onmouseout = function() { this.childNodes[0].src = out[this.childNodes[0].id].src; }
			a.onblur = function() { this.childNodes[0].src = out[this.childNodes[0].id].src; }
		}
	}
}
function getRollSrc(src, ext, hover) {
	return (hover) ? src.replace("a."+ext,"b."+ext) : src.replace("b."+ext,"a."+ext);
}


//GENERAL PURPOSE FUNCTIONS
///////////////////////////

var wini; //Reference to a window
function PopWin(url, name, width, height) {
	h = (height) ? height : 500;
	w = (width) ? width : 600;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =  'height='+ h +',width='+ w +',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable';
	wini = window.open(url,name,settings);
	if (wini) wini.focus();
	return ( !wini )
}// PopWin()

function addEvent(obj,evType,fn){
	if(obj.addEventListener){
		obj.addEventListener(evType,fn,false);
		return true;
	}
	else if(obj.attachEvent){
		var r=obj.attachEvent("on"+evType,fn);
		return r;
	}
	else{
		eval("obj.on"+evType+ " = " + fn);
		return true;
	}
}

function getObj(name, ref) {
  if (document.getElementById) {
  	this.obj = document.getElementById(name);
		if(this.obj) 
			this.style = document.getElementById(name).style;
  }
  else if (document.all) {
		this.obj = document.all[name];
		if(this.obj)
			this.style = document.all[name].style;
  }
  else if (document.layers) {
   	this.obj = document.layers[name];
		if(this.obj)
	   	this.style = document.layers[name];
  }
	return this.obj; //secondary functionality returns reference to obj
}

function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

//****************************
//** FROM: somewhere. Seen these functions elsewhere too many times to properly credit
//***************************
function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}

// EP added href stuff 10/30/05
function ImgRotator (objId,speed)
{
	this.objId = objId; // VARIABLE SHOULD BE NAMED THIS AS WELL
	this.obj = getObj(objId);
	this.speed = speed;
	this.ImgSrc = new Object();
	this.ImgAlt = new Object();
	// href
	this.href = new Object(); 
	this.curIndex =  0;
	this.count = 0;
	this.started = false;
	this.preloaded = false;
	// href
	if (this.obj) { this.addImage(this.obj.src,this.obj.alt,this.obj.href);	this.curIndex++; }
}

var IR = ImgRotator.prototype;

// href
IR.addImage = function(source,alt,href) { this.ImgSrc[this.count] = source; this.ImgAlt[this.count] = alt; this.href[this.count++] = href;}
IR.preloadImages = function() { for(i=0;i < this.count;i++) { var img= new Image(); img.src = this.ImgSrc[i]; } this.preloaded = true; }
IR.beginSlideShow = function() { if (!this.obj) return; this.started = true; setInterval("eval("+this.objId+").showImage()",this.speed);}
IR.showImage = function () { 
	if (this.obj.parentNode) {
		this.obj.parentNode.style.backgroundImage = 'url('+this.obj.src+')';
	}
	this.obj.title = this.ImgAlt[this.curIndex];
	this.obj.alt = this.ImgAlt[this.curIndex];
	this.obj.src = this.ImgSrc[this.curIndex];
	// href
	var lnk = getObj("rotLink1");
	if(lnk.tagName == 'A')
		lnk.href = this.href[this.curIndex];
	this.curIndex++; this.curIndex %= this.count;
	fadeIn(this.objId,0);
}


