//<![CDATA[
$(document).ready(function () {
	
	TemplateM.init();
});

/**
 * Template-specific subclass
 **/
var TemplateM = Template.extend();
var activeTabCount = 1;
var results = '';
var results2 = '';
var tabCount = 0;

TemplateM.init = function() {
	$(".tab-holder .errormsg").hide();
	$('#tip').hide();
	
	this.renderStraplines();
	this.renderRightTitles('#column-1of2 h2, .mod-calculate h3', 'AgendaLt');
	this.renderRightTitles('#content-footer h3');
	showTab(1);

	for(var x = 1; x <= tabCount; x++) {
		$('#tablink' + x).click(function(){
			var tab = $(this).attr("href").substring(1,2);
			showTab(tab);
		});
	}
	
	$('input[name="promotion"]').click(
		function() {
			if($('input[name="promotion"]:checked').val() == 0) {
				$("#divSelectBy-1-1").slideUp('slow'); 
			}else {
				$("#divSelectBy-1-1").slideDown('slow');
			}
		}
	);	
	
	
	
} // init

/* COMMON FUNCTIONS */
function isInteger(key)
{ 
  if((key >= "0") && (key <= "9")) 
  	return true;
  
  return false;
}

function validateInt(element) {
	result = '';
	value = $(element).val();
	if(value.length > 0){
		for(i=0;i<value.length;i++){
			a = value.substring(i, i+1)
			if(isInteger(a)){
				result = result+a;
			}
		}
	}
	element.value = result;
	return false;
}

function validatePhone(element) {
	result = '';
	value = $(element).val();
	if(value.length > 0){
		for(i=0;i<value.length;i++){
			a = value.substring(i, i+1)
			if(isInteger(a) || a == '+' || a == ' '){
				result = result+a;
			}
		}
	}
	element.value = result;
	return false;
}

function validateEmail(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = email;
   if(reg.test(address) == false) {
      return false;
   }
   return true; 
}

function showTip() {
	$('#tip').show('fast');
}

function hideTip() {
	$('#tip').hide();
}


function showTab(id) {
	if(activeTabCount >= id) {			
		for (var x = 1; x <= tabCount; x++) {				
			$('#tablink' + x).removeClass('active');				
			$('#tab' + x).hide();
		}		
		
		$('#tablink' + id).addClass('active');		
		$('#tab' + id).show("slow");
	} else
		return false;
}

function clearForm(tabId) {

$('#tab'+tabId+' .clearable').each(function() {
		var type = this.type;	
		if(type == 'text' || type == 'textarea')
			this.value = '';
		if(type == 'select-one')
			this.selectedIndex = 0;	
	}
);
};

/*******************************/

function getCompanyTypeById() {
	switch($('#companyType').val()) {
				case '1':
					companyType = 'Restaurant';
				break;
				case '2':
					companyType = 'Hôtel';
				break;
				case '3':
					companyType = 'Magasin';
				break;
				case '4':
					companyType = 'Autre';
				break;	
			}
		return companyType;	
}

/* FORM OFFER INTERNET */

function validateForm1_1() {
	
		var errors = '';

		$(".tab-holder .errormsg").hide();
		
		if($('#merchantId').val() == '') { errors = true; $('#merchantIdError').show();}
		else {
			if($('#merchantId').val().length < 7) { errors = true; $('#merchantIdShortError').show();};
		}
		
		if($('#companyName').val() == '') { errors = true; $('#companyNameError').show();};
		if($('#companyType').val() == '') { errors = true; $('#companyTypeError').show();};
		if($('#address').val() == '') { errors = true; $('#addressError').show();};
		if($('#postCode').val() == '') { errors = true; $('#postCodeError').show();};
		if($('#city').val() == '') { errors = true; $('#cityError').show();};
		if($('#merchantName').val() == '') { errors = true; $('#merchantNameError').show();};
		if($('#phone').val() == '') { errors = true; $('#phoneError').show();};
		if(!validateEmail($('#emailAccount').val())) { errors = true; $('#emailAccountError').show();};
		
		if(!errors){				
				activeTabCount = 2;
				prepareTab1_2();
				showTab(2);
		
				return false;
		}
	}

