function faSlideShow()
{
	this.ContainerImage = null;
	this.TotalImages = function (){return this.ImageAray.length;}
	this.ImageAray = new Array();
	this.Iterval = 0;
	this.intervalObj = null;
	this.Index = -1;
	this.Attempts = 0;
	this.isPlay = false;
	this.newImage = null;
	
	this.SetInterval = function (newInterval)
	{
		this.Iterval = newInterval;
	}
	
	this.checkStatus = function ()
	{
		if(this.ImageAray.length ==0)
		{
			return false;
		}
		return true;
	}
	
	this.setNextIndex = function ()
	{
		var i = this.Index;
		i++;
		this.Index = i== this.TotalImages()?0:i;
	}
	
	this.setPreviousIndex = function ()
	{
		var i = this.Index;
		i--;
		this.Index = i<0?this.TotalImages()-1:i;
	}
	
	this.Start= function ()
	{
		if(this.checkStatus() )
		{
			if(this.isPlay == false)
			{
				this.isPlay = true;
				this.Next();
			}
		}
	}
	this.Pause = function ()
	{
		clearTimeout(this.TimeoutObj);
		this.isPlay = false;
	}
	
	
	this.resizeImage = function( srcImage ){
		var viewport = getViewport();
			
		var w = srcImage.width;
		var h = srcImage.height;

		var vh	=	viewport.height - 400; 
		var vw	=	viewport.width  - 400;
		
		
		if( w > 735 || h > 500 ){
			if( w > 735 && w > h){
				srcImage.style.width  = "735px";
				srcImage.style.height = "auto";
			}
			else if( h > 500 && h > w ){
				srcImage.style.height = "500px";
				srcImage.style.width  = "auto";
			}
		}
		
		//$(image).fade({duration:1.0 , from:0,to:1,afterFinish:function(){}});

		//$(srcImage).fade({duration:0.2,from:1,to:0});
		
	}
	
	this.ShowImage = function ()
	{
		
		this.Attempts++
		if(this.Attempts > 110)
		{
			clearTimeout(this.TimeoutObj);
			this.TimeoutObj =	window.setTimeout("thisc.Next();", this.Iterval);
			this.Attempts = 0;
		}
		
 		var srcImage = this.ImageAray[this.Index];
 		if(srcImage.id == 'ads')
 		{
 			document.getElementById('adsHolder').style.display = 'inline';
 			document.getElementById('slideshow_image_info').style.display = 'none';
 			document.getElementById('slideshow_image').style.display = 'none';
 		}
 		else
 		{
 			document.getElementById('adsHolder').style.display = 'none';
 			document.getElementById('slideshow_image_info').style.display = 'block';
 			document.getElementById('slideshow_image').style.display = 'block';
 		}
 		
 		if(srcImage.complete)
		{
			
			//this.resizeImage(srcImage);
			
			var viewport = getViewport();
			
			var w = srcImage.width;
			var h = srcImage.height;
	
			var vh	=	viewport.height - 400; 
			var vw	=	viewport.width  - 400;
			
			
			if( w > 735 || h > 500 ){
				if( w > 735 && w > h){
					srcImage.style.width  = "735px";
					srcImage.style.height = "auto";
				}
				else if( h > 500 && h > w ){
					srcImage.style.height = "500px";
					srcImage.style.width  = "auto";
				}
			}
			
			//$(image).fade({duration:1.0 , from:0,to:1,afterFinish:function(){}});
			
			var self = this;
	
			//$(srcImage).setOpacity(0.1);
				
			if(self.newImage){
				self.ContainerImage.removeChild(self.newImage);//.innerHTML = '';
			}
			
			self.newImage = self.ContainerImage.appendChild(srcImage);
			self.InfoDiv.innerHTML = self.ImageInfoAray[self.Index];
				
				
				//$(srcImage).fade({duration:2,from:0.1,to:1,afterFinish:function(){
			if(self.isPlay ){
				 	clearTimeout(self.TimeoutObj);
					thisc = self;
					if(self.Iterval < 15000 && srcImage.id == 'ads')
		 			{
		 				self.TimeoutObj =	window.setTimeout("thisc.Next();", 15000);
		 			}
					else
					{
						self.TimeoutObj =	window.setTimeout("thisc.Next();", self.Iterval);
					}
			}
				//}});

			
			
		}
		else
		{
			thisc = this;
			this.TimeoutObj =	setTimeout("thisc.ShowImage()",  1*1000);
		}
		
	}
	
	
	this.Previous = function ()
	{
		if(this.checkStatus() )
		{
			clearTimeout(this.TimeoutObj);
			this.setPreviousIndex();
			this.ShowImage();
		}
	}
	
	this.Next = function ()
	{
		if(this.checkStatus() )
		{
			
			clearTimeout(this.TimeoutObj);
			this.setNextIndex();
			this.ShowImage();
		}
	}
	
	this.Stop = function ()
	{
		window.close();
	}
}

function callRegisterVisit(registerType, registerId)
{
	xajax_registerVisit(registerType, registerId);
}
