$(function() {
  $("input[type=image]#submit_btn").click(function() {
		if($("select#cv_id").val()=='')
		{
			alert("Please Select Your CV");
			$("select#cv_id").focus();
			return false;
		}
		if($("textarea#cover_letter").val()=='')
		{
			alert("Please Enter Text For Cover Letter");
			$("textarea#cover_letter").focus();
			return false;
		}
		//if($("input#nic1").val()=='')
//		{
//			alert("Please Enter NIC Number");
//			$("input#nic1").focus();
//			return false;
//		}
//		if($("input#nic2").val()=='')
//		{
//			alert("Please Enter NIC Number");
//			$("input#nic2").focus();
//			return false;
//		}
//		if($("input#nic3").val()=='')
//		{
//			alert("Please Enter NIC Number");
//			$("input#nic3").focus();
//			return false;
//		}
		var jb_id = $("input#jb_id").val();
		var actionid = $("input#actionid").val();
		var emp_id = $("input#emp_id").val();
		var cover_letter = $("textarea#cover_letter").val();
		var cv_id = $("select#cv_id").val();
		//alert(jb_id);
//		alert(actionid);
//		alert(emp_id);
//		alert(cover_letter);
//		alert(cv_id);
		var dataString = 'jb_id=' + jb_id + '&actionid=' + actionid + '&emp_id=' + emp_id + '&cover_letter=' + cover_letter + '&cv_id=' + cv_id;
	//	alert(dataString);
	//	$().ajaxStart($("div#job_loading").show()).ajaxStop($("div#job_loading").hide());
		//$.ajax({
//      type: "POST",
//      url: "apply_job_process.php",
//     data: dataString,
//      success: function() {
//		 alert("hello");
//		  
//		  }
 //    });
		
		$("div#job_loading").show();
		$.ajax({
      url: "apply_job_process.php",
      global: false,
      type: "POST",
      data: ({jb_id : jb_id, emp_id : emp_id, actionid : actionid, cover_letter : cover_letter, cv_id : cv_id }),
      dataType: "html",
      success: function(msg)
		{
		  if(msg=='False')
			{
				$("div#job_loading").hide();
				$("div#job_info_msg").append("Error: Your Application Could't be Sent!");
			  //alert('Record Saved');
			}
			else
			{
				$("div#job_loading").hide();
				$("div#apply_job").slideUp(2000);
				$("div#job_info_msg").append(msg);
				$("div#job_info").toggle(3000);
			}
      	}
		});
	
    return false;
	});
});
