/********************************************** PROSPECTOR VALIDATION *********************************************************/
function schedule_form_details (approval_status)
{
    valid = true;
	if(approval_status== "Scheduled and Confirmed" )
    {
		document.getElementById("schedule_form_div").style.display = "block";
        return false;
    }
	else
	{
		document.getElementById("schedule_form_div").style.display = "none";
        return false;
	}
}


function prospector_phone_validate (phone_no)
{
    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.getElementById("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;
	}
}



//******************************************DATE*******************************************//



function prospector_sales_lead_date_validate (sdatepic)
{alert();
    valid = true;


    var sdatepic = document.getElementById("sdatepic").value;
	if(sdatepic== "" )
    {

		document.getElementById("sdate_no_err_design").style.display = "block";
		document.getElementById("sdate_no_err_msg").style.display = "block";
        return false;
    }
	else
	{
		document.getElementById("sdate_no_err_design").style.display = "none";
		document.getElementById("sdate_no_err_msg").style.display = "none";
        return false;
	}
}
function clear_valid(str)
{
	if(str=="calendar")
	
	{
		
		document.getElementById("date_no_err_design").style.display = "none";
		document.getElementById("date_no_err_msg").style.display = "none";
		return true;
	}


}
//****************************************TIME************************************//



function prospector_lead_time_validate (time_min)



{



	



    valid = true;



	if(time_min== "" )



    {



		document.getElementById("name_no_err_design").style.display = "block";



		document.getElementById("name_no_err_msg").style.display = "block";



        return false;



    }



	if(time.length <=1)



    {



		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;







	}



}







//****************************************reason************************************//



function prospector_lead_reason_validate (reason)



{



	



    valid = true;



	if(reason== "" )



    {



		document.getElementById("reson_no_err_design").style.display = "block";



		document.getElementById("reason_no_err_msg").style.display = "block";



        return false;



    }



	if(reason.length <=3 )



    {



		document.getElementById("reson_no_err_design").style.display = "block";



		document.getElementById("reason_no_err_msg").style.display = "block";



        return false;



    }







	else



	{



		document.getElementById("reson_no_err_design").style.display = "none";



		document.getElementById("reason_no_err_msg").style.display = "none";



        return false;







	}



}



//****************************************reason************************************//



function prospector_lead_street_validate (street)



{



	



    valid = true;



	if(street== "" )



    {



		document.getElementById("street_no_err_design").style.display = "block";



		document.getElementById("street_no_err_msg").style.display = "block";



        return false;



    }



	if(street.length <=3 )



    {



		document.getElementById("street_no_err_design").style.display = "block";



		document.getElementById("street_no_err_msg").style.display = "block";



        return false;



    }







	else



	{



		document.getElementById("street_no_err_design").style.display = "none";



		document.getElementById("street_no_err_msg").style.display = "none";



        return false;







	}



}



//****************************************reason************************************//



function prospector_lead_colonia_validate (colonia)



{



	



    valid = true;



	if(colonia== "" )



    {



		document.getElementById("colonia_no_err_design").style.display = "block";



		document.getElementById("colonia_no_err_msg").style.display = "block";



        return false;



    }



	if(colonia.length <=3 )



    {



		document.getElementById("colonia_no_err_design").style.display = "block";



		document.getElementById("colonia_no_err_msg").style.display = "block";



        return false;



    }







	else



	{



		document.getElementById("colonia_no_err_design").style.display = "none";



		document.getElementById("colonia_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;


    }


	else


	{


		document.getElementById("time_of_call_err_design").style.display = "none";


		document.getElementById("time_of_call_err_msg").style.display = "none";


        return false;





	}


}

function approval_validate(approve_status){

		if (approve_status=='')

    {

		document.getElementById("approve_status_err_design").style.display = "block";

		document.getElementById("approve_status_err_msg").style.display = "block";

        return false;

    }



	else

	{

		document.getElementById("approve_status_err_design").style.display = "none";

		document.getElementById("approve_status_err_msg").style.display = "none";

        return false;



	}

}

/**************************************************************************************************/


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='';





	}


 }








/****************************** NEW PROSPECTOR ***************************************/


var p4= jQuery.noConflict();


