/********************************************** PROSPECTOR VALIDATION *********************************************************/
function prospector_phone_validate (phone_no)
{//alert();
    valid = true;

	if(phone_no== "" )
    {
		document.getElementById("phone_no_err_design").style.display = "block";
		document.getElementById("phone_no_err_msg").style.display = "block";
        return false;
    }
	if(phone_no.length <10 )
    {
		document.getElementById("phone_no_err_design").style.display = "block";
		document.getElemetById("phone_no_err_msg").style.display = "block";
        return false;
    }

	else
	{
		document.getElementById("phone_no_err_design").style.display = "none";
		document.getElementById("phone_no_err_msg").style.display = "none";
        return false;

	}
}

function prospector_lead_validate (lead_first_name)
{
	
    valid = true;
	if(lead_first_name== "" )
    {
		document.getElementById("name_no_err_design").style.display = "block";
		document.getElementById("name_no_err_msg").style.display = "block";
        return false;
    }
	if(lead_first_name.length <=3 )
    {
		document.getElementById("name_no_err_design").style.display = "block";
		document.getElementById("name_no_err_msg").style.display = "block";
        return false;
    }

	else
	{
		document.getElementById("name_no_err_design").style.display = "none";
		document.getElementById("name_no_err_msg").style.display = "none";
        return false;

	}
}

function prospector_lead_last_name1_validate(lead_last_name1)
{
    valid = true;
	if(lead_last_name1== "" )
    {
		document.getElementById("last_name_no_err_design").style.display = "block";
		document.getElementById("last_name_no_err_msg").style.display = "block";
        return false;
    }
	if(lead_last_name1.length <=3 )
    {
		document.getElementById("last_name_no_err_design").style.display = "block";
		document.getElementById("last_name_no_err_msg").style.display = "block";
        return false;
    }

	else
	{
		document.getElementById("last_name_no_err_design").style.display = "none";
		document.getElementById("last_name_no_err_msg").style.display = "none";
        return false;

	}
}


function prospector_maritial_validate (mar_status)
{
    valid = true;
	if(mar_status== "" )
    {
		document.getElementById("mar_status_no_err_design").style.display = "block";
		document.getElementById("mar_status_no_err_msg").style.display = "block";
        return false;
    }
	else
	{
		document.getElementById("mar_status_no_err_design").style.display = "none";
		document.getElementById("mar_status_no_err_msg").style.display = "none";
        return false;

	}
}
function prospector_maritial_validate (mar_status)
{
    valid = true;
	if(mar_status== "" )
    {
		document.getElementById("mar_status_no_err_design").style.display = "block";
		document.getElementById("mar_status_no_err_msg").style.display = "block";
        return false;
    }
	else
	{
		document.getElementById("mar_status_no_err_design").style.display = "none";
		document.getElementById("mar_status_no_err_msg").style.display = "none";
        return false;

	}
}
function prospector_work_type_validate (work_type)
{
    valid = true;
	if(work_type== "" )
    {
		document.getElementById("work_type_err_design").style.display = "block";
		document.getElementById("work_type_err_msg").style.display = "block";
        return false;
    }
	else
	{
		document.getElementById("work_type_err_design").style.display = "none";
		document.getElementById("work_type_err_msg").style.display = "none";
        return false;

	}
}
function prospector_spouse_work_type_validate (spouse_work_type)
{
    valid = true;
	if(spouse_work_type== "" )
    {
		document.getElementById("spwork_type_err_design").style.display = "block";
		document.getElementById("spwork_type_err_msg").style.display = "block";
        return false;
    }
	else
	{
		document.getElementById("spwork_type_err_design").style.display = "none";
		document.getElementById("spwork_type_err_msg").style.display = "none";
        return false;

	}
}
function prospector_neighbour_validate (neighbour)
{
    valid = true;
	if(neighbour== "" )
    {
		document.getElementById("neighbour_err_design").style.display = "block";
		document.getElementById("neighbour_err_msg").style.display = "block";
        return false;
    }
	else
	{
		document.getElementById("neighbour_err_design").style.display = "none";
		document.getElementById("neighbour_err_msg").style.display = "none";
        return false;

	}
}

