﻿var d='Sorry but your browser does not support the features used by this application.';var A='The server cannot be contacted at this time. Please try again in a few seconds.';var v='An error has occurred processing the request.';var t='The Voucher Code must be 8 characters long.  Please try again.';var D='You have not entered the Sender Name or Number.  Please try again.';var C='You have not entered the recipient\'s mobile number.  Please try again.';var B='You have not entered any text to send in the message.  Please try again.';var r='Hooray! Your PhonyText message has been successfully sent!<br/><br/>All being well with the network, it should be received shortly.';var k='The Voucher Code submitted is invalid, or has previously been redeemed.  The message was NOT sent.';var j='We experienced a problem trying to send your PhonyText message.  Please contact us if the problem persists.\n\nYour Voucher Code is still valid for use if you submitted one.';var g='Sender Names that are AlphaNumeric cannot be any longer than 11 characters.  Please try again.';var o='The maximum length of the Sender Number is 16 characters.  Please try again.';var m='The Recipient Mobile Number is not in the correct format.  It can only contain numbers and should be at least 9 characters long.  Please try again.';var l='Sender Names containing just numbers must be between 5 and 16 characters in length.  Please try again.';var ar='The number entered has already been previously tested. If you did not receive the original test message then please contact our support team for more information.';var T='btnSubmit';var J='imgLoader';var U='txtVoucherCode';var ad='txtSenderID';var Q='txtMSISDN';var G='txtMessage';var ab="mode";function aj(){$(J).hide();alert(v);};function ak(){$(J).hide();alert(A);};function ag(K){var ae='0123456789';var f=true;var c;for(i=0;i<K.length&&f==true;i++){c=K.charAt(i);if(ae.indexOf(c)== -1){f=false;}}return f;};function ap(L){var R=new RegExp('(-?[0-9]+)([0-9]{3})');while(R.test(L)){L=L.replace(R,'$1,$2');}return L;};function ao(as){if(as==null||as.length==0||as.indexOf('.')== -1||as.indexOf('@')== -1||as.indexOf(' ')!= -1){return false;}var rx,_match,user,domain,valid;rx=/(^\w{2,}\.?\w{2,})@/;_match=rx.exec(as);if(_match){user=RegExp.$1;}else{return false;}rx=/@(\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])$/;_match=rx.exec(as);if(_match){domain=RegExp.$1;valid=true;}else{rx=/@(\w{2,}\.(\w{2,}\.)?[a-zA-Z]{2,3})$/;_match=rx.exec(as);if(_match){domain=RegExp.$1;valid=true;}else{valid=false;}}return valid;};document.observe('dom:loaded',an);var frmEl;function an(){Ajax.Responders.register({onCreate:function(){$(J).show();},onComplete:function(){$(J).hide();}});frmEl=document.forms[0].name;document.forms[0].onsubmit=function(){return al();};$(G).onkeydown=ah;$(G).onkeyup=ah;};function al(){var s;var sId;var aq;aq=($F(ab)=='doTest');if(!aq){s=$F(U);if(s==null||s.length!=8){af(t);return false;}sId=$F(ad);if(sId==null||sId.length==0){af(D);return false;}if(ag(sId)){if(sId.length<5){af(l);return false;}if(sId.length>16){af(o);return false;}switch(true){case(sId.substring(0,2)=='00'):sId='+'+sId.substring(2);break;case(sId.substring(0,1)=='0'):sId='+44'+sId.substring(1);break;default:sId='+'+sId;break;}}else{if(sId.length>11){af(g);return false;}}s=$F(G);if(s==null||s.length==0){af(B);return false;}}s=$F(Q);if(am(s)==false){return false;}$(T).disabled=true;if(aq){if($F('cboSource').length==0){af('Please tell us how you heard about us before sending a test message.  Much appreciated!');$(T).disabled=false;return false;}var request=new Ajax.Request('ws/send.aspx',{parameters:'mode=doTest&txtMSISDN='+encodeURIComponent($F(Q))+'&cboSource='+encodeURIComponent($F('cboSource')),onComplete:ai,onException:aj,onFailure:ak});}else{var request=new Ajax.Request('ws/send.aspx',{parameters:'txtVoucher='+encodeURIComponent($F(U))+'&txtSenderID='+encodeURIComponent(sId)+'&txtMSISDN='+encodeURIComponent($F(Q))+'&txtMessage='+encodeURIComponent($F(G)),onComplete:ai,onException:aj,onFailure:ak});}return false;};function ai(transport){var resp=transport.responseText;$(T).disabled=false;$(J).hide();switch(resp){case '0':af(r);break;case 'INVALID_VOUCHER':af(k);break;case 'DUPLICATE_TEST_NUMBER':af(ar);break;default:af(j);break;}};function am(H){if(H==null||H.length==0){af(C);return false;}if(H.length<9|| !ag(H)){af(m);return false;}if(H.substring(0,1)=='0'){af('It looks like you\'re sending the message to a UK phone number (+44).  If so, please replace the zero at the start with \'44\' to make it international format and try again.');return false}if(H.substring(0,3)=='440'){af('It looks like you\'re sending the message to a UK phone number (+44).  If so, please remove the zero immediately after the \'44\' to make it international format and try again.');return false}return true;};function ah(){var s=$F(G);if(s.length>160){$(G).value=s.substring(0,159);$('msgCt').innerText='0'}$('msgCt').innerText=160-s.length;};function af(K){$('elPopupMsg').innerHTML=K;popupDo('divPopUp');};function popupDo(F){popupSize(F);popupPos(F);popupToggle('divPopUpFilm');popupToggle(F);};function popupToggle(aa){var el=document.getElementById(aa);if(el.style.display=='none'){el.style.display='block';}else{el.style.display='none';}};function popupSize(F){if(typeof window.innerWidth!='undefined'){O=window.innerHeight;}else{O=document.documentElement.clientHeight;}if((O>document.body.parentNode.scrollHeight)&&(O>document.body.parentNode.clientHeight)){filmH=O;}else{if(document.body.parentNode.clientHeight>document.body.parentNode.scrollHeight){filmH=document.body.parentNode.clientHeight;}else{filmH=document.body.parentNode.scrollHeight;}}var V=document.getElementById('divPopUpFilm');V.style.height=filmH+'px';var P=document.getElementById(F);ac=filmH/2-150;P.style.top=ac+'px';};function popupPos(F){if(typeof window.innerWidth!='undefined'){M=window.innerHeight;}else{M=document.documentElement.clientHeight;}if((M>document.body.parentNode.scrollWidth)&&(M>document.body.parentNode.clientWidth)){I=M;}else{if(document.body.parentNode.clientWidth>document.body.parentNode.scrollWidth){I=document.body.parentNode.clientWidth;}else{I=document.body.parentNode.scrollWidth;}}var P=document.getElementById(F);I=I/2-150;P.style.left=I+'px';}