/************************************************************************************
www.araveon.com

object:	Function and Variable definition and declaration.
Date:	05/02/2010
Author:	V.Nercessian
EMail:	v.nercessian@gmail.com
		contact@araveon.com

*************************************************************************************/
var strMandatoryInfo = "* Le champ est obligatoire.";
var strMandatoryBegin = "* Le champ";
var strMandatoryEnd= "est obligatoire.";
var strNameFormat = "Les caractères autorisés sont (A-Z)(a-z), (-), (.) et les espaces.";
var strNumberFormat = "Les caractères autorisés sont (0-9).";
var strPhoneFormat = "Les caractères autorisés sont (0-9), (-), (.), (+), (()) et les espaces.";
var strMailError = "L\'address de courrier électronique que vous avez saisie n'est pas valide.";
var strMandatoryEmailOrPhone = "* Un de ces champs est obligatoire (Email / Téléphone).";
var strErrorOutInDate = "* La date du retour doit être supérieure de la date de l'aller.";
var strErrorOutDate = "* La date de l'aller doit être supérieure ou égale à la date d'aujourd'hui.";
var strErrorInDate = "* La date du retour doit être supérieure ou égale à la date d'aujourd'hui.";
var strErrorOutInTime = "Erreur des sélections des horaires.";
var strMandatory = "mdr";
var strOptional = "opl";
var strAlpha = "alpha";
var strDigit = "digit";
var strDate = "date";
var strTime = "time";
var strPhone = "phone";
var strEmail = "email";
//const strPhoneFormat = "Les caractères autorisés sont (0-9), (-), (.), (+), (()) et les espaces et les parenthèses.";

window.addEventListener?window.addEventListener("load",init,false):window.attachEvent("onload",init);

function init()
{
	var urlParam = "";
	var idName ="";
	var object;
	var tagSpan;
	var tagA;
	
	/* Récupération de nom de document html courant */
	
	var url = window.location.pathname;
	var filename = url.substring(url.lastIndexOf('/')+1);
	
	/***************************************************/
	if(filename == "")
		idName = "index";
	else
		idName = filename.substring(0, filename.lastIndexOf('.'));

	object = document.getElementById(idName + "-menu");
	object.className = "cur-avmenu";
	tagA = object.getElementsByTagName("a");
	tagA[0].onmouseover = "";
	tagA[0].onmouseout = "";
	tagSpan = object.getElementsByTagName("span");
	tagSpan[0].onmouseover = "";
	tagSpan[0].onmouseout = "";

	if((filename == "") || (filename == "liens-utiles.html") 
		|| (filename == "auto.html") || (filename == "hotels.html")){
		setBlocHeight('front-announce', getBlocHeight('right-side-content-block'));
	}
	else if(filename == "orientissimes.html") {
		setBlocHeight('right-side-content', getBlocHeight('left-side-content'));
		setBlocHeight('left-side-content', getBlocHeight('left-side-content'));
	}	
	else if((filename == "voyages-groupe.html") || (filename == "contact.html")){
		InitEnabledDate();
		urlParam=getParams()[0]; 		// Récupération du premier argumen de URL
		if(urlParam == "error")
			setCodeError(urlParam); 	// Code de validation est incorrect
		else if((urlParam == "yes") || (urlParam == "no")){
			document.getElementById('submit-form').style.display = "none";
			document.getElementById('submit-form-result').style.display = "inherit";
			setSendState(urlParam);
		}
	}
}

function getParams()
{
	var name=new Array();
	var valeur=new Array();
	
	param = window.location.search.slice(1,window.location.search.length);

	first = param.split("&");

	for(var i=0;i<first.length;i++){
		second = first[i].split("=");
		name[i] = second[0];
		valeur[i] = second[1];
	}
	return valeur;
}

function getBlocWidth(blocID){
	
	return document.getElementById(blocID).offsetWidth;
}

function setBlocWidth(blocID, newWidth){
	
	document.getElementById(blocID).style.width = newWidth + "px";
}

function getBlocHeight(blocID){

	return document.getElementById(blocID).offsetHeight;
}

