$(document).ready(function() {  
	
	$("div.panel_button_advanced").click(function(e){  
		//Cancel the link behavior  
		//e.preventDefault(); 
		
		//Get the screen height and width  
		var maskHeight = $(document).height();  
		var maskWidth = $(window).width();  
		
		//Set height and width to mask to fill up the whole screen  
		$('#mask').css({'width':maskWidth,'height':maskHeight});  
		
		//transition effect       
		$('#mask').show();      
		$('#mask').fadeTo("fast",0.8);    
		$('.window').css('width', "53.7em");
		//Get the window height and width  
		var winH = $(window).height();  
		var winW = $(window).width();  
		
		var modalH = $('.window').height()/2;
		var modalW = $('.window').width()/2;
		
		var modal_top = Math.round((winH/2)-modalH)-10;
		var modal_left = Math.round((winW/2)-modalW)-20;
		
		//alert (modal_top +":"+modal_left);
		//Set the popup window to center  
		$('.window').css('top', modal_top );  
		$('.window').css('left', modal_left); 
		 
		var $loading_html = "<div align='center' style='margin-top:7em;'><img src='/graphics/ajax-loader.gif' /> </div>";
		$('.window').html($loading_html);
		$('.window').show(); 
		
		
		if($(".panel_button_advanced").attr('title') != ""){		
			var $url = "/search/advanced_search_form/";
		}
		else{
			var $url = "/public/advanced_search_form/";
			}
		
	$.post($url, { lightbox_name: "Untitled Gallery" }, function(data){	
			$('.window').html(data); 
			$("div.panel_button_advanced").toggle();
			$('.close').click(function (e) {  
				//Cancel the link behavior  
				e.preventDefault();  
				$('#mask, .window').hide();  
			}); 
		});		  	
	});	
	
  $("div#hide_button_advanced").click(function(){
		//Cancel the link behavior  
		e.preventDefault();  
		$('#mask, .window').hide();  
  	});
  
   $("ul#home_slide").innerfade({ animationtype: 'fade', speed: 1500, timeout: 4000  });


   
    
     $("#search").validate();

	
});

