function $(aId){
	return document.getElementById(aId);
}

function $$(vParentNode, vTagName){
	var vNodes = [];
	if(vParentNode.getElementsByTagName){
		vNodes = vParentNode.getElementsByTagName(vTagName);
	}
	
	return vNodes;
}

function isNull(aVar){
	var vIsNull = true;
	if(aVar != null){
		vIsNull = false;
	}
	return vIsNull;
}

function printNode( aNode ){
	return new XMLSerializer().serializeToString(aNode);
}

function getURL(aUrl, aCallback){
	SF.XMLHttpRequestHandler(aUrl, "GET", aCallback);
};

function postURL(aUrl, aCallback){
	SF.XMLHttpRequestHandler(aUrl, "POST", aCallback);
}

function parseXML(aXmlString, aXmlDocument, aAsync){
	aAsync = (aAsync != null && aAsync == true)?true:false;
	if (window.ActiveXObject){
		aXmlDocument=new ActiveXObject("Microsoft.XMLDOM");
		aXmlDocument.async = aAsync;
		aXmlDocument.loadXML(aXmlString);
	}
	else if(window.DOMParser){
		var vDomParser = new DOMParser();
		vDomParser.async = aAsync?true:false;
		aXmlDocument = vDomParser.parseFromString(aXmlString,"text/xml");
	}

	return aXmlDocument;
}

//
//	Set up String object properties/methods
//
String.empty = "";

String.prototype.toFcUpperCase = function(){
	return this.replace(/\b./g, function(s){return s.toUpperCase();});
};

String.prototype.toCamelCase = function(){
	var vString = this.replace(/\b./g, function(s){return s.toUpperCase();});
	vString = vString.stripSpaces();
	return vString.substring(0, 1).toLowerCase() + vString.substring(1);
};

String.prototype.toProperName = function(){
	return this.toLowerCase().replace(/\b./g, function(s){return s.toUpperCase();});
};

String.prototype.getCharsCount = function(aChars){
	var vCount = this.length;
	var vString = this.toString();
	if(aChars){
		var vArray = vString.split(aChars);
		vCount = vArray.length - 1;
	}
	
	return vCount;
};

String.prototype.trim = function(){
	var vString = this.toString();
	if(window._isAVGInstalled){
		var vRegExp = new RegExp("^[ \\n\\t\\r\\u00A0]");
		while(vString.match(vRegExp)){
			vString = vString.replace(vRegExp, String.empty);
		}
		vRegExp = new RegExp("[ \\n\\t\\r\\u00A0]$");
		while(vString.match(vRegExp)){
			vString = vString.replace(vRegExp, String.empty);
		}
	}
	else{
		vString = vString.replace(/^\s+/, String.empty);
		vString = vString.replace(/\s+$/, String.empty);
	}
	
	return vString;
};

String.prototype.stripSpaces = function(){
	var vString = this.toString();
	var vRegExp = new RegExp("[ \\n\\r\\u00A0]", "gi");
	vString = vString.replace(vRegExp, String.empty);
	
	return vString;
};

String.prototype.stripWhitespace = function(){
	var vString = this.toString();
	var vRegExp = new RegExp("([\\t\\n\\r]+)|((  )+)", "gi");
	vString = vString.replace(vRegExp, String.empty);
	
	return vString;
};

String.prototype.startsWith = function(aSearchParam){
	var exists = false;
	
	if(aSearchParam){
		var vString = this.toString();
		var vRegExp = new RegExp(".*\/.*", "gi");
		vString.replace(vRegExp, "\/");
		vRegExp = new RegExp(".*\..*", "gi");
		vString.replace(vRegExp, "\.");

		vRegExp = new RegExp("^" + aSearchParam);
		exists = (vString.search(vRegExp) > -1 )?true:false;
	}

	return exists;
};

String.prototype.endsWith = function(aSearchParam){
	var exists = false; 
	
	if(aSearchParam){
		var vString = this.toString();
		var vRegExp = new RegExp(".*\/.*", "gi");
		vString.replace(vRegExp, "\/");
		vRegExp = new RegExp(".*\..*", "gi");
		vString.replace(vRegExp, "\.");
		
		vRegExp = new RegExp(aSearchParam + "$");
		exists = (vString.search(vRegExp) > -1 )?true:false;
	}
	
	return exists;
};

