

// ROTATING FEATURE
	//Requires
		//jquery	
		//functions:

		function ClassRotatingFeature(strInstName){
			
			//defaults
			this.strInstName = strInstName;
			this.intTimedRotation = null;//seconds. If not set then there will be no timer by default.						
			this.objDivContainer = null;
			this.objTimer = null;

			this.Init = function() {
			    //default values				
			    this.objDivContainer = (this.objDivContainer == null) ? $j(".RotatingFeature:not(.cb,fc):eq(0)").get(0) : this.objDivContainer;
			    this.AttachEvents();
			    var intTimedRotation = parseInt(this.intTimedRotation);
			    this.intTimedRotation = (isNaN(intTimedRotation)) ? 0 : intTimedRotation * 1000//user specifies seconds	
			    this.SetTimer();
			}
			this.AttachEvents = function(){	
			//thumbnails 
				//a onmouseover="objRotatingFeature1.Show(event,this,'1.jpg');" 
				$j(this.objDivContainer).find(".ThumbnailDescription").parents("a").bind("mouseover",{objInst:this},function(e){
                    e.data.objInst.Show(e,this);																
				});
				//a onmouseout="objRotatingFeature1.SetTimer()"
				$j(this.objDivContainer).find(".ThumbnailDescription").parents("a").bind("mouseout",{objInst:this},function(e){
                    e.data.objInst.SetTimer();																
				});	
				
			//large image
				//a onmouseout="objRotatingFeature1.SetTimer()"
				$j(this.objDivContainer).find(".LargeImageDescription").parents("a").bind("mouseout",{objInst:this},function(e){
                    e.data.objInst.SetTimer();																
				});
				//a onmouseover="objRotatingFeature1.Stop();"
				$j(this.objDivContainer).find(".LargeImageDescription").parents("a").bind("mouseover",{objInst:this},function(e){
                    e.data.objInst.Stop();																
				});				
				
			}
			this.Show = function(e,objA){
				this.Stop();		
												
				//set link
				var strThumbnailHref = objA.href;
				$j(this.objDivContainer).find(".LargeImage").parent("a")[0].href = strThumbnailHref;
				
				//set image src
				var strImage = $j(objA).find(".Thumbnail")[0].src;				
				$j(this.objDivContainer).find(".LargeImage")[0].src = strImage;												
				
				//set alt and long desc	
				var strThumbnailAlt = $j(objA).find(".Thumbnail")[0].alt;
				$j(this.objDivContainer).find(".LargeImage")[0].alt = strThumbnailAlt;									
				
				var strThumbnailLongDesc = $j(objA).find(".Thumbnail")[0].longDesc;
				$j(this.objDivContainer).find(".LargeImage")[0].longDesc = strThumbnailLongDesc;								
				
				//set text
				var strThumbnailDescription = $j(objA).find(".LargeDescription")[0].innerHTML;
				$j(this.objDivContainer).find(".LargeImageDescription .ImageDescPadding")[0].innerHTML = strThumbnailDescription;

				//remove previous pointer
				$j(this.objDivContainer).find(".ThumbnailList li").removeClass("SelectedImage");

				//selection pointer
				var objLi = objA.parentNode;
				$j(objLi).addClass("SelectedImage");
				
				
			}
			this.SetTimer = function(){
				if(this.intTimedRotation > 0){
				//get index for new object to be shown
					var objLi = $j(this.objDivContainer).find(".ThumbnailList li");					
					var objSelected = objLi.filter(".SelectedImage");
					var intIndex =  objLi.index(objSelected);
					var objLiLength = objLi.length;					
					intIndex = ((intIndex + 1) < objLiLength)?intIndex + 1:0;
					
				//get new selected object
					var objA = objLi.filter(":eq(" + intIndex + ")").find("a")[0];
																		 
					var objInst = this;
					var e = null;
				//set timer to show new object
					this.objTimer = setTimeout(function(){objInst.Show(e,objA); objInst.SetTimer();},this.intTimedRotation,objInst,e,objA);
					
				}
			}
			this.Stop = function(){
				if(this.objTimer){
					clearTimeout(this.objTimer);
				}
			}
		}

			