var widthCalque = 736;
var timeoutFermetureCalque = 5000;




// function hpo_tracking(xiti_type,xiti_xtn2,xiti_page,ga_url)
function hpo_tracking(xiti_type,xiti_xtn2,xiti_page,ga_url)
{
	// alert(xiti_type + ' / ' + xiti_xtn2 + ' / ' + xiti_page + ' / ' + ga_url);
	// Xiti
	try { 
		xt_med(xiti_type,xiti_xtn2,xiti_page);
	} catch(err) {}
	
	// GA
	try { 
		pageTracker._trackPageview('/www/'+ga_url);
	} catch(err) {}
	
}

function partenaire_checkCP(champ) {
	if (isNaN(champ.value) || (champ.value.length != 5) || (champ.value.indexOf('.') != -1)) {
		return(false);
	}
	return(true);
}

function verifFormPartenaire()
{
	var objet = document.getElementById('partenaire_cp');
	var bTest = partenaire_checkCP(objet);
	if(!bTest)
	{
		alert('Veuillez saisir un code postal valide.');
		return false;
	}
	return true;
	
}


function buildAccordion(id) {
	/*
	$(id + " .accordion").accordion({
        autoHeight: false,
        header: '.accordionTitle',
        collapsible : true
    });
    */
    
    $(id + ' .accordion .accordionContent').attr('style', 'display: none;');
    $(id + ' .accordion .accordionContent:first').attr('style', 'display: block;');
    $(id + ' .accordion .accordionTitle').addClass('ui-state-default');
    $(id + ' .accordion .accordionTitle:first').addClass('ui-state-active');
    $(id + ' .accordion .accordionTitle:first').removeClass('ui-state-default');
    $(id + ' .accordion .accordionTitle').click(function() {
		// $(this).next().toggle('slow');
		if($(this).hasClass('ui-state-active')){
			$(this).removeClass('ui-state-active');
			$(this).addClass('ui-state-default');
		}
		else{
			$(this).addClass('ui-state-active');
			$(this).removeClass('ui-state-default');
		}
		$(this).next().slideToggle('');
		return false;
	});
	// }).next().hide();

    
}

$(document).ready(function () {
    buildAccordion('');
});

function changeDemandeDevisFonction(){
	var fonction = $('#fonction').val();
	if(fonction == 1){
		$('#autre_fonction_container').attr('style', 'display: block;');
        tFieldOblig[5] = '1';
        document.getElementById("verif"+tField[5]).className='verif';
	}
	else{
        document.getElementById('autre_fonction').value='';
		$('#autre_fonction_container').attr('style', 'display: none;');
        tFieldOblig[5] = '';
        document.getElementById("verif"+tField[5]).className='verif';
	}
	return true;
}

function changeDemandeDevisOffreOrigine(){
	
	var changement = $('#situation1');
	
	if(changement.attr('checked')){
		
		var origine = $('#offre_origine1');
	
		if(origine.attr('checked')){
			$('#tarif_reference_container').attr('style', 'display: block;');
		}
		else{
			$('#tarif_reference_container').attr('style', 'display: none;');
		}
		
		
	}
	return true;
}

function changeDemandeDevisSituation(){
	var changement = $('#situation1');
	
	if(changement.attr('checked')){
		$('#fournisseur').attr('style', 'display: block;');
		$('#mise_en_service').attr('style', 'display: none;');
		return true;
	}
	else
	{
		$('#fournisseur').attr('style', 'display: none;');
		$('#mise_en_service').attr('style', 'display: block;');
		var jour = $('#jour_mise_en_service').val();
		var mois = $('#mois_mise_en_service').val();
		var annee = $('#annee_mise_en_service').val();
		
		if(mois && jour && annee){
			document.getElementById("verif_date_mise_en_service").className='verif ok';
			return true;
		}
		else {
			document.getElementById("verif_date_mise_en_service").className='verif nok';
			return false;
		}
	}
	
}

