function NMCSlider ()
{
	this.position = 1;
	this.divScroll = null;	
	this.articles = new Array();
	this.dpe1 = "";
	this.dpe2 = "";
	this.onSlide = null;
	this.panArticle1 = null;
	this.panArticle2 = null;
	
	
	
	this.SetCurrentArticle = function(articleID)
	{
		this.articles.push(articleID);
	}
	

	this.BrowseBack = function()
	{
	
		if (this.articles.length > 1)
		{
			this.articles.pop();
			var articleID = this.articles[this.articles.length-1];	
			this.articles.pop();
			this.BrowseArticle(articleID);
			
		}
	}
	
	this.IsArticleSameAsCurrent = function(articleID)
	{
	    isSame = false;
	    if(this.articles.length > 0)
	    {
	    
	        var currentArticleID = this.articles[this.articles.length-1];
	        
	        if(currentArticleID == articleID)
	            isSame = true;
	            
	    }
	    
	    return isSame;
	}
		
	function InitSlideShow(panArticle)
	{	

	    if (panArticle.innerHTML == "")
	    {
	        setTimeout(function(){ InitSlideShow(panArticle); }, 500);
	    }
	    else
	    {
    		
		    // Init image slideshow
		    var startIndex = panArticle.innerHTML.indexOf("// Image slideshow script starts");
		    var endIndex = panArticle.innerHTML.indexOf("// Image slideshow script ends");
		    if (startIndex > -1 && endIndex > startIndex)
		    {
		        eval(panArticle.innerHTML.substring(startIndex, endIndex));
		    }
		    
	    }

	}
    
    function InitLightBox(panArticle)
    {

	    if (panArticle.innerHTML == "")
	    {
	        setTimeout(function(){ InitLightBox(panArticle); }, 500);
	    }
	    else
	    {
    		
		    // Init light box
		    initLightbox();
		    
	    }

    }
    
	this.BrowseArticle = function(articleID)
	{	       
        if(this.IsArticleSameAsCurrent(articleID) == false)
        {	      
		    if (this.position == 1)
		    {
			    this.BrowseArticleAux($find(this.dpe2), -675, articleID);    
			    this.position = 2;
			    
			    // Initialize slideshow
			    var param2 = this.panArticle2;
	            setTimeout(function(){ InitSlideShow(param2); }, 500);
	            
	            // Initialize lightbox
	            setTimeout(function(){ InitLightBox(param2); }, 500);
	            
		    }
		    else
		    {
			    this.BrowseArticleAux($find(this.dpe1), 0, articleID);
			    this.position = 1;
			    
			    // Initialize slideshow
			    var param1 = this.panArticle1;
	            setTimeout(function(){ InitSlideShow(param1); }, 500);
	            
	            // Initialize lightbox
	            setTimeout(function(){ InitLightBox(param1); }, 500);
	            
		    }
		    
		}
		
	}

	this.BrowseArticleAux = function(dpe, pos, articleID)
	{
		dpe.populate(articleID);
		new Effect.Move(	this.divScroll, 
							{ x: pos, 
							  y: 0, 
							  mode:'absolute',
							  duration: 0.5,
							  transition: SmoothTransition
							 } );
		this.articles.push(articleID);
		
		if (this.onSlide != undefined)
		{		
		    if (this.articles.length > 1)
		    {
		        this.onSlide(true);
		    }
		    else
		    {
		        this.onSlide(false);
		    }		    
			
	    }
	}
	
}
