jQuery(document).ready(function($){
	
	// Show all posts when the page is loaded
	var isloaded;
	if(isloaded != true){
	
	// Load all posts
	var catnamepost = "work";
		
	var Addresult = "catnamepost=" + catnamepost;
	$.ajax({ 
	type: "POST", 
	url: "http://www.madebyanalogue.co.uk/example.php",
	data: Addresult, 
	success: function(data){/*alert("name: "+ name); alert( "Data Saved: " +data );*/$("#description_span").html(data);} 
	});

	
	// Set isloaded to false
	isloaded = false;
	}
	
	// Show posts when the page is loaded once
	$("#portfolio-filter li a").click(function(){
											   
		var name = $(this).text().toLowerCase();
		
		if(name == "all"){
			name = "work";
		}
		
		// Ajax call to get the right post from the category name	
		var catnamepost = name;
			
		var Addresult = "catnamepost=" + catnamepost;
		$.ajax({ 
		type: "POST", 
		url: "http://www.madebyanalogue.co.uk/example.php",
		data: Addresult, 
		success: function(data){/*alert("name: "+ name + " titlepost: "+ titlepost); alert( "Data Saved: " +data );*/$("#description_span").html(data);} 
		});
	
		return false;
			
	});

	// Highlight post on roll over thumbnail
	$("#portfolio-list li a").hover(function(){
		var title = $(this).attr("title");
		$("#sidebar-left .left-col2 a:contains('" + title + "')").addClass("active");
	});
	
	// Desactivate highlights on mouseout
	$("#portfolio-list li a").mouseout(function(){
		var title = $(this).attr("title");
		$("#sidebar-left .left-col2 a:contains('" + title + "')").removeClass("active");
	});
	
	// Highlight thumbnail on roll over post list item
	$("#sidebar-left .left-col2 a").live("hover", function(){
		var title2 = $(this).attr("title");
		//alert("title : " + title2);
		
		// Use (this) to aplly the style for all 
  		if ($(this).attr("title") == title2 ) { $("#portfolio-list li a[title="+title2+"]").parent().stop().animate({"opacity": "1"}, "slow");	}
	
	});
	
	$("#sidebar-left .left-col2 a").live("mouseout", function(){
		var title2 = $(this).attr("title");
		// Use (this) to aplly the style for all 
  		if ($(this).attr("title") == title2 ) { $("#portfolio-list li a[title="+title2+"]").parent().stop().animate({"opacity": "0.7"}, "slow");	}
	
	});
	
	//$(".single a").live("hover", function(){
	//alert( $(this).text() + titlepost);
	//});
	
	
	jQuery(window).load(function() {
	jQuery('#loading-image').fadeOut(400);
	jQuery('#wrapper').fadeIn(500);
	
	
	});
	
	
	var eT = 0;     
    $('.all').hide().each(function() {
        $(this).delay(eT).fadeIn('slow');
        eT += 280;
    });

});//end

