// JavaScript Document
var SliderPointer = 0;
  				var Carousel = function(Container, ElementWidth, ElementHeight, Show, Delay){
  						/* Define some variables to use later */
  						var ISObj = this;
  						this.Container = document.getElementById(Container);
  						this.ElementWidth = ElementWidth;
  						this.ElementHeight = ElementHeight;
  						this.Show = Show;
  						this.Busy = false;
  						this.InactiveDelay = Delay*1000;
  						
  						
  						/* Define the array to hold the banners in the scroll */
  						this.CarouselArray = new Array();
  						this.Banner = function(Src, Href, Alt){
								this.Src = Src;
								this.Href = Href;
								this.Alt = Alt;
								this.Height = ISObj.ElementHeight;
								this.Width = ISObj.ElementWidth;
  						};
  						
  						/* Function to add banners to the array */
  						this.AddBanner = function(Src, Href, Alt){
					      this.NewBanner = new this.Banner(Src, Href, Alt);
								this.CarouselArray.push(this.NewBanner);							  
  						}
  						this.AddLeftControl = function(Src, Height, Width){  
								Height = typeof(Height) != 'undefined' ? Height : 180;
								Width = typeof(Width) != 'undefined' ? Width : 15;
							  this.LeftControl = document.createElement("img");
							  this.LeftControl.src = Src;
							  this.LeftControl.alt = "move right";
							  this.LeftControl.height = Height;
							  this.LeftControl.width = Width;
							  
  						}
  						this.AddRightControl = function(Src, Height, Width){  
								Height = typeof(Height) != 'undefined' ? Height : 180;
								Width = typeof(Width) != 'undefined' ? Width : 15;
							  this.RightControl = document.createElement("img");
							  this.RightControl.src = Src;
							  this.RightControl.alt = "move right";
							  this.RightControl.height = Height;
							  this.RightControl.width = Width;
  						}
  						
  						/* Function to draw the scroll */
  						this.Draw = function(){
								var LC_Container = document.createElement("div");
								LC_Container.id = "LeftControl";
								
								var LC_Link = document.createElement("a");
								LC_Link.className = "ImgScroll_link";
								LC_Link.ElementWidth = this.ElementWidth;
								
								/* deal with click on Left Control Element - ie move the images to the left */	
								LC_Link.onclick = function(){
								   window.clearInterval(Inactive);
									 if (ISObj.Busy){
									 		return;
									 }
									 else{
						 			    ISObj.Busy = true;
						 			   this.elemwidth = document.getElementById("ImgScroller").style.width;
						 			   this.elemsize = this.elemwidth.substring(0, (this.elemwidth.length-2));
						 			   this.elemsize = parseInt(this.elemsize) + (ISObj.ElementWidth+4);
						 			   document.getElementById("ImgScroller").style.width = this.elemsize+"px";
						 			   
						 			    document.getElementById("ImgScroller").insertBefore(document.getElementById("ImgScroller").lastChild.cloneNode(true),document.getElementById("ImgScroller").firstChild);
						 			    document.getElementById("ImgScroller").style.width = this.elemsize+"px";
											this.scrollposstr = document.getElementById("ImgScroller").style.left;
						 			   	this.scrollposstr = this.scrollposstr.substring(0, (this.scrollposstr.length-2));
						 			   	this.scrollpos = parseInt(this.scrollposstr) - (ISObj.ElementWidth+4);
						 			   	document.getElementById("ImgScroller").style.left = this.scrollpos +"px";
				   				    new Effect.Move("ImgScroller",{x:(ISObj.ElementWidth+4), duration:1, afterFinish:function(){
				   				     
			   				      document.getElementById("ImgScroller").removeChild(document.getElementById("ImgScroller").lastChild);
						 			   	this.elemwidth = document.getElementById("ImgScroller").style.width;
						 			   	this.elemsize = this.elemwidth.substring(0, (this.elemwidth.length-2));
						 			   	this.elemsize = parseInt(this.elemsize) - (ISObj.ElementWidth+4);
						 			   
				   				    ISObj.Busy = false;
				   				    SliderPointer--;
				   				    Inactive = setInterval(
								function(){
									 if (ISObj.Busy){
									 		return;
									 }
									 else{
						 			   ISObj.Busy = true;
						 			   this.elemwidth = document.getElementById("ImgScroller").style.width;
						 			   this.elemsize = this.elemwidth.substring(0, (this.elemwidth.length-2));
						 			   this.elemsize = parseInt(this.elemsize) + (ISObj.ElementWidth+4);
						 			   document.getElementById("ImgScroller").style.width = this.elemsize+"px";
						 			   
						 			   document.getElementById("ImgScroller").appendChild(document.getElementById("ImgScroller").firstChild.cloneNode(true));
		 			 				    new Effect.Move("ImgScroller",{x:-(ISObj.ElementWidth+4), duration:1, afterFinish:function(){
											SliderPointer++;											
											document.getElementById("ImgScroller").removeChild(document.getElementById("ImgScroller").firstChild);
						 			   	this.elemwidth = document.getElementById("ImgScroller").style.width;
						 			   	this.elemsize = this.elemwidth.substring(0, (this.elemwidth.length-2));
						 			   	this.elemsize = parseInt(this.elemsize) - (ISObj.ElementWidth+4);
						 			    document.getElementById("ImgScroller").style.width = this.elemsize+"px";
											this.scrollposstr = document.getElementById("ImgScroller").style.left;
						 			   	this.scrollposstr = this.scrollposstr.substring(0, (this.scrollposstr.length-2));
						 			   	this.scrollpos = parseInt(this.scrollposstr) + (ISObj.ElementWidth+4);
						 			   	document.getElementById("ImgScroller").style.left = this.scrollpos +"px";
						 			   	
											ISObj.Busy = false;	
												}});				   				    
									 }
							   },ISObj.InactiveDelay);
											 }});
											 
									 }
								}
								LC_Link.appendChild(this.LeftControl);
								LC_Container.appendChild(LC_Link);
								this.Container.appendChild(LC_Container);								
								var SlideContainer = document.createElement("div");
								SlideContainer.id = "Slider";
								SlideContainer.style.width = (this.Show * (this.ElementWidth+4)) + "px";
								SlideContainer.style.height = (this.ElementHeight + 20)+ "px";
								var ImageContainer = document.createElement("div");
								ImageContainer.id = "ImgScroller";
								ImageContainer.style.height = (this.ElementHeight + 20)+ "px";	
								ImageContainer.style.width = (this.CarouselArray.length * (this.ElementWidth+4)) + "px";									
								//ImageContainer.style.width = "auto";
								ImageContainer.style.position = "relative";							
								for (var BannerIndex = 0; BannerIndex<this.CarouselArray.length; BannerIndex++){
										var BannerContainer = document.createElement("div");
										BannerContainer.style.width = (this.ElementWidth+4)+"px";
										BannerContainer.className = "BannerContainer";
										BannerContainer.style.textAlign = "center";												
										var BannerImg = document.createElement("img");
										var BannerTxt = document.createTextNode(this.CarouselArray[BannerIndex].Alt);
										var Break = document.createElement("br");										
										BannerImg.src = this.CarouselArray[BannerIndex].Src;
										BannerImg.alt = this.CarouselArray[BannerIndex].Alt;
										BannerImg.height = this.CarouselArray[BannerIndex].Height;
										BannerImg.width = this.CarouselArray[BannerIndex].Width;
										BannerImg.style.border = "none";										
										var BannerLink = document.createElement("a");
										BannerLink.href = this.CarouselArray[BannerIndex].Href;
										BannerLink.appendChild(BannerImg);
										BannerLink.appendChild(Break);
										BannerLink.appendChild(BannerTxt);
										BannerContainer.appendChild(BannerLink)
										ImageContainer.appendChild(BannerContainer);
					/*					if (BannerIndex == this.CarouselArray.length--){
											 ImageContainer.insertBefore(ImageContainer.firstChild, BannerContainer);
										}*/
								}
								ImageContainer.style.left = -(this.ElementWidth+4)+"px";
								SlideContainer.appendChild(ImageContainer);
								this.Container.appendChild(SlideContainer);
								var RC_Container = document.createElement("div");
								RC_Container.id = "RightControl";
								
								var RC_Link = document.createElement("a");
								RC_Link.className = "ImgScroll_link";
								RC_Link.ElementWidth = this.ElementWidth;
								
								/* deal with click on Left Control Element - ie move the images to the left */	
								RC_Link.onclick = function(){
								   clearInterval(Inactive);
									 if (ISObj.Busy){
									 		return;
									 }
									 else{
						 			   ISObj.Busy = true;
						 			   this.elemwidth = document.getElementById("ImgScroller").style.width;
						 			   this.elemsize = this.elemwidth.substring(0, (this.elemwidth.length-2));
						 			   this.elemsize = parseInt(this.elemsize) + (ISObj.ElementWidth+4);
						 			   document.getElementById("ImgScroller").style.width = this.elemsize+"px";
						 			   
						 			   document.getElementById("ImgScroller").appendChild(document.getElementById("ImgScroller").firstChild.cloneNode(true));
		 			 				    new Effect.Move("ImgScroller",{x:-(ISObj.ElementWidth+4), duration:1, afterFinish:function(){
											SliderPointer++;											
											document.getElementById("ImgScroller").removeChild(document.getElementById("ImgScroller").firstChild);
						 			   	this.elemwidth = document.getElementById("ImgScroller").style.width;
						 			   	this.elemsize = this.elemwidth.substring(0, (this.elemwidth.length-2));
						 			   	this.elemsize = parseInt(this.elemsize) - (ISObj.ElementWidth+4);						 			   	
						 			    document.getElementById("ImgScroller").style.width = this.elemsize+"px";
											this.scrollposstr = document.getElementById("ImgScroller").style.left;
						 			   	this.scrollposstr = this.scrollposstr.substring(0, (this.scrollposstr.length-2));
						 			   	this.scrollpos = parseInt(this.scrollposstr) + (ISObj.ElementWidth+4);
						 			   	document.getElementById("ImgScroller").style.left = this.scrollpos +"px";
						 			   
											ISObj.Busy = false;
											Inactive = setInterval(
											function(){
	 								if (ISObj.Busy){
									 		return;
									 }
									 else{
						 			   ISObj.Busy = true;
						 			   this.elemwidth = document.getElementById("ImgScroller").style.width;
						 			   this.elemsize = this.elemwidth.substring(0, (this.elemwidth.length-2));
						 			   this.elemsize = parseInt(this.elemsize) + (ISObj.ElementWidth+4);
						 			   document.getElementById("ImgScroller").style.width = this.elemsize+"px";
						 			   
						 			   document.getElementById("ImgScroller").appendChild(document.getElementById("ImgScroller").firstChild.cloneNode(true));
		 			 				    new Effect.Move("ImgScroller",{x:-(ISObj.ElementWidth+4), duration:1, afterFinish:function(){
											SliderPointer++;											
											document.getElementById("ImgScroller").removeChild(document.getElementById("ImgScroller").firstChild);
						 			   	this.elemwidth = document.getElementById("ImgScroller").style.width;
						 			   	this.elemsize = this.elemwidth.substring(0, (this.elemwidth.length-2));
						 			   	this.elemsize = parseInt(this.elemsize) - (ISObj.ElementWidth+4);						 			   	
						 			    document.getElementById("ImgScroller").style.width = this.elemsize+"px";
											this.scrollposstr = document.getElementById("ImgScroller").style.left;
						 			   	this.scrollposstr = this.scrollposstr.substring(0, (this.scrollposstr.length-2));
						 			   	this.scrollpos = parseInt(this.scrollposstr) + (ISObj.ElementWidth+4);
						 			   	document.getElementById("ImgScroller").style.left = this.scrollpos +"px";
						 			   
											ISObj.Busy = false;	
												}});
				   				    
									 }
							   },ISObj.InactiveDelay);	
												}});				   				    
									 }
							  }				
								RC_Link.appendChild(this.RightControl);
								RC_Container.appendChild(RC_Link);
								this.Container.appendChild(RC_Container);
								var Inactive = setInterval(
								function(){
									 if (ISObj.Busy){
									 		return;
									 }
									 else{
						 			   ISObj.Busy = true;
						 			   this.elemwidth = document.getElementById("ImgScroller").style.width;
						 			   this.elemsize = this.elemwidth.substring(0, (this.elemwidth.length-2));
						 			   this.elemsize = parseInt(this.elemsize) + (ISObj.ElementWidth+4);
						 			   document.getElementById("ImgScroller").style.width = this.elemsize+"px";
						 			   
						 			   document.getElementById("ImgScroller").appendChild(document.getElementById("ImgScroller").firstChild.cloneNode(true));						 			   
		 			 				    new Effect.Move("ImgScroller",{x:-(ISObj.ElementWidth+4), duration:1, afterFinish:function(){
											SliderPointer++;											
											document.getElementById("ImgScroller").removeChild(document.getElementById("ImgScroller").firstChild);
						 			   	this.elemwidth = document.getElementById("ImgScroller").style.width;
						 			   	this.elemsize = this.elemwidth.substring(0, (this.elemwidth.length-2));
						 			   	this.elemsize = parseInt(this.elemsize) - (ISObj.ElementWidth+4);						 			   	
						 			    document.getElementById("ImgScroller").style.width = this.elemsize+"px";
											this.scrollposstr = document.getElementById("ImgScroller").style.left;
						 			   	this.scrollposstr = this.scrollposstr.substring(0, (this.scrollposstr.length-2));
						 			   	this.scrollpos = parseInt(this.scrollposstr) + (ISObj.ElementWidth+4);
						 			   	document.getElementById("ImgScroller").style.left = this.scrollpos +"px";
						 			   
											ISObj.Busy = false;	
												}});
				   				    
									 }
							   },ISObj.InactiveDelay);
  						}
  						
  				}