function changeFournisseur(){
	var valueFournisseur = $('#fournisseur_actuel').val();
	
	if(valueFournisseur == '0' && $('#situation1').attr('checked')) {
		return false;
	}
	
	if(valueFournisseur == 1)
	{
		$('#fournisseur_autre').attr('style', 'display: block;');
		$('#veriffournisseur_autre').attr('style', 'display: block;');
		$('.label_fournisseur_autre').attr('style', 'display: block;');
	}
	else
	{
		$('#fournisseur_autre').attr('style', 'display: none;');
		$('#veriffournisseur_autre').attr('style', 'display: none;');
		$('.label_fournisseur_autre').attr('style', 'display: none;');
	}
	return true;
}


function hidePrevisuDemandeDevis(){
	$('#formulaire_demandedevis_previsu').attr('style', 'display: none;');
	$('#formulaire_demandedevis_champ').attr('style', 'display: block;');
}

function showPrevisuDemandeDevis(){
	
	var i=0;
	bRet = true;
	
	while (i<tField.length){
		obj = document.getElementById(tField[i]);
		bRet = bRet & hpo_forms_verif(obj, tFieldOblig[i], tFieldFunc[i]);
		i++;
	}
	if (bRet){
        
        // Si on est sur le formulaire de contact colectivités
        if(document.getElementById('secteur1'))
        	hpo_tracking('F','4','Collectivites::Contact::COLL_Contact_previsualisation','collectivites/contact/demande-de-contact-previsu');
        else // Sinon formulaire de contact professionnels
        	hpo_tracking('F','2','Professionnels::Contact::PRO_Contact_previsualisation','professionnels/contact/demande-de-contact-previsu');
        
        $('#formulaire_demandedevis_previsu').attr('style', 'display: block;');
		$('#formulaire_demandedevis_champ').attr('style', 'display: none;');
		
		var myFields = $('#tx_hpoforms_demandedevis').serialize();
		
		jQuery.ajax(
			{
				type: "POST",
				data: myFields,
				url: 'index.php?type=313',
				timeout: 45000,
				success: function(r) {
					$('#formulaire_demandedevis_previsu_content').html(r);
				}
			}
		);
        
    }
    else {alert("Veuillez renseigner les champs incorrects");}
	
}


function hidePrevisuPartenariat(){
	$('#formulaire_partenariat_previsu').attr('style', 'display: none;');
	$('#formulaire_partenariat_champ').attr('style', 'display: block;');
}

function showPrevisuPartenariat(){
	
	var i=0;
	bRet = true;
	
	while (i<tField.length){
		obj = document.getElementById(tField[i]);
		bRet = bRet & hpo_forms_verif(obj, tFieldOblig[i], tFieldFunc[i]);
		i++;
	}
	if (bRet){
        
        hpo_tracking('F','6','La_societe::Devenir_partenaire::INSTIT_Devenir_partners_Contact_previsualisation','la-societe/devenir-partenaire/demande-de-contact-previsu');
        
        $('#formulaire_partenariat_previsu').attr('style', 'display: block;');
		$('#formulaire_partenariat_champ').attr('style', 'display: none;');
		
		var myFields = $('#tx_hpoforms_partenariat').serialize();
		
		jQuery.ajax(
			{
				type: "POST",
				data: myFields,
				url: 'index.php?type=312',
				timeout: 45000,
				success: function(r) {
					$('#formulaire_partenariat_previsu_content').html(r);
				}
			}
		);
        
    }
    else {alert("Veuillez renseigner les champs incorrects");}
	
}


function changePartenariatActivite(){
	var valueActivite = $('#activite').val();
	
	if(valueActivite == 6)
	{
		$('#activite_autre').attr('style', 'display: block;');
		$('#verifactivite_autre').attr('style', 'display: block;');
		$('.label_activite_autre').attr('style', 'display: block;');
	}
	else
	{
		$('#activite_autre').attr('style', 'display: none;');
		$('#verifactivite_autre').attr('style', 'display: none;');
		$('.label_activite_autre').attr('style', 'display: none;');
	}
	return true;
}


