function page_init() {
window.weekstart  ='1';
window.dateformat ='MM/DD/YYYY';
window.longdateformat ='Month DD, YYYY';
window.timeformat ='fmHH:fmMI am';
window.datetime_am_string ='am';
window.datetime_pm_string ='pm';
window.datetime_short_months = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","");window.phoneformat ="123-456-7890";
window.isvalid = true;
setWindowChanged(window, false);
setIsInited(window,false);
page_init2();
page_init3();
setWindowChanged(window, false);
page_init4();
setIsInited(window,true);
window.status = '';

var currentTime = new Date()
var currentMonth = currentTime.getMonth() + 1
var currentDayOfMonth = currentTime.getDate()
var currentYear = currentTime.getFullYear()
document.main_form.custentity_time_created.value = currentMonth + "/" + currentDayOfMonth + "/" + currentYear;
}



function page_unload() {
if (window.ischanged)
return('You have not yet submitted this record.') }
function page_reset() {
document.page_is_resetting=true;
document.forms['main_form'].reset();
setWindowChanged(window, false);
page_init3();
var savechanged = window.ischanged;
setWindowChanged(window, savechanged);
window.isvalid = true;
window.clickCount=0;
if (window.clickCount == 0)
{
if ( isFocusable( document.forms['main_form'].elements['custentity_due_date'] ) ) { document.forms['main_form'].elements['custentity_due_date'].focus();}
}
document.page_is_resetting=false;
}
function save_record(lastcall) {
if(document.forms['main_form'].bonsubmitisnull) return true;
if (!window.isinited) return false;
var form = document.forms['main_form'];
if (form.submitted) {
if (form.submitted.value == 'T') { 
var resubmit = false;
resubmit = confirm('You have already submitted this form, would you like to submit it again?'); 
if(!resubmit) return false;
}
}
try {
//if (!nlapiSaveRecord()) return false;
var emptylabels = checkMandatoryFields(new Array(document.forms['main_form'].elements['custentity_referred_full_name'],document.forms['main_form'].elements['custentity_referrer_address'],document.forms['main_form'].elements['custentity_referred_email'],document.forms['main_form'].elements['custentity_referred_phone'],document.forms['main_form'].elements['firstname'],document.forms['main_form'].elements['lastname'],document.forms['main_form'].elements['address1'],document.forms['main_form'].elements['city'],document.forms['main_form'].elements['state'],document.forms['main_form'].elements['zipcode'],document.forms['main_form'].elements['country'],document.forms['main_form'].elements['email'],document.forms['main_form'].elements['phone'],document.forms['main_form'].elements['custentity_due_date']),new Array('Name','Address','Email','Phone','First Name','Last Name','Address','City','State','Zip Code','Country','Email','Phone','Expected Due Date'),null,null);if (emptylabels.length>0) {
alert('Please enter value(s) for: ' + emptylabels);
return false;

//try {
//var emptylabels = checkMandatoryFields(new Array(document.forms['main_form'].elements['custentity_due_date'],document.forms['main_form'].elements['companyname'],document.forms['main_form'].elements['address1'],document.forms['main_form'].elements['city'],document.forms['main_form'].elements['state'],document.forms['main_form'].elements['zipcode'],document.forms['main_form'].elements['phone'],document.forms['main_form'].elements['email'],document.forms['main_form'].elements['custentity179']),new Array('Expected Due Date','Name','Address 1','City','State','Zip Code','Daytime Phone','Email','Insurance Provider'),null,null);if (emptylabels.length>0) {
//alert('Please enter value(s) for: ' + emptylabels);
//return false;
}
} catch(err) {
  alert('You cannot submit this form due to an unexpected error.'); return false;
}
setWindowChanged(window, false);
if(lastcall == true && form.submitted) form.submitted.value='T';
return true;
}
function checkMachineValid(mach)
{
 if (document.forms[0].elements[mach+'valid'] != null && document.forms[0].elements[mach+'valid'].value=='F') {
 alert('One or more sublists had errors.'); return false;}
 return true;
}
function delete_record(url) {
if (confirm('Are you sure you want to ' + (url == 'void.jsp' ? 'void' : 'delete') + ' this '+'transaction?')) {
document.forms['main_form'].onsubmit=null;document.forms['main_form'].bonsubmitisnull=true
setWindowChanged(window, false);
return true;
}
else return false;
}
function NLEntryForm_querySelectText(fldname, machine, linenum, value) {
if ( isValEmpty( value ) ) return null;
var url = '/app/site/crm/externalleadpage.nl?staticunlayered=T&h=df5f53b86cd30b0c6bd8&compid=328623&formid=14&subsidiary=null';
var id = document.forms['main_form'].elements['id'].value;
if ( !isValEmpty( id ) && id != -1 ) url = addParamToURL( url, 'id', id ); 
url = addParamToURL( url, 'q', fldname ); 
url = addParamToURL( url, 'si', value ); 
if ( machine == null && nlapiGetField(fldname).getParent() != null ) { var parent = nlapiGetField(fldname).getParent(); url = addParamToURL(url, 'si_'+parent.getName(), nlapiGetFieldValue(parent.getName())); }
else if ( machine != null && nlapiGetLineItemField(machine, fldname,linenum).getParent() != null ) { var parent = nlapiGetLineItemField(machine, fldname,linenum).getParent(); url = addParamToURL(url, 'si_'+parent.getName(), parent.getSubList() != null ? nlapiGetCurrentLineItemValue(machine, parent.getName()) : nlapiGetFieldValue(parent.getName())); }
url = addParamToURL( url, 'lookuplabel', 'T' ); 
if ( !isValEmpty( machine ) ) url = addParamToURL( url, 'machine', machine ); 
var response = new NLXMLHttpRequest().requestURL( url ).getBody();
eval( response.replace(/^\s*<!--[\s\S]*?-->\s*$/gm, '') );
return selectmap;
}
function NLEntryForm_querySelectValue(fldname, machine, text) {
if ( isValEmpty( text ) ) return null;
var url = '/app/site/crm/externalleadpage.nl?staticunlayered=T&h=df5f53b86cd30b0c6bd8&compid=328623&formid=14&subsidiary=null';
var id = document.forms['main_form'].elements['id'].value;
if ( !isValEmpty( id ) && id != -1 ) url = addParamToURL( url, 'id', id ); 
url = addParamToURL( url, 'q', fldname ); 
url = addParamToURL( url, 'st', escape( text ) ); 
if ( machine == null && nlapiGetField(fldname).getParent() != null ) { var parent = nlapiGetField(fldname).getParent(); url = addParamToURL(url, 'si_'+parent.getName(), nlapiGetFieldValue(parent.getName())); }
else if ( machine != null && nlapiGetLineItemField(machine, fldname).getParent() != null ) { var parent = nlapiGetLineItemField(machine, fldname).getParent(); url = addParamToURL(url, 'si_'+parent.getName(), parent.getSubList() != null ? nlapiGetCurrentLineItemValue(machine, parent.getName()) : nlapiGetFieldValue(parent.getName())); }
url = addParamToURL( url, 'resolvelabel', 'T' ); 
if ( !isValEmpty( machine ) ) url = addParamToURL( url, 'machine', machine ); 
var response = new NLXMLHttpRequest().requestURL( url ).getBody();
eval( response.replace(/^\s*<!--[\s\S]*?-->\s*$/gm, '') );
return selectmap;
}
function Syncstate(fieldspec, linenum, onlySlaveSelect, mach, addlparams)
{
}
function Liststate(fld, multi,addlparams) {
var displayField = document.forms['main_form'].elements['state'];if ( displayField != null && !displayField.isvalid) {    displayField.isvalid = true;    window.isvalid = true;    displayField.value = '';}NLPopupSelect_displayLoadingDiv('state', false);var serverUrl = '/app/site/crm/externalleadpage.nl?staticunlayered=T&h=df5f53b86cd30b0c6bd8&compid=328623&formid=14&subsidiary=null&q=state&l=T&t=main:state'+(multi ? '&multi=T' : '')+''+(addlparams?'&'+addlparams:'')+'';
document.getElementById('server_commands').src=serverUrl; }

