
function moSlideshow( slideshowElementName, slidshowName, pauseImg, playImg )
{

	this.slideElement = slideshowElementName;
	this.name = slidshowName;
	this.xmlHttp;
	this.myTimer = 0; 
	this.size = 0; 
	this.isflv = false;
	this.items = new Array();
	this.count = 0;
	this.pauseImg = pauseImg;
	this.playImg = playImg;
	
	this.addSlide = function (slideUrl, slideDesc){
		var slide = {
			url:slideUrl,
			desc:slideDesc
		}
		this.items[this.size] = slide;
		this.size++;
		
	}
	
	this.display = function (content)
	{
	
        document.getElementById(this.slideElement).innerHTML = content;
        document.getElementById(this.name+"_desc").innerHTML = this.getCurrentDesc();
        
	}

	this.showFlv = function (){
	    clearTimeout(this.myTimer);
	     var a = this.getCurrentUrl().split(':');
	        so.addVariable('flvUrl', a[1]);
	        so.write(this.slideElement); 
	}
	
	this.getCurrentUrl = function ()
	{
	    return this.items[this.count].url;
	}
	this.getCurrentDesc = function ()
	{
	    return this.items[this.count].desc;
	}
	
	this.show = function (){
			
	    if(this.getCurrentUrl().indexOf('flv')!=-1)
	        this.showFlv();
	    else
	        this.showImage();
	}
	
	this.showImage = function (){
		this.display('<img src="'+this.getCurrentUrl()+'" alr="'+this.getCurrentDesc()+'" />');
	}
	
	this.next = function ()
	{
	    this.stopAutomato();
	    this.count++;
	    if (this.count>=this.size) this.count=0;
	    this.show();
	    return false;
	}
	
	this.prev = function ()
	{
	    this.stopAutomato();
	    this.count=this.count-1;
	    if (this.count<0) this.count=this.size-1;
	    this.show();
	    return false;
	}
	
	this.startAutomato = function (){
			clearTimeout(this.myTimer); 
			this.count++;
	    if (this.count>=this.size) this.count=0;
	    this.show();
	    this.myTimer=window.setTimeout(this.name+".startAutomato()",3000);
	}
	
	this.stopAutomato = function (){
		document.getElementById(this.name+"_icon").src = this.playImg;
	  clearTimeout(this.myTimer); 
	  this.myTimer = 0;
	}
	
	this.automato = function ()
	{
	    if ((this.myTimer == 0)||(this.myTimer == null)){
				this.startAutomato();
	    	document.getElementById(this.name+"_icon").src = this.pauseImg;
	    	
	    } else {
				this.stopAutomato();
			}
	    return false;
	}
	
	this.createXMLHttpRequest = function () {
			var xmlHttp;
	    if (window.ActiveXObject) {
	        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	    } 
	    else if (window.XMLHttpRequest) {
	        xmlHttp = new XMLHttpRequest();
	    }
	    return xmlHttp;
	}
	    
	this.startRequest = function () {
	    var xmlHttp = this.createXMLHttpRequest();
	    xmlHttp.onreadystatechange = function (){
	    	
	    	if(xmlHttp.readyState == 4) {
	    	alert(xmlHttp.responseText);
	        if(xmlHttp.status == 200) {
	            this.display(xmlHttp.responseText);    
	        }
	    	}
			}//this.handleStateChange;
	    
	    xmlHttp.open("GET", this.getCurrentUrl(), true);
	    xmlHttp.send(false);
			
	}
	
}