function prepareTab1_2() {
	selectedId = $('#companyType').val();
	$('#tab2 #div-offer2 .formline').hide();
	$('#tab2 #divDateFrom').show();
	$('#tab2 #divDateTo').show();
	$('#tab2 .divBtns').show();
	
	switch(selectedId) {
		case '1':					
			$('#offerType1').show();
			$('#offerType2').hide();
			$('#offerType3').hide();
			$('#divCompanyDescription').show();
			$('#divOfferType').show();
			$('#divOfferDetails').show();
			$('#divValidPeriod').show();		
			$('#divValidate2').show();			
			selectOfferType1_2(1);
		break;
		
		case '2':
			$('#offerType1').hide();
			$('#offerType2').show();
			$('#offerType3').hide();
			$('#divCompanyDescription').show();
			$('#divOfferType').show();
			$('#divOfferDetails').show();
			$('#divValidPeriod').show();
			$('#divValidate2').show();
			
			selectOfferType1_2(2);			
		break;
		
		case '3':
			$('#offerType1').hide();
			$('#offerType2').hide();
			$('#offerType3').show();
			$('#divCompanyDescription').show();
			$('#divOfferType').show();
			$('#divOfferDetails').show();
			$('#divValidPeriod').show();		
			$('#divValidate2').show();				
			selectOfferType1_2(3);					
		break;	
		
		case '4':
			$('#offerType1').hide();
			$('#offerType2').hide();
			$('#offerType3').show();
			$('#divCompanyDescription').show();
			$('#divOfferType').show();
			$('#divOfferDetails').show();
			$('#divValidPeriod').show();		
			$('#divValidate2').show();				
			selectOfferType1_2(3);					
		break;	
	}	
}

function selectOfferType1_2(id) {
	
	valueId = $('#offerType' + id).val();
	$('.child').hide();	
	$('#divOfferType' + id + '-' + valueId).slideDown("slow");	
	if(id == 2) {
		if(valueId == 2)
			$('#divOfferType2-2-1').slideDown();
		selectOfferType1_2_4();
	}
}

function selectOfferType1_2_4() {
	
	if($('#offerType2').val() == 4) {
		if($('#offerType2-4').val() == 3){
			$('#divOfferType2-4-3').slideDown("slow");			
		}else {
			$('#divOfferType2-4-3').slideUp("slow");
		}
	}
}

