/* 
 * Functions for form submit management
 * 
 */
 
/* 
 * Function submitForm : update action et submit form
 * 
 */
 function submitForm(formId,submitUrl,action)
 {
	if(		document.getElementById('confirmSubmit')!=null 
		&&	document.getElementById('confirmSubmit').value=="confirm" 
		&&	document.getElementById('actionForm').value!="addToCart"){
		if(!confirm(document.getElementById("messageConfirmation").value)){
			return false;
		}
	}
	
	if(action.toString()=="get")
 	{
 		submitUrl += "?1=1";
	    // Add of each form element to the submitURL
	    for (var i = 0; i < document.getElementById(formId).elements.length; i++) {
	    	submitUrl += "&"+document.getElementById(formId).elements[i].name+"="+document.getElementById('formId').elements[i].value;
	    }
 	}
 	// Updates the action form value
	document.getElementById(''+formId+'').action = submitUrl.toString();
	document.getElementById(''+formId+'').submit();	
 }
 
/* 
 * Function submitAction : update hidden field action et and lauch function submitForm
 * 
 */
 function submitAction(fieldId,fieldValue,formId,submitUrl)
 {
	document.getElementById(''+fieldId+'').value = fieldValue.toString();
	var method = 'POST';
	submitForm(formId,submitUrl,method);
 }