   	/***********************************************************************************************
	
	Copyright (c) 2005 - Alf Magne Kalleland post@dhtmlgoodies.com
	
	UPDATE LOG:
	
	March, 10th, 2006 : Added support for a message while large image is loading
	
	Get this and other scripts at www.dhtmlgoodies.com
	
	You can use this script freely as long as this copyright message is kept intact.
	
	***********************************************************************************************/ 
	var displayWaitMessage=true;	// Display a please wait message while images are loading?
  	
   		
	var activeImage = false;
	var imageGalleryLeftPos = false;
	var imageGalleryWidth = false;
	var imageGalleryObj = false;
	var maxGalleryXPos = false;
	var slideSpeed = 0;
	var imageGalleryCaptions = new Array();
	function startSlide(e)
	{
		if(document.all)e = event;
		var id = this.id;
		//this.getElementsByTagName('IMG')[0].src = 'images/' + this.id + '_over.gif';	
		if(this.id=='arrow_right'){
			slideSpeedMultiply = Math.floor((e.clientX - this.offsetLeft) / 5);
			slideSpeed = -1*slideSpeedMultiply;
			slideSpeed = Math.max(-10,slideSpeed);
		}else{			
			slideSpeedMultiply = 10 - Math.floor((e.clientX - this.offsetLeft) / 5);
			slideSpeed = 1*slideSpeedMultiply;
			slideSpeed = Math.min(10,slideSpeed);
			if(slideSpeed<0)slideSpeed=10;
		}
	}
	
	function releaseSlide()
	{
		var id = this.id;
		this.getElementsByTagName('IMG')[0].src = 'images/' + this.id + '.gif';
		slideSpeed=0;
	}
		
	function gallerySlide()
	{
		if(slideSpeed!=0){
			var leftPos = imageGalleryObj.offsetLeft;
			leftPos = leftPos/1 + slideSpeed;
			if(leftPos>maxGalleryXPos){
				leftPos = maxGalleryXPos;
				slideSpeed = 0;
				
			}
			if(leftPos<minGalleryXPos){
				leftPos = minGalleryXPos;
				slideSpeed=0;
			}
			
			imageGalleryObj.style.left = leftPos + 'px';
		}
		setTimeout('gallerySlide()',20);
		
	}
	
	function showImage()
	{
		if(activeImage){
			activeImage.style.filter = 'alpha(opacity=50)';	
			activeImage.style.opacity = 0.5;
		}	
		this.style.filter = 'alpha(opacity=100)';
		this.style.opacity = 1;	
		activeImage = this;	
	}
	
	function initSlideShow()
	{
		if(document.getElementById('arrow_left')!=null){
		document.getElementById('arrow_left').onmousemove = startSlide;
		document.getElementById('arrow_left').onmouseout = releaseSlide;
		document.getElementById('arrow_right').onmousemove = startSlide;
		document.getElementById('arrow_right').onmouseout = releaseSlide;
		}
		if(document.getElementById('theImages')!=null){
		imageGalleryObj = document.getElementById('theImages');
		imageGalleryLeftPos = imageGalleryObj.offsetLeft;
		imageGalleryWidth = document.getElementById('galleryContainer').offsetWidth - 80;
		maxGalleryXPos = imageGalleryObj.offsetLeft; 
		minGalleryXPos = imageGalleryWidth - document.getElementById('slideEnd').offsetLeft;
		var slideshowImages = imageGalleryObj.getElementsByTagName('IMG');
		for(var no=0;no<slideshowImages.length;no++){
			slideshowImages[no].onmouseover = showImage;
		}
		
		var divs = imageGalleryObj.getElementsByTagName('DIV');
		for(var no=0;no<divs.length;no++){
			if(divs[no].className=='imageCaption')imageGalleryCaptions[imageGalleryCaptions.length] = divs[no].innerHTML;
		}
		gallerySlide();
		}
	}
	
	function showPreview_vid(vid_filename,vid_width,vid_height,imageIndex, duration){
			/*var subImages = document.getElementById('previewPane').innerHTML;
		if(subImages.length==0){
			var img = document.createElement('IMG');
			document.getElementById('previewPane').appendChild(img);
		}else img = subImages[0];*/
		
		/*if(displayWaitMessage){
			document.getElementById('waitMessage').style.display='inline';
		}*/
		/*document.getElementById('largeImageCaption').style.display='none';
		img.onload = function() { hideWaitMessageAndShowCaption(imageIndex); };
		img.src = imagePath;*/
/*		var videoflv ='';
		videoflv ='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ vid_width +'" height="'+ vid_height+ '"codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"><param name="movie" value="player.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#000000" /><param name="flashvars" value="fl='+ vid_filename +'" /><embed src="player.swf" flashvars="fl='+ vid_filename +'" quality="high" wmode="transparent" bgcolor="#000000" width="'+ vid_width +'" height="'+ vid_height +'" name="player" align="middle" play="true" loop="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';*/
		
videoflv = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" width="' + vid_width + '" height="' + vid_height + '" id="loaderInfoExample" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="true" /><param name="movie" value="Player.swf?movName=' + vid_filename + '&totTime='+duration+'" /><param name="quality" value="high" /><param name="bgcolor" value="#cccccc" /><embed src="Player.swf?movName=' + vid_filename + '&totTime='+duration+'" quality="high" bgcolor="#000000" width="' + vid_width + '" height="' + vid_height + '" align="middle" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage "http://www.macromedia.com/go/getflashplayer" /></object>';
		document.getElementById('previewPane').innerHTML=videoflv;
		hideWaitMessageAndShowCaption(imageIndex);
	}
	

