function SubmitLoginFrm(formnm){
if(formnm.txt_email.value==""){
	alert("Please enter the Email address");
	formnm.txt_email.focus();
}else if(formnm.txt_password.value==""){
	alert("Please enter the password");
	formnm.txt_password.focus();
}else{
	formnm.submit();
}
}


function SubmitAddClientFrm(formnm,val){
chkbox = new Array();
j=0;
k=0;
leadtype="";
for(i=1;i < val;i++){
chkbox[i] = eval("formnm.chk_lead" +i);

if(chkbox[i].checked==false){
k++;
}else{
leadtype += chkbox[i].value;
leadtype +=",";
}
}//for

technology="";
for(i=1;i <11 ;i++){
chkbox[i] = eval("formnm.chk_tech" +i);

if(chkbox[i].checked==false){
j++;
}else{
technology += chkbox[i].value;
technology +=",";
}
}//for
formnm.technology.value=technology;

formnm.txt_companyname.value = trim(formnm.txt_companyname.value);
formnm.txt_fname.value = trim(formnm.txt_fname.value);
formnm.txt_lname.value = trim(formnm.txt_lname.value);
formnm.txt_title.value = trim(formnm.txt_title.value);
formnm.txt_add1.value = trim(formnm.txt_add1.value);
formnm.txt_cemail.value = trim(formnm.txt_cemail.value);
formnm.txt_email.value = trim(formnm.txt_email.value);
formnm.txt_phone.value = trim(formnm.txt_phone.value);
formnm.txt_password.value = trim(formnm.txt_password.value);
formnm.txt_amount.value = trim(formnm.txt_amount.value);
if(formnm.txt_companyname.value==""){
	alert("Please enter the Company Name");
	formnm.txt_companyname.focus();
}else if(formnm.txt_fname.value==""){
	alert("Please enter the First Name");
	formnm.txt_fname.focus();	
}else if(formnm.txt_lname.value==""){
	alert("Please enter the Last Name");
	formnm.txt_lname.focus();
}else if(formnm.txt_title.value==""){
	alert("Please enter the Title");
	formnm.txt_title.focus();		
}else if(formnm.txt_add1.value==""){
	alert("Please enter Address Line 1");
	formnm.txt_add1.focus();
}else if(formnm.txt_cemail.value==""){
	alert("Please enter the Email Address");
	formnm.txt_cemail.focus();
}else if(formnm.txt_phone.value==""){
	alert("Please enter the Phone Number");
	formnm.txt_phone.focus();						
}else if(formnm.txt_email.value==""){
	alert("Please enter the Login");
	formnm.txt_email.focus();
}else if(formnm.txt_password.value==""){
	alert("Please Enter the password");
	formnm.txt_password.focus();		
}else if(k==(val-1)){
	alert("Please Select atleast one Lead type ");
	formnm.chk_lead1.focus();
}else if(formnm.txt_amount.value==""){
	alert("Please Enter the Billing Amount");
	formnm.txt_amount.focus();
}else if(formnm.slct_cycle.value==""){
	alert("Please select the Billing Cycle");
	formnm.slct_cycle.focus();
}else if(formnm.txt_smonth.value==""){
	alert("Please Enter the Contract Start Month");
	formnm.txt_smonth.focus();
}else if(formnm.txt_sday.value==""){
	alert("Please Enter the Contract Start Day");
	formnm.txt_sday.focus();
}else if(formnm.txt_syear.value==""){
	alert("Please Enter the Contract Start Year");
	formnm.txt_syear.focus();	
}else if(formnm.technology.value==""){
	alert("Please Enter Product Interest");
	formnm.chk_tech1.focus();	
}else{
formnm.leadtype.value=leadtype;
formnm.submit();
}
}//function

function SubmitClientID(formnm,actiontype){
if(actiontype=="edit"){
	formnm.action="edit_client.php";
	formnm.ActionType.value=actiontype;
	formnm.submit();
}

if(actiontype=="delete"){
	if(confirm("Do you really want to delete this client?")){
		formnm.action="delete_client.php";
		formnm.ActionType.value=actiontype;
		formnm.submit();
	}
}
}