Array.prototype.duplicate = function(){
	return this.slice(0);
}

//set up the RD object
if(!window.SF){
	window.SF = {};
}

if(!SF){
	SF = {};
}

SF.XMLHttpRequestHandler = function(aUrl, aAction, aCallback, aType, aEnc, aAsync){
	aAction = aAction?aAction:"GET";
	aAsync = (aAsync != null && aAsync == true)?true:false;
	var vXmlHttp = null;

	if(window.XMLHttpRequest){
		vXmlHttp = new XMLHttpRequest();
	}
	else{
		  try {
			  vXmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
		  }
		  catch(err){
			  try{
				  vXmlHttp=new ActiveXObject("Msxml2.XMLHTTP")
			  }
			  catch(err){}
		  }
	}

	if(vXmlHttp){
		vXmlHttp.open(aAction, aUrl, aAsync);
		if(aAction.toLowerCase() == "post"){
			if(aEnc){ vXmlHttp.setRequestHeader("Content-Encoding", aEnc); }
			if(aType){ vXmlHttp.setRequestHeader("Content-Type", aType); }
		}
		
		var vErrorMsg = String.empty;
		
		if(aAsync){
			vXmlHttp.onreadystatechange = function(){
				SF.XMLHttpRequestStateChange(vXmlHttp, aCallback );
			};
		}
		
		try{
			vXmlHttp.send(null);
		}
		catch(e){
			//this will catch file not found errors
			vErrorMsg = e.message;
			vXmlHttp.abort();
		}
		
		if(!aAsync){
			SF.XMLHttpRequestStateChange(vXmlHttp, aCallback );
		}
	}
};

SF.XMLHttpRequestStateChange = function(aXmlHttp, aCallback){
	if(aXmlHttp.readyState==4){
		if(aCallback){
			var vStatus = {};
			if(aXmlHttp.status == 200){
				vStatus.success = true;
				vStatus.responseXML = aXmlHttp.responseXML;
				vStatus.responseText = aXmlHttp.responseText;
				vStatus.contentType = aXmlHttp.getResponseHeader("Content-Type");
			}
			else{
				vStatus.success = false;
				vStatus.responseXML = aXmlHttp.responseXML;
				vStatus.responseText = aXmlHttp.responseText;
				vStatus.contentType = aXmlHttp.getResponseHeader("Content-Type");
			}

			if(typeof(aCallback) == "string"){
				eval(aCallback)(vStatus);
			}
			else{
				if(aCallback.operationComplete){
					aCallback.operationComplete(vStatus);
				}
				else{
					aCallback(vStatus);
				}
			}
		}
	}
};
				
//
//	Helper Methods
//
SF.getUniqueId = function(){
	window._uniqueId = window._uniqueId?window._uniqueId:new Date().getTime() + Math.round(Math.random()*1000);
	window._uniqueId++;

	return window._uniqueId.toString();
};

SF.getCdataSectionNodeList = function(aNode, aGetFirstOnly){
	var vCdataSections = [];
	var vChildNode = null;
	for(var n=0;n<aNode.childNodes.length;n++){
		var vChildNode = aNode.childNodes.item(n);
		if(vChildNode.nodeName.toLowerCase() == "#cdata-section"){
			vCdataSections[vCdataSections.length] = vChildNode;
			if(aGetFirstOnly){
				break;
			}
		}
		else if(vChildNode.childNodes && vChildNode.childNodes.length > 0){
			var vTempCdataSections = SF.getCdataSectionNodeList(vChildNode);
			vCdataSections.concat(vTempCdataSections);
		}
	}
	
	return vCdataSections;
};

SF.getFirstCdataSection = function(aNode){
	var vCdataSection = null;
	var vCdataSections = SF.getCdataSectionNodeList(aNode, true);
	if(vCdataSections.length > 0){
		vCdataSection = vCdataSections[0];
	}
	return vCdataSection;
};

SF.Rect = function( aX, aY, aWidth, aHeight ){
	this.x=aX?parseFloat(aX):0;
	this.y=aY?parseFloat(aY):0;
	this.width=aWidth?aWidth:0;
	this.height=aHeight?aHeight:0;
	this.width=(this.width.toString().indexOf("%") > -1)?this.width:parseFloat(this.width);
	this.height=(this.height.toString().indexOf("%") > -1)?this.height:parseFloat(this.height);
	
	return this;
};