function showFormPoserQuestion(id, univers, univers_orig, page_orig){
	
	hpo_tracking('F','8','Transverse::poser_question::TRANSV_poser_une_question','outils/faq/poserquestion');
	
	var el = document.getElementById(id);
	
	if(el.value == 'Saisissez votre question') {
		el.value = '';
	}
	
	hpoCalqueDialog.dialog('option', 'height', 'auto');
	hpoCalqueDialog.bind('dialogclose', function(event, ui) {
		el.value = '';
		hpo_tracking('F','8','Transverse::poser_question::TRANSV_poser_question_fermer','outils/faq/poserquestion/fermer');
	});
  
  // hpoCalqueDialog.load('index.php', {'type' : '311'; 'tx_hpoforms_pi1[question]' : el.value; 'tx_hpoforms_pi1[univers]' : univers; 'tx_hpoforms_pi1[univers_orig]' : univers_orig; 'tx_hpoforms_pi1[page_orig]' : page_orig});
	hpoCalqueDialog.load('index.php?type=311', {'tx_hpoforms_pi1[question]' : el.value, 'tx_hpoforms_pi1[univers]' : univers, 'tx_hpoforms_pi1[univers_orig]' : univers_orig, 'tx_hpoforms_pi1[page_orig]' : page_orig});
	hpoCalqueDialog.dialog('open');
	hpoCalqueDialog.attr('style', '');
	
	// showAjaxPage('index.php?type=311&tx_hpoforms_pi1[question]='+escape(el.value)+'&tx_hpoforms_pi1[univers]='+univers+'&tx_hpoforms_pi1[univers_orig]='+univers_orig+'&tx_hpoforms_pi1[page_orig]='+escape(page_orig));
	// showAjaxPage('index.php?type=311&tx_hpoforms_pi1[question]='+encodeURIComponent(el.value)+'&tx_hpoforms_pi1[univers]='+univers+'&tx_hpoforms_pi1[univers_orig]='+univers_orig+'&tx_hpoforms_pi1[page_orig]='+encodeURIComponent(page_orig));
	// showAjaxPage('index.php?type=311&tx_hpoforms_pi1[question]='+el.value+'&tx_hpoforms_pi1[univers]='+univers+'&tx_hpoforms_pi1[univers_orig]='+univers_orig+'&tx_hpoforms_pi1[page_orig]='+page_orig);
}


function hidePrevisuCandidatureLibre(){
	$('#formulaire_candidaturelibre_previsu').attr('style', 'display: none;');
	$('#formulaire_candidaturelibre_champ').attr('style', 'display: block;');
}

function showPrevisuCandidatureLibre(){
	
	// eval(document.getElementById('ajaxVerif').value);
	
	var i=0;
	bRet = true;
	
	while (i<tField.length){
		obj = document.getElementById(tField[i]);
		bRet = bRet & hpo_forms_verif(obj, tFieldOblig[i], tFieldFunc[i]);
		i++;
	}
	if (bRet){
        
        $('#formulaire_candidaturelibre_previsu').attr('style', 'display: block;');
		$('#formulaire_candidaturelibre_champ').attr('style', 'display: none;');
		
		var myFields = $('#tx_hpoforms_candidaturelibre').serialize();
		var lm = $('#lettre').val();
		var cv = $('#cv').val();
		
		myFields += '&tx_hpoforms_pi1[lettre]=' + lm + '&tx_hpoforms_pi1[cv]=' + cv;
		
		jQuery.ajax(
			{
				type: "POST",
				data: myFields,
				url: 'index.php?type=310',
				timeout: 45000,
				success: function(r) {
					$('#formulaire_candidaturelibre_previsu_content').html(r);
				}
			}
		);
        
    }
    else {alert("Veuillez renseigner les champs incorrects");}
}

