	$(document).ready(function(){
		$('#introduction-show').show();
		$('#introduction-1').hide();
		$('#introduction-2').hide();
		$('#introduction-hide').hide();
		$('#introduction-show> a').click(function(){
			$('#introduction-1').slideDown(2500);
			$('#introduction-2').slideDown(2500);
			$('#introduction-show').hide('slow');
			$('#introduction-hide').show('slow');
			$('#stuff-grid>li>a.front-title span').css("background-color","black");
			return false;
		});
		$('#introduction-hide> a').click(function(){
			$('#introduction-1').hide();
			$('#introduction-2').hide();
			$('#introduction-show').show('slow');
			$('#introduction-hide').hide('slow');
			$('#stuff-grid>li>a.front-title span').css("background-color","transparent");
			return false;
		});

		// Show grid options
		$("div#grid-options a.view-options").click(function(){
			$("div#grid-options").toggleClass('show');
			if($("div#grid-options").hasClass('show')){
				$("div#grid-options form").fadeIn('slow');
				$("div#grid-options a.view-options").html('Hide Options');
			}
			else{
				$("div#grid-options form").fadeOut('fast');
				$("div#grid-options a.view-options").html('Sort by location / category?');			
			}
			return false;
		});
		// Load new front page grid
		$("div#grid-options a.submit, table#grid-items a.next-page, table#grid-items a.previous-page").live('click', function(){
			// Get the gride options (page, category, city, person, color, etc)
			var page = $('#grid-options form input#sort-page').val();
			// Set the new page value
			if($(this).hasClass('next-page')) page++;
			else if($(this).hasClass('previous-page')) page = page - 1;
			if($(this).hasClass('submit')) page = 1;
			$('#grid-options form input#sort-page').val(page);
			var person = $('#grid-options form #sort-person').val();
			var city = $('#grid-options form #sort-city').val();
			var color = $('#grid-options form #sort-color').val();
			var category = $('#grid-options form #sort-category').val();
			$('table#grid-items td').fadeOut('fast', function(){
				$('table#grid-items').html('<tr class="loading"><td><h3>Loading</h3></td></tr>');
			});
			$('table#grid-items').load("/wp-content/themes/default/script/load_grid.php?page="+page+"&category="+category+"&color="+color+"&city="+city+"&person="+person);
			return false;
		});


		$('#stuff-grid li, table#grid-items td, table.sidebar-grid td').live('mouseover mouseout', function(event) {
			if (event.type == 'mouseover') {
				var description = $(this).find("em");
				if(!description) return false;
				$(this).css("z-index","5000");
				$(this).find("span").hide();
				$(this).find("a>img").stop().css("z-index","1000").animate({"height": "88px","width": "88px","top": "-16px","left": "-16px", "padding":"4px", "background":"black"}, 350);
				$(this).find("em").css("z-index","5005").show();
			} else {
				$(this).css("z-index","100");
				$(this).find("em").hide();
				$(this).find("span").fadeIn(400).css("z-index","5005");
				$(this).find("a>img").stop().animate({"height": "58px","width": "58px","top": "0px","left": "0px", "padding":"2px"}, 300).css("z-index","1");
			}
		});
		
		/*$("#send-message").hide();
		$("h3").click(function(){
			$("#send-message").toggle('slow');
		});
		$("#send-message").validate({
		  rules: {
			email: {
			  required: true,
			  email: true
			}
		  }
		});*/
	});