function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } function setFocus() { var links = document.getElementsByTagName("a"); for(var i=0; i 0) { for (index = 0; index < strLen; index++) { if (index == 0) { tmpChar = tmpStr.substring(0,1).toUpperCase(); postString = tmpStr.substring(1,strLen); tmpStr = tmpChar + postString; } else { tmpChar = tmpStr.substring(index, index+1); if (tmpChar == " " && index < (strLen-1)) { tmpChar = tmpStr.substring(index+1, index+2).toUpperCase(); preString = tmpStr.substring(0, index+1); postString = tmpStr.substring(index+2,strLen); tmpStr = preString + tmpChar + postString; } } } } return tmpStr; } /* Form Handling */ function showArea(aobj){ if($(aobj).style.display == "none"){ new Effect.toggle($(aobj)); $('ctoggle').src = "/_images/hide.png"; $('toggletext').update("Hide"); } else { new Effect.toggle($(aobj)); $('ctoggle').src = "/_images/reveal.png"; $('toggletext').update("Show"); } }// end Contact us function checkForm(fobj,fid,reqfields) { if(vForm(fobj,fid,reqfields)){ fobj.submit(); } } /* FAQ FUNCTIONS */ function getFAQ(faqcatid,faqkeyword) { //return; //alert(faqkeyword); var sPath = window.location.pathname; var sPage = sPath.substring(sPath.lastIndexOf('/') + 1); //alert(sPage); //return; if(sPage != "faqs") { if(faqkeyword){ window.location.href = "/pages/faqs?faqcatid="+faqcatid+"&faqkeyword="+faqkeyword; } else{ window.location.href = "/pages/faqs?faqcatid="+faqcatid; } } else { $('faqcon').update('
'); // ajax for faqs because we are on the faq page and we have a category id new Ajax.Request('/_ajax/getfaqs.php', { method:'post', parameters: {catid: faqcatid, faqkw: faqkeyword}, onSuccess: function(transport){ var response = transport.responseText || "no response text"; $('faqcon').update(response); Shadowbox.setup(); }, onFailure: function(){ alert('communication failure...') } }); } } // end get faq /* E911 FUNCTIONS */ function get911Form(aid,eid,carea) { // if eid, populate with selected e911 info new Ajax.Request('/_ajax/e911form.php', { method:'post', parameters:{account_id:aid,e911_id:eid,content_area:carea}, onSuccess: function(transport){ var response = transport.responseText || "no response text"; if(response == "no response text") { // do stuff like log error alert("Error! \nPlease contact support."); } else { if(eid) { if(document.getElementById(carea+'_crow')){ Effect.Fade($(carea+'_crow')); $(carea+'_crow').remove(); } else { // insert a row after carea row and update that content with form $(carea).insert({after:''+response+''}); Effect.Appear($(carea+'_crow')); } } else { if($(carea).style.display == "none"){ $(carea).update(response); Effect.Appear($(carea)); } else { Effect.Fade($(carea)); $(carea).update(""); } } } }, onFailure: function(){ alert('Communication Error...') } }); } // end add 911 form function updateE911Address(formobj,formid,aid,eid,carea) { if(vForm(formobj,formid,formobj.required_fields.value)) { new Ajax.Request('/_ajax/updatee911.php', { method:'post', parameters: $(formobj.id).serialize(true), onSuccess: function(transport){ var response = transport.responseText || "no response text"; if(response == "no response text") { // do stuff like log error alert("Error! \nPlease contact support."); } else { alert(response); // reload e911 addresses if(!response.match("Error")) { setAccount(aid,'get911.php','e911program'); } } }, onFailure: function(){ alert('Communication Error...') } }); } // end if validation } // end update 911 address function cNum(num) { if(isNaN(num)) { return false; } else { return true; } } /* PRIMARY / SHIPPING/ BILLING ADDRESSES */ function setState(country,section,divid,statevalue) { //alert(section); //return; if(country.toUpperCase() == "US") { getUSstates(section,divid,statevalue); } else if(country.toUpperCase() == "CA") { getCANprovinces(section,divid,statevalue); } else { getINTLstate(section,divid,statevalue); } } // end set states function getUSstates(section,divid,statevalue) { //alert(section+" "+divid+" "+statevalue); $(divid).update('
'); new Ajax.Request('/_ajax/getusstates.php', { method:'post', parameters:{section_name: section,svalue: statevalue}, onSuccess: function(transport){ var response = transport.responseText || "no response text"; $(divid).update(response); if(divid == "pstate") { $(divid+"_label").update('*State:'); } else if(divid == "bstate") { $(divid+"_label").update('*Billing State:'); } else if(divid == "sstate") { $(divid+"_label").update('*Shipping State:'); } // add state as required var current_req = $('myprofile').required_fields.value; if(!current_req.match(section+";")) { var new_req = section+";" + current_req; $('myprofile').required_fields.value = new_req; } // add county as required if section is primary if(section == "primary_state") { $('pcounty_label').update('*County/Parish:'); var current_req = $('myprofile').required_fields.value; if(!current_req.match("primary_county;")) { var new_req = "primary_county;" + current_req; $('myprofile').required_fields.value = new_req; } } }, onFailure: function(){ alert('Communication Error...') } }); } // end get us states function getCANprovinces(section,divid,statevalue) { $(divid).update('
'); new Ajax.Request('/_ajax/getcanprovinces.php', { method:'post', parameters:{section_name: section,svalue: statevalue}, onSuccess: function(transport){ var response = transport.responseText || "no response text"; $(divid).update(response); if(divid == "pstate") { $(divid+"_label").update('*Province:'); } else if(divid == "bstate") { $(divid+"_label").update('*Billing Province:'); } else if(divid == "sstate") { $(divid+"_label").update('*Shipping Province:'); } // add provinces as required var current_req = $('myprofile').required_fields.value; if(!current_req.match(section+";")) { var new_req = section+";" + current_req; $('myprofile').required_fields.value = new_req; } // remove county from required if section is primary if(section == "primary_state") { $('pcounty_label').update('County/Parish:'); var current_req = $('myprofile').required_fields.value; var new_req = current_req.replace("primary_county;",""); $('myprofile').required_fields.value = new_req; } }, onFailure: function(){ alert('Communication Error...') } }); } // end get canadian provinces function getINTLstate(section,divid,statevalue) { $(divid).update('
'); new Ajax.Request('/_ajax/getintlstate.php', { method:'post', parameters:{section_name: section,svalue: statevalue}, onSuccess: function(transport){ var response = transport.responseText || "no response text"; $(divid).update(response); if(divid == "pstate") { $(divid+"_label").update('State/Region:'); } else if(divid == "bstate") { $(divid+"_label").update('Billing State/Region:'); } else if(divid == "sstate") { $(divid+"_label").update('Shipping State/Region:'); } // remove state as required var current_req = $('myprofile').required_fields.value; var new_req = current_req.replace(section+";",""); $('myprofile').required_fields.value = new_req; // remove county as required if section is primary if(section == "primary_state") { $('pcounty_label').update('County/Parish:'); var current_req = $('myprofile').required_fields.value; var new_req = current_req.replace("primary_county;",""); $('myprofile').required_fields.value = new_req; } }, onFailure: function(){ alert('Communication Error...') } }); } // end get canadian provinces function toggleAddr(targetdiv,conimg,contxt,mastertxt){ if(document.getElementById(targetdiv)){ if($(targetdiv).style.display == "none"){ // reveal $(conimg).src = "/_images/hide.png"; $(contxt).update('Hide '+mastertxt+' Info'); Effect.Appear($(targetdiv)); } else { // hide $(conimg).src = "/_images/reveal.png"; $(contxt).update('Show '+mastertxt+' Info'); Effect.Fade($(targetdiv)); } } } // end toggle div function setCustAddr(trigger) { if($("myprofile")[trigger].checked == true){ //alert($("myprofile").primary_country.options[$("myprofile").primary_country.options.selectedIndex].value); //alert($("myprofile").billing_country.length); $("myprofile").billing_first_name.value = $("myprofile").first_name.value; $("myprofile").billing_last_name.value = $("myprofile").last_name.value; $("myprofile").billing_phone.value = $("myprofile").primary_phone.value; $("myprofile").billing_address1.value = $("myprofile").primary_address1.value; $("myprofile").billing_address2.value = $("myprofile").primary_address2.value; $("myprofile").billing_city.value = $("myprofile").primary_city.value; $("myprofile").billing_postal.value = $("myprofile").primary_postal.value; for(var x=0; x < $("myprofile").billing_country.length; x++) { if($("myprofile").billing_country.options[x].value == $("myprofile").primary_country.options[$("myprofile").primary_country.options.selectedIndex].value) { $("myprofile").billing_country.options[x].selected = true; $("myprofile").shipping_country.options[x].selected = true; break; } } //end set billing country var c = $("myprofile").primary_country.options[$("myprofile").primary_country.options.selectedIndex].value; var s = ''; if(c.toUpperCase == "US" || c.toUpperCase == "CA") { // get state from primary state dropdown for(var x=0; x < $("myprofile").primary_state.length; x++) { s = $("myprofile").primary_state.options[$("myprofile").primary_state.options.selectedIndex].value; } } else { // get state from primary intl state text box s = $("myprofile").primary_state.value; } //alert(s); setState(c,'billing_state','bstate',s); // end set billing state $("myprofile").shipping_first_name.value = $("myprofile").first_name.value; $("myprofile").shipping_last_name.value = $("myprofile").last_name.value; $("myprofile").shipping_phone.value = $("myprofile").primary_phone.value; $("myprofile").shipping_address1.value = $("myprofile").primary_address1.value; $("myprofile").shipping_address2.value = $("myprofile").primary_address2.value; $("myprofile").shipping_city.value = $("myprofile").primary_city.value; $("myprofile").shipping_postal.value = $("myprofile").primary_postal.value; setState(c,'shipping_state','sstate',s); return true; } } // end customer address //Plans - tab function // function changeTab(masterid,masternavid,tabid,ajaxfile,varstr) { //alert(varstr); //return; var thelis = $$('#'+masternavid+' li'); for(var i=0;i"); } new Ajax.Request('/_ajax/'+ajaxfile, { method:'post', parameters:varstr, onSuccess: function(transport){ //alert("ajax received response"); var response = transport.responseText || "no response text"; $('content'+masterid).update(response); //var tforms = $$('#content'+masterid+' form'); //alert(masterid); //pmanager(tforms); }, onFailure: function(){ alert('Communication Error...');$('content'+masterid).update(''); } }); }// end set tab content //////toggle divs/////// function showMorePlan(divid, imgid){ if($(divid).style.display == "none"){ //alert($(divid)); new Effect.toggle($(divid)); $(imgid).src = "/_images/collapse.png"; } else { new Effect.toggle($(divid)); $(imgid).src = "/_images/expand.png"; } }// end showMorePlan /* Contact us*/ function checkContact(fobj,fid,reqfields) { if(vForm(fobj,fid,reqfields)){ fobj.submit(); } } //////search rates/////// function searchRates(formobj) { if($(formobj.id).snumber.value == "" && $(formobj.id).scountry.selectedIndex < 1) { alert("You must enter a number or select a country."); $(formobj.id).snumber.focus(); return; } if($(formobj.id).snumber.value) { if(isNaN($(formobj.id).snumber.value)) { alert("Please enter a phone number beginning with 1 or 011, no spaces or special characters, ie 12345678901 or 0112345678901"); $(formobj.id).snumber.value = ""; $(formobj.id).snumber.focus(); return; } } new Ajax.Request('/_ajax/getrates.php', { method:'post', parameters: $(formobj.id).serialize(true), onSuccess: function(transport){ var response = transport.responseText || "no response"; $("rresult").update(response); }, onFailure: function(){ alert('Communication Error...') } }); } function openTermsWindow(file){ var pwindow = window.open(file,"twindow","location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width=650,height=700"); pwindow.moveTo(20,20); } function requestNotification(formobj,formid, required_fields) { if(vForm(formobj,formid,required_fields)) { $(formid).insert({before:'
'}); new Ajax.Request('/_ajax/ajaxupdater.php', { method:'post', parameters: $(formid).serialize(true), onSuccess: function(transport){ //var response = transport.responseText || "no response"; //alert(response); //return; var response = transport.responseXML.documentElement; var tstatus = response.getElementsByTagName("status")[0].firstChild.data; var tmessage = response.getElementsByTagName("message")[0].firstChild.data; if(tstatus.toUpperCase() == "SUCCESS") { alert("Your request has been received."); $('mailspinner').update(""); $(formid).email.value = ""; } else { alert(tstatus + ": "+tmessage); } }, onFailure: function(){ alert('Communication Error...') } }); } // end if validation } // end requestNotification function showExplain(myid,myvalue,mydiv,myfocus){ if(myvalue == 'Other' && $(mydiv).style.display == "none"){ $(mydiv).style.display = "block"; $(myfocus).focus(); } else{ $(mydiv).style.display = "none"; $(myfocus).value = ""; } } function checkPromo(fobj,fid) { if($(fid).first_name.value == "First Name" || $(fid).last_name.value == "Last Name" || $(fid).email.value == "Email" || $(fid).mobile_number.value == "Mobile Number") { alert("Please provide your sign up information"); return; } if(vForm(fobj,fid,$(fid).required_fields.value)) { var params = $(fid).serialize(true); $('promospinner').update('

