/* begin: CRgb class def */
	function CRgb(r,g,b){
		// constructor for a CRbg object
		this.r=r; this.g=g; this.b=b;			
		this.toString=_toString; 
		this.blendTo=_blendTo;
	}		
	function _toString(){return _rgb(this.r,this.g,this.b);}			
	function _blendTo(rgb){					
		var c=10;
		
		var boolRed		= _blurComp(this.r,rgb.r,c);
		var boolGreen	= _blurComp(this.g,rgb.g,c);
		var boolBlue	= _blurComp(this.b,rgb.b,c);
		
		if (boolRed && boolGreen && boolBlue){
			return false;
		}else{
			if (!boolRed){ 
				if (rgb.r<this.r) this.r-=c; 
				else if (rgb.r>this.r) this.r+=c;
			}
			if (!boolGreen){
				if (rgb.g<this.g) this.g-=c; 
				else if(rgb.g>this.g) this.g+=c;
			}
			if (!boolBlue){
				if (rgb.b<this.b) this.b-=c; 
				else if(rgb.b>this.b) this.b+=c;
			}
			
			return true;
		}
		
	}
	function _blurComp(x,y,c){
		var diff = Math.abs(x-y);
		if (diff <= c) return true;
		else return false;		
	}
	function _rgb(r,g,b){var sz="#"; return sz.concat(_hexChar(r)+_hexChar(g)+_hexChar(b));}				
	function _hexChar(i){szOut="00";szOut=szOut.concat(i.toString(16));	szOut=szOut.substr(szOut.length-2,2);return szOut;}
/* end: CRgb class def */

var _activeJob=null;	// This is needed because timer events do not include an object context.
						// This means that no more than one CFadeJob (or equivalent) can fun at the same time.
var _hTimer=0;

/* begin: CRedirectJob */	
	function CRedirectJob(szURL,iDelay){
		this.url=szURL;
		this.delay=iDelay;
		this.doJob=_starttimer;	
	}	
	function _starttimer(){
		if (this.delay>0) window.setTimeout(_redirect,this.delay); return;					
	}
	function _redirect(){
		window.location.replace(szHomePage); return;		
	}
/* end: CRedirectJob */

/* begin: CNoItalicsJob */
	function CNoItalicsJob(szObj,nextJob){
		this.obj=document.getElementById(szObj);
		this.nextJob=nextJob;
		this.doJob=_changeFont;
	}
	function _changeFont(){
		this.obj.style.fontStyle="normal";
		if (this.nextJob!=null) this.nextJob.doJob();
		return;
	}
/* end: CNoItalicsJob */

/* begin: CHideJob */
	function CHideJob(szObj,nextJob){
		this.obj=document.getElementById(szObj);
		this.nextJob=nextJob;
		this.doJob=_hide;
	}
	function _hide(){
		this.obj.style.display="none";
		if (this.nextJob!=null) this.nextJob.doJob();
		return;
	}
/* end: CHideJob */

/* begin: CPauseJob */
	function CPauseJob(iDelay, nextJob){
		this.delay=iDelay;
		this.nextJob=nextJob
		this.doJob=___start;
	}
	function ___start(){			
		_activeJob=this;		
		window.setTimeout(_cont,this.delay);return;
	}
	function _cont(){
		if(_activeJob.nextJob!=null){
			_activeJob=_activeJob.nextJob;
			_activeJob.doJob();
		}
	}		
/* begin: CPauseJob */

/* begin: CVRightJob class def */

	function CVRightJob(szObj, xEnd, iSpeed, nextJob){
		var obj=document.getElementById(szObj);
		this.obj=obj;
		this.xStart=parseInt(obj.style.left);
		this.xEnd=xEnd;
		this.speed=iSpeed;
		this.hTimer=0;
		this.nextJob=nextJob;
		this.doJob=__start;
	}
	function __start(){
		_activeJob=this;
		_activeJob.obj.style.display="";
		_activeJob.hTimer=window.setInterval(_doSlide, _activeJob.speed);
		return;	
	}	
	function _doSlide(){				
		try{
			var c=20; var bQuit=false;
			if (_blurComp(_activeJob.xStart,_activeJob.xEnd,c)){
				_activeJob.xStart=_activeJob.xEnd;
				bQuit=true;				
			}else{
				if (_activeJob.xStart<_activeJob.xEnd) _activeJob.xStart+=c;
				else if(_activeJob.xStart>_activeJob.xEnd) _activeJob.xStart=-c;				
			}	
			
			_activeJob.obj.style.zIndex=110;
			_activeJob.obj.style.left=_activeJob.xStart.toString()+"px";
			
			if (bQuit){
				window.clearInterval(_activeJob.hTimer);
				_activeJob.hTimer=0;
				
				if (_activeJob.nextJob!=null){
					_activeJob=_activeJob.nextJob;
					_activeJob.doJob();
				}			
			}
			
			return;			
		}catch(e){
			alert(e);
			window.clearInterval(_activeJob.hTimer);
			return;
		}
	}

