/* Portfolio Page */
$(document).ready(function(){ 
        //$(document).pngFix(); 
		
		// Add onClick
		$(".test").click(function(){
			$.post("getPortfolio.php",{
				client: $(this).attr("href")
				}, function(xml) {
					fadeOutDetails(xml);					
			});
		});
		
		// Add onHover
		$(".test").hover(
			function(){ $("img", this).fadeTo("fast", 0.9) 
/*			$("img", this).animate( { borderColor:"ff0000" }, 1000 )*/ },
			function(){ $("img", this).fadeTo("fast", 1)
			/*$("img", this).css({ borderColor: "272727"}) */}
		);
		
		// Add white
		$(".test").css( {background:"#FFFFFF"} );
		
		
		//if(window.location.hash){
		
		$.post("getPortfolio.php",{
			client: window.location.hash
			}, function(xml) {
				if($("redirect",xml).text())
				{
					window.location.href = "portfolio.php";
					return false;
				}	
				fadeInDetails(xml);					
		});
			
			
		//}
	 });	
	
	$(document).ajaxStart(function (){
		$("#porfolio_image").fadeOut("fast", function(){
			$("#ajaxBusy").show();
		});	
	});
	
	$(document).ajaxStop(function (){
		$("#ajaxBusy").hide();
	});

	function fadeOutDetails(xml) {
		$("#portfolio_client").fadeOut("slow");
		$("#portfolio_project").fadeOut("slow");
		$("#porfolio_description").fadeOut("slow", function(){
			fadeInDetails(xml);
		});
	}
	
	function fadeInDetails(xml){
		$("#portfolio_client").html($("client",xml).text()).fadeIn("slow");
		$("#portfolio_project").html($("project",xml).text()).fadeIn("slow");
		$("#porfolio_description").html($("description",xml).text()).fadeIn("slow");
		
		$("#ajaxBusy").hide();
		
		$("#porfolio_image").css({background:"url('" + $("image",xml).text() + "')"}).fadeIn("slow");
	}