/**
 * @author lcevallos
 */
$(document).ready(function(){
$("#send_mail_job").click(function(){


var valid = "";

/* Campos del Formulario */

var isr = " is required.";
var FirstName = $("#FirstName").val(); //requerido
if (FirstName.length<1) {
valid += '<br />A valid name '+isr;
}

var Middle=$("#Middle").val();

var LastName =  $("#LastName").val(); //requerido
if (LastName.length<1) {
valid += '<br />A valid last name '+isr;
}
var Address =  $("#Address").val(); //requerido
if (Address.length<1) {
valid += '<br />A valid Address '+isr;
}

var City =  $("#City").val(); //requerido
if (City.length<1) {
valid += '<br />A valid City '+isr;
}

var State =  $("#State").val(); //requerido
if (State.length<1) {
valid += '<br />A valid State '+isr;
}

var ZipCode =  $("#ZipCode").val(); //requerido
if (ZipCode.length<1) {
valid += '<br />A valid Zip Code '+isr;
}

var HomePhone =  $("#HomePhone").val(); //requerido
if (HomePhone.length<1) {
valid += '<br />A valid Home Phone '+isr;
}

var CellPhone=$("#CellPhone").val();

var mail =  $("#email").val(); //requerido
if (!mail.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) {
valid += '<br />A Valid Mail '+isr;
}

var DOB =  $("#DOB").val(); //requerido
if (DOB.length<1) {
valid += '<br />A valid Date of Birth '+isr;
}

var LDOB=$("#LDOB").val();

var SSN =  $("#SSN").val(); //requerido
if (SSN.length<1) {
valid += '<br />A valid SSN '+isr;
}

var citizen =  $("input[@name='citizen']:checked").val(); //requerido
if (citizen.length<1) {
valid += '<br />Are you a USA Citizen '+isr;
}

var citizen2 =  $("input[@name='citizen2']:checked").val(); //requerido
if (citizen2.length<1) {
valid += '<br />Work in the U.S. '+isr;
}

var Position =  $("#Position").val(); //requerido
if (Position.length<1) {
valid += '<br />A valid Position applied for '+isr;
}

var Wage=$("#Wage").val();

var Referredby=$("#referredby").val();

var type_employee =  $("input[@name='type_employee']:checked").val(); //requerido
if (type_employee.length<1) {
valid += '<br />A valid Type of Employment desired '+isr;
}

var swing =  $("input[@name='swing']:checked").val();

var DateAvailable =  $("#DateAvailable").val(); //requerido
if (DateAvailable.length<1) {
valid += '<br />A Date Available '+isr;
}

var drugfree= $("input[@name='drugfree']:checked").val();

var drugtest = $("input[@name='drugtest']:checked").val();
if (drugtest.length<1) {
valid += '<br />Are you willing to submit to random drug testing with the intent to detect illegal drugs, substance abuse and alcohol abuse? '+isr;
}

var felony=  $("input[@name='felony']:checked").val();

var FelonyDetails= $("#FelonyDetails").val();

// --*********Seccion Educacion   *******----\\

var HighSchool=$("#HighSchool").val();
var HighSchoolYr=$("#HighSchoolYr").val();
var HighSchoolMajor=$("#HighSchoolMajor").val();
var HighSchoolDegree=$("#HighSchoolDegree").val();
var HighSchoolGPA=$("#HighSchoolGPA").val();

var HighSchool2=$("#HighSchool2").val();
var HighSchoolYr2=$("#HighSchoolYr2").val();
var HighSchoolMajor2=$("#HighSchoolMajor2").val();
var HighSchoolDegree2=$("#HighSchoolDegree2").val();
var HighSchoolGPA2=$("#HighSchoolGPA2").val();

var HighSchool3=$("#HighSchool3").val();
var HighSchoolYr3=$("#HighSchoolYr3").val();
var HighSchoolMajor3=$("HighSchoolMajor3").val();
var HighSchoolDegree3=$("#HighSchoolDegree3").val();
var HighSchoolGPA3=$("#HighSchoolGPA3").val();

var honors=$("#honors").val();
var licenses=$("#licenses").val();
var foreignlanguage=$("#foreignlanguage").val();

var otherqualifications=$("#otherqualifications").val();

// --********* FIN Seccion Educacion   *******----\\

// --*********Seccion REFERENCIAS   *******----\\

var RefName1 =  $("#RefName1").val(); //requerido
if (RefName1.length<1) {
valid += '<br />A valid Name of Reference '+isr;
}

var RefPhone1 =  $("#RefPhone1").val(); //requerido
if (RefPhone1.length<1) {
valid += '<br />A valid Telephone '+isr;
}

var RefYrs1 =  $("#RefYrs1").val(); //requerido
if (RefYrs1.length<1) {
valid += '<br />A valid Years known '+isr;
}

var RefName2 =  $("#RefName2").val(); //requerido
if (RefName2.length<1) {
valid += '<br />A second Name of Reference '+isr;
}

var RefPhone2 =  $("#RefPhone2").val(); //requerido
if (RefPhone2.length<1) {
valid += '<br />A valid second Telephone '+isr;
}

var RefYrs2 =  $("#RefYrs2").val(); //requerido
if (RefYrs2.length<1) {
valid += '<br />A valid second field of Years known '+isr;
}

var RefName3 =  $("#RefName3").val();
var RefPhone3 =  $("#RefPhone3").val();
var RefYrs3 =  $("#RefYrs3").val();

// --********* FIN Seccion REFERENCIAS   *******----\\

// --*********Seccion EMPLOYMENT HISTORY   *******----\\

// --********* EMPLOYER 1   *******----\\

var CoName =  $("#CoName").val(); //requerido
if (CoName.length<1) {
valid += '<br />A valid Company Name '+isr;
}


var CoPhone =  $("#CoPhone").val(); //requerido
if (CoName.length<1) {
valid += '<br />A valid Telephone '+isr;
}


var CoAddress =  $("#CoAddress").val(); //requerido
if (CoAddress.length<1) {
valid += '<br />A valid Address '+isr;
}

var coFrom =  $("#coFrom").val(); //requerido
if (coFrom.length<1) {
valid += '<br />A valid Field From in section Employeer1  '+isr;
}

var coTo =  $("#coTo").val(); //requerido
if (coTo.length<1) {
valid += '<br />A valid Field To in section Employeer1  '+isr;
}

var coSalary =  $("#coSalary").val(); //requerido
if (coTo.length<1) {
valid += '<br />A valid Final Salary in section Employeer1  '+isr;
}

var coSalaryPer =  $("#coSalaryPer").val(); //requerido
if (coSalaryPer.length<1) {
valid += '<br />A valid Per in section Employeer1  '+isr;
}

var coSupervisor =  $("#coSupervisor").val(); //requerido
if (coSupervisor.length<1) {
valid += '<br />A valid Supervisor Name  '+isr;
}

var coSupervisorTitle =  $("#coSupervisorTitle").val(); //requerido
if (coSupervisorTitle.length<1) {
valid += '<br />A valid Supervisor Name  '+isr;
}
//Radio Button
var coRefContact = $("input[@name='coRefContact']:checked").val(); //requerido
if (coRefContact.length<1) {
valid += '<br />May we contact for reference?  '+isr;
}

var CoStartTitle =  $("#CoStartTitle").val(); //requerido
if (CoStartTitle.length<1) {
valid += '<br />A valid Starting Job Title '+isr;
}

var CoEndTitle =  $("#CoEndTitle").val(); //requerido
if (CoEndTitle.length<1) {
valid += '<br />A valid Final Job Title '+isr;
}

var coResponsibilities =  $("#coResponsibilities").val(); //requerido
if (coResponsibilities.length<1) {
valid += '<br />A valid Job Responsibilities '+isr;
}

var coAccomplishments =  $("#coAccomplishments").val(); //requerido
if (coAccomplishments.length<1) {
valid += '<br />A valid Accomplishments '+isr;
}

var coLeaving =  $("#coLeaving").val(); //requerido
if (coLeaving.length<1) {
valid += '<br />A valid Reason for Leaving '+isr;
}

/* -----FIN DEL EMPLOYEER 1 ----*/

/* -----iINICIO  EMPLOYEER 2 ----*/

var CoName2=$("#CoName2").val();
var CoPhone2=$("#CoPhone2").val();
var CoAddress2=$("#CoAddress2").val();
var coFrom2=$("#coFrom2").val();
var coTo2=$("#coTo2").val();
var coSalary2=$("#coSalary2").val();
var coSalaryPer2=$("#coSalaryPer2").val();
var coSupervisor2=$("#coSupervisor2").val();
var coSupervisorTitle2=$("#coSupervisorTitle2").val();
var coRefContact2=$("input[@name='coRefContact2']:checked").val();
var CoStartTitle2=$("#CoStartTitle2").val();
var CoEndTitle2=$("#CoEndTitle2").val();
var coResponsibilities2=$("#coResponsibilities2").val();
var coAccomplishments2=$("#coAccomplishments2").val();
var coLeaving2=$("#coLeaving2").val();
/* -----FIN  EMPLOYEER 2 ----*/

/* -----iINICIO  EMPLOYEER 3 ----*/
var CoName3=$("#CoName3").val();
var CoPhone3=$("#CoPhone3").val();
var CoAddress3=$("#CoAddress3").val();
var coFrom3=$("#coFrom3").val();
var coTo3=$("#coTo3").val();
var coSalary3=$("#coSalary3").val();
var coSalaryPer3=$("#coSalaryPer3").val();
var coSupervisor3=$("#coSupervisor3").val();
var coSupervisorTitle3=$("#coSupervisorTitle3").val();
var coRefContact3=$("input[@name='coRefContact3']:checked").val();
var CoStartTitle3=$("#CoStartTitle3").val();
var CoEndTitle3=$("#CoEndTitle3").val();
var coResponsibilities3=$("#coResponsibilities3").val();
var coAccomplishments3=$("#coAccomplishments3").val();
var coLeaving3=$("#coLeaving3").val();
/* -----iFIN  EMPLOYEER 3 ----*/

/* -----iINICIO  EMPLOYEER 4 ----*/
var CoName4=$("#CoName4").val();
var CoPhone4=$("#CoPhone4").val();
var CoAddress4=$("#CoAddress4").val();
var coFrom4=$("#coFrom4").val();
var coTo4=$("#coTo4").val();
var coSalary4=$("#coSalary4").val();
var coSalaryPer4=$("#coSalaryPer4").val();
var coSupervisor4=$("#coSupervisor4").val();
var coSupervisorTitle4=$("#coSupervisorTitle4").val();
var coRefContact4=$("input[@name='coRefContact4']:checked").val();
var CoStartTitle4=$("#CoStartTitle4").val();
var CoEndTitle4=$("#CoEndTitle4").val();
var coResponsibilities4=$("#coResponsibilities4").val();
var coAccomplishments4=$("#coAccomplishments4").val();
var coLeaving4=$("#coLeaving4").val();

/* -----iFIN  EMPLOYEER 4 ----*/


var certify=$('input[name=certify]').is(':checked'); //requerido
if (certify==false) {
valid += '<br />The checkbox of certify is not active ';
}

var subject ="Informacion de la pagina de empleo seccióm Ingles de: "+FirstName+" "+LastName;

/* FIN Campos del Formulario */

if (valid!='') {
$("#response").fadeIn("slow");
$("#response").html("Error:"+valid);
}
else {
var text ='PERSONAL INFORMATION: First Name: ' + FirstName
text += ' Middle: '+ Middle
text += ' Last Name: '+ LastName
text += ' Street Address : '+ Address
text += ' City: '+ City
text += ' State: '+ State
text += ' Zip Code: '+ ZipCode
text += ' Home Phone: '+ HomePhone
text += ' Cell Phone: '+ CellPhone
text += ' Email Address: '+ mail
text += ' Date of Birth: '+ DOB
text += ' Location of Birth: '+ LDOB
text += ' SSN: '+ SSN
text += ' Are you a US citizen?: '+ citizen
text += ' If not, are you authorized to work in the U.S. on an unrestricted basis?: '+ citizen2
text += '  '
text += ' JOB PREFERENCES: '
text += ' Position applied for: '+ Position
text += ' Desired Wage: '+ Wage
text += ' Referred by: '+ Referredby
text += ' Date available: '+ DateAvailable
text += ' Type of Employment desired: '+ type_employee
text += ' Are you willing to work swing shift?: '+ swing
text += ' Are you a drug free individual?: '+ drugfree
text += ' Are you willing to submit to random drug testing with the intent to detect illegal drugs, substance abuse and alcohol abuse?: '+ drugtest
text += ' Have you ever been convicted of, or pleaded guilty or no contest to a felony offense?: '+ felony
text += ' If yes, please give details: '+ FelonyDetails
text += '  '
text += ' EDUCATION: '
text += ' Name and Location High School: '+ HighSchool
text += ' Year High School: '+ HighSchoolYr
text += ' Major High School: '+ HighSchoolMajor
text += ' Degree High School: '+ HighSchoolDegree
text += ' G.P.A. High School: '+ HighSchoolGPA
text += ' Name and Location College: '+ HighSchool2
text += ' Year College: '+ HighSchoolYr2
text += ' Major College: '+ HighSchoolMajor2
text += ' Degree College: '+ HighSchoolDegree2
text += ' G.P.A. College: '+ HighSchoolGPA2
text += ' Name and Location Business: '+ HighSchool3
text += ' Year Business: '+ HighSchoolYr3
text += ' Major Business: '+ HighSchoolMajor3
text += ' Degree Business: '+ HighSchoolDegree3
text += ' G.P.A. Business: '+ HighSchoolGPA3
text += ' Honors and activities: '+ honors
text += ' List Licenses and Certifications: '+ licenses
text += ' Foreign Languages: '+ foreignlanguage
text += ' In addition to your work history, are there any other skills, qualifications, or experience we should consider?: '+ otherqualifications
text += '  '
text += ' REFERENCES: '
text += ' Name of Reference (Profession related preferred)1: '+ RefName1
text += ' Telephone1: '+ RefPhone1
text += ' Years known1: '+ RefYrs1
text += ' Name of Reference (Profession related preferred)2: '+ RefName2
text += ' Telephone2: '+ RefPhone2
text += ' Years known2: '+ RefYrs2
text += ' Name of Reference (Profession related preferred)3: '+ RefName3
text += ' Telephone3: '+ RefPhone3
text += ' Years known3: '+ RefYrs3
text += '  '
text += ' EMPLOYMENT HISTORY: (Start with most recent employer.): '
text += ' Employer 1: '
text += ' Company Name: '+ CoName
text += ' Telephone: '+ CoPhone
text += ' Address: '+ CoAddress
text += ' From: '+ coFrom
text += ' To: '+ coTo
text += ' Final Salary Rate: '+ coSalary
text += ' Per: '+ coSalaryPer
text += ' Supervisor Name: '+ coSupervisor
text += ' Supervisor Title: '+ coSupervisorTitle
text += ' May we contact for reference?: '+ coRefContact
text += ' Starting Job Title: '+ CoStartTitle
text += ' Final Job Title: '+ CoEndTitle
text += ' Job Responsibilities: '+ coResponsibilities
text += ' Accomplishments: '+ coAccomplishments
text += ' Reason for Leaving: '+ coLeaving
text += '  '
text += ' Employer 2: '
text += ' Company Name: '+ CoName2
text += ' Telephone: '+ CoPhone2
text += ' Address: '+ CoAddress2
text += ' From: '+ coFrom2
text += ' To: '+ coTo2
text += ' Final Salary Rate: '+ coSalary2
text += ' Per: '+ coSalaryPer2
text += ' Supervisor Name: '+ coSupervisor2
text += ' Supervisor Title: '+ coSupervisorTitle2
text += ' May we contact for reference?: '+ coRefContact2
text += ' Starting Job Title: '+ CoStartTitle2
text += ' Final Job Title: '+ CoEndTitle2
text += ' Job Responsibilities: '+ coResponsibilities2
text += ' Accomplishments: '+ coAccomplishments2
text += ' Reason for Leaving: '+ coLeaving2
text += '  '
text += ' Employer 3: '
text += ' Company Name: '+ CoName3
text += ' Telephone: '+ CoPhone3
text += ' Address: '+ CoAddress3
text += ' From: '+ coFrom3
text += ' To: '+ coTo3
text += ' Final Salary Rate: '+ coSalary3
text += ' Per: '+ coSalaryPer3
text += ' Supervisor Name: '+ coSupervisor3
text += ' Supervisor Title: '+ coSupervisorTitle3
text += ' May we contact for reference?: '+ coRefContact3
text += ' Starting Job Title: '+ CoStartTitle3
text += ' Final Job Title: '+ CoEndTitle3
text += ' Job Responsibilities: '+ coResponsibilities3
text += ' Accomplishments: '+ coAccomplishments3
text += ' Reason for Leaving: '+ coLeaving3
text += '  '
text += ' Employer 4: '
text += ' Company Name: '+ CoName4
text += ' Telephone: '+ CoPhone4
text += ' Address: '+ CoAddress4
text += ' From: '+ coFrom4
text += ' To: '+ coTo4
text += ' Final Salary Rate: '+ coSalary4
text += ' Per: '+ coSalaryPer4
text += ' Supervisor Name: '+ coSupervisor4
text += ' Supervisor Title: '+ coSupervisorTitle4
text += ' May we contact for reference?: '+ coRefContact4
text += ' Starting Job Title: '+ CoStartTitle4
text += ' Final Job Title: '+ CoEndTitle4
text += ' Job Responsibilities: '+ coResponsibilities4
text += ' Accomplishments: '+ coAccomplishments4
text += ' Reason for Leaving: '+ coLeaving4


var datastr ='nombre=' + FirstName + '&mail=' + mail + '&subject=' + subject + '&text=' + text;

$("#response").css("display", "block");
$("#response").html("Su mensaje fue enviando. ");
$("#response").fadeIn("slow");
setTimeout("send('"+datastr+"')",2000);
}
return false;
});
});
function send(datastr){
$.ajax({
type: "POST",
url: "mail_job.php",
data: datastr,
cache: false,
success: function(html){
$("#response").fadeIn("slow");
$("#response").html(html);
setTimeout('$("#response").fadeOut("slow")',2000);
}
});
}