function validateForm1_2() {
	var companyDescriptionValue;
	var offerDetailsValue;
	var errors = '';
	
	$(".tab-holder .errormsg").hide();
	
	companyDescriptionValue = $('#companyDescription').val();
	offerDetailsValue = $('#offerDetails').val();
	companyType =  $('#companyType').val();
	
	switch(companyType) {
		case '1':
			if($('#offerType1').val() == '0') { errors = true; $('#offerTypeError').show();};
			if($('#offerType1').val() == '1') {
				if($('#offerType1-1').val() == '') { errors = true;$('#offerType1-1Error').show();};
			}			
			if($('#offerType1').val() == '2') {
				if($('#offerType1-2').val() == '') { errors = true;$('#offerType1-2Error').show();};
				if($('#offerType1-2').val() > 6) { errors = true;$('#offerType1-2Error7').show();};
			}			
			if($('#offerType1').val() == '7') {
				if($('#offerType1-7').val() == '') { errors = true;$('#offerType1-7Error').show();};
			}
		break;
		
		case '2':
			if($('#offerType2').val() == '0') { errors = true;$('#offerTypeError').show();};			
			if($('#offerType2').val() == '1') {
				if($('#offerType2-1').val() == '') { errors = true;$('#offerType2-1Error').show();};
			}			
			if($('#offerType2').val() == '2') {
				if($('#offerType2-2').val() == '') { errors = true;$('#offerType2-2Error').show();};
				if($('#offerType2-2-1').val() == '') { errors = true;$('#offerType2-2-1Error').show();};
			}			
			if($('#offerType2').val() == '3') {
				if($('#offerType2-3').val() == '') { errors = true;$('#offerType2-3Error').show();};
			}			
			if($('#offerType2').val() == '4') {
				if($('#offerType2-4').val() == '0') { errors = true;$('#offerType2-4Error').show();};
				if($('#offerType2-4').val() == '3') {
					if($('#offerType2-4-3').val() == '') { errors = true;$('#offerType2-4-3Error').show();};
				}
			}			
			if($('#offerType2').val() == '5') {
				if($('#offerType2-5').val() == '') { errors = true;$('#offerType2-5Error').show();};
			}
		break;
		
		case '3':
			if($('#offerType3').val() == '0') { errors = true;	$('#offerTypeError').show();};		
			if($('#offerType3').val() == '1') {
				if($('#offerType3-1').val() == '') { errors = true;$('#offerType3-1Error').show();};
			}			
			if($('#offerType3').val() == '3') {
				if($('#offerType3-3').val() == '') { errors = true;$('#offerType3-3Error').show();};
			}
		break;
		
		case '4':
			if($('#offerType3').val() == '0') { errors = true;	$('#offerTypeError').show();};		
			if($('#offerType3').val() == '1') {
				if($('#offerType3-1').val() == '') { errors = true;$('#offerType3-1Error').show();};
			}			
			if($('#offerType3').val() == '3') {
				if($('#offerType3-3').val() == '') { errors = true;$('#offerType3-3Error').show();};
			}
		break;
	}
			
	if($('#companyDescription').val() == '' || companyDescriptionValue.length > 1500) { errors = true;$('#companyDescriptionError').show();};
	if($('#offerDetails').val() == '' || offerDetailsValue.length > 1500) { errors = true;	$('#offerDetailsError').show();};
	if($('#dateFrom').val() == '') { errors = true; $('#dateFromError').show();};
	if($('#dateTo').val() == '') { errors = true; $('#dateToError').show();};		
			
	if(!errors){	
		activeTabCount = 3;
		prepareTab1_3();
		showTab(3);

		return false;
	}
}

function prepareTab1_3() {

	$('#tab3 #div-offer3 .formline').hide();
	$('#tab3 .divBtns').show();
	$('#divSelectBy').show();
	$('#divWebSite2').show();
	$('#divPhone2').show();
	$('#divPromotion').show();
	
	selectByChange();
}

function selectByChange() {

	sel_1 = $("input[@id='selectBy_1']:checked").val() == 1;	
	sel_2 = $("input[@id='selectBy_2']:checked").val() == 1;	
	sel_3 = $("input[@id='selectBy_3']:checked").val() == 1;	
	
	if (sel_1 == true) {
			$('#divPromotion').slideDown("slow");
			
			if($("input[@name='promotion']:checked").val() == 0) {
				$("#divSelectBy-1-1").slideUp('slow'); 
			}else {
				$("#divSelectBy-1-1").slideDown('slow');
			}
	}
	if (sel_2 == true) {
			$('#divPromotion').slideDown("slow");
			
			if($("input[@name='promotion']:checked").val() == 0) {
				$("#divSelectBy-2-1").slideUp('slow'); 
			}else {
				$("#divSelectBy-2-1").slideDown('slow');
			}
	}
	/*if (sel_3 == true) {
			$('#divSelectBy-3-1').slideDown("slow");
	}else {
		$('#divSelectBy-3-1').slideUp("slow");
	}*/
}

function validateForm3() {
	
	var errors = '';
	$(".tab-holder .errormsg").hide();

	sel_1 = $("input[@id='selectBy_1']:checked").val() == 1;	
	sel_2 = $("input[@id='selectBy_2']:checked").val() == 1;	
	sel_3 = $("input[@id='selectBy_3']:checked").val() == 1;	

	if ((sel_1 + sel_2 + sel_3) == 0){
		errors = true;$('#selectByError').show();
	} else {
		if (sel_1) {			
			if($('#phone2').val() == '') { errors = true; $('#phone2Error').show();}
			if($("input[@name='promotion']:checked").val() == 1) {
				if($('#selectBy-1-1').val() == '') { errors = true;$('#selectBy-1-1Error').show();}
			}
		}
		if (sel_2) {			
			if($('#webSite2').val() == '') { errors = true; $('#webSite2Error').show();}
			if($("input[@name='promotion']:checked").val() == 1) {
				if($('#selectBy-2-1').val() == '') { errors = true;$('#selectBy-2-1Error').show();}
			}
		}
		
		/*if (sel_3) {			
			if($('#selectBy-3-1').val() == '') { errors = true;$('#selectBy-3-1Error').show();}
		}*/	
	}
		
	if(!errors){		
		activeTabCount = 4;
		buildResults();
		showTab(4);

		return false;
	}
}