function showFormCandidatureLibre(){
	
	//hpoCalqueDialog.dialog('option', 'height', 'auto');
	//showAjaxPage('index.php?type=309');
	
	hpoCalqueDialog.html('<iframe frameborder="0" width="676" height="630" src="index.php?type=309"></iframe>');
	
	hpoCalqueDialog.dialog('open');
	hpoCalqueDialog.attr('style', '');
	
	
}

function changeCandidatureType(){
	
	var valueType = $('#type').val();
	
	$('#duree').attr('style', 'display: none;');
	$('#verifduree').attr('style', 'display: none;');
	$('.label_duree').attr('style', 'display: none;');
	
	if(valueType == 4 || valueType == 5 || valueType == 6){
		$('#duree').attr('style', 'display: block;');
		$('#verifduree').attr('style', 'display: block;');
		$('.label_duree').attr('style', 'display: block;');
	}
	
	return true;
	
}

function emailConfirm()
{
	var valEmail = $('#email').val();
	var valEmail2 = $('#email_confirm').val();
	if(valEmail2 == '') {
		return false;
	}
	else if(valEmail2 != valEmail) {
		return false;
	}
	
	return true;
}

function showPrevisuCandidature(){
	
	var i=0;
	bRet = true;
	
	while (i<tField.length){
		obj = document.getElementById(tField[i]);
		bRet = bRet & hpo_forms_verif(obj, tFieldOblig[i], tFieldFunc[i]);
		i++;
	}
	
	if (bRet) {
		$('#formulaire_candidature_previsu').attr('style', 'display: block;');
		$('#formulaire_candidature_champ').attr('style', 'display: none;');
		
		var myFields = $('#tx_hpoforms_candidature').serialize();
		var lm = $('#lettre').val();
		var cv = $('#cv').val();
		
		myFields += '&tx_hpoforms_pi1[lettre]=' + lm + '&tx_hpoforms_pi1[cv]=' + cv;
		
		jQuery.ajax(
			{
				type: "POST",
				data: myFields,
				url: 'index.php?type=308',
				timeout: 45000,
				success: function(r) {
					$('#formulaire_candidature_previsu_content').html(r);
					// $('body').animate({scrollTop: $("#formulaire_candidature_previsu").offset().top}, 'slow');
				}
			}
		);
        
    }
    else {alert("Veuillez renseigner les champs incorrects");}
	
}

function hidePrevisuCandidature(){
	$('#formulaire_candidature_previsu').attr('style', 'display: none;');
	$('#formulaire_candidature_champ').attr('style', 'display: block;');
}


function afficheFormPostuler(){
	$('#formulaire_candidature_champ').attr('style', 'display: block;');
	$('#bouton_postuler').attr('style', 'display: none;');
}

function encartAlerteInfoSelectAll(el){
	
	$(el).parent().children('.tx-hpoindexbdd-pi1').children('input').each(function(check){
		if(el.checked) {this.checked = true;}
		else {this.checked = false;}
	});
}

function encartAlerteInfoChange(el){
	
	var allChecked = true;
	if(el.checked){
		$(el).parent('.tx-hpoindexbdd-pi1').children('input').each(function(check){
			if(!this.checked) {allChecked = false;}
		});
	}
	else{allChecked = false;}
	
	if(allChecked) {
		document.getElementById('encartAlerteInfoSelectAllinput').checked = true;
	}
	else {
		document.getElementById('encartAlerteInfoSelectAllinput').checked = false;
	}
}


