/*
	allows for multiple actions to be added to the window.onload event
	without overwriting the existing event contents

	called as
	addOnLoadAct(functionName);
	NOTE: do not include () in the function name 
*/

function addOnLoadAct(fNewOnLoad){	
	// save the existing onload event(s)
	var fCurrentOnLoad = window.onload;
	// if the existing onload does not have a function ...
	if (typeof window.onload != 'function'){
		// give it this function
		window.onload = fNewOnLoad;
	}else{
		// else add the new function to the existing function
		window.onload = function(){
			fCurrentOnLoad();
			fNewOnLoad();
		}
	}
}

var sTemp;

function getTop(obj){
	yPos = eval(obj).offsetTop;
	tempEl = eval(obj).offsetParent;
	while (tempEl != null) {
		yPos += tempEl.offsetTop;
		tempEl = tempEl.offsetParent;
	}
return yPos;
}

function getLeft(obj){
	xPos = eval(obj).offsetLeft;
	tempEl = eval(obj).offsetParent;
	while (tempEl != null) {
		xPos += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
	}
return xPos;
}


function imageSwap(objImg, sVer){
	if(sVer.toLowerCase()=='over'){
		objImg.src=objImg.src.replace(/_on|_hv|_nm/i,'_hv');
	}else{
		objImg.src=sTemp
	}
}


function showForm(objImg,sFormName){
	objImg.src=objImg.src.replace(/_on|_hv|_nm/i,'_on');
	sTemp=objImg.src;
	document.forms[sFormName].parentNode.parentNode.style.visibility='visible';
	setTimeout("document.forms['" + sFormName + "'].elements[0].focus()",1);
}

function hideForm(sImgId, sFormName){
	document.images[sImgId].src=document.images[sImgId].src.replace(/_on|_hv|_nm/i,'_nm');
	document.forms[sFormName].parentNode.parentNode.style.visibility='hidden';
}

function clickHandle(){
	hideForm('imgSearch','frmSearchIFIC');
	hideForm('imgMember','frmMemberLogin');
}


function imageStat(imgName, imgAlt, sUrl){
	this.imgName=imgName;
	this.imgAlt=imgAlt;
	this.sUrl= (sUrl ? sUrl : '')
}



var arrImgRotator=new Array()
var sRoot='/comp';
var iX=0;
var rPID;
function imageRotator(iPos,iDelay){
	if(iPos && iPos<arrImgRotator.length && iPos>=0){
		iX=iPos;
		
	}
	var localDelay=6000;
	if(iDelay){
		localDelay=iDelay*1000;
	}
	
	if(arrImgRotator.length){
		var obj=document.getElementById('rotator')
		swapfade(obj, sRoot+'/images/en/'+arrImgRotator[iX].imgName, '2', arrImgRotator[iX].imgAlt);
		localUrl=arrImgRotator[iX].sUrl;
		document.getElementById('rotator').onclick= function () {window.location=localUrl; }
		iX++;
		if(iX >arrImgRotator.length-1){
			iX=0
		}
		rPID=setTimeout('imageRotator()',localDelay);
	}
}

function createImagePointers(){
	var str='';
	for(x=1; x<arrImgRotator.length+1;x++){
		str+='<div class="imgID" onmouseover="this.className=\'imgIDover\'" onmouseout="this.className=\'imgID\'" onclick="rPID=clearTimeout(rPID);imageRotator(' + --x + ',15)">' + ++x + '</div>';
	}
	document.getElementById('divImageKey').innerHTML=str;
}

function initImageRotator(){
	document.getElementById('rotator').onclick= function () {window.location=arrImgRotator[0].sUrl;}
	createImagePointers();
	rPID=setTimeout('imageRotator()',1);
}


