// Deltascheme Website Theme 2011

function init_search_box(){

	$("#search_control").focus(function(){
		// has focus
		$("#search_box").addClass("hover");
		$("#search_control").addClass("hover");
		if($(this).val()=="Search") $(this).val("");
	}).blur(function(){
		// loses focus
		$("#search_box").removeClass("hover");
		$("#search_control").removeClass("hover");
		if ($(this).val()=="") $(this).val("Search");
	});
	
	$("#search_control").keypress(function(event) {
		if ( event.which == 13 ) {
			event.preventDefault();
			$("#search_form").submit();
   		}
   	});
}

function init_menu_panels(){



	$(".menu > UL > LI > A").click(function(){

		// alert($(this).attr("panel"));
		
		if ($(this).attr("panel") != "menu_panel_products"){
			
			var panel = "#" + $(this).attr("panel");
			
			if ($(panel).hasClass("hidden")){
				// get coords of clicked control
				var x = $(this).offset().left;
				var y = $(this).offset().top;
				var h = $(this).height();
	
				// hide all panels
				$(".menu_panel").addClass("hidden");
	
				// move the appropriate panel to the appropriate place
				$(panel).css("left",x);
				$(panel).css("top",y + h + 5);
			
				$(panel).removeClass("hidden");
			} else {
				$(panel).addClass("hidden");
			}
	
			// return false to prevent postback
			return false;
		}
	});
}

$(document).ready(function(){

	init_search_box();
	init_menu_panels();
	
	$("A").hover(function(){
		$(this).css("cursor","pointer");
	},function(){
		$(this).css("cursor","auto");
	});
	
	$("BODY").click(function(){
		$(".menu_panel").addClass("hidden");
	});
	
	$(function(){
		$("#slides").slides({
			effect:'fade',
			play:7500
		});
	});

});
