	function resetCount(textArea,counterField,maxLength){
		counterField.value = maxLength - textArea.value.length;
	}
	
	
	function countCharacters(textArea, counterField, maxLength){		
	  if(textArea !=null && textArea.value != null) {
			if (textArea.value.length > maxLength){
					alert("Your message may not exceed " +  maxLength +" characters in length.");
					textArea.value = textArea.value.substring( 0, maxLength);
			} else {
					counterField.value = maxLength - textArea.value.length;
			}
    }
	}	
	

	function addIconToMessage(textArea,newText) {
		textArea.value += newText;
		textArea.focus();
	}	

	function moveIt(item){
		seperator = "";
		itemValue = item.options[item.selectedIndex].value;
		selectedList = document.createMessage.sendToPhoneNumber.value;
		if(selectedList != ""){
			seperator = "\n";
		}
		document.createMessage.sendToPhoneNumber.value = document.createMessage.sendToPhoneNumber.value + seperator + itemValue;
		item.selectedIndex = "-1";
	}
	
	function addTxtToOptions(theList,txtObj,maxlimit){
		if(theList.length >= maxlimit) {
			alert ("Cannot add more than " + maxlimit + " items.");
		}else{
			if(txtObj.value.length > 0 ){
				theList.options[theList.length]=new Option(txtObj.value,txtObj.value);
			}	
		}
		clearValue(txtObj);				
	}
	
	function updateTxtToOptionsAtSelected(theList,txtObj){
		if(txtObj.value.length > 0){
			addItemToOptionsAtSelected(theList,txtObj.value);			
		}
		// clear the edit message text box
		clearValue(txtObj);
		// disable the edit message text box
		txtObj.disabled="disabled";	
	}
	

	function addItemToOptionsAtSelected(theList,item){
		if(item.length > 0){
			theList.options[theList.selectedIndex]=new Option(item,item);
		}		
	}
	
	function removeSelectedItemFromOptions(theList){
		if(theList.selectedIndex >= 0){
			theList.options[theList.selectedIndex] = null;
		}
	}	
	

	
	function updateMoveByOptions(theList,moveList){
		clearSelectOptions(moveList);
		if(theList.length <= 1) {
			moveList.disabled="disabled";	
		}else{
			for (var i=1; i < theList.length; i++) {		
				moveList.options[moveList.length]=new Option(i,i);
			}	
			moveList.disabled="";
		}
	}
	
	function listToStr(theList,obj){

		obj.value = "";
		for (var i=0; i < theList.length; i++) {
			if(obj.value.length > 0) obj.value += "~";
			obj.value += theList.options[i].value;
		}
	}
	
	function strToList(theList,obj){
		clearSelectOptions(theList);
		newList = obj.value.split("~");
		
		for (var i=0; i < newList.length; i++) {
			theList.options[theList.length]=new Option(newList[i],newList[i]);
		}	
		
	}
	
	function clearSelectOptions(theList){
		for(var i=theList.length - 1; i>=0; i--){		
			theList.options[i]=null;
		}		
		
	}
	
	function deleteAnItem(theList,itemNo) {   
		theList.options[itemNo]=null   
		history.go(0);
		
	}
	
	
	function sendIt(){
		fred = document.createMessage.sendToPhoneNumber.value;
		bob = "";
		newFred = fred.split(" ");
		for (var i=0; i < newFred.length; i++) {
			bob += "Cell " + i +": " + newFred[i];
		}
		document.createMessage.toSend.value = cleanString(fred);
	}
 
	function cleanString(s){
		var ch;
		var sout = "";
		
		for (var i = 0; i < s.length; i++){
		ch = s.charAt(i);
			if (ch >= "0" && ch <= "9"){
		    sout += ch;
			}
			if(ch == "\n"){
				sout += ";";
			}
		}
		return sout;
	}
	
	function editItem(theList,obj){
		if(theList.selectedIndex >= 0){
			obj.value = theList.options[theList.selectedIndex].value;
			obj.disabled="";
		}
	}
	
	function moveUp(theList,step){

		if(theList.selectedIndex >= 0){
			obj = theList.options[theList.selectedIndex];
			for (var idx = theList.selectedIndex - 1 ; idx >=0 && step > 0; step--,idx--) {
				theList.options[idx+1] = new Option(theList.options[idx].text,theList.options[idx].value);			
			}	
			theList.options[idx+1] = new Option(obj.text,obj.value);
		}
	}
	
	function moveDown(theList,step){
		if(theList.selectedIndex >= 0){
			obj = theList.options[theList.selectedIndex];
	
			for (var idx = theList.selectedIndex + 1 ; idx < theList.length && step > 0; step--,idx++) {
				theList.options[idx-1] = new Option(theList.options[idx].text,theList.options[idx].value);			
			}	
			theList.options[idx-1] = new Option(obj.text,obj.value);
		}

	}	
	
	function setValue(obj,value){
		obj.value=value;
	}
	
	function clearValue(obj){
		obj.value="";
	}

	function deleteDomainCookie(cookieName, domainName){
	   if(GetCookie(cookieName)) {
	     document.cookie=cookieName+"=; path=/; domain="+domainName+"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	   }
	}

        function GetCookie(name) { //GETS THE COOKIE VALUE FROM THE BROWSER
           if (document.cookie.length > 0) {              
              begin = document.cookie.indexOf(name+"=");       
              if (begin != -1) {           
                begin += name.length+1;       
                end = document.cookie.indexOf(";", begin);
                if (end == -1) end = document.cookie.length;
                return unescape(document.cookie.substring(begin, end));
              } 
           }
           return null;
       }

       function popUp2(page, name, w, h, scroll) {
             var winl = (screen.width - w) / 2;
             var wint = (screen.height - h) / 2;
             var winprop  = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable';
             win = window.open(page, name, winprop);
             return false;
        }