function submit_add_bdm_form(){var valid=false;var field=new Array;var msg=new Array;var count=-1;count=validate_user_fields(field,msg,count);count=validate_bdm_fields(field,msg,count);initialize_error_field();if(count>-1){Error_Text(msg,field)}else{clear_Errordivs();var form=document.getElementById('create_bdm');if(form.action!=""){form.submit()}form.action=""}}function submit_update_roda_form(){var valid=false;var field=new Array;var msg=new Array;var count=-1;var element=new Array;if(trim(document.getElementById('user_secret_answer').value)==''){count++;msg[count]='Please answer Security Question';element[count]=document.getElementById('user_secret_answer')}else{un_set_error_field_medium(document.getElementById('user_secret_answer'))}if(trim(document.getElementById('user_secret_question').value)==''){count++;msg[count]='Please select Security Question';element[count]=document.getElementById('user_secret_question')}else{un_set_error_field_medium(document.getElementById('user_secret_question'))}var count_fields=-1;count_fields=validate_roda_fields(field,msg,count_fields);initialize_error_field();if(count_fields>-1){Error_Text(msg,field)}else if(count>-1){}else{clear_Errordivs();var form=document.getElementById('update_roda');if(form.action!=""){form.submit()}form.action=""}}function submit_update_bdm_form(){var valid=false;var field=new Array;var msg=new Array;var count=-1;count=validate_bdm_fields(field,msg,count);initialize_error_field();if(count>-1){Error_Text(msg,field)}else{clear_Errordivs();var form=document.getElementById('update_bdm');if(form.action!=""){form.submit()}form.action=""}}function submit_add_da_form(){var valid=false;var field=new Array;var msg=new Array;var count=-1;count=validate_user_fields(field,msg,count);initialize_error_field();if(count>-1){Error_Text(msg,field)}else{clear_Errordivs();var form=document.getElementById('add_da');if(form.action!=""){form.submit()}form.action=""}}function submit_add_roda_form(){var valid=false;var field=new Array;var msg=new Array;var count=-1;count=validate_user_fields(field,msg,count);count=validate_roda_fields(field,msg,count);initialize_error_field();if(count>-1){Error_Text(msg,field)}else{clear_Errordivs();var form=document.getElementById('add_roda');if(form.action!=""){form.submit()}form.action=""}}function submitaddform(){var valid=false;var field=new Array;var msg=new Array;var count=-1;count=validate_user_fields(field,msg,count);count=validate_customer_fields(field,msg,count);initialize_error_field();if(count>-1){Error_Text(msg,field)}else{clear_Errordivs();if(document.getElementById("create_customer").action!=""){document.getElementById("create_customer").submit();show_loading('Please wait')}document.getElementById("create_customer").action=""}}function submiteditform(){var valid=false;var field=new Array;var msg=new Array;var count=-1;count=validate_customer_fields(field,msg,count);initialize_error_field();if(count>-1){Error_Text(msg,field)}else{clear_Errordivs();var form=document.getElementById('edit_customer');if(form.action!=""){form.submit()}form.action=""}}function validate_roda_fields(element,msg,count){if(trim(document.getElementById('user_secret_answer').value)==''){count++;msg[count]='Please enter the answer to your secret question';element[count]=document.getElementById('user_secret_answer')}else{un_set_error_field_medium(document.getElementById('user_secret_answer'))}if(trim(document.getElementById('roda_name').value)==''){count++;msg[count]='Please enter Name';element[count]=document.getElementById('roda_name')}else{un_set_error_field_medium(document.getElementById('roda_name'))}if(isalpha(trim(document.getElementById('roda_name').value))==false){count++;msg[count]='Please specify alpha characters only for Name';element[count]=document.getElementById('roda_name')}else{un_set_error_field_medium(document.getElementById('roda_name'))}if(trim(document.getElementById('roda_title').value)==''){count++;msg[count]='Please enter Title';element[count]=document.getElementById('roda_title')}else{un_set_error_field_medium(document.getElementById('roda_title'))}if(trim(document.getElementById('roda_phone').value)==''){count++;msg[count]='Please enter Phone';element[count]=document.getElementById('roda_phone')}else{un_set_error_field_medium(document.getElementById('roda_phone'))}if(isphone(trim(document.getElementById('roda_phone').value))==false&&trim(document.getElementById('roda_phone').value)!=''){count++;msg[count]='Please enter phone number in above mentioned format (###-###-####)';element[count]=document.getElementById('roda_phone')}else{un_set_error_field_medium(document.getElementById('roda_phone'))}return count}function validate_bdm_fields(element,msg,count){if(trim(document.getElementById('bdm_name').value)==''){count++;msg[count]='Please enter Name';element[count]=document.getElementById('bdm_name')}else{un_set_error_field_medium(document.getElementById('bdm_name'))}if(isalpha(trim(document.getElementById('bdm_name').value))==false){count++;msg[count]='Please specify alpha characters only for Name';element[count]=document.getElementById('bdm_name')}else{un_set_error_field_medium(document.getElementById('bdm_name'))}if(trim(document.getElementById('bdm_title').value)==''){count++;msg[count]='Please enter Title';element[count]=document.getElementById('bdm_title')}else{un_set_error_field_medium(document.getElementById('bdm_title'))}if(trim(document.getElementById('bdm_phone').value)==''){count++;msg[count]='Please enter Phone';element[count]=document.getElementById('bdm_phone')}else{un_set_error_field_medium(document.getElementById('bdm_phone'))}if(isphone(trim(document.getElementById('bdm_phone').value))==false&&trim(document.getElementById('bdm_phone').value)!=''){count++;msg[count]='Please enter phone number in above mentioned format (###-###-####)';element[count]=document.getElementById('bdm_phone');un_set_error_field_medium(document.getElementById('industry_div'))}else{un_set_error_field_medium(document.getElementById('bdm_phone'))}if(!(isCheckedInCollection('bdm[partner_ids][]'))){count++;msg[count]='Please select at least one Vendor';element[count]=document.getElementById('industry_div')}else{un_set_error_field_medium(document.getElementById('industry_div'))}if(isnum(trim(document.getElementById('bdm_extension').value))==false&&trim(document.getElementById('bdm_extension').value)!=''){count++;msg[count]='Please enter only numbers in extension';element[count]=document.getElementById('bdm_extension')}else{un_set_error_field_medium(document.getElementById('bdm_extension'))}return count}function validate_user_fields(element,msg,count){if(trim(document.getElementById('user_login').value)==''){count++;msg[count]='Please enter Login';element[count]=document.getElementById('user_login')}else{un_set_error_field_medium(document.getElementById('user_login'))}if(isemail(trim(document.getElementById('user_login').value))==false&&trim(document.getElementById('user_login').value)!=''){count++;msg[count]='Please specify a valid Email in Login';element[count]=document.getElementById('user_login')}else{un_set_error_field_medium(document.getElementById('user_login'))}if(document.getElementById('user_password').value==''){count++;msg[count]='Please enter Password';element[count]=document.getElementById('user_password')}else{un_set_error_field_medium(document.getElementById('user_password'))}if(is_alpha_and_number(document.getElementById('user_password').value)==false&&document.getElementById('user_password').value!=''){count++;msg[count]='Password must be minimum 6 letters with at least 1 number';element[count]=document.getElementById('user_password')}else{un_set_error_field_medium(document.getElementById('user_password'))}if(((trim(document.getElementById('user_password').value)).length<6||(trim(document.getElementById('user_password').value)).length>20)){count++;msg[count]='Password should be between 6 to 20 characters';element[count]=document.getElementById('user_password')}else{un_set_error_field_medium(document.getElementById('user_password'))}if(trim(document.getElementById('user_password_confirmation').value)==''){count++;msg[count]='Please enter Confirm Password';element[count]=document.getElementById('user_password_confirmation')}else{un_set_error_field_medium(document.getElementById('user_password_confirmation'))}if(document.getElementById('user_password_confirmation').value!=document.getElementById('user_password').value&&trim(document.getElementById('user_password_confirmation').value)!=''){count++;msg[count]="Password doesn't match with Confirm Password";element[count]=document.getElementById('user_password_confirmation')}else{un_set_error_field_medium(document.getElementById('user_password_confirmation'))}if(trim(document.getElementById('user_secret_answer').value)==''){count++;msg[count]='Please answer Security Question';element[count]=document.getElementById('user_secret_answer')}else{un_set_error_field_medium(document.getElementById('user_secret_answer'))}if(trim(document.getElementById('user_secret_question').value)==''){count++;msg[count]='Please select Security Question';element[count]=document.getElementById('user_secret_question')}else{un_set_error_field_medium(document.getElementById('user_secret_question'))}return count}function validate_customer_fields(element,msg,count){if(trim(document.getElementById('customer_first_name').value)==''){count++;msg[count]='Please enter Customer First Name';element[count]=document.getElementById('customer_first_name')}else{un_set_error_field_medium(document.getElementById('customer_first_name'))}if(isalpha(trim(document.getElementById('customer_first_name').value))==false){count++;msg[count]='Please specify alpha characters only for Customer First Name';element[count]=document.getElementById('customer_first_name')}else{un_set_error_field_medium(document.getElementById('customer_first_name'))}if(trim(document.getElementById('customer_last_name').value)==''){count++;msg[count]='Please enter Customer Last Name';element[count]=document.getElementById('customer_last_name')}else{un_set_error_field_full(document.getElementById('customer_last_name'))}if(isalpha(trim(document.getElementById('customer_last_name').value))==false){count++;msg[count]='Please specify alpha characters only for Customer Last Name';element[count]=document.getElementById('customer_last_name')}else{un_set_error_field_medium(document.getElementById('customer_last_name'))}if(trim(document.getElementById('customer_phone').value)==''){count++;msg[count]='Please enter Phone';element[count]=document.getElementById('customer_phone')}else{un_set_error_field_medium(document.getElementById('customer_phone'))}if(isphone(trim(document.getElementById('customer_phone').value))==false&&trim(document.getElementById('customer_phone').value)!=''){count++;msg[count]='Please enter phone number in above mentioned format (###-###-####)';element[count]=document.getElementById('customer_phone')}else{un_set_error_field_medium(document.getElementById('customer_phone'))}if(isphone(trim(document.getElementById('customer_fax').value))==false&&trim(document.getElementById('customer_fax').value)!=''){count++;msg[count]='Please enter fax number in above mentioned format (###-###-####)';element[count]=document.getElementById('customer_fax')}else{un_set_error_field_medium(document.getElementById('customer_fax'))}if(trim(document.getElementById('customer_city').value)==''){count++;msg[count]='Please enter City';element[count]=document.getElementById('customer_city')}else{un_set_error_field_medium(document.getElementById('customer_city'))}if(isalpha(trim(document.getElementById('customer_city').value))==false&&trim(document.getElementById('customer_city').value)!=''){count++;msg[count]='Please specify only alpha characters for City';element[count]=document.getElementById('customer_city')}else{un_set_error_field_medium(document.getElementById('customer_city'))}if(document.getElementById('customer_zip').value==''||isZip(document.getElementById('customer_zip').value)==false){count++;msg[count]='Please enter Zip/Postal Code in valid Format';element[count]=document.getElementById('customer_zip')}else{un_set_error_field_medium(document.getElementById('customer_zip'))}if(trim(document.getElementById('lookups_country').value)==''){count++;msg[count]='Please select a Country';element[count]=document.getElementById('lookups_country')}else{un_set_error_field_medium(document.getElementById('lookups_country'))}if(document.getElementById('states_display_div')&&trim(document.getElementById('lookups_state').value)==''){count++;msg[count]='Please select State';element[count]=document.getElementById('lookups_state')}else{un_set_error_field_medium(document.getElementById('lookups_state'))}if(trim(document.getElementById('customer_organization').value)==''){count++;msg[count]='Please enter Organization';element[count]=document.getElementById('customer_organization')}else{un_set_error_field_medium(document.getElementById('customer_organization'))}if(trim(document.getElementById('customer_address1').value)==''){count++;msg[count]='Please enter Address';element[count]=document.getElementById('customer_address1')}else{un_set_error_field_full(document.getElementById('customer_address1'))}return count}function validatestate(){var selectState=document.getElementById('lookups_state');if(selectState.selectedIndex<0){return false}return true}function contact_company(){var chkboxName='chkproducts';var productQuery='';var noOfproducts=document.getElementById('chkproducts').value;var my_file=document.getElementById('my_file');var isFirst="true";var user_id=document.getElementById('user_id').value;var checkFiles=0;for(i=1;i<=noOfproducts;i++){var chkbox=document.getElementById(chkboxName+i);if(isFirst=="true"){if(chkbox.checked){productQuery=productQuery+chkbox.value;isFirst="false";checkFiles=checkFiles+1}}else{if(chkbox.checked){productQuery=productQuery+","+chkbox.value;checkFiles=checkFiles+1}}}document.getElementById('product_id').value=productQuery;if(checkFiles!=0){document.contactCompany.submit()}else{open_alert("Please select at least one product to proceed!","Notice")}}function checkAttachment(){var my_file=document.getElementById('my_file');if(checkFileForDoc(my_file.id)){}else{my_file.focus();my_file.value=""}}function showHelp(div){if(div=="Budget"){document.getElementById('budgetHelp').style.display='block'}else if(div=="Timeline"){document.getElementById('timelineHelp').style.display='block'}}function hide_help_div(div){if(div=="Budget"){document.getElementById('budgetHelp').style.display='none'}else if(div=="Timeline"){document.getElementById('timelineHelp').style.display='none'}}function alertneedlogin(){open_alert("You must be signed in as customer to do this operation.","Notice")}function validate_and_submit_for_export_customers(action_name,msg){var customer=document.getElementById('to_submit_customers');if(msg=='all'){b=document.getElementById('export');b.value='all';a=document.getElementById('customer_form');a.action=action_name;a.submit();b.value=''}else{if(!customer){open_alert("Customers list not found.","Notice");return}if(customer.options.length<=0){open_alert(msg,"Notice");return}a=document.getElementById('customer_form');a.action=action_name;a.submit()}}function export_customer(action_name,msg){var customer=document.getElementById('to_submit_customers');if(!customer){open_alert("Customer list not found.","Notice");return}if(customer.options.length<=0){open_alert(msg,"Notice");return}a=document.getElementById('customer_form');a.action=action_name;a.submit()}function isCheckedCustomer(id){var lchks=document.getElementById("to_submit_customers");for(jjk=0;jjk<lchks.options.length;jjk++){if(lchks.options[jjk].value==id.toString()){return true}}return false}function addInCheckedCustomer(id){var lchks=document.getElementById("to_submit_customers");var option=new Option();option.value=id;option.text=id;option.selected=true;lchks.options[lchks.options.length]=option}function removeFromCheckedCustomer(id){var lchks=document.getElementById("to_submit_customers");for(jjk=0;jjk<lchks.options.length;jjk++){if(lchks.options[jjk].value==id.toString()){lchks.options[jjk]=null}}}function doOnCheckedCustomer(id,chkid){var customer_chk=document.getElementById(chkid);if(customer_chk.checked==false&&isCheckedCustomer(id))removeFromCheckedCustomer(id);else if(customer_chk.checked==true&&isCheckedCustomer(id));else if(customer_chk.checked==true&&!isCheckedCustomer(id)){addInCheckedCustomer(id)}}function select_deselect_all_customer(to_submit_leads,str_lead_ids){var checkbox=document.getElementById('select_deselect_1');if(checkbox.checked==true){var lead_ids=str_lead_ids.split(",");var leads_select=document.getElementById(to_submit_leads);leads_select.options.length=0;if(!leads_select||!lead_ids||lead_ids.length<1){open_alert('lead list not found.','Notice');return}var i=0;for(i;i<lead_ids.length;i=i+1){leads_select.options[i]=new Option(lead_ids[i],lead_ids[i]);leads_select.options[i].selected=true;check_lead_i="customer_"+i;var chk=document.getElementById(check_lead_i);if(chk){chk.checked=true}}}else if(checkbox.checked==false){var lead_ids=str_lead_ids.split(",");var leads_select=document.getElementById(to_submit_leads);if(!leads_select||!lead_ids||lead_ids.length<1){open_alert('lead list not found.','Notice');return}var i=0;for(i;i<lead_ids.length;i=i+1){leads_select.options[0]=null;var chk=document.getElementById("customer_"+i);if(chk){chk.checked=false}}}}