SF.Rect.prototype.constructor = SF.Rect;

SF.Rect.add = function(aRect_A, aRect_B){
	return new SF.Rect(
				(aRect_A.x+aRect_B.x), 
				(aRect_A.y+aRect_B.y),
				(aRect_A.width+aRect_B.width),
				(aRect_A.height+aRect_B.height)
			);
};

SF.Rect.subtract = function(aRect_A, aRect_B){
	return new SF.Rect(
				(aRect_A.x-aRect_B.x), 
				(aRect_A.y-aRect_B.y),
				(aRect_A.width-aRect_B.width),
				(aRect_A.height-aRect_B.height)
			);
};

SF.Rect.prototype.duplicate = function(){
	return new SF.Rect(this.x, this.y, this.width, this.height);
};

SF.Rect.prototype.toSVGPoint = function(){
	var vSVGPoint = SVG_ROOT.createSVGPoint();
	vSVGPoint.x = this.x;
	vSVGPoint.y = this.y;
	
	return vSVGPoint;
};

SF.Rect.prototype.toSVGRect = function(){
	var vSVGRect = SVG_ROOT.createSVGRect();
	vSVGRect.x = this.x;
	vSVGRect.y = this.y;
	vSVGRect.width = this.width;
	vSVGRect.height = this.height;
	
	return vSVGRect;
};

SF.Rect.prototype.toSASize = function(){
	return new SF.Size(this.width, this.height);
};

SF.Rect.prototype.toSAPoint = function(){
	return new SF.Point(this.x, this.y);
};

SF.Rect.prototype.toString=function(){
	return "rect(" + this.x + "," + this.y + "," + this.width + "," + this.height + ")";
};

SF.Size = function( aWidth, aHeight ){
	this.width=aWidth?aWidth:0;
	this.height=aHeight?aHeight:0;
	this.width=(this.width.toString().indexOf("%") > -1)?this.width:parseFloat(this.width);
	this.height=(this.height.toString().indexOf("%") > -1)?this.height:parseFloat(this.height);
	
	return this;
};

SF.Size.prototype.constructor = SF.Size;

SF.Size.add = function(aSize_A, aSize_B){
	return new SF.Size(
				(aSize_A.width+aSize_B.width), 
				(aSize_A.height+aSize_B.height)
			);
};

SF.Size.subtract = function(aSize_A, aSize_B){
	return new SF.Size(
				(aSize_A.width-aSize_B.width),
				(aSize_A.height-aSize_B.height)
			);
};

SF.Size.prototype.subtract = function(aValue){
	this.add(-aValue);
};

SF.Size.prototype.add = function(aValue){
	this.width += aValue;
	this.height += aValue;
};

SF.Size.prototype.duplicate = function(){
	return new SF.Size(this.width, this.height);
};

SF.Size.prototype.toString = function(){
	return "size(" + this.width + "," + this.height + ")";
};

SF.Point = function( aX, aY ){
	this.init(aX, aY);
	
	return this;
};

SF.Point.prototype.constructor = SF.Point;

SF.Point.add = function(aPoint_A, aPoint_B){
	return new SF.Point(
				(aPoint_A.x+aPoint_B.x), 
				(aPoint_A.y+aPoint_B.y)
			);
};

SF.Point.min = function(aPoint_A, aPoint_B){
	return new SF.Point(
				Math.min(aPoint_A.x, aPoint_B.x), 
				Math.min(aPoint_A.y, aPoint_B.y)
			);
};

SF.Point.max = function(aPoint_A, aPoint_B){
	return new SF.Point(
				Math.max(aPoint_A.x, aPoint_B.x), 
				Math.max(aPoint_A.y, aPoint_B.y)
			);
};

SF.Point.subtract = function(aPoint_A, aPoint_B){
	return new SF.Point(
				(aPoint_A.x-aPoint_B.x), 
				(aPoint_A.y-aPoint_B.y)
			);
};

SF.Point.prototype.init = function(aX, aY){
	this.x=aX?parseFloat(aX):0;
	this.y=aY?parseFloat(aY):0;
};