function prospector_street_validate (street)
{
    valid = true;
	if(street== "" )
    {
		document.getElementById("street_err_design").style.display = "block";
		document.getElementById("street_err_msg").style.display = "block";
        return false;
    }
	else
	{
		document.getElementById("street_err_design").style.display = "none";
		document.getElementById("street_err_msg").style.display = "none";
        return false;

	}
}

function prospector_city_validate (city)
{
    valid = true;
	if(city== "" )
    {
		document.getElementById("city_err_design").style.display = "block";
		document.getElementById("city_err_msg").style.display = "block";
        return false;
    }
	else
	{
		document.getElementById("city_err_design").style.display = "none";
		document.getElementById("city_err_msg").style.display = "none";
        return false;

	}
}



function prospector_total_family_no_validate (total_family_no)
{
    valid = true;
	if(total_family_no== "" )
    {
		document.getElementById("total_family_err_design").style.display = "block";
		document.getElementById("total_family_err_msg").style.display = "block";
        return false;
    }
	else
	{
		document.getElementById("total_family_err_design").style.display = "none";
		document.getElementById("total_family_err_msg").style.display = "none";
        return false;

	}
}
function prospector_no_work_days_validate (no_work_days)
{
    valid = true;
	if(no_work_days== "" )
    {
		document.getElementById("work_days_err_design").style.display = "block";
		document.getElementById("work_days_err_msg").style.display = "block";
        return false;
    }
	else
	{
		document.getElementById("work_days_err_design").style.display = "none";
		document.getElementById("work_days_err_msg").style.display = "none";
        return false;

	}
}
function prospector_General_impression_validate (General_impression)
{
    valid = true;
	if(General_impression== "" )
    {
		document.getElementById("impression_err_design").style.display = "block";
		document.getElementById("impression_err_msg").style.display = "block";
        return false;
    }
	else
	{
		document.getElementById("impression_err_design").style.display = "none";
		document.getElementById("impression_err_msg").style.display = "none";
        return false;

	}
}
function prospector_survey_location_validate (survey_location)
{
    valid = true;
	if(survey_location== "" )
    {
		document.getElementById("survey_location_err_design").style.display = "block";
		document.getElementById("survey_location_err_msg").style.display = "block";
        return false;
    }
	else
	{
		document.getElementById("survey_location_err_design").style.display = "none";
		document.getElementById("survey_location_err_msg").style.display = "none";
        return false;

	}
}
function prospector_datepic_validate (datepic)
{
    valid = true;
	if(datepic== "" )
    {
		document.getElementById("datepic_err_design").style.display = "block";
		document.getElementById("datepic_err_msg").style.display = "block";
        return false;
    }
	else
	{
		document.getElementById("datepic_err_design").style.display = "none";
		document.getElementById("datepic_err_msg").style.display = "none";
        return false;

	}
}
function prospector_survey_time_validate (survey_time)
{
	
    valid = true;
	if(survey_time== "" )
    {
		document.getElementById("survey_time_err_design").style.display = "block";
		document.getElementById("survey_time_err_msg").style.display = "block";
        return false;
    }
	else
	{
		document.getElementById("survey_time_err_design").style.display = "none";
		document.getElementById("survey_time_err_msg").style.display = "none";
        return false;

	}
}

