
// Insert an Emoticon to the message box
function insertEmoticon(){	
	f = document.forms['frmSendMsg'];
	if (f.emoticon.selectedIndex >=0){
		f.message.value += f.emoticon.options[f.emoticon.selectedIndex].value;
	}
}
// End


// Change the Destination number to the selected phone book contact number
function pbnumber_onchange() {
    f = document.forms['frmSendMsg'];
    f.Destination.value = f.pbnumber.value;   
}
// End


// Count the number of characters remaining in the message box
function textCounter(field, countfield, maxlimit) {
    if (field.value.length > maxlimit)
        field.value = field.value.substring(0, maxlimit);
    else 
        countfield.value = maxlimit - field.value.length;
}
// End


// Validate the form for a phone number and message to be entered (sendmessage.asp)
function validateform() {
    f = document.forms['frmSendMsg'];
    if (f.Destination.value == "") {
        alert ('Please enter a phone number for the message'); // Alert message for phone number
        f.Destination.focus();
        return false;
    }
    
    if (f.message.value == "") {
        alert ('Please enter a message to send'); // Alert message for no message
        f.message.focus();
        return false;
    }
    
    else
        f.submitbutton.value = "One Moment.."; // Change the submit button when pressed
    return true;
}
// End


// Validate the form for a phone number and message to be entered (sendbatchmessage.asp)
function batchvalidateform() {

      f = document.forms['frmSendMsg'];

      var Counter = 0;
      
      for (i=0; i < f.cDestination.length; i++) {
         if (f.cDestination[i].selected) {
            Counter++;
         }
      }

      if (Counter == 0) {
        alert("Please select a recipient for the message");
        f.cDestination.focus();
        return false;
      }

    // Make sure that there is a message to send
    if (f.message.value == "") {
        alert ('Please enter a message to send'); // Alert message for no message
        f.message.focus();
        return false;
    }
    
    else
        f.submitbutton.value = "One Moment.."; // Change the submit button when pressed
    return true;
}
// End


// Validate the form for a phone number and message to be entered (sendgroupmessage.asp)
function groupvalidateform() {
    f = document.forms['frmSendMsg'];
    if (f.message.value == "") {
        alert ('Please enter a message to send'); // Alert message for no message
        f.message.focus();
        return false;
    }
    
    else
        f.submitbutton.value = "One Moment.."; // Change the submit button when pressed
    return true;
}
// End


// Make sure that the new passwords match on the profile.asp page
function comparePass() {
 f = document.forms['frmChangePass'];
 if (f.newPassword.value != f.confirmNewPassword.value)   {
  alert('The new password does not match');
  f.newPassword.value='';
  f.confirmNewPassword.value='';
  f.newPassword.focus();
  return false;
  }  else  {
  alert('Your password has been changed');
  return true;
  }
}
// End


// Calculate the total for the credits to be purchased purchasecredits.asp
function calculatecredits()
{
 var amtValue = document.frmCredits.credits.options[document.frmCredits.credits.selectedIndex].value;
 document.frmCredits.total.value = amtValue * document.frmCredits.creditvalue.value;
}
// End


// Validate the signup form (register.asp)
function checkform(){

 f = document.forms['frmRegister'];
 
 if (f.mobileNo.value == "") {
  alert("Please enter a Mobile Phone Number");
  f.mobileNo.focus();
  return false;
 }
 
 if (f.GivenName.value == "") {
  alert("Please enter your First Name");
  f.GivenName.focus();
  return false;
 }
 
 if (f.Surname.value == "") {
  alert("Please enter your Surname");
  f.Surname.focus();
  return false;
 }
 
 if (f.streetAddress.value == "") {
  alert("Please enter your Address");
  f.streetAddress.focus();
  return false;
 }
 
 if (f.suburb.value == "") {
  alert("Please enter your Suburb");
  f.suburb.focus();
  return false;
 }
 
 if (f.postCode.value == "") {
  alert("Please enter your Post Code");
  f.postCode.focus();
  return false;
 }
 
 if (f.email.value == "") {
  alert("Please enter your Email Address");
  f.email.focus();
  return false;
 }
 
 if (f.Agree.checked == false) {
  alert("Please Agree to the Terms & Conditions");
  f.Agree.focus();
  return false;
 }

 else 
 
 {
  return true;
 }
}
// End

// Validate the purchase credits page (purchasecredits.asp)
// Need to get a credit card checker in the future
function checkcreditsform(){

 f = document.forms['frmCredits'];
 
 if (f.credits.selectedIndex == 0) {
  alert("Please select how many credits you wish to purchase");
  f.credits.focus();
  return false;
 } 

 if (f.cardnumber.value == "") {
  alert("Please enter your credit card number");
  f.cardnumber.focus();
  return false;
 }
 
 if (f.expiryMonth.selectedIndex == 0) {
  alert("Please select the expiry month");
  f.expiryMonth.focus();
  return false;
 }
 
 if (f.expiryYear.selectedIndex == 0) {
  alert("Please select the expiry year");
  f.expiryYear.focus();
  return false;
 }
 
 else 
 
 {
  f.submitbutton.value = "One Moment.."; // Change the submit button when pressed
  return true;
 }
}
// End


// Validate the phone book entry
function phonebookcheckform(){

 f = document.forms['frmAddPBook'];
 
 if (f.Description.value == "") {
  alert("Please enter a name");
  f.Description.focus();
  return false;
 }
 
 if (f.Destination.value == "") {
  alert("Please enter a phone number");
  f.Destination.focus();
  return false;
 }
 
 if (f.cboSelectGroup.selectedIndex == 0) {
  alert("Please select a group");
  f.cboSelectGroup.focus();
  return false;
 }
 
 else 
 
 {
  return true;
 }
}
// End

// Validate the group entry
function groupcheckform(){

 f = document.forms['frmGroupAdd'];
 
 if (f.GroupName.value == "") {
  alert("Please enter a name");
  f.GroupName.focus();
  return false;
 }
 
 else 
 
 {
  return true;
 }
}
// End

// Validate profile
function profilecheckform(){

 f = document.forms['frmProfile'];
 
 if (f.email.value == "") {
  alert("Please enter a email address");
  f.email.focus();
  return false;
 }
 
 if (f.operator.selectedIndex == 0) {
  alert("Please select an operator");
  f.operator.focus();
  return false;
 }
 
 else 
 
 {
  return true;
 }
}
// End