/********************************************** PROSPECTOR VALIDATION *********************************************************/

function user_designation_validate (designation)

{

    valid = true;

	if(designation== "" )

    {

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

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

        return false;

    }



	else

	{

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

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

        return false;



	}

}

function user_name_validate (user_name)

{

    valid = true;

	if(user_name== "" )

    {

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

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

        return false;

    }

	if(user_name.length<=4)

    {

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

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

        return false;

    }



	else

	{

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

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

        return false;



	}

}



/*function user_contact_no_validate(user_contact_no)

{

    valid = true;

	if(user_contact_no== "" )

    {alert("t");

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

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

        return false;

    }



	else

	{alert("test");

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

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

        return false;



	}

}*/

function user_contact_no_validate (user_contact_no)

{

    valid = true;



	if(user_contact_no== "" )

    {

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

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

        return false;

    }

	if(user_contact_no.length <=10 )

    {

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

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

        return false;

    }



	else

	{

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

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

        return false;



	}

}





function user_address_validate(user_address)

{

    valid = true;

	if(user_address== "" )

    {

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

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

        return false;

    }

	else

	{

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

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

        return false;



	}

}







function isValidEmail(user_email_id){

return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", user_email_id);

}



function user_email_id_validate (user_email_id)

{

    valid = true;

	var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;

	

	if(user_email_id== "" )

    {

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

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

        return false;

    }

	if(!filter.test(user_email_id) && user_email_id!="")

    {

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

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

        return false;

    }



	else

	{

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

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

        return false;



	}

}

//*************************************user_type_password_validate***********************************************//

function user_type_password_validate (user_password)

{

	

    valid = true;

	if(user_password== "" )

    {

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

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

        return false;

    }

	if(user_password.length <=6 )

    {

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

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

        return false;

    }



	else

	{

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

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

        return false;



	}

}



//*************************************user_type_password_validate***********************************************//

function user_type_gmail_password_validate (gmail_password)

{

	

    valid = true;

	if(gmail_password== "" )

    {

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

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

        return false;

    }

	if(gmail_password.length <=6 )

    {

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

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

        return false;

    }



	else

	{

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

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

        return false;



	}

}



//****************************************user_type_active_validate*********************************************//

function user_type_active_validate(user_type_active)

{

	

		if (user_type_active=='')

    {

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

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

        return false;

    }



	else

	{

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

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

        return false;



	}

}

//*****************************************************user_name_select_validate**************************************************//

function user_name_select_validate(user_name_list)

{ 

	    valid = true;

	if(user_name_list== "" )

    {

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

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

        return false;

    }

	else

	{

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

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

        return false;



	}

}





/*******************************user type name validate***********************************************************/

/*function get_user_type_name(user_type)

{ 



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

		p86.ajax({

		type: "GET",

		url: "user_registration/get_user_name.php",

		data: "user_type="+user_type,

		success: function(msg){p86("#user_typename_div").html(msg);}

		});

}*/

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

var p2= jQuery.noConflict();



function add_user_details(designation,name,user_address,user_contact_no,user_email_id,user_name,user_password,gmail_password,user_active)

{

	if((designation!='')&&(name!='')&&(user_address!='')&&(user_contact_no!='')&&(user_email_id!='')&&(user_name!='')&&(user_password!='')&&(user_active!='')&&(gmail_password!=''))

	{

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

		p2.ajax({

		type: "GET",

		url: "admin/eng_telemarketers_sales_entry/eng_tele_sales_entry_db.php",

		data: "designation="+designation+"&name="+name+"&user_address="+user_address+"&user_contact_no="+user_contact_no+"&user_email_id="+user_email_id+"&user_name="+user_name+"&user_password="+user_password+"&gmail_password="+gmail_password+"&user_active="+user_active+"&action=SAVE_USER",

		success: function(msg){p2("#user_details_div").html(msg);}

		});

		window.close();

	}

	else

	{

user_designation_validate(designation),user_name_validate(user_name),user_address_validate (user_address),user_contact_no_validate (user_contact_no),user_email_id_validate (user_email_id),user_type_password_validate(user_password),user_type_gmail_password_validate (gmail_password),user_type_active_validate(user_active),user_name_select_validate(user_name);

	}

}
/**********************************edit id pass*******************/
var xmlHttp1;
function  edit_user_details_id(edit_id)
{//
	//alert(edit_id);

xmlHttp1=GetXmlHttpObject_cookware();
if (xmlHttp1==null)
	 {
	 alert ("Browser does not support HTTP Request");
	 return;
	 }
     var url="admin/eng_telemarketers_sales_entry/eng_tele_sales_entry_edit.php";
     url=url+"?edit_id="+edit_id;
     url=url+"&sid="+Math.random();
	 xmlHttp1.onreadystatechange=satchanged_cookware_edit;
	 xmlHttp1.open("GET",url,true);
	 xmlHttp1.send(null);



}
function satchanged_cookware_edit() 
{ 
	 if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete")
	 { 
	 document.getElementById("user_edit_details_div").innerHTML=xmlHttp1.responseText;
	 } 
}