function prospector_time_of_call_validate (time_of_call)
{
    valid = true;
	if(time_of_call== "" )
    {
		document.getElementById("time_of_call_err_design").style.display = "block";
		document.getElementById("time_of_call_err_msg").style.display = "block";
        return false;
    }
		if(time_of_call.length<=4 )
    {
		document.getElementById("time_of_call_err_design").style.display = "block";
		document.getElementById("time_of_call_err_msg").style.display = "block";
        return false;
    }

	else
	{
		document.getElementById("time_of_call_err_design").style.display = "none";
		document.getElementById("time_of_call_err_msg").style.display = "none";
        return false;

	}
}
/****************************** NEW PROSPECTOR ***************************************/
var p1= jQuery.noConflict();
function add_lead_details(lead_first_name,lead_last_name1,lead_last_name2,phone_no,phone_type,phone_no2,maritial_status,work_type,spouse_work_type,colonia,street,city,total_family_no,spend_on_food,general_impression,survey_location,datepic,survey_time,time_of_call,am_pm)
{
if(maritial_status=="Married")
{ 
		if(spouse_work_type!="")
		{
			var aa = "OK";	
		}
		else
		{
			var aa = "";	
			prospector_spouse_work_type_validate (spouse_work_type);
		}
}
if(maritial_status=="Unmarried")
{	
var aa = "OK";	
}
		if((lead_first_name!="")&&(lead_last_name1!='')&&(phone_no!='')&&(maritial_status!='')&&(work_type!='')&&(colonia!='')&&(city!='')&&(total_family_no!='')&&(spend_on_food!='')&&(general_impression!='')&&(survey_location!='')&&(aa=='OK'))
		{
		p1("#lead_details_div").html('<img src="images/ajax-loader.gif"> Loading...');
		p1.ajax({
		type: "GET",
		url: "prospector_entry/prospector_entry_english/eng_prospector_entry_db.php",
		data: "lead_first_name="+lead_first_name+"&lead_last_name1="+lead_last_name1+"&lead_last_name2="+lead_last_name2+"&phone_no="+phone_no+"&phone_type="+phone_type+"&phone_no2="+phone_no2+"&maritial_status="+maritial_status+"&work_type="+work_type+"&spouse_work_type="+spouse_work_type+"&colonia="+colonia+"&street="+street+"&city="+city+"&total_family_no="+total_family_no+"&spend_on_food="+spend_on_food+"&general_impression="+general_impression+"&survey_location="+survey_location+"&datepic="+datepic+"&survey_time="+survey_time+"&time_of_call="+time_of_call+"&am_pm="+am_pm+"&action=SAVE",
		success: function(msg){p1("#lead_details_div").html(msg);}
		});
		document.getElementById("lead_first_name").value="";
		document.getElementById("lead_last_name1").value="";
		document.getElementById("lead_last_name2").value="";
		document.getElementById("phone_no").value="";
		document.getElementById("maritial_status").value="";
		document.getElementById("work_type").value="";
		document.getElementById("spouse_work_type").value="";
		document.getElementById("colonia").value="";
		document.getElementById("street").value="";
		document.getElementById("city").value="";
		document.getElementById("total_family_no").value="";
		document.getElementById("spend_on_food").value="";
		document.getElementById("general_impression").value="";
		document.getElementById("survey_location").value="";
		document.getElementById("survey_time").value="";
		document.getElementById("time_of_call").value="";
		document.getElementById("phone_no2").value="";
		document.getElementById("calendar-inputField").value="";
		window.close();
		}
		else
		{
		prospector_lead_validate(lead_first_name),prospector_lead_last_name1_validate(lead_last_name1),prospector_phone_validate (phone_no),prospector_maritial_validate (maritial_status),prospector_work_type_validate (work_type),prospector_neighbour_validate (colonia),prospector_city_validate (city),prospector_total_family_no_validate (total_family_no),prospector_no_work_days_validate (spend_on_food),prospector_General_impression_validate (general_impression),prospector_survey_location_validate (survey_location),prospector_datepic_validate(datepic),prospector_survey_time_validate(survey_time),prospector_time_of_call_validate (time_of_call);
	}
	
}
/****************************** EDIT FORM***************************************/
function update_lead_details(lead_first_name,lead_last_name1,lead_last_name2,phone_no,phone_type,phone_no2,maritial_status,work_type,spouse_work_type,colonia,street,city,total_family_no,spend_on_food,general_impression,survey_location,datepic,survey_time,time_of_call,am_pm,edit_id)
{ 
if(maritial_status=="Married")
{ 
		if(spouse_work_type!="")
		{
			var aa = "OK";	
		}
		else
		{
			var aa = "";	
			prospector_spouse_work_type_validate (spouse_work_type);
		}
}
if(maritial_status=="Unmarried")
{	
var aa = "OK";	
}

		if((lead_first_name!="")&&(lead_last_name1!='')&&(phone_no!='')&&(maritial_status!='')&&(work_type!='')&&(colonia!='')&&(city!='')&&(total_family_no!='')&&(spend_on_food!='')&&(general_impression!='')&&(survey_location!='')&&(aa=='OK'))
		{
		p1("#lead_details_div").html('<img src="images/ajax-loader.gif"> Loading...');
		p1.ajax({
		type: "GET",
		url: "prospector_entry/prospector_entry_english/eng_prospector_entry_db.php",
		data: "lead_first_name="+lead_first_name+"&lead_last_name1="+lead_last_name1+"&lead_last_name2="+lead_last_name2+"&phone_no="+phone_no+"&phone_type="+phone_type+"&phone_no2="+phone_no2+"&maritial_status="+maritial_status+"&work_type="+work_type+"&spouse_work_type="+spouse_work_type+"&colonia="+colonia+"&street="+street+"&city="+city+"&total_family_no="+total_family_no+"&spend_on_food="+spend_on_food+"&general_impression="+general_impression+"&survey_location="+survey_location+"&datepic="+datepic+"&survey_time="+survey_time+"&time_of_call="+time_of_call+"&am_pm="+am_pm+"&edit_id="+edit_id+"&action=UPDATE",
		success: function(msg){p1("#lead_details_div").html(msg);}
		});
		document.getElementById("lead_first_name").value="";
		document.getElementById("lead_last_name1").value="";
		document.getElementById("lead_last_name2").value="";
		document.getElementById("phone_no").value="";
		document.getElementById("maritial_status").value="";
		document.getElementById("work_type").value="";
		document.getElementById("spouse_work_type").value="";
		document.getElementById("colonia").value="";
		document.getElementById("street").value="";
		document.getElementById("city").value="";
		document.getElementById("total_family_no").value="";
		document.getElementById("spend_on_food").value="";
		document.getElementById("general_impression").value="";
		document.getElementById("survey_location").value="";
		document.getElementById("datepic").value="";
		document.getElementById("survey_time").value="";
		document.getElementById("time_of_call").value="";
		document.getElementById("phone_no2").value="";
		
		window.close();
		}
		else
		{
		prospector_lead_validate(lead_first_name),prospector_lead_last_name1_validate(lead_last_name1),prospector_phone_validate (phone_no),prospector_work_type_validate (work_type),prospector_neighbour_validate (colonia),prospector_street_validate (street),prospector_city_validate (city),prospector_total_family_no_validate (total_family_no),prospector_no_work_days_validate (spend_on_food),prospector_General_impression_validate (general_impression),prospector_survey_location_validate (survey_location),prospector_datepic_validate(datepic),prospector_survey_time_validate(survey_time),prospector_time_of_call_validate (time_of_call);
		}
}
/****************************** EDIT FORM***************************************/
function delete_lead_details(delete_id)
{ 
if(confirm('Are You Sure! You Want To Delete?'))
{

		p1("#lead_details_div").html('<img src="images/ajax-loader.gif"> Loading...');
		p1.ajax({
		type: "GET",
		url: "prospector_entry/prospector_entry_english/eng_prospector_entry_db.php",
		data: "delete_id="+delete_id+"&action=DELETE",
		success: function(msg){p1("#lead_details_div").html(msg);}
		});
}
}
/*****************************************************************************/
function get_telemarketer_lead_phone_type(type)
{
	if(document.getElementById("televerify_phone").checked==true){
var phone_type=type;
if(phone_type!='')
{
document.getElementById("phone_type").value=phone_type;
}
	}
	else{
		document.getElementById("phone_type").value='';

	}
 }


