// JavaScript Document
$().ready(function(){
	callback_init();			   
});

function callback_init(){
	if($("#callback").length > 0){
		$("#callback-form").submit(function(){	
			if($("#callback_name").val() != "" && $("#callback_phone").val() != ""){
				var req_address = $(this).attr("action");
				req_address += "&ac=true";
				var serial = $(this).serialize();			
				$.post(req_address,serial,function(data){
					$("#callback").html(data);
					$("#callback").fadeIn("slow");
				});				
			} else {
				var firstfield = "callback_name";
				if($("#callback_name").val() != ""){
					firstfield = "callback_phone";
				}
				$.prompt('Please fill all the compulsory fields',{top : "40%",callback: function(){ $("#"+firstfield).focus();	}});
			}
			
			return false;	
		});
	}
}

function report_init(){
	$("#sendreport").click(function(){
		$("#report_form").submit();		
		return false;
	});
	$("#report_form").submit(function(){
		if($("#report_name").size() > 0){
			if($("#report_name").val() == ""){
				alert("You have to type your name prior to submit the report");
				$("#report_name").focus();
				return false;	
			}	
		}//end if
		if($("#report_email").size() > 0){
			if($("#report_email").val() == ""){
				alert("You have to type your email address prior to submit the report");
				$("#report_email").focus();
				return false;	
			}	
		}//end if
		if($("#reason").val() == ""){
			alert("Please provide us some details");
			$("#reason").focus();
			return false;	
		}			  
		return true;
	});
}