function showFormAlerteInfo(){
	var el = document.getElementById('encart_alerte_info_email');
	if(!checkEmail(el)) {
		$(el).addClass('inputError');
		hpo_tracking('F','8','outils::abonnement::alerteinfo::erreur','outils/abonnement/alerteinfo/erreur');
	}
	else
	{
		$(el).removeClass('inputError');
		var theme = '';
		var bTest = false;
		$(el).parent().children('.tx-hpoindexbdd-pi1').children('input').each(function(check){
			if(this.checked){
				bTest = true;
				theme += '&' + this.name + '=1';
			}
		});
		if(bTest)
		{
			hpo_tracking('F','8','outils::abonnement::alerteinfo::ok','outils/abonnement/alerteinfo/ok');
			hpoCalqueDialog.dialog('option', 'height', 'auto');
			hpoCalqueDialog.bind('dialogclose', function(event, ui) {
				document.getElementById('encart_alerte_info_email').value = '';
				hpo_tracking('F','8','outils::abonnement::alerteinfo::fermer','outils/abonnement/alerteinfo/fermer');
			});
			showAjaxPage('index.php?type=307&tx_hpoforms_pi1[email]='+el.value+theme);
		}
		else {
			hpo_tracking('F','8','outils::abonnement::alerteinfo::erreur','outils/abonnement/alerteinfo/erreur');
			alert('Veuillez choisir au moins un thème.');
		}
	}
}

function changeAlerteinfoQualite(){
	var valueQualite = $('#qualite').val();
	$('#publication_titre').attr('style', 'display: none;');
	$('#verifpublication_titre').attr('style', 'display: none;');
	$('.label_publication_titre').attr('style', 'display: none;');
	$('#publication_site').attr('style', 'display: none;');
	$('#verifpublication_site').attr('style', 'display: none;');
	$('.label_publication_site').attr('style', 'display: none;');
	
	if(valueQualite == 1){
		$('#publication_titre').attr('style', 'display: block;');
		$('#verifpublication_titre').attr('style', 'display: block;');
		$('.label_publication_titre').attr('style', 'display: block;');
		$('#publication_site').attr('style', 'display: block;');
		$('#verifpublication_site').attr('style', 'display: block;');
		$('.label_publication_site').attr('style', 'display: block;');
	}
	return true;
}

function changeSyntheseQualite(){
	var valueQualite = $('#qualite').val();
	$('#publication_titre').attr('style', 'display: none;');
	$('#verifpublication_titre').attr('style', 'display: none;');
	$('.label_publication_titre').attr('style', 'display: none;');
	$('#publication_site').attr('style', 'display: none;');
	$('#verifpublication_site').attr('style', 'display: none;');
	$('.label_publication_site').attr('style', 'display: none;');
	$('#fonction').attr('style', 'display: none;');
	$('#veriffonction').attr('style', 'display: none;');
	$('.label_fonction').attr('style', 'display: none;');
	
	$('#autre').attr('style', 'display: none;');
	$('#verifautre').attr('style', 'display: none;');
	$('.label_autre').attr('style', 'display: none;');
	
	if(valueQualite == 0) return false;
	
	if(valueQualite == 1){
		$('#publication_titre').attr('style', 'display: block;');
		$('#verifpublication_titre').attr('style', 'display: block;');
		$('.label_publication_titre').attr('style', 'display: block;');
		$('#publication_site').attr('style', 'display: block;');
		$('#verifpublication_site').attr('style', 'display: block;');
		$('.label_publication_site').attr('style', 'display: block;');
		$('#fonction').attr('style', 'display: block;');
		$('#veriffonction').attr('style', 'display: block;');
		$('.label_fonction').attr('style', 'display: block;');
	}
	if(valueQualite == 7){
		$('#autre').attr('style', 'display: block;');
		$('#verifautre').attr('style', 'display: block;');
		$('.label_autre').attr('style', 'display: block;');
	}
	return true;
}

function showFormNewsletter(){
	var el = document.getElementById('header_input_newsletter');
	if(el.value == '') {
		alert('Veuillez indiquer votre email.');
		hpo_tracking('F','8','Transverse::footer::TRANSV_newsletter_erreur','newsletter/erreur');
	}
	else if(!checkEmail(el)) {
		$(el).addClass('inputError');
		hpo_tracking('F','8','Transverse::footer::TRANSV_newsletter_erreur','newsletter/erreur');
	}
	else{
		hpo_tracking('F','8','Transverse::footer::TRANSV_newsletter_ok','newsletter/ok');
		$(el).removeClass('inputError');
		hpoCalqueDialog.dialog('option', 'height', 'auto');
		hpoCalqueDialog.bind('dialogclose', function(event, ui) {
			document.getElementById('header_input_newsletter').value = '';
			hpo_tracking('F','8','Transverse::footer::TRANSV_newsletter_fermer','newsletter/fermer');
		});
		// hpoCalqueDialog.dialog('option', 'height', 600);
		showAjaxPage('index.php?type=302&tx_hpoforms_pi1[email]='+el.value);
	}
}