function setBlocHeight(blocID, newHeight){
	
	document.getElementById(blocID).style.height = newHeight + "px";
}

function IsValidGroupForm(){
	return IsValidContactForm();
}

/*function IsValidGroupForm()
{
	var bResult = true;
	//var nCount = 0;
	var strDateOut = "";
	var strDateIn = "";
	var dateOut;
	var dateIn;
	var strTimeOut = "";
	var strTimeIn = "";
	var iEmail = 0;
	var iPhone = 0;
	var cInput = '';
	var strInputTitle = "";
	var strInputStatus = "";
	var strInputFormat = "";
	var strInputType = "";
	var strInputValue = "";
	var strInputName = "";
	var strInputMandatory = false;
	var strInputEmptyErrors = "";
	var strInputErrors = "";
	var objSubmitForm = document.getElementById('SubmitForm');
	var objInput = objSubmitForm.getElementsByTagName('input');
	var objTextarea = objSubmitForm.getElementsByTagName('textarea');
	var timeOut = document.getElementById('mdr_time_horairealler_id');
	var timeIn = document.getElementById('mdr_time_horaireretour_id');
	var checkboxAller = document.getElementById('opt_checkbox_aller_id');
	var checkboxRetour = document.getElementById('opt_checkbox_retour_id');
	var todayDate;
	
	strTimeOut = timeOut.value;
	strTimeIn = timeIn.value;

	for(i = 0; i < objInput.length; i++)
	{
		if(objInput[i].getAttribute("name") != null)
		{
			strInputType = objInput[i].getAttribute("type");

			if((strInputType == "text") || (strInputType == "hidden")){
				strInputName = objInput[i].getAttribute("name");
				strInputTitle = objInput[i].getAttribute("title");
				strInputValue = trim(objInput[i].value);

				strInputStatus = strInputName.substr(0, 3);
				strInputFormat = strInputName.substr(4, strInputName.indexOf('_', 4) - 4);
	
				if(strInputValue.length == 0) {
					
					if(strInputName == "mdr_phone"){
						if(iEmail == -1){
							strInputErrors = strMandatoryEmailOrPhone;
							setFormState("mdr_phone_number_id", strMandatoryEmailOrPhone, true, false);
							setFormState("mdr_email_address_id", strMandatoryEmailOrPhone, true, false);
							bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
						}
						else if((iEmail == 0) || (iEmail == 1)){
							strInputErrors = "";
							setFormState("mdr_email_address_id", "", true, false);
							setFormState("mdr_phone_number_id", "", true, false);
							bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
						}
						iPhone = -1;
					}
					else if(strInputName == "mdr_email"){
						if(iPhone == -1){
							strInputErrors = strMandatoryEmailOrPhone;
							setFormState("mdr_email_address_id", strMandatoryEmailOrPhone, true, false);
							setFormState("mdr_phone_number_id", strMandatoryEmailOrPhone, true, false);
							bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
						}
						else if((iPhone == 0) || (iPhone == 1)){
							strInputErrors = "";
							setFormState("mdr_email_address_id", "", true, false);
							setFormState("mdr_phone_number_id", "", true, false);
							bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
						}
						iEmail = -1;
					}
					else if(strInputStatus == strMandatory){
						strInputErrors = strMandatoryBegin + " (" + strInputTitle + ") " + strMandatoryEnd;
						setFormState(strInputName + "_id", strInputErrors, true, false);
						bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
					}
				}
				else if(strInputValue.length > 0){
					if(strInputFormat == strAlpha){
						strInputErrors = IsValidName(strInputValue);
						setFormState(strInputName + "_id", strInputErrors, true, false);
						bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
					}
					else if((strInputFormat == strDigit) && (strInputName != "mdr_digit_code")){
						strInputErrors = IsValidNumber(strInputValue);
						setFormState(strInputName + "_id", strInputErrors, true, false);
						bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
					}
					else if(strInputFormat == strDate){
						if((checkboxAller.checked == true) || (checkboxRetour.checked == true))
						{	
							todayDate = new Date();
							todayDate.setHours('00');
							todayDate.setMinutes('00');
							todayDate.setSeconds('00');
							todayDate.setMilliseconds('00');
							
							if((strInputName == "mdr_date_datealler") && (checkboxAller.checked == true)){
								strDateOut = strInputValue;
								dateOut = new Date(strDateOut);
								dateOut.setHours('00');
								dateOut.setMinutes('00');
								dateOut.setSeconds('00');
								dateOut.setMilliseconds('00');
								
								if(dateOut < todayDate){
									strInputErrors = strErrorOutDate;
									setFormState("mdr_date_datealler_id", strInputErrors, true, false);
									bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true; 
								}
								else{
									strInputErrors = "";
									setFormState("mdr_date_datealler_id", strInputErrors, true, false);
									bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
									setFormState("mdr_date_dateallerretour_id", strInputErrors, true, false);
									dateOut.setHours(strTimeOut);
									bResult = true;
								}
							}
							else if((strInputName == "mdr_date_dateretour") && (checkboxRetour.checked == true)){
								strDateIn = strInputValue;
								dateIn = new Date(strDateIn);
								dateIn.setHours('00');
								dateIn.setMinutes('00');
								dateIn.setSeconds('00');
								dateIn.setMilliseconds('00');

								if(dateIn < todayDate){
									strInputErrors = strErrorInDate;
									setFormState("mdr_date_dateretour_id", strInputErrors, true, false);
									bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true; 
								}
								else{
									strInputErrors = "";
									setFormState("mdr_date_dateretour_id", strInputErrors, true, false);
									setFormState("mdr_date_dateallerretour_id", strInputErrors, true, false);
									bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
									dateIn.setHours(strTimeIn);
									bResult = true;
								}

							}
							
							if((bResult == true) && ((checkboxAller.checked == true) && (checkboxRetour.checked == true)) 
								&& ((strDateOut.length > 0) && (strDateIn.length > 0)))
							{	
								if(dateOut >= dateIn){
									strInputErrors = strErrorOutInDate;
									setFormState("mdr_date_dateallerretour_id", strInputErrors, true, false);
									bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;							
								}
								else{
									strInputErrors = "";
									setFormState("mdr_date_dateallerretour_id", strInputErrors, true, false);
									bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;								
								}
							}
						}
						
						if((strInputName == "mdr_date_datealler") && (checkboxAller.checked == false)){
							strInputErrors = "";
							setFormState("mdr_date_datealler_id", strInputErrors, true, false);
							setFormState("mdr_date_dateallerretour_id", strInputErrors, true, false);
							bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
						}
						else if((strInputName == "mdr_date_dateretour") && (checkboxRetour.checked == false)){
							strInputErrors = "";
							setFormState("mdr_date_dateretour_id", strInputErrors, true, false);
							setFormState("mdr_date_dateallerretour_id", strInputErrors, true, false);
							bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
						}
					}
					else if(strInputFormat == strEmail){
						strInputErrors = IsValidMail(strInputValue);
						setFormState(strInputName + "_id", strInputErrors, true, false);
						bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
						if(bResult == false)
							iEmail = 1;
					}
					else if(strInputFormat == strPhone){
						strInputErrors = IsValidPhone(strInputValue);
						setFormState(strInputName + "_id", strInputErrors, true, false);
						bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
						if(bResult == false)
							iPhone = 1;
					}
				}
			}
		}
	}
	
	strInputValue = trim(objTextarea[0].value);
	strInputName = objTextarea[0].name;
	strInputTitle =  objTextarea[0].title;
	strInputStatus = strInputName.substr(0, 3);

	if((strInputValue.length == 0) || (strInputValue == "Laissez votre message ici"))
	{
		if(strInputStatus == strMandatory){
			strInputErrors = strMandatoryBegin + " (" + strInputTitle + ") " + strMandatoryEnd;
			setFormState(strInputName + "_id", strInputErrors, true, false);
			bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
		}
	}
	else{
		setFormState(strInputName + "_id", "", true, false);
	}
	
	bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
	return bResult;
}*/

