
	//Begin Slider jQuery
	
	   	$(function(){
	   		
	   		//reset scroll on reload
	   		$("#topBody_photo2_scroll").scrollTo(0,1,{axis:'x'})
	   		
			var picGap = 10;
			var moveDur= 400;
			var picIndex=1;
			var indexMax=$("#scrollable").children().size(); 
			var clickable=true;
			var picHeight='360px';

				
			function makeClickable(){
				$(this).wait(moveDur,function(){clickable=true;});	
				
			}
			
			//fade all but first image
			$(".sliderPhoto").fadeTo(0,.5);
			$("#s_div1").fadeTo(0,1);
			
			//remove loader, show images, set up scroll area
			$("#loader").remove();
			$(".sliderPhoto").css("display","inline");
			$("#scrollable").css("width",'15000px');
			
			var maxScroll=0;

			
			var picArray= new Array;
			picArray.push(0);
			
			//				$('#DEBUGBOX').append('1');

			for(var i=1;i<(indexMax);i++){
				picArray.push($("#s_photo"+(i)).css("width"));
				
			
				//console.log($("#s_photo"+(i)).attr("src"));
				
				$("#s_div"+i).css('background',"url('"+($("#s_photo"+(i)).attr("src"))+"')");
				$("#s_photo"+(i)).css("height",0)
				

				$("#s_div"+i).css("height",picHeight)
				$("#s_div"+i).append('<div id="blocker" style="width:'+($("#s_photo"+(i)).css("width"))+';height:'+picHeight+'"></div>')


								
				//$('#DEBUGBOX').append($("#s_photo"+(i)).css("width")+" ");

					//		$('#DEBUGBOX').append(' Fill'+i);

				picArray[i]=picArray[i].substring(0,picArray[i].length-2);
				

				picArray[i]=Number(picArray[i])+Number(picGap);
				//console.log(picArray[i]);
				
				if(i<(indexMax-1)){
				maxScroll+=Number(picArray[i]);
				}
				//console.log(maxScroll);
				//$(maxScroll).appendTo($("#bodyContent"))
				
				//add number buttons and listeners to all pictures
				
				
			}
			
				$(picArray).each(function(a,s){
			
			if(a!=0){
			
			
	//			$("#numbers").append(' <a onclick="directPic('+a+');" id="goTo'+a+'">'+a)
				
				$("#numbers").append(' <a id="goTo'+a+'">'+a+"</a>")				
				//$("#goTo"+i).data('theIndex',i)

				//$("#DEBUGBOX").append(a);

				$("#goTo"+a).click(function(){
						directPic(a)
					});
					
				$("#s_div"+a).click(function(){
						directPic(a)
					});
				
				
			}			
			
			});
			
			$('#goTo1').css('font-weight','700');
			

			function nextPic(){
				if(clickable==true){
	        	
	        	$("*[id^=goTo]").css('font-weight','400');

	        	
			//	$('#DEBUGBOX').append('Start');
	        	//set up array with widths

			
			
			//End setup
	        	
	        	//block multiple clicks
	        	clickable=false;
	        	
				//$('#DEBUGBOX').append(' Max='+maxScroll);

	        	
	        	//set up scroll destination
	        	
	     	    var scrollDest= ($("#s_photo"+picIndex).css("width"));

	    	    scrollDest=scrollDest.substring(0,scrollDest.length-2);
	   		    scrollDest=(Number(scrollDest)+picGap);
	        	scrollDest="+="+scrollDest;
	       
	        	
	        	picIndex++;
	        	
	        	
	        	if(picIndex==indexMax){
	        	picIndex=1;
	        	scrollDest=0;
	        	}

	        	$(".sliderPhoto").fadeTo(moveDur/4,.5);
		   	    $("#s_div"+picIndex).fadeTo(moveDur,1);


	   		    $("#topBody_photo2_scroll").scrollTo(scrollDest, moveDur, 
	   		    {
	   		    axis:'x'
	   		    });
		   	    
		   	    $('#goTo'+picIndex).css('font-weight','700');

		   	    makeClickable();
		   
	  		
//	  		console.log(scrollDest);	        
	        	
	        	}


			
			}
			
			
			function prevPic(){
				if(clickable==true){
	        	
	        	$("*[id^=goTo]").css('font-weight','400');

	        	//set up array with widths
			
			//End setup
	        	
	        	//block multiple clicks
	        	clickable=false;
	        	
	        	//set up scroll destination
	        	
	     	    var scrollDest= ($("#s_photo"+(picIndex-1)).css("width"));
	     	    
	     	    if(picIndex==1){
	        	picIndex=(indexMax);
	        	scrollDest=maxScroll+"px";
	        
	        	}
	        	
	    	    scrollDest=scrollDest.substring(0,scrollDest.length-2);
	   		    scrollDest=(Number(scrollDest)+picGap);
	        	scrollDest="-="+scrollDest;
				
				
	        		        	//console.log(scrollDest)
				
	        	if(picIndex==(indexMax)){
	        	
	        	scrollDest=scrollDest.substring(2);

	        		        	//console.log(scrollDest)
				
	        	}
	        	
	        	
	        	picIndex--;
	        	
	        	

	        	$(".sliderPhoto").fadeTo(moveDur/4,.5);
		   	    $("#s_div"+picIndex).fadeTo(moveDur,1);


	   		    $("#topBody_photo2_scroll").scrollTo(scrollDest, moveDur, 
	   		    {
	   		    axis:'x'
	   		    
		   	    });
		   	    
		   	    makeClickable();
		   
		     	    $('#goTo'+picIndex).css('font-weight','700');

	  		
//	  		console.log(scrollDest);	        
	        	
	        	}

			
			}
			
			
			function directPic(q){
				if(clickable==true && q!=picIndex){
	        	
	          $("*[id^=goTo]").css('font-weight','400');

	        	
			//	$('#DEBUGBOX').append('Start');
	        	//set up array with widths

			
			
			//End setup
	        	
	        	//block multiple clicks
	        	clickable=false;
	        	
				//$('#DEBUGBOX').append(' Max='+maxScroll);

	        	
	        	//set up scroll destination
	        	
	        	if(q>picIndex){
	        	var scrollDest= ($("#s_photo"+picIndex).css("width"));
				scrollDest=scrollDest.substring(0,scrollDest.length-2);
				scrollDest=(Number(scrollDest)+picGap);
	        	
	        	var adder=0;
	        	
	        	for(var r=(picIndex+1);r<q;r++){
				
				
				adder=($("#s_photo"+r).css("width"));
				adder=adder.substring(0,adder.length-2);
				adder=(Number(adder)+picGap);
				
	        	scrollDest+=adder;
	        	
	        		}
	        		
	           	scrollDest="+="+scrollDest;

	        	}
	        	
	        	if(q<picIndex){
	        	
	        	//$('#DEBUGBOX').append(' Dest:'+q);

	        	var scrollDest= ($("#s_photo"+(picIndex-1)).css("width"));
				scrollDest=scrollDest.substring(0,scrollDest.length-2);
				scrollDest=(Number(scrollDest));
	        	
	        	var adder=0;
	        	
	        	//$('#DEBUGBOX').append(' BEGINS:'+scrollDest);
	        	
	        	for(var r=(picIndex-2);r>=(q);r--){
			
				//$('#DEBUGBOX').append(' Current:'+r);

				//$("#s_photo"+r).css('border','solid red 2px');

				adder=($("#s_photo"+r).css("width"));
				adder=adder.substring(0,adder.length-2);
				

				adder=(Number(adder)+picGap);
				
				//$('#DEBUGBOX').append(' adding:'+adder);

	        	scrollDest+=adder;
	        	
	            //$('#DEBUGBOX').append(' after '+r+": "+scrollDest);

	        	

	        		}
	        	
	        	//fadder=($("#s_photo"+q).css("width"));
				//fadder=fadder.substring(0,fadder.length-2);
	        	
	        	scrollDest+=picGap;
	        	
	        	//scrollDest+=fadder;

	         	scrollDest="-="+scrollDest;

				//$('#DEBUGBOX').append(' Finale:'+scrollDest);
				
	        	
	        	}
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	              	
	        	

	        		    	    				//			$('#DEBUGBOX').append(' TheDest'+scrollDest);

	        	
	        	picIndex=q;
	        	
	        
	        	$(".sliderPhoto").fadeTo(moveDur/4,.5);
		   	    $("#s_div"+picIndex).fadeTo(moveDur,1);


	   		    $("#topBody_photo2_scroll").scrollTo(scrollDest, moveDur, 
	   		    {
	   		    axis:'x'
	   		    });
		   	    
		   	    makeClickable();
		   
		   		$('#goTo'+picIndex).css('font-weight','700');

	  		
//	  		console.log(scrollDest);	        
	        	
	        	}
	        }
	        	
	        
			
			
	        $("#goNext").click(function(){
	        nextPic();
	        
	        	        })
	        
	        
	        $("#goPrev").click(function(){
	        prevPic();
	        //	directPic(7);
	        })
	        
	      
	        
	       // $("#s_div"+)
	        
	        
	        
	        
	     });
	     
	     //end jQuery