var tOptionProfil= new Object;
function changeProfil(){
    
    var client = document.getElementById('is_client1').checked;
    
    var valueProfil = $('#profil').val();
    
    valueOk = 0;
    
    if (!tOptionProfil.length)
        tOptionProfil = $('#profil option').clone();
    $('#profil').empty();
    $('#profil').append(tOptionProfil);
    
    $('#profil option').each(function(index) {
        if ($(this).val() == valueProfil)
            document.getElementById('profil').selectedIndex=index;    
        if (client && $(this).val()!=0 && $(this).val()!=4 && $(this).val()!=5 && $(this).val()!=6 ){
            $(this).remove();
            if ($(this).val() == valueProfil)
                valueOk = 1;    
        }
    });
    
    if (valueOk)
        document.getElementById('profil').selectedIndex=0;
    
    changeContactProfil();
    return true;    
}

function changeContactProfil(){
    
    var client = document.getElementById('is_client1').checked;
    var noclient = document.getElementById('is_client2').checked;
    var valueProfil = $('#profil').val();
    
    $('#ref_client').attr('style', 'display: none;');
    $('#verifref_client').attr('style', 'display: none;');
    $('.label_ref_client').attr('style', 'display: none;');
                
    $('#societe_entite').attr('style', 'display: none;');
    $('#verifsociete_entite').attr('style', 'display: none;');
    $('.label_societe_entite').attr('style', 'display: none;');
                
    $('#profil_libre').attr('style', 'display: none;');
    $('#verifprofil_libre').attr('style', 'display: none;');
    $('.label_profil_libre').attr('style', 'display: none;');
    $('#ref_client').removeClass('ref_client_particulier');
    
    if (valueProfil == 0){
        // document.getElementById("verifprofil").innerHTML='Ce champ est obligatoire, veuillez le renseigner';
        return false;
    }
    
    if (valueProfil == 4 || valueProfil == 5 || valueProfil == 6){
        if (client) {
            $('#ref_client').attr('style', 'display: block;');
            $('#verifref_client').attr('style', 'display: block;');
            $('.label_ref_client').attr('style', 'display: block;');
            if (valueProfil == 4){
                $('#ref_client').addClass('ref_client_particulier');
                $('.label_ref_client').html('Référence client');
            } else {
                $('.label_ref_client').html('Référence client ou N° de contrat');
            }
        }
        
        if (valueProfil == 5 || valueProfil == 6){
            if (valueProfil == 5){
                $('.label_societe_entite').html('Nom de la société');
            } else {
                $('.label_societe_entite').html('Nom de l\'entité');
            }
            $('#societe_entite').attr('style', 'display: block;');
            $('#verifsociete_entite').attr('style', 'display: block;');
            $('.label_societe_entite').attr('style', 'display: block;');
        }            
    } else if(valueProfil == 3){
        $('#profil_libre').attr('style', 'display: block;');
        $('#verifprofil_libre').attr('style', 'display: block;');
        $('.label_profil_libre').attr('style', 'display: block;');
    }
    
    // change object by AJAX
        profil = document.getElementById('profil').options[document.getElementById('profil').selectedIndex].value;
        objet = document.getElementById('objet').options[document.getElementById('objet').selectedIndex].value;
        
        myFields = '&tx_hpoforms_pi1[profil]=' + profil + '&tx_hpoforms_pi1[objet]=' + objet;
        
        jQuery.ajax(
            {
                type: "POST",
                data: myFields,
                url: 'index.php?type=321',
                timeout: 45000,
                success: function(retVal) {
                    $('#objet').replaceWith(retVal);
                    hpo_forms_verif(document.getElementById('objet'),'1','changeContactObjet');
                }
            }
        );
        
    return true;
    
}

