// jQuery functions
$(function(){
	$("#dialog").jqm();
	
	$("#nav-c a").click(function(event){
		event.preventDefault();
		$.scrollTo( $('#footer'), 400 );
	});
		/*$("label.l-inline + .cf-elem").focus(function () {
			$(this).parent().find("label.l-inline").addClass("focus");
			//$(this).parent().find("input.txtinput").addClass("hidden");
			//$(this).parent().find("textarea.txtarea").removeClass("hidden");
			//alert( $(this).parent().find("textarea.txtarea").size() )
			//if ( $(this).parent().find("textarea.txtarea").size() == 1 ) {
			//	$(this).parent().find("textarea.txtarea").focus();
			//}
		});*/
		
	  $("label.l-inline + .cf-elem").each(function (type) {
			if($(this).val() !== "") { 
				$(this).parent().find("label.l-inline").addClass("has-text");
			}
			
			$(this).focus(function () { 
				$(this).parent().find("label.l-inline").addClass("focus");
			});
					
			$(this).keypress(function () {
				$(this).parent().find("label.l-inline").addClass("has-text").removeClass("focus");
			});
			$(this).blur(function () {
				
				if($(this).val() == "") {
					$(this).parent().find("label.l-inline").removeClass("has-text").removeClass("focus");
					//if($(this).attr('type')=='text' && $(this).parent().find("textarea.txtarea").size() == 1) return false;
					//if ( $(this).parent().find("textarea.txtarea").size() == 1 ) {
						//$(this).parent().find("input.txtinput").focus();
					//	$(this).parent().find("input.txtinput").removeClass("hidden");
					//	$(this).parent().find("textarea.txtarea").addClass("hidden");
					//	$(this).parent().find("label.l-inline").removeClass("focus");
					//}
				}
				
				
			});
		});
	
	$("#cf-contact").validate({
		errorElement: "span",
		errorClass: "required",
		errorLabelContainer: ".contact-errors",
		wrapper: "span",
		rules: {
			"cffirm": {
				required: true				
			},			
			"cfemail": {
				required: true,
				email: true
			},
			"cfmessage": {
				required: true
			}			
		},
		messages: {
			cffirm: "Introduce&#355;i numele firmei",
			cfmessage: "Introduce&#355;i mesajul",
			cfemail: {
				required: "Introduce&#355;i adresa de e-mail",
				email: "Introduce&#355;i o adres&#259; de e-mail valid&#259;"
			}
		},
		submitHandler: function(form){
				$("#cf-contact").ajaxSubmit(function(data){
					$(".data-recieved").html(data);
				});	
	    }
	});

});