SF.Point.prototype.duplicate = function(){
	return new SF.Point(this.x, this.y);
};

SF.Point.prototype.toSVGPoint = function(){
	var vSVGPoint = SVG_ROOT.createSVGPoint();
	vSVGPoint.x = this.x;
	vSVGPoint.y = this.y;
	
	return vSVGPoint;
};

SF.Point.prototype.toPointString=function(){
	return this.x + "," + this.y;
};

SF.Point.prototype.toString=function(){
	return "point(" + this.x + "," + this.y + ")";
};

SF.Animation = function(aArgs){
	this.init(aArgs);
};

SF.Animation.TYPE = {
	MOVE:0
	,OPACITY:1
	/*
	,SWAP:2
	//,ROTATE:3 -- currently not supported
	*/
};

SF.Animation.STATUS = {
	ERROR:0
	,ON:1
	,OFF:2
	,PAUSED:3
};

SF.Animation.animationObjects = [];

SF.Animation.animate = function(aIndex){
	SF.Animation.animationObjects[aIndex].animate();
}

SF.Animation.prototype.init = function(aArgs){
	/*
	this._pauseAmount = aArgs.pauseAmount?aArgs.pauseAmount:0;
	this._pauseTime = 0;
	*/
	this._index = SF.Animation.animationObjects.length;
	SF.Animation.animationObjects.push(this);
	
	this._intervalId = null;
	this._status = SF.Animation.STATUS.OFF;
	this._statusMessage = String.empty;
	this._alertErrors = (aArgs.alertErrors != null)?aArgs.alertErrors:false;
	this._intervalAmount = aArgs.intervalAmount?aArgs.intervalAmount:33;
	this._startTime = aArgs.startTime?aArgs.startTime:0;
	this._repeatCount = aArgs.repeatCount?aArgs.repeatCount:0;
	this._fill = aArgs.fill?aArgs.fill:"remove";
	this._currentRepeatCount = null;
	this._currentTime = 0;
	this._effectTypes = [];
	
	this._changeAmount = (aArgs.changeAmount != null)?aArgs.changeAmount:[1];
	this._changeStyleProperty = aArgs.changeStyleProperty?aArgs.changeStyleProperty:["left"];
	this._startValue = (aArgs.startValue != null)?aArgs.startValue:[0];
	this._endValue = (aArgs.endValue != null)?aArgs.endValue:[0];
	this._changeNode = aArgs.changeNode;
	this._callback = aArgs.callback;
	
	if(typeof(this._changeAmount) != "object"){
		this._changeAmount = [this._changeAmount];
	}
	if(typeof(this._changeStyleProperty) != "object"){
		this._changeStyleProperty = [this._changeStyleProperty];
	}
	if(typeof(this._startValue) != "object"){
		this._startValue = [this._startValue];
	}
	if(typeof(this._endValue) != "object"){
		this._endValue = [this._endValue];
	}

	for(var n=0;n<this._changeStyleProperty.length;n++){
		switch(this._changeStyleProperty[n]){
			case "opacity":
				this._effectTypes.push(SF.Animation.TYPE.OPACITY);
				break;
			default:
				this._effectTypes.push(SF.Animation.TYPE.MOVE);
				break;
		}
	}
	
	if(this._changeNode){
		if(typeof(this._changeNode) == "string"){
			this._changeNode = $(this._changeNode);
		}
	}
	
	if(!this._changeNode){
		this._status = SF.Animation.STATUS.ERROR;
		this._statusMessage = "Change node does not exist";
	}
};

SF.Animation.prototype.setStyleProperty = function(aProperty, aValue){
	switch(aProperty){
		default:
			if(typeof(aValue) != "string"){
				aValue = aValue.toString() + "px";
				break;
			}
			break;
	}
	
	this._changeNode.style[aProperty] = aValue;
};

SF.Animation.prototype.start = function(){
	if(this._status == SF.Animation.STATUS.ERROR){
		if(this._statusMessage.length > 0 && this._alertErrors){
			alert(this._statusMessage)
		}
	}
	else{
		if(this._currentRepeatCount != null && this._repeatCount != "indefinate"){
			this._currentRepeatCount++;
		}
		else{
			this._currentRepeatCount = 0;
		}
		
		this._status = SF.Animation.STATUS.ON;
		this._currentValue = this._startValue.duplicate();
		this._currentTime = 0;
		
		this.animate(true);
		
		this._intervalId = setInterval("SF.Animation.animate(" + this._index + ")", this._intervalAmount);
	}
};