function showPreview_vid1(vid_filename,vid_width,vid_height,imageIndex, duration) {
			/*var subImages = document.getElementById('previewPane').innerHTML;
		if(subImages.length==0){
			var img = document.createElement('IMG');
			document.getElementById('previewPane').appendChild(img);
		}else img = subImages[0];*/
		
		/*if(displayWaitMessage){
			document.getElementById('waitMessage').style.display='inline';
		}*/
		/*document.getElementById('largeImageCaption').style.display='none';
		img.onload = function() { hideWaitMessageAndShowCaption(imageIndex); };
		img.src = imagePath;*/
/*		var videoflv ='';
		videoflv ='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ vid_width +'" height="'+ vid_height+ '"codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"><param name="movie" value="player.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#000000" /><param name="flashvars" value="fl='+ vid_filename +'" /><embed src="player.swf" flashvars="fl='+ vid_filename +'" quality="high" wmode="transparent" bgcolor="#000000" width="'+ vid_width +'" height="'+ vid_height +'" name="player" align="middle" play="true" loop="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';*/

/*
		alert('video') ;
		
		var videoflv = '' ;
		videoflv += '<object ' ;
		videoflv += '	classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
		videoflv += '	codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" ';
		videoflv += '	width="' + vid_width + '" ';
		videoflv += '	height="' + vid_height + '" ';
		videoflv += '	id="loaderInfoExample" ';
		videoflv += '	align="middle">';
		alert(videoflv) ;
		videoflv += '	<param name="allowScriptAccess" value="sameDomain" />';
		videoflv += '	<param name="wmode" value="transparent" />';
		videoflv += '	<param name="movie" value="js_player.swf?file=flv_uploads/' + vid_filename + '&totTime='+duration+'" />';
		videoflv += '	<param name="quality" value="high" /><param name="bgcolor" value="#cccccc" />';
		alert(videoflv) ;
		videoflv += '	<embed src="jw_player.swf?file=flv_uploads/' + vid_filename + '&totTime='+duration+'" ';
		videoflv += '		quality="high" ';
		videoflv += '		bgcolor="#000000" ';
		videoflv += '		width="' + vid_width + '" ';
		videoflv += '		height="' + vid_height + '" ';
		videoflv += '		align="middle" ';
		videoflv += '		allowScriptAccess="sameDomain" ';
		videoflv += '		wmode="transparent" ';
		videoflv += '		type="application/x-shockwave-flash" ';
		videoflv += '		pluginspage "http://www.macromedia.com/go/getflashplayer" />';
		videoflv += '</object>';


		var videoflv = "" ;
		videoflv += "<div id=\"container\"><a href=\"http://www.macromedia.com/go/getflashplayer\">Get the Flash Player</a> to see this player.</div>" ;
		videoflv += "	" ;
		videoflv += "	<script type=\"text/javascript\">" ;
		videoflv += "		var s1 = new SWFObject(\"jw_player.swf\",\"ply\",\"328\",\"200\",\"9\",\"#FFFFFF\");" ;
		videoflv += "		s1.addParam(\"allowfullscreen\",\"true\");" ;
		videoflv += "		s1.addParam(\"allowscriptaccess\",\"always\");" ;
		videoflv += "		s1.addParam(\"flashvars\",\"file=" + vid_filename + "&image=" + imageIndex + "&width=" + vid_width + "&height=" + vid_height + "\");" ;
		videoflv += "		s1.write(\"container\");" ;
		videoflv += "	</script>" ;
	
		alert(videoflv) ;


		var s1 = new SWFObject("jw_player.swf","ply","328","200","9","#FFFFFF");
		s1.addParam("allowfullscreen","true");
		s1.addParam("allowscriptaccess","always");
		s1.addParam("flashvars","file=flv_uploads/" + vid_filename + "&image=" + imageIndex + "&width=" + vid_width + "&height=" + vid_height);
		s1.write("container");
*/
//		var videoflv = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" width="' + vid_width + '" height="' + vid_height + '" id="loaderInfoExample" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="true" /><param name="movie" value="Player.swf?movName=' + vid_filename + '&totTime='+duration+'" /><param name="quality" value="high" /><param name="bgcolor" value="#cccccc" /><embed src="Player.swf?movName=' + vid_filename + '&totTime='+duration+'" quality="high" bgcolor="#000000" width="' + vid_width + '" height="' + vid_height + '" align="middle" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
		
//		alert(vid_filename + "\n" + vid_width + "\n" + vid_height + "\n" + imageIndex + "\n" + duration) ;

		vid_filename = "flv_uploads/" + vid_filename ;
		
		
		
		var videoflv = "" ;
		videoflv += "<object " ;
		videoflv += "	classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' " ;
		videoflv += "	codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' " ;
		videoflv += "	width='" + vid_width + "' " ;
		videoflv += "	height='" + vid_height + "' " ;
		videoflv += "	id='loaderInfoExample' " ;
		videoflv += "	align='middle'>" ;

		videoflv += "	<param name='allowScriptAccess' value='sameDomain' />" ;
		videoflv += "	<param name='movie' value='jw_player.swf?file=" + vid_filename + "' />" ;
		videoflv += "	<param name='wmode' value='transparent' />" ;
		videoflv += "	<param name='quality' value='high' />" ;
		videoflv += "	<param name='bgcolor' value='#cccccc' />" ;
		videoflv += "	<param name='fFlashVars' value='file=" + vid_filename + "' />	" ;

		videoflv += "	<embed " ;
		videoflv += "		src='jw_player.swf?file=" + vid_filename + "' " ;
		videoflv += "		FlashVars='file=" + vid_filename + "' " ;
		videoflv += "		quality='high' " ;
		videoflv += "		bgcolor='#000000' " ;
		videoflv += "		width='" + vid_width + "' " ;
		videoflv += "		height='" + vid_height + "' " ;
		videoflv += "		align='middle' " ;
		videoflv += "		wmode='transparent' " ;
		videoflv += "		allowScriptAccess='sameDomain' " ;
		videoflv += "		type='application/x-shockwave-flash' " ;
		videoflv += "		pluginspage='http://www.macromedia.com/go/getflashplayer' />" ;

		videoflv += "</object>" ;

		//alert(videoflv) ;
		document.getElementById('previewPane').innerHTML=videoflv;
		hideWaitMessageAndShowCaption(imageIndex);
	}
	