function buildResults() {
	var results = '';
	var results2 = '';
	
	companyType = getCompanyTypeById();
	
	results +=  '<div class="formresult">'				+
							'<label>N° commerçant</label>' + 949 + $('#merchantId').val()+ '</div>'								+
							'<div class="formresult"><label>Nom du commerce</label>'				+ $('#companyName').val()	+ '</div>' +
							'<div class="formresult"><label>Type d\'établissement</label>'	+ companyType+ '</div>';
	
	results +=  '<div class="formresult"><label>Adresse</label>' 				+ $('#address').val() 			+ '</div>' +
							'<div class="formresult"><label>Code postal</label>' 		+ $('#postCode').val() 			+ '</div>' +
							'<div class="formresult"><label>Ville</label>' 					+ $('#city').val() 					+ '</div>' +
							'<div class="formresult"><label>Nom du contact</label>' 	+ $('#merchantName').val() 	+ '</div>' +
							'<div class="formresult"><label>Téléphone</label>' 			+ $('#phone').val() 				+ '</div>' +
							'<div class="formresult"><label>Email</label>' 					+ $('#emailAccount').val()	+ '</div>';
							
	if($('#webSite').val()) { results += '<div class="formresult"><label>Site internet</label>' 	+ $('#webSite').val() + '</div>'; }
	
	results += '<div class="formresult"><label>Description de votre enseigne</label><div style="display:block; float:left; width:375px;" >' + $('#companyDescription').val() + '</div></div>';
	
	switch($('#companyType').val()) {
		case '1':
			if($('#offerType1').val() == '1') 
				results += '<div class="formresult"><label>Modèle de l\'offre</label>Réduction de ' + $('#offerType1-1').val() + '% sur l\'addition</div>';				
			if($('#offerType1').val() == '2') 
				results += '<div class="formresult"><label>Modèle de l\'offre</label>' + ' Bouteille(s) de champagne/vin. ' + 'Personnes:' + $('#offerType1-2').val() +'</div>';
			if($('#offerType1').val() == '3') 
				results += '<div class="formresult"><label>Modèle de l\'offre</label>1 coupe de champagne offerte par personne</div>';
			if($('#offerType1').val() == '4') 
				results += '<div class="formresult"><label>Modèle de l\'offre</label>Entrée ou Dessert offert</div>';	
			if($('#offerType1').val() == '5') 
				results += '<div class="formresult"><label>Modèle de l\'offre</label>Gâteau d’anniversaire offert</div>';		
			if($('#offerType1').val() == '6') 
				results += '<div class="formresult"><label>Modèle de l\'offre</label>Un apéritif ou digestif offert par convive</div>';	
			if($('#offerType1').val() == '7') 
				results += '<div class="formresult"><label>Modèle de l\'offre</label>Autre - ' + $('#offerType1-7').val() + '</div>';
									
		break;
		case '2':
			if($('#offerType2').val() == '1') 
				results += '<div class="formresult"><label>Modèle de l\'offre</label>' + $('#offerType2-1').val() 	+ '% de remise sur le séjour</div>';
			if($('#offerType2').val() == '2') { 
				results += '<div class="formresult"><label>Modèle de l\'offre</label>' + $('#offerType2-2').val() 	+ ' nuit(s) offerte(s) pour ' + $('#offerType2-2-1').val() + ' nuit(s) minimum</div>';
				results += '<div class="formresult"><label>&nbsp;</label>' + $('#offerType2-2-1').val() + ' nuit(s) minimum</div>';
			}
			if($('#offerType2').val() == '3') 
				results += '<div class="formresult"><label>Modèle de l\'offre</label>' + $('#offerType2-3').val() 	+ ' package exclusif</div>';
			if($('#offerType2').val() == '4') 
				if($('#offerType2-4').val() == '1') results += '<div class="formresult"><label>Modèle de l\'offre</label>Accueil VIP - 1 bouteille de champagne</div>';
				if($('#offerType2-4').val() == '2') results += '<div class="formresult"><label>Modèle de l\'offre</label>Accueil VIP - Un bouquet de fleurs</div>';
				if($('#offerType2-4').val() == '3') results += '<div class="formresult"><label>Modèle de l\'offre</label>Accueil VIP - AUTRE - ' + $('#offerType2-4-3').val() + '</div>';				
			if($('#offerType2').val() == '5') 
				results += '<div class="formresult"><label>Modèle de l\'offre</label>AUTRE - ' + $('#offerType2-5').val() + '</div>';			
		break;
		case '3':
			if($('#offerType3').val() == '1') 
				results += '<div class="formresult"><label>Modèle de l\'offre</label>Réduction pour tout achat à hauteur de ' + $('#offerType3-1').val() + '%</div>';
			if($('#offerType3').val() == '2') 
				results += '<div class="formresult"><label>Modèle de l\'offre</label>Cadeau surprise</div>';	
			if($('#offerType3').val() == '3') 
				results += '<div class="formresult"><label>Modèle de l\'offre</label>Autre - ' + $('#offerType3-3').val() + '</div>';
		break;
		case '4':
			if($('#offerType3').val() == '1') 
				results += '<div class="formresult"><label>Modèle de l\'offre</label>Réduction pour tout achat à hauteur de ' + $('#offerType3-1').val() + '%</div>';
			if($('#offerType3').val() == '2') 
				results += '<div class="formresult"><label>Modèle de l\'offre</label>Cadeau surprise</div>';	
			if($('#offerType3').val() == '3') 
				results += '<div class="formresult"><label>Modèle de l\'offre</label>Autre - ' + $('#offerType3-3').val() + '</div>';
		break;	
	}						
	
	results += '<div class="formresult"><label>Détails et conditions de l\'offre</label><div style="display:block; float:left; width:375px;" >' + $('#offerDetails').val() + '</div></div>';
	results += '<div class="formresult"><label>Validité de l\'offre</label> Du ' + $('#dateFrom').val() + ' au ' + $('#dateTo').val() + '</div>';
	
	sel_1 = $("input[@id='selectBy_1']:checked").val() == 1;	
	sel_2 = $("input[@id='selectBy_2']:checked").val() == 1;	
	sel_3 = $("input[@id='selectBy_3']:checked").val() == 1;	
	if (sel_1) {			
		results += '<div class="formresult"><label>Par téléphone</label> ' + $('#phone2').val();
		if($("input[@name='promotion']:checked").val() == 1) {
			results += ' / Promo code: ' + $('#selectBy-1-1').val() + '</div>';
		}else { 
			results += '</div>'; 
		}		
	}
	if (sel_2) {			
		results += '<div class="formresult"><label>Par internet</label> ' + $('#webSite2').val();
		if($("input[@name='promotion']:checked").val() == 1) {
			results += ' / Promo code: ' + $('#selectBy-1-1').val() + '</div>';
		}else { 
			results += '</div>'; 
		}
	}
	if (sel_3) {			
		results += '<div class="formresult"><label>Coupon</label>';
		//results += $('#selectBy-3-1').val() + '</div>';
		results += 'Sur place avec coupon émis sur le site American Express SELECTS' + '</div>';
	}	
	$("#div-offer4").html(results);
	
}