SF.Animation.prototype.end = function(){
	this._status = SF.Animation.STATUS.OFF;

	if(this._intervalId){
		clearInterval(this._intervalId);
	}
	
	if(this._fill != "freeze"){
		this._status = SF.Animation.STATUS.ON;
		this._currentValue = this._startValue.duplicate();
		this._currentTime = 0;
		
		this.animate(true);

		this._status = SF.Animation.STATUS.OFF;
	}
	this.animateCallback();
};

SF.Animation.prototype.animate = function(aInit){
	var vEnd = true;
	
	if((this._currentTime >= this._startTime/* || aInit*/) && this._status == SF.Animation.STATUS.ON){
		var vTempEnd = true;
		for(var n=0;n<this._changeStyleProperty.length;n++){
			switch(this._effectTypes[n]){
				case SF.Animation.TYPE.OPACITY:
					vTempEnd = this.opacity(n, aInit);
					break;
				case SF.Animation.TYPE.MOVE:
					vTempEnd = this.move(n, aInit);
					break;
				default:
					vTempEnd = this.move(n, aInit);
					break;
			}
			
			if(!vTempEnd){
				vEnd = false;
			}
		}
		
		if(vEnd){
			this.end();
		}
	}
	
	this._currentTime += this._intervalAmount;
	
	if(!vEnd){
		this.animateCallback();
	}
	else{
		if(this._repeatCount == "indefinate" || (isNull(this._currentRepeatCount) || this._currentRepeatCount < this._repeatCount)){
			this.start();
		}
	}
};

SF.Animation.prototype.animateCallback = function(){
	if(this._callback){
		this._callback(this);
	}
}

SF.Animation.prototype.opacity = function(aIndex, aInit){
	var vEnd = true;
	var vValue = this._currentValue[aIndex];
	if(aInit){
		vEnd = false;
	}
	else{
		vValue += this._changeAmount[aIndex];
		
		if((this._changeAmount[aIndex] > 0 && vValue >= this._endValue[aIndex]) || (this._changeAmount[aIndex] < 0 && vValue <= this._endValue[aIndex])){
			vValue = this._endValue[aIndex];
		}
		else{
			vEnd = false;
		}
	}

	this._currentValue[aIndex] = vValue;
	this.setOpacity(vValue);

	return vEnd;
};

SF.Animation.prototype.move = function(aIndex, aInit){
	var vEnd = true;
	var vValue = this._currentValue[aIndex];
	if(aInit){
		vEnd = false;
	}
	else{
		vValue += this._changeAmount[aIndex];
		
		if((this._changeAmount[aIndex] > 0 && vValue >= this._endValue[aIndex]) || (this._changeAmount[aIndex] < 0 && vValue <= this._endValue[aIndex])){
			vValue = this._endValue[aIndex];
		}
		else{
			vEnd = false;
		}
	}

	this._currentValue[aIndex] = vValue;
	this.setStyleProperty(this._changeStyleProperty[aIndex], this._currentValue[aIndex]);

	return vEnd;
};

SF.Animation.prototype.getOpacity = function(){
	vOpacityPercent = 0;
	
	if(this._changeNode.filters){
		var vOpacityDegree = this._changeNode.style.filter.toLowerCase().split("(opacity=");
		vOpacityDegree = vOpacityDegree[1].substring(0, vOpacityDegree[1].length-1);
		vOpacityPercent = parseInt(vOpacityDegree, 10);
	}
	else if(this._changeNode.style.KhtmlOpacity != null){
		parseInt(this._changeNode.style.KhtmlOpacity, 10) * .01;
	}
	else{
		vOpacityPercent =  parseInt(this._changeNode.style.MozOpacity, 10) * .01;
	}
	
	return vOpacityPercent;
};

