/**
 * @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;
				}
			}
		}
	
		if (isValid)
		{
			Joomla.submitform(task);
			return true;
		}
		else
		{
			alert(Joomla.JText._('COM_HELLOWORLD_HELLOWORLD_ERROR_UNACCEPTABLE','Some values are unacceptable'));
			return false;
		}
	}
}

function discount()
{
	var path 	 = document.getElementById('site_path').value;
	var p		 = document.getElementById('jform_product_price').value;
	var dis		 = document.getElementById('jform_product_discount').value;

	var reduction= p*(dis/100);
	var savevalue= roundNumber(reduction,2);
	var amount	 = p-reduction;
	var deal 	 = roundNumber(amount,2);

	document.getElementById('jform_you_save').value = savevalue;
	document.getElementById('jform_deal_price').value = deal;
}

function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}


