// JavaScript Document
$(document).ready( function() 
							
	{
		loc=top.location.href;
		thisq_loc=loc.lastIndexOf('?')
		//this_loc=loc.substring(loc.lastIndexOf('/'), loc.length);
		this_loc=loc.substring(loc.lastIndexOf('/'), thisq_loc);
	//alert(this_loc);
			if (this_loc=="/digital-art.php" || this_loc=="/websites.php")
			{
	
	$("#data h2").after('<br /><div id="scroll-nav"><a href="#" id="prev">Prev</a> <a href="#" id="next">Next</a></div>');

							
			}
			
		$("#data").append('<div id="loader-holder"></div>');
		//$("#loader-holder").css({width:700, height:1100, margin:"auto", clear:"both", display:"block"});
		
	$("#loader-holder").css({width:700, margin:"auto", clear:"both", display:"block", "padding-bottom":"50px"});

		
		$spacing=140;		
		$width=$spacing*count_thumbs();
		$viewable=$spacing*5;
		$neg_width=$width*-1;
		$speed=700;
		$(".thumbnails").css({width:$width, "margin-left":0});
		$(".thumbnails li").css({margin:5, padding:0});
		$("#scroll-box").css({width:$viewable, height:200, overflow:"hidden", margin:"auto"});	
		$cur_thumbs=count_thumbs();
		$("#scroll-nav").css({margin:"auto", "text-align":"center"});
		$("#next").click(function(){move_left(); return false});
		$("#prev").click(function(){move_right(); return false});	

		

		$(".thumbnails li a").click(function(){
							 loc=$(this).attr("href");
							 img=new Image();
							 vis=$("#loader-holder").css("display");
							// alert (vis);
		$("#loader-holder").empty().append("Loading...");
	//hard code image to aoid IE 6 cache bug. 
	
						$(img).load(function(){
											 $("#loader-holder").empty().hide().append('<img src=\"'+loc+'\" />').show("slow");
											 
											 }).attr("src",loc);
						   	 //$("#loader-holder").empty().append('<img src=\"'+loc+'\" />');
							 return false;
						   });

		function count_thumbs ()
		{
			 var $thumbs;
			$thumbs=$('.thumbnails').children().size();
			//alert($thumbs);
			return $thumbs;
		}
		
		
		function get_margin()
		{
			$thu_margin=$("ul.thumbnails").css("margin-left");
			return $thu_margin;
		}
		
		
function move_left()
		{
		//get current position
		
		var current_pos=$("ul.thumbnails").css("margin-left");
		current_pos=parseFloat(current_pos);
		//3 is how many thumbs will moved
	//set boundary make sure they can't click too much
	//current postion with divide evenly with viewable
			if((current_pos>$neg_width+$viewable) && !(current_pos%$viewable))
			{
				$left_position=(current_pos-$viewable);
				$("ul.thumbnails").animate({ 
			   marginLeft: $left_position
				}, $speed );
			}
      
		}
		
		function move_right()
		{
		var current_pos=$("ul.thumbnails").css("margin-left");
		 current_pos=parseFloat(current_pos);
		//set boundary
			if(current_pos<0 && !(current_pos%$viewable))
			{
				$right_position=current_pos+$viewable;
				$("ul.thumbnails").animate({ 
			   marginLeft: $right_position
				}, $speed );
			
			}
		
			
 
		}




	
	
	
	
		
		
	
	
	
	
	
	$(".thumbnails img").reflect();
	
	
	
	
	
	});