function showConfirmation() {
	$('#header2').html("Confirmation");
	$('#text-above-tabs').html("Merci pour votre confiance ! Votre offre sera mise en ligne sous 3 semaines environ.");
}

function showConfirmationThanks() {
	$('#header2').html("Confirmation");
	$('#text-above-tabs').html("Merci pour votre confiance ! Votre message sera diffusé à vos clients sous 3 semaines maximum.");
}

/* FORM REMERCIEMENT */
function validateForm2_1() {
	var errors = '';
	$(".tab-holder .errormsg").hide();
	
	if($('#merchantId').val() == '') { errors = true;$('#merchantIdError').show();}
	else {
		if($('#merchantId').val().length < 7) { errors = true;$('#merchantIdShortError').show();};	
	}
	
	if($('#companyName').val() == '') { errors = true;$('#companyNameError').show();};
	if($('#companyType').val() == '') { errors = true;$('#companyTypeError').show();};
	if($('#address').val() == '') { errors = true;$('#addressError').show();};
	if($('#postCode').val() == '') { errors = true;$('#postCodeError').show();};
	if($('#city').val() == '') { errors = true;$('#cityError').show();};
	if($('#merchantName').val() == '') { errors = true;$('#merchantNameError').show();};
	if($('#phone').val() == '') { errors = true;$('#phoneError').show();};
	
	if(!validateEmail($('#emailAccount').val())) { errors = true;$('#emailAccountError').show();};
	
	if(!errors){
			activeTabCount = 2;
			showTab(2);
	
			return false;
	}
}