function IsValidContactForm()
{
	var bResult = true;
	//var nCount = 0;
	var strDateOut = "";
	var strDateIn = "";
	var dateOut;
	var dateIn;
	var strTimeOut = "";
	var strTimeIn = "";
	var iEmail = 0;
	var iPhone = 0;
	var cInput = '';
	var strInputTitle = "";
	var strInputStatus = "";
	var strInputFormat = "";
	var strInputType = "";
	var strInputValue = "";
	var strInputName = "";
	var strInputMandatory = false;
	var strInputEmptyErrors = "";
	var strInputErrors = "";
	var objSubmitForm = document.getElementById('SubmitForm');
	var objInput = objSubmitForm.getElementsByTagName('input');
	var objTextarea = objSubmitForm.getElementsByTagName('textarea');
	var timeOut = document.getElementById('mdr_time_horairealler_id');
	var timeIn = document.getElementById('mdr_time_horaireretour_id');
	var checkboxAller = document.getElementById('opt_checkbox_aller_id');
	var checkboxRetour = document.getElementById('opt_checkbox_retour_id');
	var todayDate;
	
	strTimeOut = timeOut.value;
	strTimeIn = timeIn.value;
				
	setFormState("mdr_email_address_id", "", true, false);
	setFormState("mdr_phone_number_id", "", true, false);
			
	for(var i = 0; i < objInput.length; i++)
	{
		if(objInput[i].getAttribute("name") != null)
		{
			strInputType = objInput[i].getAttribute("type");

			if((strInputType == "text") || (strInputType == "hidden")){
				strInputName = objInput[i].getAttribute("name");
				strInputTitle = objInput[i].getAttribute("title");
				strInputValue = trim(objInput[i].value);
		
				strInputStatus = strInputName.substr(0, 3);
				strInputFormat = strInputName.substr(4, strInputName.indexOf('_', 4) - 4);

				if(strInputValue.length == 0) {
	
					if(strInputName == "mdr_phone_number"){
						if(iEmail == 0){
							strInputErrors = strMandatoryEmailOrPhone;
							setFormState("mdr_phone_number_id", strMandatoryEmailOrPhone, true, false);
							setFormState("mdr_email_address_id", strMandatoryEmailOrPhone, true, false);
							bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
						}
						/*else if((iEmail == 0) || (iEmail == 1)){
							strInputErrors = "";
							setFormState("mdr_email_address_id", "", true, false);
							setFormState("mdr_phone_number_id", "", true, false);
							bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
						}*/
						iPhone = 0;
					}
					else if(strInputName == "mdr_email_address"){
						if(iPhone == 0){
							strInputErrors = strMandatoryEmailOrPhone;
							setFormState("mdr_email_address_id", strMandatoryEmailOrPhone, true, false);
							setFormState("mdr_phone_number_id", strMandatoryEmailOrPhone, true, false);
							bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
						}
						/*else if((iPhone == 0) ||(iPhone == 1)){
							strInputErrors = "";
							setFormState("mdr_email_address_id", "", true, false);
							setFormState("mdr_phone_number_id", "", true, false);
							bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
						}*/
						iEmail = 0;
					}
					else if(strInputStatus == strMandatory){
						strInputErrors = strMandatoryBegin + " (" + strInputTitle + ") " + strMandatoryEnd;
						setFormState(strInputName + "_id", strInputErrors, true, false);
						bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
					}
				}
				else if(strInputValue.length > 0){
					if(strInputFormat == strAlpha){
						strInputErrors = IsValidName(strInputValue);
						setFormState(strInputName + "_id", strInputErrors, true, false);
						bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
					}
					else if((strInputFormat == strDigit) && (strInputName != "mdr_digit_code")){
						strInputErrors = IsValidNumber(strInputValue);
						setFormState(strInputName + "_id", strInputErrors, true, false);
						bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
					}
					else if(strInputFormat == strDate){
													
						if((checkboxAller.checked == true) || (checkboxRetour.checked == true))
						{	
							todayDate = new Date();
							todayDate.setHours('00');
							todayDate.setMinutes('00');
							todayDate.setSeconds('00');
							todayDate.setMilliseconds('00');
							
							if((strInputName == "mdr_date_datealler") && (checkboxAller.checked == true)){
								strDateOut = strInputValue;
								dateOut = new Date(strDateOut);
								dateOut.setHours('00');
								dateOut.setMinutes('00');
								dateOut.setSeconds('00');
								dateOut.setMilliseconds('00');
								
								if(dateOut < todayDate){
									strInputErrors = strErrorOutDate;
									setFormState("mdr_date_datealler_id", strInputErrors, true, false);
									bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
								}
								else{
									strInputErrors = "";
									setFormState("mdr_date_datealler_id", strInputErrors, true, false);
									bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
									setFormState("mdr_date_dateallerretour_id", strInputErrors, true, false);
									dateOut.setHours(strTimeOut);
									bResult = true;
								}
							}
							else if((strInputName == "mdr_date_dateretour") && (checkboxRetour.checked == true)){
								strDateIn = strInputValue;
								dateIn = new Date(strDateIn);
								dateIn.setHours('00');
								dateIn.setMinutes('00');
								dateIn.setSeconds('00');
								dateIn.setMilliseconds('00');

								if(dateIn < todayDate){
									strInputErrors = strErrorInDate;
									setFormState("mdr_date_dateretour_id", strInputErrors, true, false);
									bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true; 
								}
								else{
									strInputErrors = "";
									setFormState("mdr_date_dateretour_id", strInputErrors, true, false);
									setFormState("mdr_date_dateallerretour_id", strInputErrors, true, false);
									bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
									dateIn.setHours(strTimeIn);
									bResult = true;
								}

							}

							if((bResult == true) && ((checkboxAller.checked == true) && (checkboxRetour.checked == true)) 
								&& ((strDateOut.length > 0) && (strDateIn.length > 0)))
							{	
								/*dateOut = new Date(strDateOut);
								dateIn = new Date(strDateIn);
								dateOut.setHours(strTimeOut);
								dateIn.setHours(strTimeIn);*/

								if(dateOut >= dateIn){
									strInputErrors = strErrorOutInDate;
									setFormState("mdr_date_dateallerretour_id", strInputErrors, true, false);
									bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;							
								}
								else{
									strInputErrors = "";
									setFormState("mdr_date_dateallerretour_id", strInputErrors, true, false);
									bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;								
								}
							}
						}
						
						if((strInputName == "mdr_date_datealler") && (checkboxAller.checked == false)){
							strInputErrors = "";
							setFormState("mdr_date_datealler_id", strInputErrors, true, false);
							setFormState("mdr_date_dateallerretour_id", strInputErrors, true, false);
							bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
						}
						else if((strInputName == "mdr_date_dateretour") && (checkboxRetour.checked == false)){
							strInputErrors = "";
							setFormState("mdr_date_dateretour_id", strInputErrors, true, false);
							setFormState("mdr_date_dateallerretour_id", strInputErrors, true, false);
							bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
						}
					}
					else if(strInputFormat == strPhone){
						strInputErrors = IsValidPhone(strInputValue);
						setFormState(strInputName + "_id", strInputErrors, true, false);
						bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
						if(bResult == false)
							iPhone = -1;
						else{
							iPhone = 1;
												
							if(iEmail == 0){
								strInputErrors = "";
								setFormState("mdr_email_address_id", "", true, false);
								setFormState("mdr_phone_number_id", "", true, false);
								bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
							}
						}
					}
					else if(strInputFormat == strEmail){
						strInputErrors = IsValidMail(strInputValue);
						setFormState(strInputName + "_id", strInputErrors, true, false);
						bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
						if(bResult == false)
							iEmail = -1;
						else
							iEmail = 1;
						
						if(iPhone == 0){
							strInputErrors = "";
							setFormState("mdr_phone_number_id", "", true, false);
							bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
						}
					}
				}
			}
		}
	}

	strInputValue = trim(objTextarea[0].value);
	strInputName = objTextarea[0].name;
	strInputTitle =  objTextarea[0].title;
	strInputStatus = strInputName.substr(0, 3);

	if((strInputValue.length == 0) || (strInputValue == "Laissez votre message ici"))
	{
		if(strInputStatus == strMandatory){
			strInputErrors = strMandatoryBegin + " (" + strInputTitle + ") " + strMandatoryEnd;
			setFormState(strInputName + "_id", strInputErrors, true, false);
			bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;
		}
	}
	else{
		setFormState(strInputName + "_id", "", true, false);
	}
	
	bResult = ((strInputErrors.length > 0) || (bResult == false))? false : true;

	return bResult;
}

