var thumbid = 'thumbs';
var auto = false;
var autodelay = 5;
 var milisec=0
 var seconds=0


var slideShow=function(){
	var ci,t,tar,tarl,total;
	ta=document.getElementById(thumbid);
	t=ta.getElementsByTagName('li');

	for(i=0;i<t.length;i++){
		if (t[i].style.display ==""){
			var li_id = parseFloat(t[i].getAttribute('el_num'))
			var li_style = t[i].style;
		}
	}
	if(t.length==li_id){
		document.getElementById("next").style.display="none";
	}
	if(li_id==1){
		document.getElementById("prev").style.display="none";
	}

	ie=document.all?true:false;
	return{

		display:function(id){
			seconds=0;

			 if (seconds<=0){
			    milisec+=1
			    seconds=0
			 }
			 if(milisec>=11){
			 	seconds+=1;
			 	milisec=0;
			 }
			 else{
			 if(milisec == 10){
			 	seconds+=1;
			 }

			    document.getElementById('li_'+id).style.opacity=seconds+"."+milisec
			    setTimeout("slideShow.display('"+id+"')",250)
			    }
			},
		preload:function(id){
			if (id>0 && id<window.total_images){
				var image = new Image();
				 image.src = document.getElementById("picture_src_"+id).innerHTML;
				 if (image.src.length>1){

					 document["picture_"+id].src=image.src;
				 }
				// document.getElementById("picture_src_"+id).innerHTML="";
			}
		},
		getimg:function(id){
			if(!ci){

				if(!document.getElementById('li_'+id)){
					document.getElementById('li_'+id).style.display ="";
				}else{

					var width_imd = document.getElementById('li_'+id).style.width;
					var height_imd = document.getElementById('li_'+id).style.height;
					document.getElementById("image").style.height=height_imd;
					document.getElementById("image").style.width=width_imd;
					document.getElementById("thumbs").style.height=height_imd;
					document.getElementById("thumbs").style.width=width_imd;

					if (document.getElementById("picture_src_"+id) != null){
						var image = new Image();
						 image.src = document.getElementById("picture_src_"+id).innerHTML;
						 if (image.src.length>1){

							 document["picture_"+id].src=image.src;
						 }
						 //document.getElementById("picture_src_"+id).innerHTML="";
						this.preload(id-1);	this.preload(id+1);
						this.preload(id-2); this.preload(id+2);
					}

					 document.getElementById('li_'+id).style.display ="";


				}



			}

		},
		nav:function(d,module){
			var c=0;

			for(i=0;i<t.length;i++){
				if (t[i].style.display ==""){
					var li_id = parseFloat(t[i].getAttribute('el_num'))
					var li_style = t[i].style;
				}
			}
			if (window.total_images == undefined){
				var total_images=t.length;
			}else{
				var total_images=window.total_images;
			}
			var li = document.getElementById('li_'+li_id);
			if(d>0){

				var li_index = document.getElementById('li_'+(li_id+1)).value;

				if(document.getElementById("photo_id")) document.getElementById("photo_id").value=li_index;
				document.getElementById("pos_image").innerHTML=(li_id+1)+"/"+total_images;
				if(total_images==li_id+1){
					document.getElementById("next").style.display="none";
					document.getElementById("prev").style.display="block";
				}
				else{
					document.getElementById("prev").style.display="block"
				}

				if(li.style.display == ""){
					li.style.display ="none"
					this.getimg(li_id+1);
				}
				show_position_tag(module);
			}
			else{
				var li_index = document.getElementById('li_'+(li_id-1)).value;
				if(document.getElementById("photo_id"))document.getElementById("photo_id").value=li_index;
				document.getElementById("pos_image").innerHTML=(li_id-1)+"/"+total_images;

				if(li_id-1==1){
					document.getElementById("prev").style.display="none";
					document.getElementById("next").style.display="";
				}
				else{
					document.getElementById("next").style.display="";
				}
				if(li.style.display ==""){
					li.style.display ="none";
					this.getimg(li_id-1);

				}
				show_position_tag(module);
			}

			// modify the location's hash with a current Photo ID (after the AJAX-based navigation)
			switch(module){
				case "galleries":
					location.hash = "evnphoid_" + li_index;
					break;
			}

			if(pageTracker){
				switch(module){
					case "galleries":
						strTrackURL = MainURL+"index.php?page=events_galleries_view_picture&gal_id="+gal_id+"&evn_pho_id="+li_index;
						pageTracker._trackPageview(strTrackURL);
						// debug
						// alert("URL tracked: "+strTrackURL);
					break;
					case "album":
						strTrackURL = MainURL+"index.php?page=photos&section=album&per_id="+per_id+"&pho_id="+li_index+"&alb_id="+alb_id;
						pageTracker._trackPageview(strTrackURL);
						// debug
						// alert("URL tracked: "+strTrackURL);
					break;
					case "members":
						strTrackURL = MainURL+"index.php?page=events_member_view&event_id="+evn_id+"&evn_pic="+li_index;
						pageTracker._trackPageview(strTrackURL);
						// debug
						// alert("URL tracked: "+strTrackURL);
				}
			}

			/*
			 * Here's the a trick for AJAX-based call of Quantcast
			 */
			var objXmlHttp_qoptions = null;
			try{objXmlHttp_qoptions = new XMLHttpRequest();}
			catch(e){
				try{objXmlHttp_qoptions = new ActiveXObject("Msxml2.XMLHTTP");}
				catch(e){objXmlHttp_qoptions = new ActiveXObject("Microsoft.XMLHTTP");}
			}
			objXmlHttp_qoptions.onreadystatechange = function() {
				if(objXmlHttp_qoptions.readyState == 4){
					strResultValue = '' + objXmlHttp_qoptions.responseText;
					// Execute
					eval(strResultValue);
					if(_qoptions){
						var objXmlHttp_quantcast = null;
						try{objXmlHttp_quantcast = new XMLHttpRequest();}
						catch(e){
							try{objXmlHttp_quantcast = new ActiveXObject("Msxml2.XMLHTTP");}
							catch(e){objXmlHttp_quantcast = new ActiveXObject("Microsoft.XMLHTTP");}
						}
						objXmlHttp_quantcast.onreadystatechange = function() {
							if(objXmlHttp_quantcast.readyState == 4){
								strResultValue = '' + objXmlHttp_quantcast.responseText;
								// Execute
								eval(strResultValue);
							}
						}
						objXmlHttp_quantcast.open("GET","./jscript/quantcast/quant.js",true);
						objXmlHttp_quantcast.send("");
					}
				}
			}
			objXmlHttp_qoptions.open("GET","./jscript/quantcast/quant_qoptions.js",true);
			objXmlHttp_qoptions.send("");

		}
	};
}();

