$(document).ready(function(){
						   
$("#morebutton").click(function() {
								slideleft();	 
								 });
$("#prevbutton").click(function() {
								slideright();	 
								 });

$("#hidewintext").click(function() {
								closewindow();	 
								 });

$("#showwintext").click(function() {
								openwindow();	 
								 });

$("#desc").css("opacity",0);

newleft=35;
$("#infowinshader").css("opacity",.7);
myfadeinimage=$(".fadeinimage").children(".puthere");
myfeatureimage=$(".featureimage").children(".puthere");

firstthumbpos=$(".slidethumb:first").css("left");
lastthumbpos=$(".slidethumb:last").css("left");

// start the slide left and slide right functions

function hideprevious(){
	$("#prevbutton").css("top",700);
}
function showprevious(){
	$("#prevbutton").css("top",485);
}
function hidenext(){
	$("#morebutton").css("top",700);
}
function shownext(){
	$("#morebutton").css("top",485);
}

function checkbuttons(){
	//alert ($(".slidethumb:first").css("left"));
	if ($(".slidethumb:first").css("left")=="35px"){
	hideprevious();
	
		
	} else {
	showprevious();		
	}
	
	if ($(".slidethumb:first").css("left")=="-870px"||$(".slidethumb:eq(9)").length == 0){
	hidenext();	
		
	} else {
	shownext();		
	
	}
	
}

function slideleft(){
	newleft=-870;
$(".slidethumb").each(function(){

$(this).animate({left: newleft},{ queue:true, duration:500, easing: 'easeOutExpo'});

newleft=newleft+100;	
});
setTimeout(function(){checkbuttons();}, 600);	
} // end of slide left

function slideright(){
	newleft=35;
$(".slidethumb").each(function(){

$(this).animate({left: newleft},{ queue:true, duration:500, easing: 'easeOutExpo'});
newleft=newleft+100;	
});
setTimeout(function(){checkbuttons();}, 600);	

	
} // end of slide left






		
		
function clearallthumbs(){
	$(".slidethumb").each(function(){
			
$(this).css("opacity",.4);	
});
}		
function showthehidebutton(){
$("#hidewintext").css("opacity",1);	
//alert($(".slidethumb:eq(9)").css("left"));
}
function hidethehidebutton(){
$("#hidewintext").css("opacity",0);	
}
function showtheshowbutton(){
$("#showwintext").css("opacity",1);	
}
function hidetheshowbutton(){
$("#showwintext").css("opacity",0);	
}
function slidewindow(){
	
	if ($('#infowin').css("width")=="0px"){
		//alert ("troy"+$('#infowin').css("width"));
	openwindow();
	} else {
	closewindow();	
		
	}
	
}
function closewindow(){
	hidethehidebutton();
	hidethewords();
	$('#infowin').stop().animate({width: 0},{ queue:true, duration:1000, easing: 'easeOutExpo', complete:showtheshowbutton });	

}
function openwindow(){
	hidetheshowbutton();
	$('#infowin').stop().animate({width: 300},{ queue:true, duration:1000, easing: 'easeOutExpo', complete:showthewords });	
	checkbuttons();	
	
	
}
function showthewords(){
	

	$('#desc').stop().animate({opacity: 1},{ queue:true, duration:500, easing: 'easeOutExpo', complete:showthehidebutton });	
	
}
function hidethewords(){
	

	$('#desc').stop().animate({opacity: 0},{ queue:true, duration:100, easing: 'easeOutExpo' });	
	
}

$("#showin").click(function() {
		//$('#infowin').toggleClass('newClass', 1000);
	slidewindow();
			
					
							});

$(".slidethumb").each(function(){
			
			
			

			$(this).css("opacity",.4);	
			
			//$(this).animate({top: 500},{ queue:true, duration:1000 });
			//$(this).animate({left: newleft},{ queue:true, duration:500 });
			$(this).animate({top: 485},{ queue:true, duration:1000, easing: 'easeOutExpo' }).animate({left: newleft},{ queue:true, duration:500, easing: 'easeOutExpo',complete:openwindow  });
			newleft=newleft+100;
			
			$(this).mouseover(function() {	
									if($(myfadeinimage).attr("src")!="/images10/portfolio_images/"+(this.id)+".jpg"){
						$(this).stop().animate({opacity: 1},{ queue:false, duration:250 });
									}
									   }); //end of mouse over
			
			$(this).mouseout(function() {	
									  if($(myfadeinimage).attr("src")!="/images10/portfolio_images/"+(this.id)+".jpg"){
						$(this).stop().animate({opacity: .4},{ queue:false, duration:250 });
									  }
									   }); //end of mouse out
			
			
			
								  
	$(this).click(function() {
						   
	if($(myfadeinimage).attr("src")!="/images10/portfolio_images/"+(this.id)+".jpg"){
		
		clearallthumbs();
						 //  $('#infowin').removeClass('newClass', 1000);
		//$("#myhide").attr("src", "http://www.sofia-rose.com/archives1208/large/"+(this.id)+".jpg");				   
						   
		closewindow();	
		$(this).css("opacity",1);
		
		myloadlayer=$("#loader");
		//$(myfadeinimage).attr("src", "images/realgallims/"+(this.id)+".jpg");
		$(myfadeinimage).attr("src", "/images10/portfolio_images/"+(this.id)+".jpg");
		$(myloadlayer).css("top",200);
		myseeker=(this.id);
		
		$(myfadeinimage).load(function(){
								$(myloadlayer).css("top",-425);	   
		$(myfeatureimage).stop(true).animate({opacity: 0},{ queue:false, duration:1000, complete:function(){
																							   
			$(myfeatureimage).attr("src",$(myfadeinimage).attr("src"));
			$(myfeatureimage).css("opacity",1);
			//start get the new text
		
		$.get("/portserver.php", { ID: ""+(myseeker)+"" },
   function(data){
	  newdata= data.split("|");
    // alert("Data Loaded: "+(myseeker) + data);
	$("#desc").html(newdata[1]);
	$("#porttitles").html(newdata[0]);
	openwindow();
	
   });
		
		
		// end get the text
			
			
			} // end of complete function
		 }); // end of animate
		
		
		
		
		
		
		
		
		
									   }); //end of load function
			
	}
	});	//end of onclick		
			
			
			
			
			
			
			
			
			
			
			
}); //end of slidethumb each
						   
						   
						   

						   
						   
}); //end of jquery
