All pastes #254546 Raw Edit

Stuff

public javascript v1 · immutable
#254546 ·published 2006-11-21 23:47 UTC
rendered paste body
var fee_count=0;function clean_form(){  alert('in clean form');  document.getElementById('form_address1_input').value = $F('form_address1_input').replace(/[^a-zA-Z0-9\s\-]/g,'');  document.getElementById('form_address2_input').value = $F('form_address2_input').replace(/[^a-zA-Z0-9\s\-]/g,'');  document.getElementById('form_city_input').value = $F('form_city_input').replace(/[^a-zA-Z\s\-]/g,'');  document.getElementById('state_input').value = $F('state_input').replace(/[^a-zA-Z]/g,'');  document.getElementById('form_zip_input').value = $F('form_zip_input').replace(/[^0-9\-]/g,'');  document.getElementById('form_borrower1_input').value = $F('form_borrower1_input').replace(/[^a-zA-Z\s\-]/g,'');  document.getElementById('form_borrower2_input').value = $F('form_borrower2_input').replace(/[^a-zA-Z\s\-]/g,'');  document.getElementById('form_phone1_input').value = $F('form_phone1_input').replace(/[^0-9]/g,'');  //document.getElementById('form_ext1_input').value = $F('form_ext1_input').replace(/[^0-9]/g,'');  document.getElementById('form_phone2_input').value = $F('form_phone2_input').replace(/[^0-9]/g,'');  //document.getElementById('form_ext2_input').value = $F('form_ext2_input').replace(/[^0-9]/g,'');  document.getElementById('form_phone3_input').value = $F('form_phone3_input').replace(/[^0-9]/g,'');  document.getElementById('form_ext3_input').value = $F('form_ext3_input').replace(/[^0-9]/g,'');  document.getElementById('form_contact_input').value = $F('form_contact_input').replace(/[^a-zA-Z\s\-]/g,'');  document.getElementById('form_contact_number1_input').value = $F('form_contact_number1_input').replace(/[^0-9]/g,'');  document.getElementById('form_contact_number2_input').value = $F('form_contact_number2_input').replace(/[^0-9]/g,'');  //document.getElementById('form_contact_ext2_input').value = $F('form_contact_ext2_input').replace(/[^0-9]/g,'');  //document.getElementById('form_contact_ext1_input').value = $F('form_contact_ext1_input').replace(/[^0-9]/g,'');  document.getElementById('bank_input').value = $F('bank_input').replace(/[^a-zA-Z0-9\.\s\-]/g,'');    document.getElementById('form_lender_estimate').value = $F('form_lender_estimate').replace(/[^0-9maxMAX\+\,]/g,'');  document.getElementById('form_sales_price').value = $F('form_sales_price').replace(/[^0-9\,]/g,'');  document.getElementById('property_type').value = $F('property_type').replace(/[^0-9\,]/g,'');  document.getElementById('appraisal_type').value = $F('appraisal_type').replace(/[^0-9\,]/g,'');  document.getElementById('priority').value = $F('priority').replace(/[^0-9\,]/g,'');  document.getElementById('payment_type').value = $F('payment_type').replace(/[^0-9\,]/g,'');  alert('leaving clean form');}function form_validate(){  alert('in form validate');  clean_form();    var errors = 0;    if ($F('company_id')==0){ errors+=1;$('#company_error').show();} else $('#company_error').hide();  if (document.getElementById('branch_id').selectedIndex==0){ errors+=1;$('#branch_error').show();} else $('#branch_error').hide();  if ($F('form_street_num_input').length<1){ errors+=1;$('#street_num_error').show();} else $('#street_num_error').hide();  //if ($F('form_suffix_input').length<1){ errors+=1;$('#suffix_error').show();} else $('#suffix_error').hide();  if ($F('form_address1_input').length<1){ errors+=1;$('#address_error').show();} else $('#address_error').hide();  if ($F('form_city_input').length==0){ errors+=1;$('#city_error').show();} else $('#city_error').hide();  if ($F('state_input')==0){ errors+=1;$('#state_error').show();} else $('#state_error').hide();  if ($F('form_county_input')==0){ errors+=1;$('#county_error').show();} else $('#county_error').hide();  if ($F('form_zip_input').length<5){ errors+=1;$('#zip_error').show();} else $('#zip_error').hide();  if ($F('property_type')==0){ errors+=1;$('#property_type_error').show();} else $('#property_type_error').hide();  if ($F('appraisal_type')==0){ errors+=1;$('#appraisal_type_error').show();} else $('#appraisal_type_error').hide();  if ($F('priority')==0){ errors+=1;$('#priority_error').show();} else $('#priority_error').hide();  if ($F('form_lender_estimate').length==0){ errors+=1;$('#lender_estimate_error').show();} else $('#lender_estimate_error').hide();  if ($F('payment_type')==0){ errors+=1;$('#payment_type_error').show();} else $('#payment_type_error').hide();    if (document.getElementById('ordered_by_text').selectedIndex==0){ errors+=1;$('#ordered_by_error').show();} else $('#ordered_by_error').hide();  if (document.getElementById('loan_officer_text').selectedIndex==0){ errors+=1;$('#loan_officer_error').show();} else $('#loan_officer_error').hide();  alert('done error checking returning errors');  if(errors ==0)  {    //document.getElementById('submit_button').disabled=false;    return true;  }  else  {    return false;  }}function add_fee_box(){  var FeeTypeSelect = document.createElement('select');  FeeTypeSelect.name='form[fee]['+fee_count+'][type]';  FeeTypeSelect.id='new_fee_type'+fee_count;      FeeTypeSelect.options[0]=new Option('--Fee Type--','');  FeeTypeSelect.options[1]=new Option('Full SFR',1);  FeeTypeSelect.options[2]=new Option('Full SFR Mil',2);  FeeTypeSelect.options[3]=new Option('Full Condo',3);  FeeTypeSelect.options[4]=new Option('Full 2-4 Income',4);  FeeTypeSelect.options[5]=new Option('Full Commercial',5);  FeeTypeSelect.options[6]=new Option('Full Other',6);    FeeTypeSelect.options[7]=new Option('442 SFR',7);  FeeTypeSelect.options[8]=new Option('442 SFR Mil',8);  FeeTypeSelect.options[9]=new Option('442 Condo',9);  FeeTypeSelect.options[10]=new Option('442 2-4 Income',10);  FeeTypeSelect.options[11]=new Option('442 Commercial',11);  FeeTypeSelect.options[12]=new Option('442 Other',12);    FeeTypeSelect.options[13]=new Option('Drive By SFR',13);  FeeTypeSelect.options[14]=new Option('Drive By SFR Mil',14);  FeeTypeSelect.options[15]=new Option('Drive By Condo',15);  FeeTypeSelect.options[16]=new Option('Drive By 2-4 Income',16);  FeeTypeSelect.options[17]=new Option('Drive By Commercial',17);  FeeTypeSelect.options[18]=new Option('Drive By Other',18);    FeeTypeSelect.options[19]=new Option('Other',30);  FeeTypeSelect.options[20]=new Option('Next Day Rush',37);  FeeTypeSelect.options[21]=new Option('Same Day Rush',38);  document.getElementById('fee_box').appendChild(FeeTypeSelect);    var FeeToSelect = document.createElement('select');  FeeToSelect.name='form[fee]['+fee_count+'][charge_to]';  FeeToSelect.id='new_fee_charge_to'+fee_count;      FeeToSelect.options[0]=new Option('--Charge To--','');  FeeToSelect.options[1]=new Option('Loan Officer',1);  FeeToSelect.options[2]=new Option('Borrower',2);  document.getElementById('fee_box').appendChild(FeeToSelect);    var FeeAmount=document.createElement('input');  FeeAmount.name='form[fee]['+fee_count+'][amount]';  FeeAmount.id='new_fee_amount'+fee_count;  document.getElementById('fee_box').appendChild(FeeAmount);    var txt = document.createElement('br');    document.getElementById('fee_box').appendChild(txt);  fee_count+=1;}   function getPayment(){    if(parseInt($F("branch_id"))>0)  {	  var url = "remote/getPayment.php";	  var pars = 'branch_id=' + $F("branch_id");    var myAjax = new Ajax.Updater('payment_type_div', url, { method: 'post', parameters: pars});  }}function enable_button(){  alert('in enable button');  document.getElementById('submit_button').disabled=false;  alert('leaving enable button');  return true;}function disable_button(){  alert('in disable button');  document.getElementById('submit_button').disabled=true;  window.setTimeout('enable_button()',5000);  alert('exiting button');  return true;}function rmtAddBranch(){  var url="../../../includes/remote/addBranch.php";  var pars= 'branch_name=' + $F('branch_name');  pars+= '&branch_address1=' + $F('branch_address1');  pars+= '&branch_address2=' + $F('branch_address2')  pars+= '&branch_city=' + $F('branch_city')  pars+= '&branch_state=' + $F('branch_state');  pars+= '&branch_zip=' + $F('branch_zip');  pars+= '&&branch_phone1=' + $F('branch_phone1');  pars+= '&branch_phone2=' + $F('branch_phone2');  pars+= '&branch_fax=' + $F('branch_fax');  pars+= '&branch_bill_approval_status=' + $F('branch_bill_approval_status');  pars+= '&company_id=' + $F('company_id');  var myAjax = new Ajax.Request(url, { method: 'post', parameters: pars, onComplete: addBranchCallback});}function addBranchCallback(info){    var x = info.responseText;    if(x=='false')    {         $('#addBranchError').html('Error adding Branch');    }    else    {    //refresh branches        rmtGetBranches();        $('#addLenderError').html('SUCCESS');        TB_remove();    }}function rmtAddLender(){  var url="../../../includes/remote/addLender.php";  var pars= 'lender_name=' + $F('lender_name');  pars+= '&lender_address1=' + $F('lender_address1');  pars+= '&lender_address2=' + $F('lender_address2')  pars+= '&lender_city=' + $F('lender_city')  pars+= '&lender_state=' + $F('lender_state');  pars+= '&lender_zip=' + $F('lender_zip');  pars+= '&lender_phone1=' + $F('lender_phone1');  pars+= '&lender_phone2=' + $F('lender_phone2');  pars+= '&lender_fax=' + $F('lender_fax');  pars+= '&sameInfoCheckBox=' + $F('sameInfoCheckBox');    pars+= '&branch_name=' + $F('branch_name');  pars+= '&branch_address1=' + $F('branch_address1');  pars+= '&branch_address2=' + $F('branch_address2')  pars+= '&branch_city=' + $F('branch_city')  pars+= '&branch_state=' + $F('branch_state');  pars+= '&branch_zip=' + $F('branch_zip');  pars+= '&&branch_phone1=' + $F('branch_phone1');  pars+= '&branch_phone2=' + $F('branch_phone2');  pars+= '&branch_fax=' + $F('branch_fax');  pars+= '&branch_bill_approval_status=' + $F('branch_bill_approval_status');  var myAjax = new Ajax.Request(url, { method: 'post', parameters: pars, onComplete: rmtGetLenders});}  function rmtAddLenderProcess(){  var errors=0;  document.getElementById('lender_address1').value = $F('lender_address1').replace(/[^a-zA-Z0-9\s\-]/g,'');  document.getElementById('lender_address2').value = $F('lender_address2').replace(/[^a-zA-Z0-9\s\-]/g,'');  document.getElementById('lender_city').value = $F('lender_city').replace(/[^a-zA-Z\s]/g,'');  document.getElementById('lender_state').value = $F('lender_state').replace(/[^a-zA-Z]/g,'');  document.getElementById('lender_zip').value = $F('lender_zip').replace(/[^0-9]/g,'');  document.getElementById('lender_phone1').value = $F('lender_phone1').replace(/[^0-9]/g,'');  document.getElementById('lender_phone2').value = $F('lender_phone2').replace(/[^0-9]/g,'');  document.getElementById('lender_fax').value = $F('lender_fax').replace(/[^0-9]/g,'');    document.getElementById('branch_address1').value = $F('branch_address1').replace(/[^a-zA-Z0-9\s\-]/g,'');  document.getElementById('branch_address2').value = $F('branch_address2').replace(/[^a-zA-Z0-9\s\-]/g,'');  document.getElementById('branch_city').value = $F('branch_city').replace(/[^a-zA-Z]/g,'');  document.getElementById('branch_state').value = $F('branch_state').replace(/[^a-zA-Z]/g,'');  document.getElementById('branch_zip').value = $F('branch_zip').replace(/[^0-9]/g,'');  document.getElementById('branch_phone1').value = $F('branch_phone1').replace(/[^0-9]/g,'');  document.getElementById('branch_phone2').value = $F('branch_phone2').replace(/[^0-9]/g,'');  document.getElementById('branch_fax').value = $F('branch_fax').replace(/[^0-9]/g,'');    if($F('lender_name')==''){ errors+=1; $('#lender_name_error').show();}else{$('#lender_name_error').hide();}  if($F('lender_address1')=='') {errors+=1;$('#lender_address1_error').show();}else{$('#lender_address1_error').hide();}  if($F('lender_city')=='') {errors+=1;$('#lender_city_error').show();}else{$('#lender_city_error').hide();}  if($F('lender_state').length !=2) {errors+=1;$('#lender_state_error').show();}else{$('#lender_state_error').hide();}  if($F('lender_phone1')=='') {errors+=1;$('#lender_phone1_error').show();}else{$('#lender_phone1_error').hide();}    if($F('sameInfoCheckBox') != 'on')  {    if($F('branch_name')==''){ errors+=1; $('#branch_name_error').show();}else{$('#branch_name_error').hide();}    if($F('branch_address1')=='') {errors+=1;$('#branch_address1_error').show();}else{$('#branch_address1_error').hide();}    if($F('branch_city')=='') {errors+=1;$('#branch_city_error').show();}else{$('#branch_city_error').hide();}    if($F('branch_state').length !=2) {errors+=1;$('#branch_state_error').show();}else{$('#branch_state_error').hide();}    if($F('branch_phone1')=='') {errors+=1;$('#branch_phone1_error').show();}else{$('#branch_phone1_error').hide();}  }  if(errors !=0)  {    $('#addLenderError').html('Error adding Lender');  }  else  {    rmtAddLender();  }}function rmtAddBranchProcess(){  var errors=0;    document.getElementById('branch_address1').value = $F('branch_address1').replace(/[^a-zA-Z0-9\s\-]/g,'');  document.getElementById('branch_address2').value = $F('branch_address2').replace(/[^a-zA-Z0-9\s\-]/g,'');  document.getElementById('branch_city').value = $F('branch_city').replace(/[^a-zA-Z]/g,'');  document.getElementById('branch_state').value = $F('branch_state').replace(/[^a-zA-Z]/g,'');  document.getElementById('branch_zip').value = $F('branch_zip').replace(/[^0-9]/g,'');  document.getElementById('branch_phone1').value = $F('branch_phone1').replace(/[^0-9]/g,'');  document.getElementById('branch_phone2').value = $F('branch_phone2').replace(/[^0-9]/g,'');  document.getElementById('branch_fax').value = $F('branch_fax').replace(/[^0-9]/g,'');    if(($F('company_id')=='')||($F('company_id')=='0')){ errors+=1; $('#company_id_error').show();}else{$('#lender_name_error').hide();}    if($F('branch_name')==''){ errors+=1; $('#branch_name_error').show();}else{$('#branch_name_error').hide();}  if($F('branch_address1')=='') {errors+=1;$('#branch_address1_error').show();}else{$('#branch_address1_error').hide();}  if($F('branch_city')=='') {errors+=1;$('#branch_city_error').show();}else{$('#branch_city_error').hide();}  if($F('branch_state').length !=2) {errors+=1;$('#branch_state_error').show();}else{$('#branch_state_error').hide();}  if($F('branch_phone1')=='') {errors+=1;$('#branch_phone1_error').show();}else{$('#branch_phone1_error').hide();}  if(errors !=0)  {    $('#addBranchError').html('Error adding Branch');  }  else  {    rmtAddBranch();  }}  function rmtGetLenders(info){  var x = info.responseText;  if(x !='false')  {    var update = x.split('|');    var companyId=update[0];    var branchId=update[1];  var url = "../../../includes/remote/getLenders.php";  var pars = 'company_id=' + companyId;        var myAjax = new Ajax.Updater('lenderSelect', url, { method: 'post', parameters: pars});        var url2 = "../../../includes/remote/getBranches.php";    var pars2 = 'company_id=' + companyId + '&branch_id=' + branchId;    var myAjax2 = new Ajax.Updater('branchSelect', url2, { method: 'post', parameters:pars2, onComplete: rmtGetBranchInfo});    $("#new_lo").show();    TB_remove();    $('#addLenderError').html('SUCCESS');  }  else  {    alert('failure');    $('#addLenderError').html('Error adding Lender');  }}  function sameBranchCheck(){  if($F('sameInfoCheckBox')=='on')  {    $('#modalBranchInfo').hide();    clearBranchInfo2();  }  else     $('#modalBranchInfo').show();}  function rmtGetCounties(){  var state = $F('state_input');  var url = "remote/getCounties.php";  var pars = 'state=' + state;        var myAjax = new Ajax.Updater('countySelect', url, { method: 'post', parameters: pars});}  function clearBranchInfo(){  $('#form_branch_name').html('');  $('#form_branch_address1').html('');  $('#form_branch_address2').html('');  $('#form_branch_city').html('');  $('#form_branch_state').html('');  $('#form_branch_zip').html('');  $('#form_branch_phone1').html('');  $('#form_branch_phone2').html('');  $('#form_branch_fax').html(''); }  function clearBranchInfo2(){  document.getElementById('branch_name').value='';  document.getElementById('branch_address1').value='';  document.getElementById('branch_address2').value='';  document.getElementById('branch_city').value='';  document.getElementById('branch_state').value='';  document.getElementById('branch_zip').value='';  document.getElementById('branch_phone1').value='';  document.getElementById('branch_phone2').value='';  document.getElementById('branch_fax').value='';}  function rmtGetBranches(){  var compId = $F('company_id');var url = "../../../includes/remote/getBranches.php";var pars = 'company_id=' + compId;        var myAjax = new Ajax.Updater('branchSelect', url, { method: 'post', parameters: pars});    if(compId==0)  {    clearBranchInfo()   } }function rmtGetBranches2(compId){var url = "../../../includes/remote/getBranches.php";var pars = 'company_id=' + compId;        var myAjax = new Ajax.Updater('branchSelect', url, { method: 'post', parameters: pars});    if(compId==0)  {    clearBranchInfo()   } }function rmtGetBranchInfo(){var branchId = $F('branch_id');  if((branchId=='')||(branchId==0))  {    clearBranchInfo()  }  else  {  var url = "remote/getBrancheInfo.php";  var pars = 'branch_id=' + branchId;      var myAjax = new Ajax.Request(url, { method: 'post', parameters: pars, onComplete: showBranchInfo});  }}  function showBranchInfo(info){  var x = info.responseText;  x = eval("(" + x + ")");  if(x.name!=null) $('#form_branch_name').html(x.name);  if(x.address1!=null) $('#form_branch_address1').html(x.address1);  if(x.address2!=null) $('#form_branch_address2').html(x.address2);  if(x.city!=null) $('#form_branch_city').html(x.city);  if(x.state!=null) $('#form_branch_state').html(x.state);  if(x.zip!=null) $('#form_branch_zip').html(x.zip);  if(x.phone1!=null) $('#form_branch_phone1').html(x.phone1);  if(x.phone2!=null) $('#form_branch_phone2').html(x.phone2);  if(x.fax!=null) $('#form_branch_fax').html(x.fax);   //if(x.bill_approval_status!=null) }  function getOrderedBy(){//alert($F("branch_id"));  if($F("branch_id")>0)  {    var url='../../../includes/remote/getOrderedBy.php';    var pars='branch_id=' + $F('branch_id');    //var myAjax = new Ajax.Request(url, { method: 'get', parameters: pars, onComplete: getOrderedByCallback});    var myAjax = new Ajax.Updater('ordered_by_select', url, { method: 'post', parameters: pars});  }}function getLOs(){  //alert($F("branch_id"));  if($F("branch_id")>0)  {    var url='../../../includes/remote/getLo.php';    var pars='branch_id=' + $F('branch_id');    var myAjax = new Ajax.Updater('lo_select', url, { method: 'post', parameters: pars});  }}function getBothLO(update){  var ret = update.responseText;  if('login'==ret)  {    $('#addLoError').html('That email address is already in use, please choose another.');    $('#addLoError').show();    return;  }  if(ret!='false')  {    getOrderedBy();    getLOs();    $('#addLoError').html('SUCCESS');    TB_remove();  }  else  {    $('#addLoError').html('Error');  }}function rmtAddLo(){  var url="../../../includes/remote/addLo.php";  var pars= 'first_name=' + $F('lo_first_name');  pars+= '&last_name=' + $F('lo_last_name');  pars+= '&email=' + $F('lo_email');  pars+= '&phone1=' + $F('lo_phone1')  pars+= '&ext1=' + $F('lo_ext1')  pars+= '&phone2=' + $F('lo_phone2');  //pars+= '&ext2=' + $F('lo_ext2');  pars+= '&fax=' + $F('lo_fax');  pars+= '&company_id=' + $F('company_id');  pars+= '&branch_id=' + $F('branch_id');  var myAjax = new Ajax.Request(url, { method: 'post', parameters: pars, onComplete: getBothLO});}function rmtAddLoProcess(){  var errors=0;  document.getElementById('lo_first_name').value = $F('lo_first_name').replace(/[^a-zA-Z]/g,'');  document.getElementById('lo_last_name').value = $F('lo_last_name').replace(/[^a-zA-Z]/g,'');  //document.getElementById('lo_email').value = $F('lo_email').replace(/[^a-zA-Z\s]/g,'');  document.getElementById('lo_phone1').value = $F('lo_phone1').replace(/[^0-9]/g,'');  document.getElementById('lo_phone2').value = $F('lo_phone2').replace(/[^0-9]/g,'');  document.getElementById('lo_ext1').value = $F('lo_ext1').replace(/[^a-zA-Z0-9]/g,'');  //document.getElementById('lo_ext2').value = $F('lo_ext2').replace(/[^a-zA-Z0-9]/g,'');  document.getElementById('lo_fax').value = $F('lo_fax').replace(/[^0-9]/g,'');  if($F('lo_first_name')==''){ errors+=1; $('#lo_first_name_error').show();}else{$('#lo_first_name_error').hide();}    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;  if (!filter.test(document.getElementById('lo_email').value)){ errors+=1; $('#lo_email_error').show();}else{$('#lo_email_error').hide();}  if(errors !=0)  {    $('#addLoError').html('Error adding Lo');    $('#addLoError').show();      }  else  {    rmtAddLo();  }}