function upddstlist( iTerritoryID) { var myForm = document.frm_operatorMgmt; myForm.Distrib1.selectedIndex=0; myForm.Distrib1.options.length=1; myForm.Distrib1.options[0].text='Updating List Please Wait....'; var oScriptParent = document.body; var ajaxScriptElement = document.getElementById( "ajaxScriptElement" ); if( ajaxScriptElement != null ) { oScriptParent = ajaxScriptElement.parentNode; oScriptParent.removeChild( ajaxScriptElement ); } ajaxScriptElement = document.createElement( "script" ); ajaxScriptElement.type="text/javascript"; ajaxScriptElement.src="utilities/utl_updatedstlist.cfm?dataOnly=true&territoryid="+iTerritoryID; oScriptParent.appendChild( ajaxScriptElement ); }; function walkTree( oRoot, fnCallback, iContactSpots ) { if( oRoot && oRoot.nodeType == 1 && fnCallback ) { fnCallback( oRoot, iContactSpots ); } if( oRoot && oRoot.hasChildNodes() ) { var oChild = oRoot.firstChild; while( oChild ) { walkTree( oChild, fnCallback, iContactSpots ); oChild = oChild.nextSibling; } } }; function patchNames( oElement, iContactSpots ) { var bField = false; if( oElement.tagName == "INPUT" ) { bField = true; } else if ( oElement.tagName == "SELECT" ) { bField = true; } if( bField ) { // names var sBaseName = oElement.name; var sNewName = sBaseName + iContactSpots; oElement.name = sNewName; // reset values oElement.value = ""; // patch fse attributes var sLabelId = oElement.getAttribute( "fse:labelelementid" ); if( sLabelId ) { var reBaseId = /(^.*)(_label$)/; var aParts = sLabelId.match( reBaseId ); if( aParts ) { var sNewName = aParts[1] + iContactSpots; sLabelId = sLabelId.replace( new RegExp( aParts[1] ), sNewName ); oElement.setAttribute( "fse:labelelementid", sLabelId ); } } } else { var sBaseId = oElement.id; if( sBaseId ) { var reBaseId = /(^.*)(_label$)/; var aParts = sBaseId.match( reBaseId ); if( aParts ) { var sNewId = aParts[1] + iContactSpots; sBaseId = sBaseId.replace( new RegExp( aParts[1] ), sNewId ); oElement.id = sBaseId; } } } }; function countContactSpots() { var iContactSpots = 1; while( document.getElementById( "contact" + ( iContactSpots + 1 ))) { iContactSpots++; } return iContactSpots; }; function makeRoomForAnotherContact() { var oFirstContact = document.getElementById( "contact" ); if( oFirstContact ) { var iContactSpots = countContactSpots(); var oLastContact = document.getElementById( "contact" + iContactSpots ); if( ! oLastContact ) { oLastContact = oFirstContact; } iContactSpots++; var oNewContact = oFirstContact.cloneNode( true ) oNewContact.id = "contact" + iContactSpots; var oFragment = document.createDocumentFragment(); oFragment.appendChild( oNewContact ); walkTree( oNewContact, patchNames, iContactSpots ); if( oLastContact.nextSibling ) { oLastContact.parentNode.insertBefore( oFragment, oLastContact.nextSibling ); } else { oLastContact.parentNode.appendChild( oFragment ); } } return true; }; function preValidateOperatorForm( oForm ) { var preValidatedFields = new Array(); for( var idx=2; oForm["Salutation"+idx] != undefined; idx++ ) { // if ALL of the fields are empty, the contact isn't required if( oForm["Salutation"+idx].value == "" && oForm["FirstName"+idx].value == "" && oForm["LastName"+idx].value == "" && oForm["Title"+idx].value == "" && oForm["Email"+idx].value == "" ) { preValidatedFields["Salutation"+idx] = true; preValidatedFields["FirstName"+idx] = true; preValidatedFields["LastName"+idx] = true; preValidatedFields["Title"+idx] = true; preValidatedFields["Email"+idx] = true; } } if( oForm["Phone"].value.length == 7) { var sPhone = oForm["Phone"].value; sPhone = sPhone.substring( 0, 3) + "-" + sPhone.substr( 3, 4 ); oForm["Phone"].value = sPhone; } return preValidatedFields; }; /* disabled for now - see forms fse:onpostvalidate="" */ function postValidateOperatorForm( oForm ) { var bSubmit = true; var oHeaders = { "submit_mode" : "check" }; var xhRequest = Fse.Ajax.sendForm( oForm, { headers : oHeaders } ); if( xhRequest ) { if( xhRequest.status == "200" ) { var sMessage = xhRequest.getResponseHeader( "form_message" ); var sStatus = xhRequest.getResponseHeader( "form_status" ); if( sStatus != "OK" ) { var sAlertText = sMessage; /* sAlertText = sAlertText + "\n\t" + xhRequest.getResponseHeader( "match_companyname" ) + "\n\t" + xhRequest.getResponseHeader( "match_address" ) + "\n\t" + xhRequest.getResponseHeader( "match_address2" ) + "\n\t" + xhRequest.getResponseHeader( "match_city" ) + ", " + xhRequest.getResponseHeader( "match_state" ) + " " + xhRequest.getResponseHeader( "match_zipcode" ) + "\n\t" + "(" + xhRequest.getResponseHeader( "match_areacode" ) + ") " + xhRequest.getResponseHeader( "match_phone" ); */ alert( sAlertText ); bSubmit = false; } } else { bSubmit = false; document.documentElement.innerHTML = xhRequest.responseText; } } return bSubmit; }; function showLocalMarketAgent() { var oDetail = document.getElementById( "localMarketAgentDetail" ); if( oDetail ) { oDetail.style.display = ((oDetail.style.display == "none") ? "block" : "none"); } return false; }; function reAssignNow( oForm, sFieldLabel, sField ) { var oHeaders = { "submit_mode" : "re_assign", "re_assign" : sField }; var xhRequest = Fse.Ajax.sendForm( oForm, { headers : oHeaders } ); if( xhRequest ) { if( xhRequest.status != "200" ) { alert( "An error has occurred. " + sFieldLabel + " was not updated at this time. Please use the Save Changes button instead." ); } else { alert( sFieldLabel + " has be updated." ); var refresh = xhRequest.getResponseHeader( "refresh" ); if( refresh == "true" ) { location.reload( true ); } } } };