Provisioning your account.
Please stand by.
'); // call ajax updater new Ajax.Request('/_ajax/ajaxupdater.php', { method:'post', parameters: params, onSuccess: function(transport) { //var response = transport.responseText || "no response text"; //alert(response); //return; var response = transport.responseXML.documentElement; var pstatus = response.getElementsByTagName("status")[0].firstChild.data; var pmessage = response.getElementsByTagName("message")[0].firstChild.data; if(pstatus == "SUCCESS") { $('promospinner').update('
Your MyGlobalTalk™ account has been created. Please consult your welcome email for information about using your account.

Thank You for trying MyGlobalTalk™
'); } else { $('promospinner').update('
The following error was encountered while creating your account:
'+pmessage+'
Please contact support.
'); } }, onFailure: function() { alert('Communication Error...'); $('promospinner').update('
Please contact support.
'); } }); } // end validation } // end promo provisioner function changeSnumber() { $("rsearch").snumber.value = ""; return; } function showCopy(objid,btnobj) { var plans = new Array('mgtcopy','i2ucopy','n2ncopy','unlcopy'); var btns = new Array('mgtbtn','i2ubtn','n2nbtn','unlbtn'); for(x=0;x < plans.length;x++) { if(plans[x] == objid) { continue; } else { $(plans[x]).style.display = "none"; $(btns[x]).value = "Learn More"; } } if($(objid).style.display == "none") { new Effect.Appear($(objid),{duration:1.0,from:0.0,to:.9}); $(btnobj).value = "Hide Info"; } else { new Effect.Fade($(objid),{duration:1.0,from:0.9,to:.0}); $(btnobj).value = "Learn More"; } } function goTo(page) { document.location = page; }