function add_lead_sales_person(lead_first_name,lead_last_name1,lead_last_name2,phone_no,phone_no2,phone_type,maritial_status,work_type,spouse_work_type,colonia,street,city,total_family_no,spend_on_food,general_impression,survey_location,datepic,time_of_call,survey_time,am_pm,approval_status,sdatepic,time_hr,time_min,end_time_hr,end_time_min,note_to_telemarketer)
{
alert(approval_status);
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(approval_status=="Scheduled and Confirmed")
{ 
		if((sdatepic!="")&&(time_hr!='')&&(time_min!=''))
		{
			var bb = "OK";	
		}
		else
		{
			var bb = "";	
            prospector_sales_lead_date_validate(sdatepic);
		}
}
if(approval_status=="Priority1")
{ 
			var bb = "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!='')&&(datepic!='')&&(time_of_call!='')&&(approval_status!='')&&(aa=='OK')&&(bb=='OK'))
	{
		p4("#lead_details_sales_entry_div").html('<img src="images/ajax-loader.gif"> Loading...');
		p4.ajax({
		type: "GET",
		url: "sales_approval/sales_person_create_lead/create_new_lead_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_no2="+phone_no2+"&phone_type="+phone_type+"&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+"&time_of_call="+time_of_call+"&survey_time="+survey_time+"&am_pm="+am_pm+"&approval_status="+approval_status+"&sdatepic="+sdatepic+"&time_hr="+time_hr+"&time_min="+time_min+"&end_time_hr="+end_time_hr+"&end_time_min="+end_time_min+"&note_to_telemarketer="+note_to_telemarketer+"&action=SAVE",

		success: function(msg){p4("#lead_details_sales_entry_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("date-inp-form").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_city_validate (city),prospector_maritial_validate (maritial_status),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),approval_validate (approval_status);


	}


}


/****************************** EDIT FORM***************************************/


function update_lead_details_sales_entry(lead_first_name,lead_last_name1,lead_last_name2,phone_no,phone_no2,phone_type,maritial_status,work_type,spouse_work_type,colonia,street,city,total_family_no,spend_on_food,general_impression,survey_location,datepic,time_of_call,survey_time,am_pm,approval_status,sdatepic,time_hr,time_min,end_time_hr,end_time_min,note_to_telemarketer,edit_id)


{ 
//alert(sdatepic);

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(approval_status=="Scheduled and Confirmed")
{ 
		if((sdatepic!="")&&(time_hr!='')&&(time_min!=''))
		{
			var bb = "OK";	
		}
		else
		{
			var bb = "";	
            prospector_sales_lead_date_validate(sdatepic);
		}
}
if(approval_status=="Priority1")
{ 
			var bb = "OK";	
}

//alert(aa);

	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!='')&&(datepic!='')&&(time_of_call!='')&&(approval_status!='')&&(aa=='OK')&&(bb=='OK'))


	{
//alert();

		p4("#lead_details_sales_entry_div").html('<img src="images/ajax-loader.gif"> Loading...');


		p4.ajax({


		type: "GET",


		url: "sales_approval/sales_person_create_lead/create_new_lead_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_no2="+phone_no2+"&phone_type="+phone_type+"&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+"&time_of_call="+time_of_call+"&survey_time="+survey_time+"&am_pm="+am_pm+"&approval_status="+approval_status+"&sdatepic="+sdatepic+"&time_hr="+time_hr+"&time_min="+time_min+"&end_time_hr="+end_time_hr+"&end_time_min="+end_time_min+"&note_to_telemarketer="+note_to_telemarketer+"&edit_id="+edit_id+"&action=UPDATE",


		success: function(msg){p4("#lead_details_sales_entry_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),approval_validate (approval_status);


	}


}





/****************************** EDIT FORM***************************************/


function delete_lead_sales_del_details(delete_id)


{ 


if(confirm('Are You Sure! You Want To Delete?'))


{





		p4("#lead_details_sales_entry_div").html('<img src="images/ajax-loader.gif"> Loading...');


		p4.ajax({


		type: "GET",


		url: "sales_approval/sales_person_create_lead/create_new_lead_db.php",


		data: "delete_id="+delete_id+"&action=DELETE",


		success: function(msg){p4("#lead_details_sales_entry_div").html(msg);}


		});


}


}





