jQuery(document).ready(function($) {

	/* Grid hack */
	$("#objects ul").each(function(){ 
		$(this).find("li:nth-child(4n)").addClass("grid_last");
   });
   $("#gallery_thumbs").each(function(){ 
		$(this).find(".ngg-gallery-thumbnail-box:nth-child(3n)").addClass("grid_last");
   });

   /* Map toggle */
	$("#gmap_objects").hide();
	/*$("#nav_map").click(function(){
		$(this).toggleClass( "active" );
		$("#gmap_objects").slideToggle("fast");
		checkResize();
		google.maps.event.trigger(map, "resize");

	});
	*/
	
	$("#gmaplink").click(function(){
		$("#gallery_image_box").hide("fast");
		$("#map_single").removeClass("hidden");
		
	});
	
	/* Gallery make image */
	$(".ngg-gallery-thumbnail-box a").each(function() {
		$(this).click(function(){
			$("#map_single").addClass("hidden");
			$("#gallery_image_box").show("fast");
			img_link = $(this).attr("href");
			img_title = $(this).attr("title");
			if( img_title.length > 1 ) {
				img_titlehtml="<p>"+img_title+"</p>";
				} else if( img_title.length <2 ) {
				img_titlehtml="";
				} 
			//alert(img_title.length);
			
			img_box =""+img_titlehtml+"<img src='"+img_link+"'>";
			//alert(img_link);
			$("#gallery_image_box").html(img_box );
			return false;
		});
	});

	
	
	
	
	
	
   
	/* Form value hack */
	$(".input_label label").each(function() {
		sisu=$(this).html;
	});
	
	
	
	
	/* Form clear */
	$('.contct_form input, .contct_form textarea').focus(function() {
			value=$(this).val();
			$(this).attr("value","");
		});
		$('.contct_form input,.contct_form textarea').blur(function() {
			if($(this).val()=="") {
				$(this).val(value);
			}
		});
	
	
	
	/* Filter */
	$(".nav_filter").click(function(){
		 var myFilter = $(this).attr("filter");
		$("#objects li").each(function(){ 
			$(this).removeClass("passive");	
			var objFilter = $(this).attr("filter");
			if (myFilter != objFilter){
				$(this).addClass("passive");
			}
		});
		$(".nav_filter").each(function(){
		$(this).removeClass("active");	
		 });	
		$(this).addClass("active");
		

	});
	/* Reset filter */
	$("#reset").click(function(){
		$("#objects li").each(function(){ 
			$(this).removeClass("passive");	
		});
		$(".nav_filter").each(function(){
			$(this).removeClass("active");	
			
		 });
		$(this).addClass("active");	
	});

});