/* end: CVRightJob class def */

/* begin: CFadeJob class def */
	
		
	function CFadeJob(szObj, rgbStart, rgbEnd, iFadeSpeed, nextJob){
		this.obj=document.getElementById(szObj);			
		this.rgbStart=new CRgb(rgbStart.r,rgbStart.g,rgbStart.b);
		this.rgbEnd=rgbEnd;
		this.speed=iFadeSpeed;
		this.nextJob=nextJob;
		this.hTimer=0;					
		this.doJob=_start;										
	}
	function _start(){
		_activeJob=this
		_activeJob.obj.style.display="";
		_activeJob.hTimer=window.setInterval(_doFade, _activeJob.speed);
		return;	
	}
		
	function _doFade(){						
		try{				
			if (_activeJob.rgbStart.blendTo(_activeJob.rgbEnd)){ 	
				_activeJob.obj.style.color=_activeJob.rgbStart.toString();
				_activeJob.obj.style.zIndex=100;
			}else{
				window.clearInterval(_activeJob.hTimer);
				_activeJob.obj.style.color=_activeJob.rgbEnd.toString();
				_activeJob.hTimer=0;
				
				// finished so start next job is applicable					
				if (_activeJob.nextJob!=null) {						
					_activeJob=_activeJob.nextJob;
					_activeJob.doJob();					
				}
			}
			
		} catch(e) {
			// shut down the timer
			window.clearInterval(_activeJob.hTimer);								
			return;
		}			
		return;
	}
/* end: CFadeJob class def */

function moveElementOffscreenLeft(szElement,szParent){
	var obj=document.getElementById(szElement);
	if (obj==null) return false;
	
	var cx=new Number(parseInt(obj.style.width)+20);	//extra pixels for good measuer
	var x=new Number(-1 * cx);
	
	if(szParent!=null){
		var objP=document.getElementById(szParent);
		if (objP!=null){
			x -= parseInt(objP.style.left);			
		}	
	}

	obj.style.left=x.toString()+"px";
	return true;
}

function centerElement(szElement, bAllowNegative){			
	var obj=document.getElementById(szElement);
	if (obj==null) return false;		
	
	var cxWindow=new Number((thisbrowser.isns)?window.innerWidth:window.document.body.offsetWidth);
	var cyWindow=new Number((thisbrowser.isns)?window.innerHeight:window.document.body.offsetHeight);
	
	var cx=new Number(parseInt(obj.style.width));
	var cy=new Number(parseInt(obj.style.height));		
	
	var x=new Number((cxWindow.valueOf()-cx.valueOf())/2);
	var y=new Number((cyWindow.valueOf()-cy.valueOf())/2);
	
	if (bAllowNegative==false){
		if (x.valueOf()<0)x=0;
		if (y.valueOf()<0)y=0;
	}
	
	obj.style.left=x.toString()+"px";
	obj.style.top=y.toString()+"px";
	
	return true;
}

function centerChildElement(szChild, szParent){
	centerChildElementX(szChild,szParent);
	centerChildElementY(szChild,szParent);
}	

function centerChildElementX(szChild, szParent){
	var objChild=document.getElementById(szChild);
	if (objChild==null) return false;
	
	var objParent=document.getElementById(szParent);
	if (objParent==null) return false;
	
	var cxp=new Number(parseInt(objParent.style.width));
	var cx=new Number(parseInt(objChild.style.width));
	var x=new Number((cxp.valueOf()-cx.valueOf())/2);
	
	objChild.style.left=x.toString()+"px";
	return true;
}

function centerChildElementY(szChild, szParent){
	var objChild=document.getElementById(szChild);
	if (objChild==null) return false;
	
	var objParent=document.getElementById(szParent);
	if (objParent==null) return false;
	
	var cyp=new Number(parseInt(objParent.style.height));
	var cy=new Number(parseInt(objChild.style.height));
	var y=new Number((cyp.valueOf()-cy.valueOf())/2);
			
	objChild.style.top=y.toString()+"px";
	return true;
}