SF.Animation.prototype.setOpacity = function(vOpacityPercent){
	vOpacityPercent = (vOpacityPercent > 0)?vOpacityPercent:0;

	this._changeNode.style.filter="alpha(opacity=" + vOpacityPercent + ")";

	this._changeNode.style.opacity = vOpacityPercent * 0.01;
	this._changeNode.style.KhtmlOpacity = vOpacityPercent * 0.01;
	this._changeNode.style.MozOpacity = vOpacityPercent * 0.01;
};

SF.Rotator = function(aArgs){
	this.init(aArgs);
};

SF.Rotator.prototype.init = function(aArgs){
	this._rect = new SF.Rect(0,0,0,0);
	this._rect.width = aArgs.width?aArgs.width:100;
	this._rect.height = aArgs.height?aArgs.height:100;
	this._slideLeftWidth = aArgs.slideLeftWidth;
	this._tagName = aArgs.tagName;
	this._intervalAmount = (aArgs.intervalAmount != null)?aArgs.intervalAmount:33;
	this._rotateAmount = (aArgs.rotateAmount != null)?aArgs.rotateAmount:1;
	this._pauseAmount = (aArgs.pauseAmount != null)?aArgs.pauseAmount:[0];
    if(typeof(this._pauseAmount) == "number"){
        this._pauseAmount = [this._pauseAmount];
    }
	this._pauseTime = 0;
	this._id = (aArgs.id != null)?aArgs.id:SF.getUniqueId();
	this._currentIndex = 0;
	this._elements = [];
	this._contentNode = $("divContent");
	this._elementsNode = null
	this._selectorId = aArgs.selectorId;
	this._selectors = [];
	this._nextIndex = -1;
	this._slideAnimation = null
	this._fadeAnimation = null;
	this._parentNode = $(aArgs.parentId);

	if(this._parentNode){
		var vObj = this;
		var vOnLoadObj = window.onload;
		window.onload = document.body.onload = function(){
			vObj.load();
			if(vOnLoadObj){
				vOnLoadObj();
			}
		}
		
		this._elementsNode = aArgs.elementsNode;
		
		if(aArgs.htmlContent){
			if(typeof(aArgs.htmlContent) == "string" && aArgs.htmlContent.endsWith(".xml")){
				//don't run in asynchronous mode so we can write to the document
				SF.XMLHttpRequestHandler(aArgs.htmlContent + "?" + new Date().getTime(), "GET", this, null, null, false);
			}
		}
	}
};

SF.Rotator.prototype.load = function(evt){
	var vElement = null;

	var vCount = 0;
	var vTableCells = $$(this._contentNode, "td");
	
	//reverse the order because of how we need to stack the images
	for(var n=this._elementsNode.childNodes.length-1;n>=0;n--){
		vElement = this._elementsNode.childNodes[n];
		
		if(vElement && vElement.nodeName.toLowerCase() == this._tagName.toLowerCase()){
			//were going to store all the elements at load time so we have the order for later use
			
			var vContentNodes = [];
			
			for(var z=0;z<vElement.childNodes.length;z++){
				var vContentNode = vElement.childNodes[z];
				
				if(vContentNode && vContentNode.nodeName.toLowerCase() == this._tagName.toLowerCase()){
					vContentNodes.push(vContentNode);
					//vContentNode.style.cssFloat = "none";
					//vContentNode.style.styleFloat = "none";
					
					if(vContentNodes.length == 2){
						break;
					}
				}
			}
			
			this._elements.push(vContentNodes);
			vTableCells[0].appendChild(vContentNodes[0]);

			if(vCount != this._currentIndex){
				vContentNodes[0].style.display = "none";
				vContentNodes[1].style.visibility = "hidden";
			}

			vCount++;
		}
	}

	if(this._elements.length > 0){
		for(var n=this._elements.length-1;n>=0;n--){
			vTableCells[1].appendChild(this._elements[n][1]);
			if(n < this._elements.length-1){
				this._elements[n][1].style.marginTop = -(this._rect.height) + "px";
			}
		}

		vElement = $(this._selectorId);
		if(vElement){
			this._selectors = $$(vElement, "a");
			
			/* NOT NEEDED ANYMORE
			
			for(var n=0;n<this._selectors.length;n++){
				this._selectors[n].onmouseover = function(evt){
					evt = evt?evt:window.event;
					var vTarget = evt.srcElement?evt.srcElement:evt.currentTarget;
					if(vTarget != window.Rotator._selectors[window.Rotator._currentIndex]){
						if(vTarget.src.indexOf("on.jpg") > -1){
							vTarget.src = vTarget.src.replace("on.jpg", "off.jpg");
						}
						else{
							vTarget.src = vTarget.src.replace("off.jpg", "on.jpg");
						}
					}
					
					window.Rotator.mousedOverTarget = vTarget;
				};
				
				this._selectors[n].onmouseout = function(evt){
					evt = evt?evt:window.event;
					var vTarget = evt.srcElement?evt.srcElement:evt.currentTarget;
					if(vTarget != window.Rotator._selectors[window.Rotator._currentIndex]){
						if(vTarget.src.indexOf("on.jpg") > -1){
							vTarget.src = vTarget.src.replace("on.jpg", "off.jpg");
						}
						else{
							vTarget.src = vTarget.src.replace("off.jpg", "on.jpg");
						}
					}
					
					window.Rotator.mousedOverTarget = null;
				};
			}*/
		}
		
		/////this._selectors[this._currentIndex].src = this._selectors[this._currentIndex].src.replace("off.jpg", "on.jpg");
        //this._selectors[this._currentIndex].setAttribute("class", "tabOn");
        
		this.start();
	}
	else{
		vElement = $(this._selectorId);
		vElement.style.display = "none";
	}
};

