
var MAX_MESSAGE_LENGTH=160;var MAX_UNICODE_MESSAGE_LENGTH=70;var MAX_MESSAGE_PARTS=5;var MAX_MESSAGE_PART_LENGTH=MAX_MESSAGE_LENGTH-"x of x: ".length;var MAX_UNICODE_MESSAGE_PART_LENGTH=MAX_UNICODE_MESSAGE_LENGTH-"x of x: ".length;var MAX_TOTAL_MESSAGE_LENGTH=MAX_MESSAGE_PARTS*MAX_MESSAGE_PART_LENGTH;var MAX_TOTAL_UNICODE_MESSAGE_LENGTH=MAX_MESSAGE_PARTS*MAX_UNICODE_MESSAGE_PART_LENGTH;var req;var numb='0123456789';function submitButtonDown(){document.getElementById('sendError').innerHTML='<font>Sending message. Please wait...</font>';}
function isValid(parm,val){if(parm===""){return true;}
for(i=0;i<parm.length;i++){if(val.indexOf(parm.charAt(i),0)==-1){return false;}}
return true;}
function isNum(parm){return isValid(parm,numb);}
function valid(form){var hasError=false;document.getElementById('numberError').innerHTML='';document.getElementById('messageError').innerHTML='';var memberIdError=document.getElementById('memberIdError');if(memberIdError){memberIdError.innerHTML='';}
document.getElementById('sendError').innerHTML='';var badNumber=false;var number=form.internationalNumber.value;if(!number||number.length===0){badNumber=true;}else{if(number.charAt(0)=='+'){number=number.substring(1);}
if(!isNum(number)||(number.charAt(0)=='0')||(number.length<4)||(number.length>16)){badNumber=true;}}
if(badNumber){hasError=true;form.internationalNumber.focus();document.getElementById('numberError').innerHTML='<font color="red">Enter a number in international format</font>';}
var message=form.message.value;if(!message||message.length===0){document.getElementById('messageError').innerHTML='<font color="red">Enter a message</font>';if(!hasError){form.message.focus();form.message.select();hasError=true;}}else if((needsUnicode(message)&&(message.length>MAX_TOTAL_UNICODE_MESSAGE_LENGTH))){document.getElementById('messageError').innerHTML='<font color="red">Messages requiring Unicode can only have '+MAX_TOTAL_UNICODE_MESSAGE_LENGTH+' characters</font>';if(!hasError){form.message.focus();hasError=true;}}
var memberId=form.memberId;if(memberId){if(!memberId.value||(memberId.value.length<4)){if(!hasError){memberId.focus();hasError=true;}
document.getElementById('memberIdError').innerHTML='<font color="red">Invalid Member ID</font>';}}
var password=form.password;if(password){if(!password.value||(password.value.length===0)){if(!hasError){password.focus();hasError=true;}
document.getElementById('passwordError').innerHTML='<font color="red">Enter your password</font>';}}
if(hasError){document.getElementById('sendError').innerHTML='<font color="red">Please correct the errors above.</font>';}
return(!hasError);}
function setup(){setValuesFromCookies();MM_preloadImages('../media/btno-01.gif','../media/btno-02.gif','../media/btno-03.gif','../media/btno-04.gif');}
var GSM_ALPHABET=new Array(64,163,36,165,232,233,249,236,242,216,248,197,229,95,94,123,125,92,91,126,93,124,198,230,223,201,32,33,34,35,164,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,161,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,196,214,209,220,167,191,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,228,246,241,252,224,231,10,12,13);var GSM_ALPHABET_LENGTH=GSM_ALPHABET.length;function needsUnicode(message){var numChars=message.length;var unicodeNeeded=false;for(i=0;i<numChars;i++){var currentCharCode=message.charCodeAt(i);var charIsGsm=false;for(j=0;j<GSM_ALPHABET_LENGTH;j++){if(currentCharCode==GSM_ALPHABET[j]){charIsGsm=true;break;}}
if(!charIsGsm){unicodeNeeded=true;break;}}
return unicodeNeeded;}
function updateCounts(message){var unicode=needsUnicode(message.value);var numChars=message.value.length;if(numChars>MAX_TOTAL_MESSAGE_LENGTH){message.value=message.value.substr(0,MAX_TOTAL_MESSAGE_LENGTH);numChars=MAX_TOTAL_MESSAGE_LENGTH;}
document.getElementById('characterCount').innerHTML="Chars: "+numChars;if(unicode){document.getElementById('unicode').innerHTML="; Unicode";if(numChars>MAX_TOTAL_UNICODE_MESSAGE_LENGTH){document.getElementById('messageError').innerHTML='<font color="red">Messages requiring Unicode can only have '+MAX_TOTAL_UNICODE_MESSAGE_LENGTH+' characters</font>';}else{document.getElementById('messageError').innerHTML="";}}else{document.getElementById('unicode').innerHTML="";document.getElementById('messageError').innerHTML="";}
numParts=1;if(unicode){if(numChars>MAX_UNICODE_MESSAGE_LENGTH){numParts=Math.ceil(numChars/MAX_UNICODE_MESSAGE_PART_LENGTH);}}else{if(numChars>MAX_MESSAGE_LENGTH){numParts=Math.ceil(numChars/MAX_MESSAGE_PART_LENGTH);}}
document.getElementById('partCount').innerHTML="; Parts: "+numParts;}
function getCookie(cookieName){var allCookies=""+document.cookie;var cookieValue="";var cookieStartIndex=allCookies.indexOf(cookieName);if((cookieStartIndex!=-1)&&(cookieName!=="")){var cookieEndIndex=allCookies.indexOf(';',cookieStartIndex);if(cookieEndIndex==-1){cookieEndIndex=allCookies.length;}
cookieValue=unescape(allCookies.substring(cookieStartIndex+cookieName.length+1,cookieEndIndex));}
return cookieValue;}
function setValuesFromCookies(){var recipientNumber=getCookie('InternationalNumber');document.getElementById("internationalNumber").value=recipientNumber;}
function MM_preloadImages(){var d=document;if(d.images){if(!d.MM_p){d.MM_p=new Array();}
var i,j=d.MM_p.length,a=MM_preloadImages.arguments;for(i=0;i<a.length;i++){if(a[i].indexOf("#")!==0){d.MM_p[j]=new Image();d.MM_p[j++].src=a[i];}}}}
function MM_swapImgRestore(){var i,x,a=document.MM_sr;for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++){x.src=x.oSrc;}}
function MM_findObj(n,d){var p,i,x;if(!d){d=document;}
if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}
if(!(x=d[n])&&d.all){x=d.all[n];}
for(i=0;!x&&i<d.forms.length;i++){x=d.forms[i][n];}
for(i=0;!x&&d.layers&&i<d.layers.length;i++){x=MM_findObj(n,d.layers[i].document);}
return x;}
function MM_swapImage(){var i,j=0,x,a=MM_swapImage.arguments;document.MM_sr=new Array();for(i=0;i<(a.length-2);i+=3){if((x=MM_findObj(a[i]))!==null){document.MM_sr[j++]=x;if(!x.oSrc){x.oSrc=x.src;}
x.src=a[i+2];}}}
function MM_displayStatusMsg(msgStr){status=msgStr;document.MM_returnValue=true;}