function validateForm2_2() {
	
	var content;
	var companyType;
	var errors = '';
	var offerDetailsValue;
	$(".tab-holder .errormsg").hide();

	offerDetailsValue = $('#offerDetails').val();
	if($('#offerDetails').val() == '' || offerDetailsValue.length > 80) { errors = true;$('#offerDetailsError').show();}
	if($('#dateFrom').val() == '') { errors = true;$('#dateFromError').show();}
	if($('#dateTo').val() == '') { errors = true;$('#dateToError').show();}
	
	if(!errors){
		activeTabCount = 3;
		companyType = getCompanyTypeById();
		content = '<div class="formresult"><label>N° commercant</label>949' 							+ $('#merchantId').val()  	+ '</div>' 	+
							'<div class="formresult"><label>Nom du commerce</label>' 							+ $('#companyName').val() 	+ '</div>' 	+
							'<div class="formresult"><label>Type d\'établissement</label>' 				+ companyType 							+ '</div>' 	+
							'<div class="formresult"><label>Adresse</label>' 											+ $('#address').val() 			+ '</div>' 	+ 
							'<div class="formresult"><label>Code postal</label>' 									+ $('#postCode').val() 			+ '</div>' 	+ 
							'<div class="formresult"><label>Ville</label>' 												+ $('#city').val() 					+ '</div>' 	+
							'<div class="formresult"><label>Nom du contact</label>' 								+ $('#merchantName').val() 	+ '</div>' 	+	
							'<div class="formresult"><label>Téléphone</label>' 										+ $('#phone').val() 				+ '</div>' 	+
							'<div class="formresult"><label>Email</label>' 												+ $('#emailAccount').val() 	+ '</div>';
							if($('#webSite').val())
								content += '<div class="formresult"><label>Site internet</label>'			+ $('#webSite').val() 			+ '</div>';
		content +='<div class="formresult"><label>Description de votre enseigne</label>'	+ $('#offerDetails').val() 	+ '</div>' 	+
							'<div class="formresult"><label>Validité de l\'offre</label>' 					+ $('#dateFrom').val() 			+ ' - ' + $('#dateTo').val()	+ '</div>';
							
		$('#div-offer3').html(content);
		showTab(3);
		return false;
	}
}

function clearFormNewToAmex() {
	$('#merchantId').val('');
	$('#companyName').val('');
	$('#date').val('');
	$('#companyType').val('');
	$('#companyAddress').val('');
	$('#companyZip').val('');
	$('#companyCity').val('');
	$('#merchantName').val('');
	$('#phone').val('');
	$('#webSite').val('');
	$('#message').val('');
	$('#filename').val('');
	$('#logo').val('');
}

function validateNewToAmexForm() {
	
	var errors = false;
	
	$(".tab-holder .errormsg").hide();
	
	if(($('#merchantId').val() == '') || ($('#merchantId').val().length != 7)) { errors = true; $('#merchantIdError').show();}
	if($('#companyName').val() == '') { errors = true; $('#companyNameError').show();}
	if($('#companyType').val() == '') { errors = true; $('#companyTypeError').show();}
	if($('#date').val() == '') { errors = true; $('#dateError').show();}
	if($('#companyAddress').val() == '') { errors = true; $('#companyAddressError').show();}
	if($('#companyZip').val() == '') { errors = true; $('#companyZipError').show();}
	if($('#companyCity').val() == '') { errors = true; $('#companyCityError').show();}
	if($('#merchantName').val() == '') { errors = true; $('#merchantNameError').show();}
	if($('#phone').val() == '') { errors = true; $('#phoneError').show();}
	
	if($('#message').val() == '') { errors = true; $('#messageError').show();}
	else if($('#message').val().length > 500) { errors = true; $('#messageLongError').show();}
	
	if($('#filename').val() == '') { errors = true; $('#filenameError').show();}
	
	if(!errors)
		document.getElementById('main_form').submit();
}