function InitEnabledDate()
{
	setEnabledDate(document.getElementById('opt_checkbox_aller_id'));
	setEnabledDate(document.getElementById('opt_checkbox_retour_id'));
}

function setEnabledDate(objCheckbox)
{
	var stringID = "";
	var objTime;
	var attribSrc = document.createAttribute('src');
	var attribOnclick = document.createAttribute('onclick');

	if(objCheckbox.value == "aller"){
		stringID = "datealler";
		objTime  = document.getElementById('mdr_time_horairealler_id');
	}
	else if(objCheckbox.value == "retour"){
		stringID = "dateretour";
		objTime  = document.getElementById('mdr_time_horaireretour_id');
	}
	
	var objDay   = document.getElementById('mdr_date_'+ stringID + '_Day_ID');
	var objMonth = document.getElementById('mdr_date_'+ stringID + '_Month_ID');
	var objYeart = document.getElementById('mdr_date_'+ stringID + '_Year_ID');
	var objDate  = document.getElementById('mdr_date_'+ stringID + '_ID_Link');
	
	objDay.disabled    = (objCheckbox.checked == 0)? true : false;
	objMonth.disabled  = (objCheckbox.checked == 0)? true : false;
	objYeart.disabled  = (objCheckbox.checked == 0)? true : false;
	objTime.disabled   = (objCheckbox.checked == 0)? true : false;
	
	objDay.style.color   = (objCheckbox.checked == 0)? '#808080' : '#000000';
	objMonth.style.color = (objCheckbox.checked == 0)? '#808080' : '#000000';
	objYeart.style.color = (objCheckbox.checked == 0)? '#808080' : '#000000';
	objTime.style.color  = (objCheckbox.checked == 0)? '#808080' : '#000000';
			
	if(objCheckbox.checked == 0){
		attribOnclick.value="return false";
		objDate.setAttributeNode(attribOnclick);
		objDate.style.cursor = "default";
	}
	else{
		objDate.removeAttribute('onclick');
		objDate.style.cursor = "pointer";		
	}

	attribSrc.value = (objCheckbox.checked == 0)? 'img/calendardisabled.jpg' : 'img/calendar.jpg';
	objDate.childNodes[0].setAttributeNode(attribSrc);
}
	
