function calculateur_paiement()
{
	//we first calculate our subtotal & add it into the form:
	var i_montant = parseInt(document.getElementById('cmontant').value);
	var i_depot_init = parseInt(document.getElementById('cdepot').value);
	var i_depot_echange = parseInt(document.getElementById('cechange').value);
	var i_subtotal = i_montant - (i_depot_init + i_depot_echange);
	document.getElementById('cfinancer').value = i_subtotal;

	/*
		Pour le moment, on calcule linteret de facon tres simple
	*/
	var i_interet = parseFloat(document.getElementById('cinteret').value);
	var i_frequence = parseInt(document.getElementById('tpaiements').value);
	var i_terme = parseInt(document.getElementById('cterme').value);
	var i_paiements = (((i_subtotal / ((i_terme/12) * 365)) * ( 1 + i_interet)) * i_frequence);

	document.getElementById('cpaiements').value = (Math.round(i_paiements * 100)/100);
	return false;
}


function ChangerImage(href, src)
{
	document.getElementById("grandeImageSrc").src = src;
	document.getElementById("grandeImageLien").href = href;
}		


function changesucc()
{
	document.getElementById('changesucc').onchange = function()
	{
		if (this.value == 2)
		{
			window.location = 'succ_beauce.php'; 
			return;
		}

		if (this.value == 1)
		{
			window.location = 'succ_quebec.php'; 
			return;
		}

		if (this.value == 3)
		{
			window.location = 'index.php?resetsucc=1'; 
			return;
		}
	}
}

Event.observe(window, 'load', function()
{
	/*if ($('formsendtoafriend'))
	{
		Event.observe('formsendtoafriend', 'submit', function(_evt)
		{
			//we stop our event:
			Event.stop(_evt);

			//we clean our message box:
			$('sendtofriendupdateajax').hide();
		
			//we send our ajax request:
			var s_url = 'ajaxforms.php?action=sendtoafriend';
			new Ajax.Request(s_url, {
						method: 'post',
						parameters: 'urlpage=' + $('urlpage').value + '&vcourriel=' + $('vcourriel').value + '&courriel=' + $('courriel').value + '&commentaires=' + $('commentaires').value + "&name=" + $('name').value,
						onSuccess: function(_object)
						{	


							var obj_json = _object.responseText.evalJSON();
							if (!obj_json.b_worked)
								$('sendtofriendupdateajax').setStyle({color: 'red'});
							else
								$('sendtofriendupdateajax').setStyle({color: '#FF9600'});

							$('sendtofriendupdateajax').update(obj_json.message);
							$('sendtofriendupdateajax').show();
						}
			});
		});
	}*/

	if ($('formdemandeinformations'))
	{
		Event.observe('formdemandeinformations', 'submit', function(_evt)
		{
			//we stop our event:
			Event.stop(_evt);

			//we clean our message box:
			$('demandeinformationsupdateajax').hide();

			var s_motodetails = '';
			if (document.getElementById('motoid'))
				s_motodetails = 'motoid=' + $('motoid').value;
			else if (document.getElementById('motoharleyneuveid'))
				s_motodetails = 'motoharleyneuveid=' + $('motoharleyneuveid').value;
			else if (document.getElementById('motobuellneuveid'))
				s_motodetails = 'motobuellneuveid=' + $('motobuellneuveid').value;
		
			//we send our ajax request:
			var s_url = 'ajaxforms.php?action=demandeinformations';
			new Ajax.Request(s_url, {
						method: 'post',
						parameters: s_motodetails + '&sectionname = ' + $('sectionname').value + '&telephone=' + $('telephone').value + '&courriel=' + $('courriel').value + '&commentaires=' + $('commentaires').value + "&name=" + $('name').value,
						onSuccess: function(_object)
						{	


							var obj_json = _object.responseText.evalJSON();
							if (!obj_json.b_worked)
								$('demandeinformationsupdateajax').setStyle({color: 'red'});
							else
								$('demandeinformationsupdateajax').setStyle({color: '#FF9600'});

							$('demandeinformationsupdateajax').update(obj_json.message);
							$('demandeinformationsupdateajax').show();
						}
			});
		});
	}
}, false);

function ChangeImage()
{
	document.getElementById('imagesec').src = 'securimage/securimage_show.php?sid=' + Math.random(); 
}

