
function shifter(targetName, identifier, width, height, moduleNumber) {
	
	this.targetName = targetName;
	this.id = identifier;
	this.width = width;
	this.height = height;
	this.moduleNumber = moduleNumber;
	this.items = new Array();
	
	this.currentPage = 1;
	this.pageItemLimit = 5;
	this.totalPages;
	this.lastActiveMovie;
	
	
	this.addItem = function (shifterItem){
		
		this.items[this.items.length] = shifterItem;
		
		this.totalPages = Math.floor(this.items.length / this.pageItemLimit);
	}
	
	
	this.shiftTo = function (itemIndex){
		
		if(this.flashPluginFound()){
		
			targetId = this.targetName + this.id + '_target';
			
			element = document.getElementById('flashObjectWrapper' + this.id);
			
			if(document.getElementById(targetId)){
				child = document.getElementById(targetId);
				element.removeChild(child);
			}
			
			var so = new SWFObject(this.items[(itemIndex - 1)].src, targetId, this.width, this.height,'8');
			
		  	so.addParam('allowscriptaccess','always');
		  	so.addParam('allowfullscreen','true');
		  	
		  	so.addVariable('width',this.width);
		 	so.addVariable('height', this.height);
		  	/*so.addVariable('file','/flash/flashPlayer.swf?file=' + this.items[(itemIndex - 1)].src);
		  	so.addVariable('data','/flash/flashPlayer.swf?file=' + this.items[(itemIndex - 1)].src);*/
		  	/*so.addVariable('javascriptid',targetId);
		  	so.addVariable('enablejs','true');*/
		  	so.write('flashObjectWrapper' + this.id);
		  	
		  	//resize wrapper
		  	element = document.getElementById('splitFlash' + this.moduleNumber);
		  	element.style.height = this.height + 'px';
		  	
		  	if(document.getElementById(targetId)){
		  	
		  		obj = document.getElementById(targetId);
		  		
		  		//obj.Play();
		  		
		  		if(document.getElementById('movie' + itemIndex)){
		  			
		  			if(document.getElementById('movie' + this.lastActiveMovie)){
		  				
		  				lastMovie = document.getElementById('movie' + this.lastActiveMovie);
		  				lastMovie.style.color = '#ffffff';
		  				
		  				if(document.getElementById('movieLength' + this.lastActiveMovie)){
		  					
		  					lastMovieLength = document.getElementById('movieLength' + this.lastActiveMovie);
		  					lastMovieLength.style.color = '#ffffff';
		  				}
		  			}
		  			
		  			this.lastActiveMovie = itemIndex;
		  			
		  			movie = document.getElementById('movie' + itemIndex);
		  			
		  			movie.style.color = '#cc9900';
		  			
		  			if(document.getElementById('movieLength' + itemIndex)){
		  					
		  					movieLength = document.getElementById('movieLength' + itemIndex);
		  					movieLength.style.color = '#cc9900';
		  				}
		  		}
		  	}
		}
	}

	
	
	this.flashPluginFound = function(){
		
		pluginAvailable = false;
		
		if (navigator.plugins 
			&& ((navigator.plugins["Shockwave Flash"] 
			&& navigator.plugins["Shockwave Flash"]["application/x-shockwave-flash"]) 
			|| navigator.plugins["Shockwave Flash 2.0"] 
			&& navigator.plugins["Shockwave Flash 2.0"]["application/x-shockwave-flash"]))
           	pluginAvailable = true;
           	
           if(navigator.appName == 'Microsoft Internet Explorer'){
           		pluginAvailable = true;
           }
	        
        return(pluginAvailable);
	}
	
	
	this.previousPage = function (navName){
		
		prevPage = (this.currentPage == 1) ? this.totalPages : (this.currentPage - 1);
		
		hideMenu = document.getElementById(navName + '_' + this.currentPage + '_' + this.id);
		hideMenu.style.display = 'none';
		showMenu = document.getElementById(navName + '_' + prevPage + '_' + this.id);
		showMenu.style.display = 'block';
		
		this.currentPage = prevPage;
		
		//activateMovie = (((this.currentPage * this.pageItemLimit) - this.pageItemLimit) + 1);
		//this.shiftTo(activateMovie);
		
		this.updatePageInfo();
	}
	
	
	this.nextPage = function (navName){
		
		nextPage = (this.currentPage == this.totalPages) ? 1 : (this.currentPage + 1);
		
		hideMenu = document.getElementById(navName + '_' + this.currentPage + '_' + this.id);
		hideMenu.style.display = 'none';
		showMenu = document.getElementById(navName + '_' + nextPage + '_' + this.id);
		showMenu.style.display = 'block';
		
		this.currentPage = nextPage;
		
		//activateMovie = (((this.currentPage * this.pageItemLimit) - this.pageItemLimit) + 1);
		//this.shiftTo(activateMovie);
		
		this.updatePageInfo();
	}
	
	
	this.updatePageInfo = function (){
		
		pageInfo = document.getElementById('pageInfo' + this.id);
		pageInfo.innerHTML = this.currentPage + ' / ' + this.totalPages;
	}
		
}	