SF.Rotator.prototype.operationComplete = function(vStatus){
	if(!vStatus.success){
		this._statusMessage = vStatus.responseText;
		//alert(this._statusMessage)
	}
	else{
		if(vStatus.responseXML && vStatus.responseXML.childNodes.length > 0){
			var vNodeList = vStatus.responseXML.getElementsByTagName("item");
			var vNode = null;
			var vValue = String.empty;

			var vValues = [];
			
			for(var n=0;n<vNodeList.length;n++){
				vNode = vNodeList[n];
		
				if(vNode.nodeName == "item"){
					var vCdataSection = SF.getFirstCdataSection(vNode);
					if(vCdataSection){
						vValues[vValues.length] = vCdataSection.nodeValue;
					}
				}
			}
			
			for(var n=vValues.length-1;n>=0;n--){
				document.write(vValues[n]);
			}
		}
	}
};

SF.Rotator.prototype.setNextIndex = function(aNextIndex){
	if(aNextIndex < this._elements.length && aNextIndex > -1){
		this._nextIndex = aNextIndex;
		
		if(!isNull(this._slideAnimation) && this._slideAnimation._currentTime < this._slideAnimation._startTime){
			this._slideAnimation._currentTime = this._slideAnimation._startTime;
		}
	}
};

SF.Rotator.prototype.setCurrentIndex = function(aCurrentIndex){
	var vPreviousIndex = this._currentIndex;
	if(aCurrentIndex != null){
		if(aCurrentIndex > this._elements.length - 1){
			aCurrentIndex = this._elements.length-1;
		}
		else if(aCurrentIndex < 0){
			aCurrentIndex = 0;
		}
		
		this._currentIndex = aCurrentIndex;
	}

	this._elements[vPreviousIndex][0].style.display = "none";
	this._elements[this._currentIndex][0].style.display = "block";

	this.updateHierarchy(vPreviousIndex);

	this._elements[vPreviousIndex][1].style.visibility = "visible";
	this._elements[this._currentIndex][1].style.visibility = "visible";
	
	if(this.mousedOverTarget != this._selectors[vPreviousIndex]){
		//this._selectors[vPreviousIndex].src = this._selectors[vPreviousIndex].src.replace("on.jpg", "off.jpg");
		this._selectors[vPreviousIndex].setAttribute("class", "tabOff");
		this._selectors[vPreviousIndex].setAttribute("className", "tabOff");
	}
	
	/////this._selectors[this._currentIndex].src = this._selectors[this._currentIndex].src.replace("off.jpg", "on.jpg");
	this._selectors[this._currentIndex].setAttribute("class", "tabOn");
	this._selectors[this._currentIndex].setAttribute("className", "tabOn");
};

