// JavaScript Document

photoalbumhover = function() {
			var bundleEls = document.getElementById("photoalbumnav").getElementsByTagName("LI");
			for (var i=0; i<bundleEls.length; i++) {
				bundleEls[i].onmouseover=function() {
					this.className+=" photoalbumhover";
				}
				bundleEls[i].onmouseout=function() {
					this.className=this.className.replace(new RegExp(" photoalbumhover\\b"), "");
				}
			}
		}
if (window.attachEvent) window.attachEvent("onload", photoalbumhover);


	var browserCanBlend = (is_ie5_5up);
	var cur=0;
	var play=false;
	var manualScolling = false;
if (window.addEventListener) {
	window.addEventListener("load", doLoadFirstImage, false);
}
else if (window.attachEvent) {
	window.attachEvent("onload", doLoadFirstImage);
}
	
	var runningId=0;

	function doLoadFirstImage(){
		if(imgarray && imgarray.length>0){
			 setStripImage(1);
			 doPush(1);			
			doLoadOtherImages();
		}
	}
	function doLoadOtherImages(){
		for(i=2;i<=imgarray.length;i++){
			 setStripImage(i);
		}
	}
	function setStripImage(i){
		var img=new Image();
		img.Source='photograph.php?id='+imgarray[i-1]+'&dt='+new Date();
		document.getElementById('p'+i).src=img.Source;
	}
	function doOpen(Cur){
		cur=Cur;
		if(cur>imagecount) cur=1;
		play=false;
		setMainGraph(cur);
	}
	function doShow(Cur) {
		if(play==false){
			cur=Cur;
			 doPush(Cur);
		}
		else {
			cur=Cur-1;
		}
	}
	function doPush(Cur) {
		if(play==false){
			cur=Cur;
			document.images['showimage'].src=document.getElementById('p'+Cur).src;
			document.images['showimage'].style.MozOpacity=1;
			document.images['showimage'].style.Opacity=100;
			lastname='showimage';
			if(document.getElementById('player-window'))document.getElementById('player-window').style.visibility='visible';
			runningId=cur;
			if(document.getElementById('p'+runningId+'-container')){
				document.getElementById('p'+runningId+'-container').className = 'player-photograph running-photograph';
			}
			play=true;
			setTimeout("doPlay();",5000);
		}
	}

	function doNext() {
		cur++;
		if(cur>imagecount) cur=1;
		play=false;
		setMainGraph(cur);
	}
	function doPrevious() {
		cur--;
		if(cur<=0) cur=imagecount;
		play=false;
		setMainGraph(cur);
	}
	var playcode=0;
	function doPlay() {
			play=true;
			playcode++;
			doPlaySlideShow(playcode);
	}
	function doPlaySlideShow(pc){
		if(play==true && pc==playcode) {
			cur++;
			if(cur>imagecount) {
				cur=1;
				top=0;
				if(manualScolling == false) {
					moveElement('photostrip',8,0);
				}
			}
			setMainGraph(cur);
			setTimeout("doPlaySlideShow("+pc+");",5000);
		}
	}
	function doStop() {
		play=false;
		cur=1;
		document.getElementById('player-window').style.visibility='hidden';
	}
	function doPauze() {
		play=false;
	}
	
	function doScrollPhotostripUp(){
		manualScolling = true;
		ScrollStripUp();		
	}
	function doScrollPhotostripDown(){
		manualScolling = true;
		ScrollStripDown();		
	}
	function setMainGraph(id) {
		if(document.getElementById('p'+runningId+'-container')){
			document.getElementById('p'+runningId+'-container').className = 'player-photograph';
		}
		runningId=id;
		if(document.getElementById('p'+runningId+'-container')){
			document.getElementById('p'+runningId+'-container').className = 'player-photograph running-photograph';
			if(document.getElementById('photostrip').style.top == '' ) {document.getElementById('photostrip').style.top = '0px'}
			var top = parseInt(document.getElementById('photostrip').style.top.replace('px',''));
			var check = document.getElementById('p'+runningId+'-container').offsetTop + top;
			if( check > 1 && check<= 300) {
				manualScolling =false;
			}
			if(manualScolling == false && check>=300) {
				ScrollStripDown();
			}
		}	
				next = id+1;
		if(next>imagecount) next=1;
		nextsource =document.getElementById('p'+next);
		if(nextsource.width==0 || nextsource.clientWidth==0 || nextsource.complete==false) {
			setStripImage(next);
		}

	  source= document.getElementById('p'+id)	
	  if (browserCanBlend){
		  
		document.images['showimage'].style.filter="progid:DXImageTransform.Microsoft.Fade(duration=2)";
		document.images['showimage'].filters[0].Apply();
		document.images['showimage'].src=source.src;
		document.images['showimage'].filters[0].Play();
	  } 
	  else {
		if(lastname=='showimage'){
			document.images['showimage'].style.MozOpacity=1;
			document.images['showimage2'].style.MozOpacity=0.01;
			document.images['showimage2'].src=source.src;
			InitFade(document.images['showimage2'], 0, 100, 2);
			lastname='showimage2';
		}
		else {
			document.images['showimage'].style.MozOpacity=1;
			document.images['showimage'].src=source.src;
			InitFade(document.images['showimage2'], 100, 0, 2);
			lastname='showimage';
		}
	  }
		
	  doSetProgress();
	}
	
	function doSetProgress(){
	  if(imagecount>0){
		document.getElementById("player-progress").style.width=((cur)/imagecount)*383;								
	  }
	}
	var lastname
	
	
	var top=0;
	function ScrollStripDown(){
		if(top>-1*(imagecount-5)*65)	top=top-260;								
		moveElement('photostrip',8,top);								
		return true;
	}						
	function ScrollStripUp(){
		if(top<0)	top=top+260;								
		moveElement('photostrip',8,top);								
		return true;
	}
	function moveElement(id, x, y)
	{
	  // move the element with id to x,y
	  // where x,y are the horizontal
	  // and vertical position in pixels
	
	  var elm = null;
	  if (document.getElementById)
	  {
		// browser implements part of W3C DOM HTML
		// Gecko, Internet Explorer 5+, Opera 5+
		elm = document.getElementById(id);
	  }
	  else if (document.all)
	  {
		// Internet Explorer 4 or Opera with IE user agent
		elm = document.all[id];
	  }
	  else if (document.layers)
	  {
		// Navigator 4
		elm = document.layers[id];
	  }
	
	  if (!elm)
	  {
		// browser not supported or element not found
	  }
	  else if (elm.style)
	  {
		// browser implements part of W3C DOM Style
		// Gecko, Internet Explorer 4+, Opera 5+
	
		if (typeof(elm.style.left) == 'number')
		{
		  // Opera 5/6 do not implement the standard correctly
		  // and assume that elm.style.left and similar properties
		  // are numbers.
		  elm.style.left = x;
		  elm.style.top  = y;
		}
		else
		{
		  // Gecko/Internet Explorer 4+
		  // W3C DOM Style states that elm.style.left is a string
		  // containing the length followed by the unit. e.g. 10px
		  // Gecko will allow you to omit the unit only in Quirks 
		  // mode. 
		  // Gecko REQUIRES the unit when operating in Standards
		  // mode.
		  elm.style.left = x + 'px';
		  elm.style.top  = y + 'px';
		}
	  }
	  else if (typeof(elm.left) == 'number')
	  {
		// Navigator 4
		elm.left = x;
		elm.top  = y;
	  }
	}
	
	