function showNewToAmexConfirmation() {
	$('#header2').html("Confirmation");
	$('#confirmation-text').html("Merci pour votre confiance ! Votre demande de parution a bien été enregistrée et votre message sera visible en ligne sous 8 semaines environ, après validation par notre comité de relecture. ");
}

function clearFormHotel() {
	$('#merchantId').val('');
	$('#nameOfTrade').val('');
	$('#address').val('');
	$('#postCode').val('');
	$('#city').val('');
	$('#pays').val('');
	$('#contactName').val('');
	$('#phone').val('');
	$('#fax').val('');
	$('#email').val('');
}

function validateFormHotel() {
	
	var errors = false;
	
	$(".tab-holder .errormsg").hide();
	
	merchantID  = new String();
	merchantID = $('#merchantId').val();
	
	if(($('#merchantId').val() == '') || (merchantID.length != 7)) { errors = true; $('#merchantIdError').show();}
	if($('#nameOfTrade').val() == '') { errors = true; $('#companyNameError').show();}
	if($('#contactName').val() == '') { errors = true; $('#nameOfTradeError').show();}
	if($('#address').val() == '') { errors = true; $('#addressError').show();}
	if($('#postCode').val() == '') { errors = true; $('#postCodeError').show();}
	if($('#city').val() == '') { errors = true; $('#cityError').show();}
	if($('#pays').val() == '') { errors = true; $('#paysError').show();}
	if($('#contactName').val() == '') { errors = true; $('#contactNameError').show();}
	if($('#phone').val() == '') { errors = true; $('#phoneError').show();}
	if(!validateEmail($('#email').val())) { errors = true; $('#emailError').show();}
	
	if(!errors) 
		document.getElementById('main_form').submit();
}

function showHotelHubConfirmation() {
	$('#header3').html("Confirmation");
	$('#confirmation-text').html("");
	$('#confirmation-text2').html("Merci pour votre confiance ! Nous reprendrons contact avec vous dans les meilleurs délais pour finaliser votre demande d’adhésion.");
}

function clearFormSelectionCorporate() {
	$('#merchantId').val('');
	$('#companyName').val('');
	$('#companyType').val('');
	$('#address').val('');
	$('#postCode').val('');
	$('#city').val('');
	$('#phone').val('');
}

function validateFormSelectionCorporate() {
	
	var errors = false;
	
	$(".tab-holder .errormsg").hide();
	
	merchantID  = new String();
	merchantID = $('#merchantId').val();
	
	if(($('#merchantId').val() == '') || (merchantID.length != 7)) { errors = true; $('#merchantIdError').show();}
	if($('#companyName').val() == '') { errors = true; $('#companyNameError').show();}
	if($('#companyType').val() == '0') { errors = true; $('#companyTypeError').show();}
	if($('#address').val() == '') { errors = true; $('#addressError').show();}
	if($('#postCode').val() == '') { errors = true; $('#postCodeError').show();}
	if($('#city').val() == '') { errors = true; $('#cityError').show();}
	
	if(!errors) 
		document.getElementById('main_form').submit();
}

function showSelectionCorporateConfirmation() {
	$('#header1').html("AVEC SELECTIONCORPORATE.FR OFFREZ-VOUS <br/>UNE CLIENTÈLE D’AFFAIRES");
	$('#header2').html("Confirmation");
	$('#confirmation-text').html("");
	$('#confirmation-text2').html("Merci pour votre confiance ! Vos informations seront mises en ligne pour une durée de 3 mois dans les 3 mois suivant votre demande.");
}




//]]>