function getFieldFormat(strInputName, strDescription, boldMsgdelete, bNewLineAfter) {
	setFormState(strInputName, strDescription, boldMsgdelete, bNewLineAfter);
}

function setFormState(strInputName, strErrorDescription, boldMsgdelete, bNewLineAfter) {

	var p = document.getElementById(strInputName);
	var childNodes = p.childNodes;
	var br;
	
	p.style.display = "block";
	if(boldMsgdelete){
		while(childNodes.length)
			p.removeChild(childNodes[childNodes.length - 1]);
		
	}
	
	if(bNewLineAfter == true){
		br = document.createElement('br');
		p.appendChild(br);
	}
	
	if(strErrorDescription.length > 0)
		p.appendChild(document.createTextNode(strErrorDescription));
	else
		p.style.display = "none";
}
	
function setSendState(urlParam) {

	var strState="";
	var strDescription="";
	var td = null;
	var br = null;
	var a = null;
	
	td = document.getElementById('stateDscrip');
	if(urlParam == 'yes'){
		strState = "Votre message a été envoyé avec succès !";
		strDescription = "Merci de nous avoir contacté et de l'intérêt que vous nous portez.";
		td.appendChild(document.createTextNode(strDescription));
		br = document.createElement('br');
		td.appendChild(br);
		td.appendChild(document.createTextNode("Vous allez recevoir un email de confirmation d'ici quelques minutes à l'adresse que vous avez indiquée."));
	}
	else if(urlParam == 'no'){
		strState="Erreur lors de l'envoi du message.";
		//strDescription="Votre message n'a pas été envoyé, veuillez réessayer ultérieurement.";
		strDescription="Votre message n'a pas été envoyé.";
		td.appendChild(document.createTextNode(strDescription));			   
		br = document.createElement('br');
		td.appendChild(br);
		br = document.createElement('br');
		td.appendChild(br);
		td.appendChild(document.createTextNode("* Veuillez vérifier la validité de l'adresses de messagerie que vous avez précisé. "));
		br = document.createElement('br');
		td.appendChild(br);
		td.appendChild(document.createTextNode("* Ou veuillez réessayer ultérieurement."));
		br = document.createElement('br');
		td.appendChild(br);
		br = document.createElement('br');
		td.appendChild(br);
		a = document.createElement('a');
		a.setAttribute('href', 'javascript:history.back()');
		a.appendChild(document.createTextNode("Revenir a la page precedente."));
		td.appendChild(a);
	}
	else{
		strState="Nous contacter";
	}
	document.getElementById("stateTitle").childNodes[0].nodeValue = strState;
}