SF.Rotator.prototype.updateHierarchy = function(aPreviousIndex){
	var vParentNode = this._elements[0][1].parentNode;
	vParentNode.insertBefore(this._elements[this._currentIndex][1], this._elements[aPreviousIndex][1]);
	
	var vChildNodes = vParentNode.childNodes;
	var vCount = 0;
	for(var n=0;n<vChildNodes.length;n++){
		if(vChildNodes[n].nodeName.toLowerCase() == this._tagName.toLowerCase()){
			if(vCount == 0){
				vChildNodes[n].style.marginTop = "0px";
			}
			else{
				vChildNodes[n].style.marginTop = -(this._rect.height) + "px";
			}
			vCount++;
		}
	}
};

SF.Rotator.prototype.start = function(){
	if(isNull(this._slideAnimation)){
        var vPauseAmount = 0;
        if(this._currentIndex < this._pauseAmount.length){
            vPauseAmount = this._pauseAmount[this._currentIndex];
        }
        else{
            vPauseAmount = this._pauseAmount[this._pauseAmount.length - 1];
        }

		this._slideAnimation = new SF.Animation({
			changeNode:this._elements[this._currentIndex][0]
			,changeStyleProperty:"left"
			,intervalAmount:this._intervalAmount
			,changeAmount:-this._rotateAmount
			,startValue:58
			,endValue:-this._slideLeftWidth
			,startTime:vPauseAmount
			,fill:"freeze"
			,callback:this.onAnimateSlide
			,alertErrors:true
		});
	}
	
	this._slideAnimation.start();
};


SF.Rotator.prototype.end = function(){
	this._slideAnimation.end();
};

SF.Rotator.prototype.onAnimateSlide = function(aAnimate){
	if(aAnimate._status == SF.Animation.STATUS.OFF){
		var vLeft = parseInt(aAnimate._changeNode.style.left, 10);
		
		if( vLeft == -window.Rotator._slideLeftWidth){
			var vCurrentIndex = window.Rotator._currentIndex + 1;
			if(window.Rotator._nextIndex > -1 && window.Rotator._nextIndex != window.Rotator._currentIndex){
				vCurrentIndex = window.Rotator._nextIndex;
				window.Rotator._nextIndex = -1;
			}

			if(vCurrentIndex >= window.Rotator._elements.length){
				vCurrentIndex = 0;
			}

			var vPreviousIndex = window.Rotator._currentIndex;
			
			window.Rotator.setCurrentIndex(vCurrentIndex);
			
			aAnimate._startValue = [-window.Rotator._slideLeftWidth];
			aAnimate._endValue = [58];
			aAnimate._changeAmount = [window.Rotator._rotateAmount];
			aAnimate._startTime = 0;
			aAnimate._changeNode = window.Rotator._elements[window.Rotator._currentIndex][0];

			if(isNull(window.Rotator._fadeAnimation)){
				window.Rotator._fadeAnimation = new SF.Animation({
					changeNode:window.Rotator._elements[vPreviousIndex][1]
					,changeStyleProperty:"opacity"
					,intervalAmount:window.Rotator._intervalAmount
					,changeAmount:-5
					,startValue:100
					,endValue:0
					,startTime:0
					,fill:"none"
					,callback:window.Rotator.onAnimateFade
				});
			}
			else{
				window.Rotator._fadeAnimation._endValue = [0];
				window.Rotator._fadeAnimation._startTime = 0;
				window.Rotator._fadeAnimation._changeNode = window.Rotator._elements[vPreviousIndex][1];
			}
			window.Rotator._fadeAnimation.start();
		}
		else{
			var vPauseAmount = 0;
			if(window.Rotator._currentIndex < window.Rotator._pauseAmount.length){
				vPauseAmount = window.Rotator._pauseAmount[window.Rotator._currentIndex];
			}
			else{
				vPauseAmount = window.Rotator._pauseAmount[window.Rotator._pauseAmount.length - 1];
			}
		
			aAnimate._startValue = [58];
			aAnimate._endValue = [-window.Rotator._slideLeftWidth];
			aAnimate._changeAmount = [-window.Rotator._rotateAmount];
			aAnimate._startTime = vPauseAmount;
		}
		
		aAnimate.start();
	}
};

SF.Rotator.prototype.onAnimateFade = function(aAnimate){
	if(aAnimate._status == SF.Animation.STATUS.OFF){
		aAnimate._changeNode.style.visibility = "hidden";
	}
};
