<!--
   
	/* 
	// Name: validateAddForm 
	//
	// Desc: Controller for the main user login form
	//
	// Params: An HTML form (document object)
	//
	// Options: none
	//
	// Usage: @ Public
	*/
  	function validateLoginForm(theForm)
	{
		var why = "";
		why += checkText(theForm.txtUsername.value, 'PLEASE ENTER YOUR USERNAME.\nThis was provided to you when you registered.\n');
		why += checkText(theForm.txtPassword.value, 'PLEASE ENTER YOUR PASSWORD.\nIf you have forgotten your password you can request it to be sent to you.\n\n');
		
		if (why != "") {
		   alert(why);
		   return false;
		}
		return true;
	}
	
	/* 
	// Name: validateAddForm 
	//
	// Desc: Controller for the Add PixCode Form
	//
	// Params: An HTML form (document object)
	//
	// Options: none
	//
	// Usage: @ Public
	*/
	function validateAddForm(theForm)
	{
		var why = "";
		why += checkText(theForm.txtName.value,    'PLEASE ENTER A NAME.\nThis name will be used to help you find it in the future.\n');
		why += checkText(theForm.txtMessage.value, 'PLEASE ENTER A MESSAGE.\nThis is the text that will be sent via SMS.\n\n');
		
		if (why != "") {
		   alert(why);
		   return false;
		}
		return true;
	}
	
	/* 
	// Name: checkText 
	//
	// Desc: Ensure textbox is not blank
	//
	// Params:  'field' - Name of the textbox to be checked
	//			'msg'   - User message to be displayed if there is an error
	//
	// Usage: @ Private
	*/
	function checkText(field, msg)
	{
		var error = "";
		if (field == "")
		{
	   		error = msg+"\n";
	   	}
		return error;
	}
	
	/* 
	// Name: textBlocker
	//
	// Desc: Prevent text within a textarea exceeding a defined amount
	//
	// Params: 'field'    - Name of the textarea to be controlled
	//		   'maxLimit' - Max number of chars that will be accepted
	//
	// Usage: @ Public
	*/
	function textBlocker(field, maxlimit)
	{	
		if (field.value.length > maxlimit)
			field.value = field.value.substring(0, maxlimit);
	}
	
	/* 
	// Name: smsCounter
	//
	// Desc: Count SMS Characters and Increment Message Parts as required
	//
	// Params: 'field'    - Name of the textarea to be controlled
	//		   'maxLimit' - Max number of chars that will be accepted
	//
	// Usage: @ Public
	*/
	function smsCounter(field, maxlimit, notice, doSums)
	{	
		var chrStr;
		var chrNum;
		var msgNum;
		var hidNum;
		
		notice = typeof(notice) != 'undefined' ? notice : 'yes';
		doSums = typeof(doSums) != 'undefined' ? doSums : false;
		
		msgNum = document.getElementById('msgNum');
		chrStr = document.getElementById('chrStr');
		
		// Protect Max Length
		if (field.value.length >= maxlimit)
			field.value = field.value.substring(0, maxlimit);
		
		// Reset Chr Num
		if(field.value.length == 462)
			chrStr.innerHTML = '154';
		if(field.value.length == 308)
			chrStr.innerHTML = '154';
		if(field.value.length == 154)
			chrStr.innerHTML = '154';
		
		// Increment Msg Num
		if(field.value.length <= 615)
		{
			msgNum.innerHTML = '4';
			chrStr.innerHTML = 616-field.value.length;
		}
		if(field.value.length <= 462)
		{
			msgNum.innerHTML = '3';
			chrStr.innerHTML = 463-field.value.length;
		}
		if(field.value.length <= 308)
		{
			msgNum.innerHTML = '2';
			chrStr.innerHTML = 309-field.value.length;
		}
		
		if(field.value.length <= 154)
		{
			msgNum.innerHTML = '1';
			chrStr.innerHTML = 155-field.value.length;
		}
		
		if(doSums)
		{
			var newTotal = calculateTotal($("#txtGroup").val());
		
			$("#totalCost").text(''+newTotal+'');
		}
		
		if(field.value.length == 155)
		{
			if(notice == 'yes')
			{
				alert('NOTICE - You have reached the limit for a single part message. All remaining characters in this message will be sent to recipients via WAP rather then SMS. To continue typing your message, press OK.');
			}
		}
	}
	
	/* 
	// Name: confirmation
	//
	// Desc: Prompt user to confirm that they wish to proceed
	//
	// Params:  'message' - User message to be displayed
	//
	// Usage: @ Public
	*/
	function confirmation(message)
	{
		var answer = confirm(message)
		
		if (answer)
			return true;
		else
			return false;
	}
	
	/* 
	// Name: currencyFormat
	//
	// Desc: Format a float number into currency format
	//
	// Params:  'num' - The number to be formatted
	//
	// Returns:  formatted number (string)
	//
	// Usage: @ Public
	*/
	function currencyFormat(num)
	{
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
		return (((sign)?'':'-') + num + '.' + cents);
	}
	
	/* 
	// Name: pause
	//
	// Desc: Pause the Script for a defined number of milliseconds
	//
	// Params:  'ms' - The number of milliseconds to pause the script
	//
	// Returns:  void
	//
	// Usage: @ Public
	*/
	function pause(ms)
	{
		var date    = new Date();
		var curDate = null;

		do { curDate = new Date(); }
		while(curDate-date < ms);
	} 
	-->