/**
 * @version		$Id: submitbutton.js 74 2010-12-01 22:04:52Z chdemko $
 * @package		Joomla16.Tutorials
 * @subpackage	Components
 * @copyright	Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
 * @author		Christophe Demko
 * @link		http://joomlacode.org/gf/project/helloworld_1_6/
 * @license		License GNU General Public License version 2 or later
 */

Joomla.submitbutton = function(task)
{
	if (task == '')
	{
		return false;
	}
	else
	{
		var isValid=true;
		var action = task.split('.');
		if (action[1] != 'cancel' && action[1] != 'close')
		{
			var forms = $$('form.form-validate');
			for (var i=0;i<forms.length;i++)
			{
				if (!document.formvalidator.isValid(forms[i]))
				{
					isValid = false;
					break;
				}
			}

			var theurl		= document.getElementById('jform_email');
			var thelabel	= document.getElementById('jform_email-lbl');

			if (theurl.value == "")
    		{
				alert("Please enter your E-Mail Id.");
        		theurl.focus();
        		return false;
    		}
    		{
				var x=theurl.value;
				var atpos=x.indexOf("@");
				var dotpos=x.lastIndexOf(".");
				if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
	  			{
				alert("Not a valid e-mail address");
				thelabel.style.color = "red";
				theurl.style.color = "red";
	 			return false;
  				}
			}
		}

		if (isValid) {
			Joomla.submitform(task);
			return true;
		} else {
			return false;
		}
	}
}

