//String.prototype.trim = function() { // var x=this; // x=x.replace(/^\s*(.*)/, "$1"); // x=x.replace(/(.*?)\s*$/, "$1"); // return x; //} function swapSelects(flag) { var selects = dw_main.document.getElementsByTagName("select"); for (var i = 0; i < selects.length; i++) { if (flag==1) { //selects[i].style.visibility = (flag) ? "visible" : "hidden"; selects[i].style.visibility = "hidden"; } else { selects[i].style.visibility = "visible"; } } } function opencalx(mypage,width,height) { var tmp; limit = 5000; today = new Date(); num = today.getTime(); num = Math.round(Math.abs(Math.sin(num) * 1000000)) % limit; if (!width) { width = 440; } if (!height) { height = 320; } var winl = (screen.width - width) / 2; var wint = (screen.height - height) / 2; tmp = window.open(mypage,'newwindow'+num,'width='+width+',height='+height+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,left='+winl+',top='+wint); } function FormatData(str) { var tstr; var xstr; //tstr = str.value.toLowerCase().trim(); tstr = str.value.toLowerCase(); xstr = tstr.substring(0,1).toUpperCase(); nextUp = 0; for (k=1; k < tstr.length; k++) { xchar = tstr.substring(k,(k+1)); if (nextUp==1) { xstr = xstr + xchar.toUpperCase(); nextUp = 0; } else { xstr = xstr + xchar; } if (xchar==' ') { nextUp = 1; } } str.value=xstr; } function AllUpper(str) { var tstr; var xstr; tstr = str.value.toUpperCase(); str.value=tstr; } var slugdisplay=''; function toggleslug(slugid) { eval('slugdisplay = document.all.slg_'+slugid+'.style.display'); if (slugdisplay=='none') { eval('document.all.slg_'+slugid+'.style.display = \'\''); document.images['slg'+slugid].src = '/images/slug.up.gif'; } else { eval('document.all.slg_'+slugid+'.style.display = "none"'); document.images['slg'+slugid].src = '/images/slug.down.gif'; } } function showtab(slugid) { eval('document.all.slg_'+slugid+'.style.display = \'\''); } function cancelOrder(type) { // this cancels an order from the main page.. xx = confirm('Proceeding will cancel the order and purge your data. Click OK to continue.'); if (xx) { document.OrderEntry.STAT.value = "2"; document.OrderEntry.submit(); } } function validateOrder(type) { var mt; var passed; mt = document.OrderEntry.marketType.value; // this function validates the entire order.. // passed = false; if (type==1) { // this is a proposal.. document.OrderEntry.STAT.value = "1"; } if (type==3) { // this is a submitted residential order.. document.OrderEntry.STAT.value = "3"; } if (type==4) { // this is a submitted commercial order.. document.OrderEntry.STAT.value = "4"; } if (type==6) { // this is order edit... document.OrderEntry.STAT.value = "6"; } if (type==9) { // this is a credit resubmit.. document.OrderEntry.STAT.value = "9"; } stripAlpha(document.OrderEntry.PrimaryPhoneNumber); stripAlpha(document.OrderEntry.Zip); stripAlpha(document.OrderEntry.Zip4); stripAlpha(document.OrderEntry.BillZip); stripAlpha(document.OrderEntry.BillZip4); stripAlpha(document.OrderEntry.ReferralPhone); if (document.OrderEntry.ppn.value == "-1") { } else { document.OrderEntry.ppn.value = document.OrderEntry.PrimaryPhoneNumber.value; } if (mt==1) { // these are the residential rules.. if (!document.OrderEntry.FirstName.value) { alert('First Name is a required field.'); } else if (!document.OrderEntry.LastName.value) { alert('Last Name is a required field.'); } else if (!document.OrderEntry.AddressNumber.value) { alert('Street Number is a required field.'); } else if (!document.OrderEntry.addressstreetname.value) { alert('Street Name is a required field.'); } else if (!document.OrderEntry.City.value) { alert('City is a required field.'); } else if (!document.OrderEntry.State.value) { alert('State is a required field.'); } else if (!document.OrderEntry.Zip.value) { alert('Zip is a required field.'); } //else if (!document.OrderEntry.SSN.value) { alert('SSN is a required field.'); } else if (!document.OrderEntry.billFirstName.value) { alert('Billing First Name is a required field.'); } else if (!document.OrderEntry.billLastName.value) { alert('Billing Last Name is a required field.'); } //else if (!document.OrderEntry.billaddressnumber.value) { alert('Billing Street Number is a required field.'); } else if (!document.OrderEntry.billaddressstreetname.value) { alert('Billing Street Name is a required field.'); } else if (!document.OrderEntry.BillCity.value) { alert('Billing City is a required field.'); } else if (!document.OrderEntry.BillState.value) { alert('Billing State is a required field.'); } else if (!document.OrderEntry.BillZip.value) { alert('Billing Zip is a required field.'); } else if (!document.OrderEntry.dyno_contactphone.value) { alert('Contact Phone is a required field.'); } else if (!document.OrderEntry.dyno_timetocall.value) { alert('Time to Call is a required field.'); } else if (document.OrderEntry.HowHeard.selectedIndex<1) { alert('How Heard is a required field.'); } //else if (document.OrderEntry.company.selectedIndex<1) { alert('Company is a required field.'); } //else if (document.OrderEntry.aggregator.selectedIndex<1) { alert('Aggregator is a required field.'); } else { passed = true; } // warn about the ssn.. if (!document.OrderEntry.SSN.value) { kk = confirm('Even though SSN is not a required field, it is HIGHLY recommended. Click OK to continue processing order without SSN.'); if (kk) { if (passed==true) { passed = true; } } else { passed = false; } } } else if (mt==2) { // these are the commercial rules.. if (!document.OrderEntry.FirstName.value) { alert('First Name is a required field.'); } else if (!document.OrderEntry.CompanyName.value) { alert('Company Name is a required field.'); } else if (!document.OrderEntry.BillCompany.value) { alert('Billing Company Name is a required field.'); } else if (!document.OrderEntry.LastName.value) { alert('Last Name is a required field.'); } else if (!document.OrderEntry.AddressNumber.value) { alert('Street Number is a required field.'); } else if (!document.OrderEntry.addressstreetname.value) { alert('Street Name is a required field.'); } else if (!document.OrderEntry.City.value) { alert('City is a required field.'); } else if (!document.OrderEntry.State.value) { alert('State is a required field.'); } else if (!document.OrderEntry.Zip.value) { alert('Zip is a required field.'); } else if (!document.OrderEntry.dyno_estldusage.value) { alert('Estimated LD Usage is a required field.'); } else if (!document.OrderEntry.dyno_contactphone.value) { alert('Contact Phone is a required field.'); } else if (!document.OrderEntry.dyno_timetocall.value) { alert('Time to Call is a required field.'); } else if (!document.OrderEntry.dyno_sigdate.value) { // we could need to stop ourselves.. if (type==1) { // we can go on.. passed = true; } else { alert('Signature Date is a required field.'); } } else if (document.OrderEntry.HowHeard.selectedIndex<1) { alert('How Heard is a required field.'); } //else if (document.OrderEntry.company.selectedIndex<1) { alert('Company is a required field.'); } //else if (document.OrderEntry.aggregator.selectedIndex<1) { alert('Aggregator is a required field.'); } else { passed = true; } } // now check the billing options; make sure we are good on these.. if (document.OrderEntry.BillingOption[1].checked) { // we are e-bill.. need to make sure we have selected an email address.. if (!document.OrderEntry.BillingEmail.value) { alert('You must enter an email address to use E-Bill.'); passed = false; } } // now check the payment options.. if (document.OrderEntry.PaymentOption[1].checked) { // checking account.. we need to collect these fields. stripAlpha(document.OrderEntry.CheckingAccountNumber); stripAlpha(document.OrderEntry.CheckingRoutingNumber); } if (document.OrderEntry.PaymentOption[2].checked) { // credit card.. need to verify we have the info we need.. if (!document.OrderEntry.PaymentCCardNumber.value) { alert('You must enter the Credit Card Number.'); passed = false; } if (!document.OrderEntry.PaymentExpDate.value) { alert('You must enter the Expiration Date.'); passed = false; } if (!document.OrderEntry.PaymentCardName.value) { alert('You must enter the Name on Card.'); passed = false; } } // now check the at-residency field.. if (document.OrderEntry.dyno_atres[0].checked) { //passed = true; } else if (document.OrderEntry.dyno_atres[1].checked) { //passed = true; } else if (document.OrderEntry.dyno_atres[2].checked) { //passed = true; } else { passed = false; alert('\'At Residence\' is a required field.'); } if (passed==true) { //alert('submit!'); document.OrderEntry.submit(); } } function revieworder(xstart,xend) { // fist, check if our order even has SON/ON/CN if (!document.OrderEntry.SON.value) { alert('You must add lines to your order before submitting.'); } else { // this function opens all the tabs, and adds its 'submit' to the top for (c=xstart; c <= 7; c++) { z = 'slg_' + c; y = 'tab_' + c; if (document.all[y]) { document.all[y].className = 'tabOffFill'; } if (document.all[z]) { document.all[z].style.display = "none"; } } for (c=xstart; c <= 7; c++) { z = 'slg_' + c; y = 'tab_' + c; if (document.all[y]) { document.all[y].className = 'tabOffFill'; } if (document.all[z]) { document.all[z].style.display = ""; } } document.all.tab_6.className = 'tabOnFill'; document.all.slg_6.style.display = ""; document.all.slg_5.style.display = "none"; document.all.slg_4.style.display = "none"; } } function toggletab(slugid,xstart,xend) { eval('slugdisplay = document.all.slg_'+slugid+'.style.display'); // hide all the others first.. for (c=xstart; c <= xend; c++) { z = 'slg_' + c; y = 'tab_' + c; if (document.all[y]) { document.all[y].className = 'tabOffFill'; } document.all[z].style.display = "none"; } if (slugdisplay=='none') { eval('document.all.slg_'+slugid+'.style.display = \'\''); x = 'tab_'+slugid; document.all[x].className = 'tabOnFill'; } eval('document.all.slg_'+slugid+'.style.display = \'\''); x = 'tab_'+slugid; document.all[x].className = 'tabOnFill'; } function openwin(mypage,width,height) { var tmp; limit = 5000; today = new Date(); num = today.getTime(); num = Math.round(Math.abs(Math.sin(num) * 1000000)) % limit; if (!width) { width = 440; } if (!height) { height = 320; } var winl = (screen.width - width) / 2; var wint = (screen.height - height) / 2; tmp = window.open(mypage,'newwindow'+num,'width='+width+',height='+height+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,left='+winl+',top='+wint); } function OPprint(oid,sid) { var tmp; var myname; var mypage; var w; var h; myname = 'op'; mypage = '/orders/detail_local_op.asp?oid=' + oid + '&sid=' + sid; limit = 5000; today = new Date(); num = today.getTime(); num = Math.round(Math.abs(Math.sin(num) * 1000000)) % limit; if (!w) { w = 400; } if (!h) { h = 0; } var winl = 1; var wint = 1; tmp = window.open(mypage,myname+num,'width='+w+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,left='+winl+',top='+wint); } function openwinX(mypage,myname,w,h) { var tmp; limit = 5000; today = new Date(); num = today.getTime(); num = Math.round(Math.abs(Math.sin(num) * 1000000)) % limit; if (!w) { w = 440; } if (!h) { h = 320; } var winl = (screen.width - w) / 2; var wint = (screen.height - h) / 2; tmp = window.open(mypage,myname+num,'width='+w+',height='+h+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,left='+winl+',top='+wint); } function openwinY(mypage,myname,w,h) { var tmp; if (!w) { w = 440; } if (!h) { h = 320; } var winl = (screen.width - w) / 2; var wint = (screen.height - h) / 2; tmp = window.open(mypage,myname,'width='+w+',height='+h+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,left='+winl+',top='+wint); } function radio_button_checker(form,field) { // set var radio_choice to false var radio_choice = false; // Loop from zero to the one minus the number of radio button selections for (counter = 0; counter < eval("document."+form+"."+field+".length"); counter++) { // If a radio button has been selected it will return true // (If not it will return false) if (eval("document."+form+"."+field+"[counter].checked")) { radio_choice = true; } } //alert('xx'); if (!radio_choice) { // If there were no selections made display an alert box return (false); } else { return true; } } function chkNAN(char2chk) { var validNum = "0123456789"; if (validNum.indexOf(char2chk) == "-1") { stripLast = true; return(0); } } var stripLast; var lastCount; var lastCountDate; stripLast = false; lastCount = 0; lastCountDate = 0; function maskIt(fld) { var isNamedFone; fldVal = fld.value; var tmpStr = ""; keyCount = fldVal.length; keyEntered =fldVal.substring(keyCount-1,keyCount); if (keyCount < 2) isNamedFone = false; if (!isNamedFone) isNamedFone = chkNAN(keyEntered); keyCount++; with (document.OrderEntry) { switch (keyCount) { case 2: tmpStr += fldVal; fld.value = tmpStr; break; case 4: fld.value += "-"; break; case 8: fld.value += "-"; break; } } if (stripLast) { // we want to strip the last character if the character is not a valid int, OR // it could be a - if if ( ((fld.value.substring(fld.value.length-1,fld.value.length)=="-")&&(fld.value.length==keyCount-1)&&(lastCount>keyCount)) ) { } else { fld.value = fld.value.substring(0,fld.value.length-1); } stripLast = false; } lastCount = fld.value.length; } function maskDate(fld) { var isNamedFone; fldVal = fld.value; var tmpStr = ""; keyCount = fldVal.length; keyEntered =fldVal.substring(keyCount-1,keyCount); if (keyCount < 2) isNamedFone = false; if (!isNamedFone) isNamedFone = chkNAN(keyEntered); keyCount++; with (document.OrderEntry) { switch (keyCount) { case 2: tmpStr += fldVal; fld.value = tmpStr; break; case 3: fld.value += "/"; break; case 6: fld.value += "/"; break; } } if (stripLast) { // we want to strip the last character if the character is not a valid int, OR // it could be a - if if ( ((fld.value.substring(fld.value.length-1,fld.value.length)=="/")&&(fld.value.length==keyCount-1)&&(lastCountDate>keyCount)) ) { } else { fld.value = fld.value.substring(0,fld.value.length-1); } stripLast = false; } lastCountDate = fld.value.length; } function GetNumericString(strString) { var strValidChars = "0123456789"; var strChar; var retString = ""; // test strString consists of valid characters listed above for (i = 0; i < strString.length; i++) { strChar = strString.charAt(i); if (strValidChars.indexOf(strChar) != -1) { retString = retString + strChar } //end if } //for return retString; } function checkMyDate(oo) { var _value = oo.value; var _test = Date.parse(_value); if (isNaN(_test)) { oo.value = ""; alert("Not a valid date!"); oo.focus(); } else { return true; } } function parseSSN(ii) { var i; i = GetNumericString(ii.value); ii.value = i; if ((i.length<9)&&(i.length>0)) { alert('The SSN entered is not valid. Please Verify the entry.'); ii.focus(); } if (i.length>9) { alert('The SSN entered is not valid. Please Verify the entry.'); ii.focus(); } } function stripAlpha(ii) { var i; i = GetNumericString(ii.value); ii.value = i; } function parseDOB(ii) { var i; i = ii.value; if (i.length>0) { // validate the date.. if (!validateUSDate(i)) { alert('Invalid Date - '+i+' - Please verify the entry'); ii.focus(); } } } function validateUSPhone( strValue ) { /************************************************ DESCRIPTION: Validates that a string contains valid US phone pattern. Ex. (999) 999-9999 or (999)999-9999 PARAMETERS: strValue - String to be tested for validity RETURNS: True if valid, otherwise false. *************************************************/ var objRegExp = /^d{4}\-\d{3}\-\d{4}$/; //check for valid us phone with or without space between //area code return objRegExp.test(strValue); } function validateUSDate( strValue ) { var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/ if(!objRegExp.test(strValue)) { return false; } else { var strSeparator = strValue.substring(2,3) var arrayDate = strValue.split(strSeparator); var arrayLookup = { '01' : 31,'03' : 31, '04' : 30,'05' : 31,'06' : 30,'07' : 31, '08' : 31,'09' : 30,'10' : 31,'11' : 30,'12' : 31} var intDay = parseInt(arrayDate[1]); //check if month value and day value agree if(arrayLookup[arrayDate[0]] != null) { if(intDay <= arrayLookup[arrayDate[0]] && intDay != 0) return true; //found in lookup table, good date } //check for February var intYear = parseInt(arrayDate[2]); var intMonth = parseInt(arrayDate[0]); if( ((intYear % 4 == 0 && intDay <= 29) || (intYear % 4 != 0 && intDay <=28)) && intDay !=0) return true; //Feb. had valid number of days } return false; } function moveNext(field, digits, nextfield){ if (field.value.length >= digits) { //field.blur(); nextfield.focus(); } } function qualifynumber(x) { var SubmitForm = true; var agreez; var ani; var valid = true; var kk; kk = GetNumericString(x.NPA.value); x.NPA.value = kk; kk = GetNumericString(x.NXX.value); x.NXX.value = kk; kk = GetNumericString(x.NUMB.value); x.NUMB.value = kk; if (x.NPA.value.length < 3) { alert("Fill in NPA.") x.NPA.focus(); SubmitForm = false; } else if (x.NXX.value.length < 3) { alert("Fill in NXX.") x.NXX.focus(); SubmitForm = false; } else { kk = GetNumericString(x.NUMB.value); x.NUMB.value = kk; if (x.NUMB.value.length < 4) { x.NUMB.value = "XXXX"; valid = false; } if (valid==true) { x.submit(); } else { ani = x.NPA.value + "-" + x.NXX.value + "-" + x.NUMB.value; alert('The number you have entered - ' + ani + ' - does not appear to be a valid number.\nPlease verify the number and try again.'); x.NUMB.focus(); SubmitForm = false; } } return SubmitForm; } function qualifyclear(x) { x.NPA.value = ""; x.NXX.value = ""; x.NUMB.value = ""; }