function setCodeError(urlParam)
{
	if(urlParam == "error"){
		setFormState("mdr_digit_code_id", "Le saisie est incorrect.", true, false);
	}
}

function IsValidName(strValue) {

	var strResult = "";
	var strReg = "";
	
	var reg = /[\sa-zA-Zéèêàïôç.-]+$/;
	strReg = reg.exec(strValue);
	
	if(strReg == null){
		strResult = strNameFormat;
		return strResult;
	}
	return strResult;
}

function IsValidNumber(strNumber) {

	var strResult = "";
	var strReg = "";

	//var reg = /[0-9]/;
	var reg = /[0-9]/;
	strReg = reg.exec(strNumber);
	
	if(strReg == null){
		strResult = strNumberFormat;
		return strResult;
	}
	return strResult;
}

function IsValidPhone(strPhone) {

	var strResult = "";
	var strReg = "";

	//var reg = /^[0-9.-]+$/;
	var reg = /[\s\+\(\)0-9.-]+$/;
	strReg = reg.exec(strPhone);
	
	if(strReg == null){
		strResult = strPhoneFormat;
		return strResult;
	}
	return strResult;
}

function IsValidMail(strEmail) {

	var bResult = false;
	var nLength = 0;
	var nPosition = -1;
	var nPositionTmp = -1;
	var cFirst, cLast, cSpecial;
	var strResult = "";
	var strTemp = "";
	var strReg = "";
	var cArray=new Array();
	var strArray=new Array();

	var reg = /^[a-zA-Z0-9._-]{2,}@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,}$/;
	
	cArray[0] = '.';
	cArray[1] = '_';
	cArray[2] = '-';

	strReg = reg.exec(strEmail);
	
	if(strReg == null){
		strResult = strMailError;
		return strResult;
	}

	strArray = strEmail.split("@");
   
	if(strArray.length != 2){
		strResult = strMailError;
		return strResult;
	}

	for(var i = 0; i < 2; i++)
	{
		strTemp = strArray[i];
		nLength = strTemp.length;
		cFirst = strTemp.charAt(0).toLowerCase();
		cLast = strTemp.charAt(nLength - 1).toLowerCase();

		if((((cFirst >= 'a') && (cFirst <= 'z')) || ((cFirst >= 0) && (cFirst <= 9)))
				&& (((cLast >= 'a') && (cLast <= 'z')) || ((cLast >= 0) && (cLast <= 9))))
		{
			for(var j = 0; j < cArray.length; j++)
			{	
				cSpecial = cArray[j];
				
				do{
					nPosition = strTemp.indexOf(cArray[j], nPositionTmp + 1);
					
					if(nPosition != -1){
						if((strTemp.charAt(nPosition + 1) == '.') || (strTemp.charAt(nPosition + 1) == '_')
								|| (strTemp.charAt(nPosition + 1) == '-'))
						{
							j = cArray.length;
							i = 2;
							strResult = strMailError;
							break;
						}
	
					}
					nPositionTmp = nPosition;
					
				}while(nPosition != -1);
			}
		}
		else
		{
			strResult = strMailError;
			break;
		}
	}
	return strResult;
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

