$(document).ready(function() {
						   
	$("#id_type_used").change(function() {
		
		$('#search_container div').each(function(index){
			$('#search_container div').eq(index).addClass('hide');
			$('#search_container div').eq(index).removeClass("show");
		});
		
		$("#search_" + $(this).val()).addClass("show");
	});
						   
	$(".tooltip").mouseover(function(){
		$left = $(this).offset().left+($(this).width()/2)+60+"px";
		$top  = $(this).offset().top+$(this).height()-40+"px";
		$text = $(this).attr("title").split("|");
		$("#prod_title").text($text[0]);
		$("#prod_brief").text($text[1]);		
		$("#tooltip").css("left", $left).css("top", $top).show();
	});
	$(".tooltip").mouseout(function(){
		$("#tooltip").hide();
	});
	
	
	$(".validatefrm").submit(function() {
		var frm = $(this);
		var errors = 0;
		frm.find("input").each(function(i) {
			var el = $(this);
			if(el.attr("req")=="true") {
				if(el.attr("type")=="text" || el.attr("type")=="password") {
					if($.trim(el.val())=="") {
						alert(el.attr("title"));
						el.focus();
						errors = 1;
						return false;
					}
				}
			}
		});
		if(errors==1) {
			return false;
		}
		frm.find("select").each(function(i) {
			var el = $(this);
			if(el.attr("req")=="true") {
				if($.trim(el.val())=="0") {
					alert(el.attr("title"));
					el.focus();
					errors = 1;
					return false;
				}
			}
		});
		if(errors==1) {
			return false;
		}
		frm.find("textarea").each(function(i) {
			var el = $(this);
			if(el.attr("req")=="true") {
				if($.trim(el.val())=="") {
					alert(el.attr("title"));
					el.focus();
					errors = 1;
					return false;
				}
			}
		});
		if(errors==1) {
			return false;
		}		
	});
	
				
});
