$(function() {
	
	set_lp_height();
	
	//site search
	$("#search").submit(function(e){		
		txt = $("#search").find("input[type=text]");		
		if(txt.val()=='') { 
			e.preventDefault();
			txt.focus(); 
		}
	});
	
	$("#search a").click(function(e){
		e.preventDefault();
		txt = $("#search").find("input[type=text]");
		if(txt.val()=='' || txt.val()==search_phrase) {
			$(txt).focus(); 
		} else {
			$("#search form").submit();
		}
	});
	
	function site_search(e) { 
		
	}
	
	/* FORM */
	var w_color = '#a8a8a8';
	//applying watermark to the textboxes
	$('#search_keyword').Watermark(search_phrase,w_color);
		
	
	//HOVER EFFECT FOR THE MENU
	$("#menu ul li.main").hoverIntent({ 
		over: function(){ $(this).find("ul:first").slideDown(200); }, // function = onMouseOver callback (REQUIRED)
		timeout: 0, // number = milliseconds delay before onMouseOut
		out: function(){ $(this).find("ul:first").slideUp(200); } // function = onMouseOut callback (REQUIRED)
	});

	
	
	//go to top
	$('#go_to_top').click(function(evt) {
		var destination = $('#main').offset().top;
		$("html,body").animate({ scrollTop: destination-50}, 300 );
		evt.preventDefault();
	});
	
	//jquery corners
	$(".corner3").corner('3px');
	
	//textshadow
	var option = { x:1, y:2, radius:3, color:"#fff"};
	$(".text_shadow").textShadow( option );
	
	
	// setup ul.tabs to work as tabs for each div directly under div.panes
	$("#footer_tabs").tabs("div.panes > div.pane");
	
	//the locations in the footer
	//alert(($('.loc_dd').find('ul').height()+$('.loc_dd').height()));
	loc_ul_h = $('.loc_dd').find('ul').height();	
	
	$(".loc_dd span").click(function(e){		
		//$('.loc_dd').find('ul').stop().animate({ top: '-'+loc_ul_h }, 200);	
		$('.loc_dd').find('ul').fadeIn(200);
	});
	
	$('.loc_dd ul li').click(function(e){
		id = $(this).attr('data-filter');		
		$(".loc_dd span").text($(this).text());
		//$('.loc_dd').find('ul').stop().animate({ top: '+'+loc_ul_h }, 0);
		$('.loc_dd').find('ul').fadeOut(200);
		$('.loc_panes .pane').hide();
		$('#loc_pane_'+id).show();
	});		
	
});


function set_lp_height() { 
	//alert($("#rp").height());
	$("#lp_spacer").height($("#rp").height()-$("#submenu").height()-$("#lp .back-container").outerHeight());
}