/*	
	// Nicholas Stephan
	// Another attempt to fix this weird system they've got here...
	function showPreview_vid2(vid_filename,vid_width,vid_height,imageIndex, duration) {
		vid_filename = "flv_uplaods/" + vid_filename ;
		
		var videoflv = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" width="' + vid_width + '" height="' + vid_height + '" id="loaderInfoExample" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="true" /><param name="movie" value="jw_player.swf?file=' + vid_filename + '" /><param name="quality" value="high" /><param name="bgcolor" value="#cccccc" /><embed src="jw_player.swf?file=' + vid_filename + '" quality="high" bgcolor="#000000" width="' + vid_width + '" height="' + vid_height + '" align="middle" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage "http://www.macromedia.com/go/getflashplayer" /></object>';
		
		document.getElementById('previewPane').innerHTML=videoflv;
		hideWaitMessageAndShowCaption(imageIndex);
	}
*/
	
	function showPreview_embedd(videoflv,imageIndex){
	
		/*var subImages = document.getElementById('previewPane').innerHTML;
		if(subImages.length==0){
			var img = document.createElement('IMG');
			document.getElementById('previewPane').appendChild(img);
		}else img = subImages[0];*/
		
		/*if(displayWaitMessage){
			document.getElementById('waitMessage').style.display='inline';
		}*/
		/*document.getElementById('largeImageCaption').style.display='none';
		img.onload = function() { hideWaitMessageAndShowCaption(imageIndex); };
		img.src = imagePath;*/
		
		document.getElementById('previewPane').innerHTML=videoflv;
		hideWaitMessageAndShowCaption(imageIndex);
	}
	function hideWaitMessageAndShowCaption(imageIndex)
	{
		document.getElementById('waitMessage').style.display='none';	
		document.getElementById('largeImageCaption').innerHTML = imageIndex;
		document.getElementById('largeImageCaption').style.display='block';
		
	}
	window.onload = initSlideShow;