function Synccustentity_where_heard(fieldspec, linenum, onlySlaveSelect, mach, addlparams)
{
}
function Listcustentity_where_heard(fld, multi,addlparams) {
var displayField = document.forms['main_form'].elements['custentity_where_heard'];if ( displayField != null && !displayField.isvalid) {    displayField.isvalid = true;    window.isvalid = true;    displayField.value = '';}NLPopupSelect_displayLoadingDiv('custentity_where_heard', false);var serverUrl = '/app/site/crm/externalleadpage.nl?staticunlayered=T&h=df5f53b86cd30b0c6bd8&compid=328623&formid=14&subsidiary=null&q=custentity_where_heard&l=T&t=main:custentity_where_heard'+(multi ? '&multi=T' : '')+''+(addlparams?'&'+addlparams:'')+'';
document.getElementById('server_commands').src=serverUrl; }

var ftabs = new Array();
var ftypes = new Array();
var fparents = new Array();
ftypes['custentity_due_date']='date';
ftabs['custentity_due_date']='main';
ftypes['companyname']='text';
ftabs['companyname']='main';
ftypes['address1']='text';
ftabs['address1']='main';
ftypes['address2']='text';
ftabs['address2']='main';
ftypes['city']='text';
ftabs['city']='main';
ftypes['state']='select';
ftabs['state']='main';
ftypes['zipcode']='text';
ftabs['zipcode']='main';
ftypes['phone']='phone';
ftabs['phone']='main';
ftypes['custentity_evening_phone']='phone';
ftabs['custentity_evening_phone']='main';
ftypes['email']='email';
ftabs['email']='main';
ftypes['comments']='textarea';
ftabs['comments']='main';
ftypes['custentity_promo_code_website_form']='text';
ftabs['custentity_promo_code_website_form']='main';
ftypes['custentity179']='select';
ftabs['custentity179']='main';
ftypes['custentity_where_heard']='select';
ftypes['custentity_time_created']='date';
ftypes['taxable']='checkbox';
var fscriptIds = new Array();
var fDeployIds = new Object();
var fBundleIds = new Object();
window.nsDefaultContextObj={"user":"-4","environment":"PRODUCTION","rolecenter":"CUSTOMER","company":"328623","version":"2009.2","department":"0","contact":"0","context":"userinterface","role":"31","email":"onlineformuser@328623.com","roleid":"online_form_user","location":"0","subsidiary":"1","name":"-System-"};
function checkemailaccess(id) {
document.getElementById('server_commands').src='/app/common/entity/checkemailaccess.nl?compid=328623&id='+id+'&email='+document.forms['main_form'].elements['email'].value;
}
function addShortcut() {
nlOpenWindow('/core/pages/addShortcut.nl?label='+escape('Request for Information')+'&taskid=null&params=h%3Ddf5f53b86cd30b0c6bd8%26compid%3D328623%26formid%3D14%26subsidiary%3Dnull','addshortcut','scrollbars=no,width=400,height=150');
}
function localEval(s) {
return eval(s);
}
function page_init3() {
document.forms['main_form'].elements['whence'].value = '/app/site/crm/externalleadpage.nl?compid=328623&formid=14&h=df5f53b86cd30b0c6bd8';
document.forms['main_form'].elements['whence'].defaultValue='/app/site/crm/externalleadpage.nl?compid=328623&formid=14&h=df5f53b86cd30b0c6bd8';
}


var vismachs = new Array();
var allmachs = new Array();
allmachs['main']='';
function page_init2() {
}
function page_init4() {
if (window.clickCount == 0)
{
if ( isFocusable( document.forms['main_form'].elements['custentity_due_date'] ) ) { document.forms['main_form'].elements['custentity_due_date'].focus();}
}
}