/****************************** EDIT FORM***************************************/
var xmlHttp2;
 function update_user_details(designation,name,user_address,user_contact_no,user_email_id,user_name,user_password,gmail_password,user_active,edit_id)

{ //alert();
//alert(edit_id);
	if((designation!="")&&(name!='')&&(user_address!='')&&(user_contact_no!='')&&(user_email_id!='')&&(user_name!='')&&(user_password!='')&&(user_active!='')&&(gmail_password!=''))

	{
	xmlHttp2=GetXmlHttpObject_cookware();
	
	if (xmlHttp2==null)
	 {
	 alert ("Browser does not support HTTP Request");
	 return;
	 }

		var url= "admin/eng_telemarketers_sales_entry/eng_tele_sales_entry_db.php";

		url=url+"?designation="+designation+"&name="+name+"&user_address="+user_address+"&user_contact_no="+user_contact_no+"&user_email_id="+user_email_id+"&user_name="+user_name+"&user_password="+user_password+"&gmail_password="+gmail_password+"&user_active="+user_active+"&edit_id="+edit_id+"&action=UPDATE_USER";

		url=url+"&sid="+Math.random();
		 xmlHttp2.onreadystatechange=satchanged_cookware_edit_details;
		 xmlHttp2.open("GET",url,true);
		 xmlHttp2.send(null);

		alert("Successfully Updated");
		document.sales_entry_form.designation.value="";
		document.sales_entry_form.full_name.value="";
		document.sales_entry_form.user_active.value="";
		document.sales_entry_form.user_name.value="";
		document.sales_entry_form.user_email_id.value="";
		
		document.sales_entry_form.user_contact_no.value="";
		document.sales_entry_form.user_address.value="";
		document.sales_entry_form.user_password.value="";
		document.sales_entry_form.gmail_password.value="";
		//document.sales_entry_form.ADD.value="ADD";

		//window.location.href='main_fram.php?file=eng_tele_sales_entry_form';

	}

	else

	{

user_designation_validate(designation),user_name_validate(user_name),user_address_validate (user_address),user_contact_no_validate (user_contact_no),user_email_id_validate (user_email_id),user_type_password_validate(user_password),user_type_gmail_password_validate (gmail_password),user_type_active_validate(user_active),user_name_select_validate(user_name);

	}

}
function satchanged_cookware_edit_details() 
{ 
	 if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
	 { 
	 window.location.href='main_fram.php?file=eng_tele_sales_entry_form';
	 document.getElementById("user_details_div").innerHTML=xmlHttp2.responseText;
	 } 
}


/*function update_user_details(designation,name,user_address,user_contact_no,user_email_id,user_name,user_password,gmail_password,user_active,edit_id)

{ 

	if((designation!="")&&(name!='')&&(user_address!='')&&(user_contact_no!='')&&(user_email_id!='')&&(user_name!='')&&(user_password!='')&&(user_active!='')&&(gmail_password!=''))

	{

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

		p2.ajax({

		type: "GET",

		url: "admin/eng_telemarketers_sales_entry/eng_tele_sales_entry_db.php",

		data: "designation="+designation+"&name="+name+"&user_address="+user_address+"&user_contact_no="+user_contact_no+"&user_email_id="+user_email_id+"&user_name="+user_name+"&user_password="+user_password+"&gmail_password="+gmail_password+"&user_active="+user_active+"&edit_id="+edit_id+"&action=UPDATE_USER",

		success: function(msg){p2("#user_details_div").html(msg);}

		});

		window.close();

		alert("Successfully Updated");

		//window.location.href='main_fram.php?file=eng_tele_sales_entry_form';

	}

	else

	{

user_designation_validate(designation),user_name_validate(user_name),user_address_validate (user_address),user_contact_no_validate (user_contact_no),user_email_id_validate (user_email_id),user_type_password_validate(user_password),user_type_gmail_password_validate (gmail_password),user_type_active_validate(user_active),user_name_select_validate(user_name);

	}

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

function delete_user_details_admin(delete_id)

{ 

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

{

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

		p2.ajax({

		type: "GET",

		url: "admin/eng_telemarketers_sales_entry/eng_tele_sales_entry_db.php",

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

		success: function(msg){p2("#user_details_div").html(msg);}

		});

}

}



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

function GetXmlHttpObject_cookware()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

