
function slideshow(thisname,id,type){

	
	onError=null;
	this.name = thisname;
	this.id = id;
	this.type = type;

	this.mediaplayer = "/_includes/flash/media_player_popup.cfm";
	this.wallpaper = "/public/fun/wallpaper/viewer.cfm";
	
	this.picList = new Array();
	this.current = 0;
	//thumbPath = "/public/images/side_photos/thumbnails/";
	//picPath = "/public/images/side_photos/";
	this.divText = '<div class="controls">'
	this.divText += '<div class="button"><a href="javascript: ' + this.name + '.goStart();">';
	this.divText += '<img src="/_includes/images/buttons/button_sidebar_start.gif" alt="|<<" name="goStart'+this.id+'" width="15" height="11" border="0" class="hidePic" id="goStart'+this.id+'">';
	this.divText += '</a></div>';

	this.divText += '<div class="button"><a href="javascript: ' + this.name + '.goLeft();">';
	this.divText += '<img src="/_includes/images/buttons/button_sidebar_left.gif" alt="<<" name="goLeft'+this.id+'" width="15" height="11" border="0" class="hidePic" id="goLeft'+this.id+'">';
	this.divText += '</a></div>';
	this.divText +='<div class="buttonText" id="sidebar'+this.name+'textcell'+this.id+'"></div>';

	this.divText += '<div class="button"><a href="javascript: '+ this.name + '.goRight();">';
	this.divText += '<img src="/_includes/images/buttons/button_sidebar_right.gif" alt=">>" name="goRight'+this.id+'" width="15" height="11" border="0" class="showPic" id="goRight'+this.id+'">';
	this.divText += '</a></div>';

	this.divText += '<div class="button"><a href="javascript: '+ this.name + '.goEnd();">';
	this.divText += '<img src="/_includes/images/buttons/button_sidebar_end.gif" alt=">>|" name="goEnd'+this.id+'" width="15" height="11" border="0" class="showPic" id="goEnd'+this.id+'">';
	this.divText += '</a></div>';
	this.divText += '</div>'


	this.messageRow ='<div class="controls" id="sidebar'+this.name+'messagerow'+this.id+'"></div>';
	
/* ******************************************************** */	
/* ******************************************************** */	
	this.goStart = function(){
		this.current = 0;
		identity = document.getElementById("goRight"+this.id); identity.className = "showPic";
		identity = document.getElementById("goEnd"+this.id); identity.className = "showPic";
		if (this.current > 0) { this.current--; } 
		if (this.current == 0) {	
			document.getElementById("goLeft"+this.id).className = "hidePic"; 
			document.getElementById("goStart"+this.id).className = "hidePic"; 
		}
	    document.images["picBox"+this.id].src = this.picList[this.current].thumbfile;
			   	 document.images["picBox"+this.id].parentNode.href = this.picList[this.current].fullfile;
	   	 document.images["picBox"+this.id].parentNode.title = '<strong>'+this.picList[this.current].title+'</strong> - '+this.picList[this.current].caption;
	    this.setLabel();
	}	  
/* ******************************************************** */	
/* ******************************************************** */	
	this.goLeft = function(){
		identity = document.getElementById("goRight"+this.id); identity.className = "showPic";
		identity = document.getElementById("goEnd"+this.id); identity.className = "showPic";
		if (this.current > 0) { this.current--; } 
		if (this.current == 0) {	
			document.getElementById("goLeft"+this.id).className = "hidePic"; 
			document.getElementById("goStart"+this.id).className = "hidePic"; 
		
		}
	    document.images["picBox"+this.id].src = this.picList[this.current].thumbfile;
			   	 document.images["picBox"+this.id].parentNode.href = this.picList[this.current].fullfile;
	   	 document.images["picBox"+this.id].parentNode.title = '<strong>'+this.picList[this.current].title+'</strong> - '+this.picList[this.current].caption;
	    this.setLabel();
	}
/* ******************************************************** */	
/* ******************************************************** */	
	
	this.goRight = function(){
		identity = document.getElementById("goLeft"+this.id); identity.className = "showPic";
		identity = document.getElementById("goStart"+this.id); identity.className = "showPic";
		if (this.current < this.picList.length - 1) {	this.current++; } 
		if (this.current == this.picList.length - 1) { 
			document.getElementById("goRight"+this.id).className = "hidePic";	
			document.getElementById("goEnd"+this.id).className = "hidePic";	
		
		}
	     document.images["picBox"+this.id].src = this.picList[this.current].thumbfile;
	   	 document.images["picBox"+this.id].parentNode.href = this.picList[this.current].fullfile;
	   	 document.images["picBox"+this.id].parentNode.title = '<strong>'+this.picList[this.current].title+'</strong> - '+this.picList[this.current].caption;
		 
	     this.setLabel();
	}
	
/* ******************************************************** */	
/* ******************************************************** */	
	
	this.goEnd = function(){
		this.current = this.picList.length -1;
		identity = document.getElementById("goLeft"+this.id); identity.className = "showPic";
		identity = document.getElementById("goStart"+this.id); identity.className = "showPic";
		if (this.current < this.picList.length - 1) {	this.current++; } 
		if (this.current == this.picList.length - 1) { 
			document.getElementById("goRight"+this.id).className = "hidePic";	
			document.getElementById("goEnd"+this.id).className = "hidePic";	
		
		}
	     document.images["picBox"+this.id].src = this.picList[this.current].thumbfile;
		 	   	 document.images["picBox"+this.id].parentNode.href = this.picList[this.current].fullfile;
	   	 document.images["picBox"+this.id].parentNode.title = '<strong>'+this.picList[this.current].title+'</strong> - '+this.picList[this.current].caption;
	     this.setLabel();
	}	  
	
/* ******************************************************** */	
/* ******************************************************** */	
	this.setLabel = function ()
	{
		identity = document.getElementById("sidebar"+this.name+"textcell"+this.id);
		identity.innerHTML = this.current+1 + " of "+ this.picList.length;
		this.setTypeMessage();
		
	}
/* ******************************************************** */	
/* ******************************************************** */	
	
	this.addMessage = function (value)
	{
		identity = document.getElementById("sidebar"+this.name+"messagerow"+this.id);
		if (identity)
		{
			identity.innerHTML = value;
		}
	}	
/* ******************************************************** */	
/* ******************************************************** */	
	this.setTypeMessage = function()
	{
		if (this.type == 'wallpaper')
	 	{
	 		files = this.picList[this.current].files;
	 		messagestring = "";
	 		
	 		
	 		for(i=0;i< files.length; i++)
	 		{
	 			messagestring+= '<a href="'+files[i].fullpath+'" target="_blank">'+files[i].size+'</a><br>';
	 		}
	 		this.addMessage(messagestring);
	 	
	 	}
	
	}
	
	
/* ******************************************************** */	
/* ******************************************************** */	
	this.addPics = function(thumbfile,fullfile,title,caption) {
		var thispic = new Object();
		thispic.thumbfile = thumbfile;
		thispic.fullfile = fullfile;
		thispic.title= title;
		thispic.caption = caption;
		this.picList[this.picList.length] = thispic;
	}
/* ******************************************************** */	
/* ******************************************************** */	
	
	this.addVideo = function(thumbfile,id,title,caption) {
		var thispic = new Object();
		thispic.thumbfile = thumbfile;
		thispic.id = id;
		thispic.title= title;
		thispic.caption = caption;
		this.picList[this.picList.length] = thispic;
	}	
/* ******************************************************** */	
/* ******************************************************** */	
	
	this.addWallpaper = function(thumbfile,fullpath,title,caption) 
	{
	//alert(fullpath);
		
		foundid = this.picList.length;
		if (foundid > 0)
		{
			for(i=0; i<=this.picList.length; i++)
			{
				if (this.picList[i] && this.picList[i].thumbfile == thumbfile)
				{
					foundid = i;
				}
			}
		}
		//If the item wasn't found in the list, create a new
		//pic
		if (foundid == this.picList.length)
		{
			var thisthumb = new Object();
			thisthumb.thumbfile = thumbfile;
			thisthumb.files = new Array();
		}
		else
		{
			thisthumb = this.picList[foundid];
		}
	
		var tsize = fullpath.split(".")[0];
	
		tsize = tsize.split("_")[tsize.split("_").length-1];
		
		twidth = tsize.split("x")[0];
		theight = tsize.split("x")[1];
	
		var thispic = new Object();
		thispic.id = id;
		thispic.fullpath = fullpath;
		thispic.title= title;
		thispic.size = tsize;
		thispic.width= twidth;
		thispic.height = tsize;
		thispic.caption= caption;
		
		thisthumb.files[thisthumb.files.length] = thispic;
		
		
		this.picList[foundid] = thisthumb;
	}	
/* ******************************************************** */	
/* ******************************************************** */	
	this.renderPhotoGallery = function()
	{
		document.write('<a href="'+this.picList[this.current].fullfile+'" class="thickbox" title="<strong>'+this.picList[this.current].title+'</strong> - '+this.picList[this.current].caption+'" onfocus="this.blur();"><img src="'+this.picList[this.current].thumbfile+'" name="picBox'+this.id+'" id="picBox'+this.id+'" border="0"></a>');
		// document.write('<a href="'+this.picList[this.current].fullfile+'" title="x" class="thickbox" onfocus="this.blur();"><img src="'+this.picList[this.current].thumbfile+'" name="picBox'+this.id+'" id="picBox'+this.id+'" border="0"></a>');
		if (this.picList.length > 1) {	document.write(this.divText); 
		this.setLabel();
		document.write(this.messageRow);
		this.addMessage('<a href="'+window.location.pathname+'?modeSet=gallery&gallery_name='+this.id+'">Full Gallery</a>');
		}
		
		document.getElementById("picBox"+this.id).className = "sidebarImage";
		
	}
/* ******************************************************** */	
/* ******************************************************** */	
	
	this.renderVideoGallery = function()
	{

		document.write('<a href="javascript:'+this.name+'.picLink(320);" onfocus="this.blur();"><img src="'+this.picList[this.current].thumbfile+'" name="picBox'+this.id+'" id="picBox'+this.id+'" border="0"></a>');
		if (this.picList.length > 1) {	
			document.write(this.divText); 
			this.setLabel();
		}
		document.write(this.messageRow);
		document.getElementById("picBox"+this.id).className = "sidebarImage";
		
		
		this.addMessage('&nbsp;<a href="javascript:'+this.name+'.picLink(320);">Watch</a>&nbsp;|&nbsp;<a href="javascript:'+this.name+'.picLink(-5);">Download</a>')
	}	
	
/* ******************************************************** */	
/* ******************************************************** */	
	
	this.renderWallpaperGallery = function()
	{

		document.write('<img src="'+this.picList[this.current].thumbfile+'" name="picBox'+this.id+'" id="picBox'+this.id+'" border="0">');
		if (this.picList.length > 1) {	
			document.write(this.divText); 
			this.setLabel();
		}
		document.write(this.messageRow);
		document.getElementById("picBox"+this.id).className = "sidebarImage";
			

		this.setTypeMessage();
	}		
/* ******************************************************** */	
/* ******************************************************** */	
	
		
	 this.picLink = function(val) {
	 	if (this.type == 'photo')
	 	{
			// showLightbox(this.picList[this.current].fullfile,this.picList[this.current].title,this.picList[this.current].caption);
		}
		
	 	if (this.type == 'video')
	 	{
			var popUpWin = 0;
			var URLStr = this.mediaplayer + "?videoID="+this.picList[this.current].id+"&videoWidth="+val;
			  if(popUpWin)
			  {
			    if(!popUpWin.closed) popUpWin.close();
			  }
			  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width=360,height=400');
			//showLightbox(this.picList[this.current].fullfile,this.picList[this.current].title,this.picList[this.current].caption);
		}
		
		if (this.type == 'wallpaper')
	 	{
			var popUpWin = 0;
			var URLStr = val;
			  if(popUpWin)
			  {
			    if(!popUpWin.closed) popUpWin.close();
			  }
			  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width=360,height=400');
			//showLightbox(this.picList[this.current].fullfile,this.picList[this.current].title,this.picList[this.current].caption);
		}
		
		
	}

}