function changeContactObjet(){
	
	var valueObjet = $('#objet').val();
	$('#type_desinscription').attr('style', 'display: none;');
	$('#veriftype_desinscription').attr('style', 'display: none;');
	$('.label_type_desinscription').attr('style', 'display: none;');
	$('#objet_libre').attr('style', 'display: none;');
	$('#verifobjet_libre').attr('style', 'display: none;');
	$('.label_objet_libre').attr('style', 'display: none;');
    $('#adresse').attr('style', 'display: none;');
    $('#verifadresse').attr('style', 'display: none;');
    $('.label_adresse').attr('style', 'display: none;');
    $('#adressehtml').attr('style', 'display: none;');
    $('.label_adressehtml').attr('style', 'display: none;');
	// adresse
    tFieldOblig[10] = '';
    
	if(valueObjet == 0){
		// document.getElementById("verifobjet").innerHTML='Ce champ est obligatoire, veuillez le renseigner';
		return false;
	}
	else if(valueObjet == 1){
		$('#type_desinscription').attr('style', 'display: block;');
		$('#veriftype_desinscription').attr('style', 'display: block;');
		$('.label_type_desinscription').attr('style', 'display: block;');
		document.getElementById("verifobjet").innerHTML='';
	} else if(valueObjet == 2){
		$('#objet_libre').attr('style', 'display: block;');
		$('#verifobjet_libre').attr('style', 'display: block;');
		$('.label_objet_libre').attr('style', 'display: block;');
		document.getElementById("verifobjet").innerHTML='';
    } else if(valueObjet == 9 || valueObjet == 10){
        tFieldOblig[10] = '1';
        $('#adresse').attr('style', 'display: block;');
        $('#verifadresse').attr('style', 'display: block;');
        $('.label_adresse').attr('style', 'display: block;');
        $('#adressehtml').attr('style', 'display: block;');
        $('.label_adressehtml').attr('style', 'display: block;');
        document.getElementById("verifobjet").innerHTML='';
    }
    return true;
	
}


function showPrevisuContact(){
	
	var i=0;
	bRet = true;
	
	while (i<tField.length){
		obj = document.getElementById(tField[i]);
		bRet = bRet & hpo_forms_verif(obj, tFieldOblig[i], tFieldFunc[i]);
		i++;
	}
	if (bRet){
        
        hpo_tracking('F','8','Transverse::footer::TRANSV Contact Previsualisation','outils/contact/preview');
        
		var myFields = $('#tx_hpoforms_contact').serialize();
		
		jQuery.ajax(
			{
				type: "POST",
				data: myFields,
				url: 'index.php?type=303',
				timeout: 45000,
				success: function(r) {
					$('#formulaire_contact_previsu_content').html(r);
					$('#formulaire_contact_previsu').attr('style', 'display: block;');
					$('#formulaire_contact_champ').attr('style', 'display: none;');
				}
			}
		);
        
    }
    else 
    {
    	hpo_tracking('F','8','Transverse::footer::TRANSV Contact erreur','outils/contact/erreur');
    	alert("Veuillez renseigner les champs incorrects");
    }
	
}

function hidePrevisuContact(){
	hpo_tracking('F','8','Transverse::footer::TRANSV Contact Correction','outils/contact/corriger');
	$('#formulaire_contact_previsu').attr('style', 'display: none;');
	$('#formulaire_contact_champ').attr('style', 'display: block;');
}

function changeFilterActuUnivers(){
	var curVal = $('#news_filter_univers').val();
	if(curVal) {$('#news_filter_theme').attr('disabled', 'disabled');}
	else {$('#news_filter_theme').attr('disabled', '');}
}

function changeFilterActuTheme(){
	var curVal = $('#news_filter_theme').val();
	if(curVal) {$('#news_filter_univers').attr('disabled', 'disabled');}
	else {$('#news_filter_univers').attr('disabled', '');}
}

