JQ(document).ready(function(){
//	JQ("#menuh li > ul").hide();
	JQ("#menuh li").hover( function(){
		JQ("ul",this).slideDown("slow");
		JQ(this).addClass("active");
	},function(){
		JQ("ul",this).slideUp("slow");
		JQ(this).removeClass("active");
	});
});

function refreshVerImg(imgid){
	var currentTime = new Date();
	document.getElementById(imgid).src = '/includes/captcha.php?' + currentTime.getTime();
}

JQ().ready(function(){
	JQ('label.required').append('&nbsp;<em class="required">*</em>&nbsp;');	
});

JQ(document).ready(function() {
	var loader = JQ('<p id="loader"><img src="images/ajax-loader.gif" alt="loading..." />Sending form ..... </p>').hide();
	JQ().ajaxStart(function() {
		JQ("#result").show().html(loader);
		loader.show();
	}).ajaxStop(function() {
		loader.hide();
		refreshVerImg('imgCaptcha');
	});

	JQ().ajaxError(function(a, b, e) {
		throw e;
	});
	
	var v = JQ("#formContact").validate({
		errorPlacement: function(error, element) {
			error.appendTo( element.parent("td") );
		},
		submitHandler: function(form) {
			JQ(form).ajaxSubmit({
				target: "#result",
				after: function(result) {
					JQ("#result").show();
					if(result.status) {
						v.showErrors(result.text);
						v.focusInvalid();
					}
				}
			});
		}
	});
	
	JQ("#trimite").click(function(){
		JQ("form#formContact").submit();
		return false;
	});
	
});