$().ready(function(){	
//	popInit();	
	sendForm();
});


function popInit() {
	$("#submit").prettyPopin({
		modal : false, /* true/false */
		width : 480, /* false/integer */
		height: 300, /* false/integer */
		opacity: 0.5, /* value from 0 to 1 */
		animationSpeed: 'fast', /* slow/medium/fast/integer */
		followScroll: true, /* true/false */
		loader_path: 'gr/prettyPopin/images/ajax-loader-3.gif', /* path to your loading image */
		callback: function(){} /* callback called when closing the popin */
	});
};

function sendForm(){
	$("#sendquote").submit(function(){
		var $result = true;
		$(".compulsory").each(function(){
			if($(this).val() == ""){							
				$result = false;
				$(this).removeClass("good");
				$(this).addClass("error");			
			} else {
				$(this).removeClass("error");
				$(this).addClass("good");				
			}//end if
		});	
		if($result == true){
			var req_address = $(this).attr("action");			
			var serial = $(this).serialize();		
			$.post(req_address,serial,function(data){											  
				$("#form_area").html(data);
				//$("#sendquote").fadeOut("slow",function(){
					$("#response").hide().fadeIn("slow");											 
				//});
				/*if($("#restoreform").size() > 0){
					$("#restoreform").click(function(){													 
						return false;								 
					});	
				}*/
			});
		}//end if
		return false;
		//return $result;
	});		
}