function poplogo(imgname){
	var popurl = "view_logo.php?id="+imgname;
	props=window.open(popurl, 'mywindow', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubar=no, resizable=1, width=625, height=200, left = 160, top = -90');
}

function SubmitLead(formnm,id,actiontype){
formnm.id.value=id;
formnm.ActionType.value=actiontype;

if(actiontype=="edit"){
formnm.submit();
}

if(actiontype=="delete"){
 if(confirm("Do you really want to delete this Lead?")){
 formnm.submit();
 }
}
}

function SubmitSource(formnm,id,actiontype){
formnm.id.value=id;
formnm.ActionType.value=actiontype;

if(actiontype=="edit"){
formnm.action="manage_lead_sources4.php";
formnm.submit();
}

if(actiontype=="delete"){
 if(confirm("Do you really want to delete this Lead Source?")){
 formnm.submit();
 }
}
}


function SubmitType(formnm,id,actiontype){
formnm.id.value=id;
formnm.ActionType.value=actiontype;
formnm.submit();
}

function SubmitAllCheck(formnm,val){
j=0;
box0 = eval("formnm.chk_comp" + j); 
for (var j = 1; j <= val ; j++) {
box = eval("formnm.chk_comp" + j); 
if(box0.checked == true){
	if (box.checked == false) box.checked = true;
}

if(box0.checked == false){
	if (box.checked == true) box.checked = false;
}

   }
}


function SubmitClientLeadFrm(formnm){
techno="";

for(k=1;k<11;k++){
chkbox = eval("formnm.chk_tech"+k);
if(chkbox.checked==true){
techno += chkbox.value;
techno +=",";
}
}
formnm.technology.value=techno;
formnm.txt_companyname.value = trim(formnm.txt_companyname.value);
formnm.txt_contactfname.value = trim(formnm.txt_contactfname.value);
formnm.txt_contactlname.value = trim(formnm.txt_contactlname.value);
formnm.txt_title.value = trim(formnm.txt_title.value);
formnm.txt_add1.value = trim(formnm.txt_add1.value);
formnm.txt_city.value = trim(formnm.txt_city.value);
formnm.txt_zip.value = trim(formnm.txt_zip.value);
formnm.txt_phone.value = trim(formnm.txt_phone.value);

if(formnm.txt_companyname.value==""){
alert("Please Enter the Company Name");
formnm.txt_companyname.focus();
}else if(formnm.txt_contactfname.value==""){
alert("Please Enter the Contact First Name");
formnm.txt_contactfname.focus();
}else if(formnm.txt_contactlname.value==""){
alert("Please Enter the Contact Last Name");
formnm.txt_contactlname.focus();
}else if(formnm.txt_title.value==""){
alert("Please Enter the Title");
formnm.txt_title.focus();
}else if(formnm.txt_add1.value==""){
alert("Please Enter the Address Line 1");
formnm.txt_add1.focus();
}else if(formnm.txt_city.value==""){
alert("Please Enter the City");
formnm.txt_city.focus();
}else if(formnm.slct_state.value==""){
alert("Please Enter the State");
formnm.slct_state.focus();
}else if(formnm.txt_zip.value==""){
alert("Please Enter the Zip/Postal code");
formnm.txt_zip.focus();
}else if(formnm.txt_phone.value==""){
alert("Please Enter the Phone Number");
formnm.txt_phone.focus();
}else{
formnm.submit();
}
}

function CheckallTerritory(){
var j= document.adduserFrm.chk_territory.length;
i=0;
box0 = eval("document.adduserFrm.chk_territory["+ i +"]");
for (i=1; i <= j  ; i++){
box = eval("document.adduserFrm.chk_territory["+ i +"]");
if(box0.checked == true){
	if (box.checked == false) box.checked = true;
}

if(box0.checked == false){
	if (box.checked == true) box.checked = false;
  }
 }
}//function

function SubmitAdduserFrm(formnm,val){
var j= formnm.chk_territory.length;

var territory="";

for (i=1; i <=64  ; i++){
	box = eval("formnm.chk_territory["+ i +"]");
	if (box.checked == true){
	territory += box.value;
	territory +=",";
	}
 }
formnm.territory.value = territory;

leadid="";
j=0;
for(i=1;i<=val;i++){
chkbox=eval("formnm.chk_lead"+i);
	if(chkbox.checked==false){
	 j++;
	}else{
	 leadid += chkbox.value;
	 leadid +=",";
       }
}//for
formnm.leadid.value=leadid;

formnm.txt_companyname.value = trim(formnm.txt_companyname.value);
formnm.txt_fname.value = trim(formnm.txt_fname.value);
formnm.txt_lname.value = trim(formnm.txt_lname.value);
formnm.txt_title.value = trim(formnm.txt_title.value);
formnm.txt_add1.value = trim(formnm.txt_add1.value);
formnm.txt_city.value = trim(formnm.txt_city.value);
formnm.txt_zip.value = trim(formnm.txt_zip.value);
formnm.txt_email.value = trim(formnm.txt_email.value);
formnm.txt_phone.value = trim(formnm.txt_phone.value);
formnm.txt_password.value = trim(formnm.txt_password.value);

if(formnm.txt_title.value=""){
/*alert("Please Enter the Title");
formnm.txt_title.focus();*/
formnm.txt_title.value="-";
}else if(formnm.txt_add1.value==""){
/*alert("Please Enter the Address Line 1");
formnm.txt_add1.focus();*/
formnm.txt_add1.value="-";
}else if(formnm.txt_city.value==""){
/*alert("Please Enter the City");
formnm.txt_city.focus();*/
formnm.txt_city.value="-";
}else if(formnm.slct_state.value==""){
/*alert("Please Select the state");
formnm.slct_state.focus();*/
formnm.slct_state.value="-";
}else if(formnm.txt_zip.value==""){
/*alert("Please Enter the Zip/Postal Code");
formnm.txt_zip.focus();*/
formnm.txt_zip.value="-";
}else if(formnm.txt_phone.value==""){
/*alert("Please Enter the Phone Number");
formnm.txt_phone.focus();*/
formnm.txt_zip.value="-";
}

if(formnm.txt_fname.value==""){
alert("Please Enter the First Name");
formnm.txt_fname.focus();
}else if(formnm.txt_lname.value==""){
alert("Please Enter the Last Name");
formnm.txt_lname.focus();
}else if(formnm.txt_companyname.value==""){
alert("Please Enter the Company Name");
formnm.txt_companyname.focus();
}else if(formnm.txt_email.value==""){
alert("Please Enter the Email");
formnm.txt_email.focus();
}else if(formnm.txt_password.value==""){
alert("Please Enter the Password");
formnm.txt_password.focus();
}else if(formnm.leadid.value==""){
alert("Please Select Lead Type");
formnm.chklead1.focus();
}else{
formnm.submit();
}
}//function


function SubmitSort(formnm,sortby,sortorder,sortprev){

if(sortprev==sortby){
	if(sortorder == "asc"){
	 sortorder = "desc";
     }else{    
	 sortorder ="asc";
     }
  }else{
  sortorder="asc";
  }
  formnm.sortby.value=sortby;	  
  formnm.sortorder.value=sortorder;
  formnm.submit();
}//function


function SubmitEditUser(formnm){
formnm.submit();

}

function SubmitSearchFrm(formnm){
formnm.submit();
}

function SubmitClientleadFrm(formnm,actiontype,user){

if(actiontype=="returnlead"){
formnm.ActionType.value=actiontype;
if(user=="client"){
formnm.action="lead_return.php";
}
if(user=="clientuser"){
formnm.action="lead_return_clientuser.php";
}
if(user=="user"){
formnm.action="lead_return_user.php";
}

formnm.submit();
}

/*if(actiontype=="update_status" || actiontype=="update_assignto" || actiontype=="add_notes"){
formnm.ActionType.value=actiontype;
}*/
//if(formnm.name=="businessFrm"){
if(formnm.name=="leadstatusFrm"){
techno="";
for(k=1;k<11;k++){
chkbox = eval("formnm.chk_tech"+k);

if(chkbox.checked==true){
techno += chkbox.value;
techno +=",";
}
}
formnm.technology.value=techno;
}
/*
if((!(isNaN(formnm.txt_companyname.value.charAt(0))))){
alert("Please Enter the Company Name");
formnm.txt_companyname.focus();
}else if((!(isNaN(formnm.txt_contactfname.value.charAt(0))))){
alert("Please Enter the Contact First Name");
formnm.txt_contactfname.focus();
}else if((!(isNaN(formnm.txt_contactlname.value.charAt(0))))){
alert("Please Enter the Contact Last Name");
formnm.txt_contactlname.focus();
}else if((!(isNaN(formnm.txt_title.value.charAt(0))))){
alert("Please Enter the Title");
formnm.txt_title.focus();
}else if((!(isNaN(formnm.txt_add1.value.charAt(0))))){
alert("Please Enter the Address Line 1");
formnm.txt_add1.focus();
}else if((!(isNaN(formnm.txt_city.value.charAt(0))))){
alert("Please Enter the City");
formnm.txt_city.focus();
}else if(formnm.slct_state.value==""){
alert("Please Enter the State");
formnm.slct_state.focus();
}else if((!(isNaN(formnm.txt_zip.value.charAt(0))))){
alert("Please Enter the Zip/Postal code");
formnm.txt_zip.focus();
}else if((!(isNaN(formnm.txt_phone.value.charAt(0))))){
alert("Please Enter the Phone Number");
formnm.txt_phone.focus();*/
formnm.txt_companyname.value = trim(formnm.txt_companyname.value);
formnm.txt_contactfname.value = trim(formnm.txt_contactfname.value);
formnm.txt_contactlname.value = trim(formnm.txt_contactlname.value);
formnm.txt_title.value = trim(formnm.txt_title.value);
formnm.txt_add1.value = trim(formnm.txt_add1.value);
formnm.txt_city.value = trim(formnm.txt_city.value);
formnm.txt_zip.value = trim(formnm.txt_zip.value);
formnm.txt_phone.value = trim(formnm.txt_phone.value);

if(formnm.txt_companyname.value==""){
alert("Please Enter the Company Name");
formnm.txt_companyname.focus();
}else if(formnm.txt_contactfname.value==""){
alert("Please Enter the Contact First Name");
formnm.txt_contactfname.focus();
}else if(formnm.txt_contactlname.value==""){
alert("Please Enter the Contact Last Name");
formnm.txt_contactlname.focus();
}else if(formnm.txt_title.value==""){
alert("Please Enter the Title");
formnm.txt_title.focus();
}else if(formnm.txt_add1.value==""){
alert("Please Enter the Address Line 1");
formnm.txt_add1.focus();
}else if(formnm.txt_city.value==""){
alert("Please Enter the City");
formnm.txt_city.focus();
}else if(formnm.slct_state.value==""){
alert("Please Enter the State");
formnm.slct_state.focus();
}else if(formnm.txt_zip.value==""){
alert("Please Enter the Zip/Postal code");
formnm.txt_zip.focus();
}else if(formnm.txt_phone.value==""){
alert("Please Enter the Phone Number");
formnm.txt_phone.focus();
}else{
formnm.ActionType.value=actiontype;
formnm.submit();
}
}


function SubmitClientNotes(formnm,notesid,actiontype){
if(actiontype=="delete_notes"){
	if(confirm("Do You Really want to delete this note?")){
		formnm.ActionType.value=actiontype;
		formnm.notesid.value=notesid;
		formnm.submit();
	}
 } 
}//function

function SubmitDeleteUser(formnm){
if(confirm("Do you Really want to delete this user?")){
formnm.submit();
}
}

function SubmitLeadStatusFrm(formnm,leadstatus){
formnm.leadstatus.value=leadstatus;
formnm.submit();
}

function SubmitLeadStatusFrm1(formnm,leadstatus){
formnm.leadstatus.value=leadstatus;
formnm.action="client_view_user.php";
formnm.submit();
}

function SubmitLeadFrm(formnm,actiontype,val,clientleadid){

if(actiontype=="viewdetails"){
formnm.clientleadid.value=clientleadid;
formnm.action="view_detail.php";
formnm.submit();
}

leadid="";
j=0;
for(i=1;i<=val;i++){
chkbox=eval("formnm.chk_leadstatus"+i);
	if(chkbox.checked==false){
	 j++;
	}else{
	 leadid += chkbox.value;
	 leadid +=",";
       }
}//for

if(actiontype=="assignto"){
	if(j==val){
	alert("Please Select at least one Lead");
	}else if(formnm.slct_user.value==""){
	alert("Please Select the User");
	}else{
 	formnm.leadids.value=leadid;
 	formnm.ActionType.value=actiontype;
 	formnm.submit(); 
 	}  
}	

if(actiontype=="status"){

	if(j==val){
	alert("Please Select atleast one Lead");
	}else if(formnm.slct_assignstatus.value==""){
	alert("Please Select the Status");
	}else{
 	formnm.leadids.value=leadid;
 	formnm.ActionType.value=actiontype;
 	formnm.submit(); 
 	}  
	
}	



if(actiontype=="delete"){
if(confirm("Are you sure you want to Delete ?")){
formnm.clientleadid.value=clientleadid;
formnm.ActionType.value=actiontype;
formnm.submit();
}
}


}//function

function SubmitCompanydetails(formnm,clientid){
//window.open("admin.php?clientid="+clientid, "newwin","height='100%',width='100%',scrollbars=yes");
//window.open("lead_notes.php?leadid="+leadid, "newwin","height=400,width=600,scrollbars=yes")
/*formnm.action="admin.php";
formnm.clientid.value=clientid;
formnm.submit();*/

}//function

function SubmitUserlead(formnm,leadstatus){
formnm.leadstatus.value=leadstatus;
formnm.submit();
}

function SubmitDisplayFrm(formnm){
formnm.submit();
}

function SubmitPageFrm(formnm,page){
formnm.page.value=page;
formnm.submit();
}

function SubmitUserLeadFrm(formnm,val,actiontype){

if(actiontype=="delete"){
if(confirm("Are you sure you want to Delete?")){
formnm.clientleadid.value=val;
formnm.ActionType.value=actiontype;
formnm.submit();
}
}

if(actiontype=="viewdetails"){
formnm.clientleadid.value=val;
formnm.action="user_view_detail.php";
formnm.submit();
}else{	

leadid="";
j=0;
for(i=1;i<=val;i++){
chkbox=eval("formnm.chk_leadstatus"+i);
	if(chkbox.checked==false){
	 j++;
	}else{
	 leadid += chkbox.value;
	 leadid +=",";
       }
}//for

if(j==val){
	alert("Please Select atleast one Lead");
	}else if(formnm.slct_assignstatus.value==""){
	alert("Please Select the Status");
	}else{
	formnm.leadids.value=leadid;
	formnm.ActionType.value="assignto";
	formnm.submit(); 
	}	
}		
}//function

function SubmitUserLeadFrm1(formnm,val,actiontype){

if(actiontype=="delete"){
if(confirm("Are you sure you want to Delete?")){
formnm.clientleadid.value=val;
formnm.ActionType.value=actiontype;
formnm.submit();
}
}


if(actiontype=="viewdetails"){
formnm.clientleadid.value=val;
formnm.action="client_view_userdetail.php";
formnm.submit();
}else{	

leadid="";
j=0;
for(i=1;i<=val;i++){
chkbox=eval("formnm.chk_leadstatus"+i);
	if(chkbox.checked==false){
	 j++;
	}else{
	 leadid += chkbox.value;
	 leadid +=",";
       }
}//for

if(j==val){
	alert("Please Select atleast one Lead");
	}else if(formnm.slct_assignstatus.value==""){
	alert("Please Select the Status");
	}else{
	formnm.leadids.value=leadid;
	formnm.ActionType.value="assignto";
	formnm.submit(); 
	}	
}		
}//function




function PopupNotes(leadid){
window.open("lead_notes.php?leadid="+leadid, "newwin","height=400,width=600,scrollbars=yes")
}

function SubmitCheckAll(formnm,val){
var ids="";
if(formnm.chk_all.checked==true){
formnm.chk_md.checked=true;
for(i=0;i < val;i++){
checkbox = eval("formnm.chk_comp"+i);
checkbox.checked = true;

 }//for 
 
}
 
if(formnm.chk_all.checked==false){
formnm.chk_md.checked=false;
for(i=0;i < val;i++){
checkbox = eval("formnm.chk_comp"+i);
checkbox.checked = false;
 }//for 
 }
}//function


function SubmitExportFrm(formnm,val){
var ids="";
for(i=0;i < val;i++){
checkbox = eval("formnm.chk_comp"+i);
if(checkbox.checked == true){
ids += checkbox.value;
ids +=",";
 }//if
}//for 
 formnm.compids.value=ids;
 formnm.submit();
 }//function
 
 
function SubmitForgotPasswordFrm(formnm,val){
if(formnm.txt_email.value==""){
alert("Please enter your email-address");
formnm.txt_email.focus();
}else{
formnm.submit();
}
}

function SubmitImportLeadsFrm(formnm,val){
extension = formnm.upload_file.value.split(".");

j=0;
k=0;
//box0 = eval("formnm.chk_comp" + j); 
for (var j = 1; j <= val ; j++) {
box = eval("formnm.chk_comp" + j); 
if(box.checked == false){
	k++;
 }//if
}//for

if(formnm.upload_file.value==""){
alert("Please Upload the file");
formnm.upload_file.focus();
/*}else  if(extension[1]!="xls"){
    alert("Please Enter .XLS files only");
    formnm.upload_file.focus();*/
}else if(formnm.slct_type.value==""){
alert("Please select the Lead Type");
formnm.slct_type.focus();
}else if(formnm.slct_source.value==""){
alert("Please select the Lead Source");
formnm.slct_source.focus();
}else if(k==val){
alert("Please Select Assign to");
formnm.chk_comp0.focus();
}else{
formnm.submit();
}
}

function SubmitSetreminderFrm(formnm){
if(formnm.txt_reminder.value==""){
alert("Please Enter the reminder date ");
formnm.txt_reminder.focus();
}else{
formnm.submit();
}
}


function popupwindow(){
	var popurl = "manage_lead_sources.php";
	props=window.open(popurl, 'mywindow', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubar=no, resizable=1, width=785, height=500, left = 160, top = -90');
}

function popupwindow1(){
	var popurl = "manage_lead_types.php";
	props=window.open(popurl, 'mywindow', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubar=no, resizable=1, width=785, height=500, left = 160, top = -90');
}

function popuplead(formnm,clientnm,leadid,comp_logo){
	
	if(formnm.slct_reason.value==""){
	alert("Please Specify the reason for return");
	formnm.slct_reason.focus();
	}else if(formnm.slct_reason.value=="Other - Please Specify" && formnm.txt_reason.value==""){
	alert("Please Specify the reason");
	formnm.txt_reason.focus();	
	}else if(formnm.slct_reason.value=="Other - Please Specify"){
	var popurl = "lead_return2.php?client_name="+clientnm+"&clientleadid="+leadid+"&comp_logo="+comp_logo+"&ActionType=leadreturn&slreason="+formnm.slct_reason.value+"&txtreason="+formnm.txt_reason.value;
	props=window.open(popurl, 'mywindow', 'toolbars=0, scrollbars=0, location=0,statusbars=0, menubar=no, resizable=1, width=780, height=500, left = 160, top = -90');
	}else if(formnm.slct_reason.value!="Other - Please Specify"){
	var popurl = "lead_return2.php?client_name="+clientnm+"&clientleadid="+leadid+"&comp_logo="+comp_logo+"&ActionType=leadreturn&slreason="+formnm.slct_reason.value;
	props=window.open(popurl, 'mywindow', 'toolbars=0, scrollbars=0, location=0,statusbars=0, menubar=no, resizable=1, width=780, height=500, left = 160, top = -90');
	}
}

function popupleadclientuser(formnm,clientnm,leadid,comp_logo){
	if(formnm.slct_reason.value==""){
	alert("Please Specify the reason for return");
	formnm.slct_reason.focus();
	}else if(formnm.slct_reason.value=="Other - Please Specify" && formnm.txt_reason.value==""){
	alert("Please Specify the reason");
	formnm.txt_reason.focus();	
	}else if(formnm.slct_reason.value=="Other - Please Specify"){
	var popurl = "lead_return_clientuser2.php?client_name="+clientnm+"&clientleadid="+leadid+"&comp_logo="+comp_logo+"&ActionType=leadreturn&slreason="+formnm.slct_reason.value+"&txtreason="+formnm.txt_reason.value;
	props=window.open(popurl, 'mywindow', 'toolbars=0, scrollbars=0, location=0,statusbars=0, menubar=no, resizable=1, width=780, height=500, left = 160, top = -90');
	}else if(formnm.slct_reason.value!="Other - Please Specify"){
	var popurl = "lead_return_clientuser2.php?client_name="+clientnm+"&clientleadid="+leadid+"&comp_logo="+comp_logo+"&ActionType=leadreturn&slreason="+formnm.slct_reason.value;
	props=window.open(popurl, 'mywindow', 'toolbars=0, scrollbars=0, location=0,statusbars=0, menubar=no, resizable=1, width=780, height=500, left = 160, top = -90');
	}
	
}



function popupleaduser(formnm,clientnm,leadid,comp_logo){
	if(formnm.slct_reason.value==""){
	alert("Please Specify the reason for return");
	formnm.slct_reason.focus();
	}else if(formnm.slct_reason.value=="Other - Please Specify" && formnm.txt_reason.value==""){
	alert("Please Specify the reason");
	formnm.txt_reason.focus();	
	}else if(formnm.slct_reason.value=="Other - Please Specify"){
	var popurl = "lead_return_user2.php?client_name="+clientnm+"&clientleadid="+leadid+"&comp_logo="+comp_logo+"&ActionType=leadreturn&slreason="+formnm.slct_reason.value+"&txtreason="+formnm.txt_reason.value;
	props=window.open(popurl, 'mywindow', 'toolbars=0, scrollbars=0, location=0,statusbars=0, menubar=no, resizable=1, width=780, height=500, left = 160, top = -90');
	}
	else if(formnm.slct_reason.value!="Other - Please Specify"){
	var popurl = "lead_return_user2.php?client_name="+clientnm+"&clientleadid="+leadid+"&comp_logo="+comp_logo+"&ActionType=leadreturn&slreason="+formnm.slct_reason.value;
	props=window.open(popurl, 'mywindow', 'toolbars=0, scrollbars=0, location=0,statusbars=0, menubar=no, resizable=1, width=780, height=500, left = 160, top = -90');
	}	
}

function CheckFileExt(formnm,val){
extension = val.split(".");
	/*if(extension[1]!="xls"){
		alert("Please Enter only .XLS files");
		formnm.upload_file.focus();
	}*/
}

function SubmitMasterAssignFrm(formnm,actiontype,val,clientleadid,rspage){
if(rspage > val){
val = val;
}else{
val = rspage;
}

leadid="";
k=0;
for(i=1;i<=val;i++){
chkbox=eval("formnm.chk_leadstatus"+i);
	if(chkbox.checked==false){
	 k++;
	 }else{
	 leadid += chkbox.value;
	 leadid +=",";
       }
   }//for

if(actiontype=="assigntoclient"){
	if(k=="20"){
	alert("Please Select atleast one Lead");
	}else{
 	var popurl = "client_list.php?leadids="+leadid;
	props=window.open(popurl, 'mywindow', 'toolbars=0, scrollbars=0, location=0,statusbars=0, menubar=no, resizable=1, width=780, height=500, left = 160, top = -90');
 	}  
	
}	

}//function


function SubmitassigntoclientFrm(formnm,val){
clientid="";
clientcount=0;
for(i=1;i<=val;i++){
chkbox=eval("formnm.chk_client"+i);
	if(chkbox.checked==false){
	 clientcount++;
	 }else{
	 clientid += chkbox.value;
	 clientid +=",";
       }
   }//for
   
   if(clientcount==val){
   alert("Please Select atlest one Client");
   formnm.chk_client1.focus();
   }else{
   formnm.clientids.value=clientid;
   formnm.submit();
     }
}

function SubmitSignupFrm(formnm,val){

chkbox = new Array();
j=0;
leadtype="";
for(i=1;i <= val;i++){
chkbox[i] = eval("formnm.chk_lead" +i);

if(chkbox[i].checked==false){
j++;
}else{
leadtype += chkbox[i].value;
leadtype +=",";
}
}//for
formnm.leadtype.value=leadtype;
technology="";
for(i=1;i < 11;i++){
chkbox[i] = eval("formnm.chk_tech" +i);

if(chkbox[i].checked==false){
j++;
}else{
technology += chkbox[i].value;
technology +=",";
}
}//for
formnm.technology.value=technology;
if(formnm.txt_fname.value==""){
	alert("Please enter the First Name");
	formnm.txt_fname.focus();
}else if(formnm.txt_lname.value==""){
	alert("Please enter the Last Name");
	formnm.txt_lname.focus();
}else if(formnm.txt_companyname.value==""){
	alert("Please enter the Company Name");
	formnm.txt_companyname.focus();
}else if(formnm.txt_cemail.value==""){
	alert("Please enter the Email Address");
	formnm.txt_cemail.focus();
}else if(formnm.leadtype.value==""){
	alert("Please Select atleast one Lead type ");
	formnm.chk_lead1.focus();
}else if(formnm.technology.value==""){
	alert("Please Enter Product Interest");
	formnm.chk_tech1.focus();	
}else{
formnm.leadtype.value=leadtype;
formnm.submit();
}
}


function SubmitActionLeadFrm(formnm,actiontype){
if(actiontype=="exportlead"){
formnm.action="export_leads.php";
}
if(actiontype=="addlead"){
formnm.action="add_lead.php";
}
formnm.submit();
}

function CheckAllStatus(formnm,val){
var ids="";
if(formnm.chk_all.checked==true){
//formnm.chk_md.checked=true;
for(i=1;i <= val;i++){
checkbox = eval("formnm.chk_status"+i);
checkbox.checked = true;
 }//for 
 
}
 
if(formnm.chk_all.checked==false){
//formnm.chk_md.checked=false;
for(i=1;i <= val;i++){
checkbox = eval("formnm.chk_status"+i);
checkbox.checked = false;
 }//for 
 }
}//function


function SubmitExportLeadsFrm(formnm,val){
checkbox = new Array();
var leadstatus="";
var j="0";
for(i=1;i <= val;i++){
checkbox[i] = eval("formnm.chk_status"+i);
if(checkbox[i].checked == false){
j++;
}else{
leadstatus += checkbox[i].value;
leadstatus += ",";
}//else
 }//for

 if(j==val){
 alert("Please Select atleast one Lead status");
 formnm.chk_status1.focus();
 }else{
  formnm.leadstatus.value=leadstatus;
  formnm.submit();
 } 
}//function

function Submitclient(formnm,actionval,val){

formnm.ISClient.value='Y';
formnm.action=actionval;
if(val==""){
formnm.clientid.value="0";
}else{
formnm.clientid.value=val;
}
formnm.submit();
}

function enableText(formnm,val){
if(val=="Other - Please Specify"){
formnm.txt_reason.disabled=false;
}else{
formnm.txt_reason.disabled=true;
}
}

function trim(s) {
    // Remove leading spaces and carriage returns
    while((s.substring(0,1)==' ') || (s.substring(0,1)== '\n') ||(s.substring(0,1)== '\r')){
                 s = s.substring(1,s.length);
         }
    return s;
}