function showCalque(el){
	
	var calqueContent = $(el).parent().children('.calqueContent').html();
	hpoCalqueDialog.html(calqueContent);
	hpoCalqueDialog.dialog('open');
	hpoCalqueDialog.attr('style', '');
}

function loadAjaxMenu(urlPageAjaxMenu)
{
		//alert(urlPageAjaxMenu);
		$('#MENU_FILLE').load(urlPageAjaxMenu);	
}

function deplaceMenu(urlPageAjaxMenu)
{
		$('#MENU_FILLE').insertAfter('#HEADER');
		setTimeout("loadAjaxMenu('"+urlPageAjaxMenu+"')",200);
}

var timerIn;
var timerOut;
function showGlossaryDiv(divElement){
    timerIn = setTimeout( function(){
        //alert('show');
        $("SPAN.definition").hide();
        $("#"+divElement).show();
    }, 500);
    clearTimeout(timerOut);
}
function hideGlossaryDiv(divElement){
    clearTimeout(timerIn);
    isActive = 0;
    if (document.getElementById(divElement).style.display!='none'){
        isActive = 1;
    }
    $("SPAN.definition").hide();
    if (isActive == 1){        
        $("#"+divElement).show();
    }
    timerOut = setTimeout( function(){
        $("#"+divElement).fadeOut("fast");
        clearTimer();
    }, 250);    
}
function clearTimer(){
    clearTimeout(timerIn);
    clearTimeout(timerOut);
}


function showPrevisuAffiliation(){
    
    var i=0;
    bRet = true;
    
    var partenaire = document.getElementById('page_id').value;
    if (partenaire == 437)
      partenaire = 'EBAY1';
    else
      partenaire = 'PI';
    
    while (i<tField.length){
        obj = document.getElementById(tField[i]);
        bRet = bRet & hpo_forms_verif(obj, tFieldOblig[i], tFieldFunc[i]);
        i++;
    }
    if (bRet){
        
        if (partenaire == 'PI')
          hpo_tracking('F','10','Marketing::Affiliation::MKG Affiliation contact previsualisation','affiliation/contact/preview');
        else if (partenaire == 'EBAY1')
          hpo_tracking('F','10','Marketing::Ebay1::MKG Ebay 1 contact previsualisation','ebay1/contact/preview');
        
        var myFields = $('#tx_hpoforms_affiliation').serialize();
        
        jQuery.ajax(
            {
                type: "POST",
                data: myFields,
                url: 'index.php?type=320',
                timeout: 45000,
                success: function(r) {
                    $('#formulaire_affiliation_previsu_content').html(r);
                    $('#formulaire_affiliation_previsu').attr('style', 'display: block;');
                    $('#formulaire_affiliation_champ').attr('style', 'display: none;');
                }
            }
        );
        
    }
    else 
    {
        if (partenaire == 'PI')
          hpo_tracking('F','10','Marketing::Affiliation::MKG Affiliation contact erreur','affiliation/contact/erreur');
        else if (partenaire == 'EBAY1')
          hpo_tracking('F','10','Marketing::Ebay1::MKG Ebay 1 contact erreur','ebay1/contact/erreur');
        alert("Veuillez renseigner les champs incorrects");
    }
    
}

function hidePrevisuAffiliation(){
    var partenaire = document.getElementById('page_id').value;
    if (partenaire == 437)
      partenaire = 'EBAY1';
    else
      partenaire = 'PI';
      
    if (partenaire == 'PI')
        hpo_tracking('F','10','Marketing::Affiliation::MKG Affiliation contact corriger','affiliation/contact/corriger');
    else if (partenaire == 'EBAY1')
      hpo_tracking('F','10','Marketing::Ebay1::MKG Ebay 1 contact corriger','ebay1/contact/corriger');
      
    $('#formulaire_affiliation_previsu').attr('style', 'display: none;');
    $('#formulaire_affiliation_champ').attr('style', 'display: block;');
}
