function launchContact()
{var femail=document.formContact['femail'].value;var ftexte=document.formContact['ftexte'].value;var action=document.formContact['action'].value;var annonce=document.formContact['annonce'].value;var captcha=document.formContact['captcha_code'].value;$.ajax({type:"POST",url:"/action/contact.html",data:'femail='+femail+'&ftexte='+ftexte+'&annonce='+annonce+'&action='+action+'&captcha='+captcha,success:function(data){$('#contactformulaire').html(data);}});}
function setTriListe(sReload,sTriValue)
{$.ajax({type:"POST",url:"/action/tri.html",data:'tri='+sTriValue,success:function(data){location.href=sReload;}});}
function delImage(pid,pmid)
{$.ajax({type:"POST",url:"/action/suppimg.html",data:'pid='+pid+'&pmid='+pmid,success:function(data){$('#photobloc').html(data);}});}
/*
    gere l authentification
*/
function launchIdent()
{
    var sOffreId="";
    var slEmail=document.formPost['lEmail'].value;
    var slPwd=document.formPost['lPwd'].value;
    
    if($("#lOffre").val()!=undefined){
        sOffreId ="&sOffreId="+$("#lOffre").val();
    }else{
        sOffreId="";
    }
    

    $.ajax({
        type:"POST",
        dataType: "json",
        url:"/action/login.html",
         data:'slEmail='+slEmail+'&slPwd='+slPwd+'&action=ident'+sOffreId,
        success:function(data){
            if(data.valide){
                if(data.iOffreId){
                    $("#formPost").attr("action", "/deposer-candidature-offre-direct/"+data.iOffreId+"/");
                }else{
		    $("#formPost").attr("action", "/mon-profil.html");
                }
		$("#formPost").submit();
            }
            else{
                var sFinalError='';
                var sError=data.commentaires;
                var aError=sError.split("|");

                for(var i=0; i<aError.length; i++){
                    if(aError[i]!='')
                        sFinalError +=aError[i]+"<br>";
                }
                $("#cont-error").addClass("cont-error");
                $("#cont-error").append(sFinalError);
                $("#cont-error").click(function(){
                    $(this).empty();
                    $(this).removeClass("cont-error");
                });
                
            }    
        }
    });

}
function launchSondage(){
    var iRepId=$(".reponseSondage:checked").val();
    var iSondId=$("#iIdSondage").val();
    
    $.ajax({
        type:"POST",
        dataType: "html",
        url:"/action/vote.html",
         data:'iSondage='+iSondId+'&iRepSondage='+iRepId+'&action=participe',
        success:function(data){
            if(data){
                $("#containerSondageArea").html(data); 
            }
        }
    });
    
}

function launchCandidatureMetier(pMetId){
    $("#pMetId").val(pMetId);
    $("#candidatureMetierForm").submit();
}
/*
 Gere le click du bouton pour postuler a une offre
 sur la page offre detail
*/
function launchCandidatureOffre(pOffreId, pConnected){
    if(pConnected==false){
        /*
        si je suis pas connecté je par
        a la connexion.
        */
        $("#pOffreId").val(pOffreId);
        $("#candidatureOffreForm").attr("action","/mon-compte.html");
        $("#candidatureOffreForm").submit();
    }else{
        /*
        si je suis connecté je par en traitement pour postuler
        */
        $("#pOffreId").val(pOffreId);
        $("#candidatureOffreForm").attr("action", "/deposer-candidature-offre-direct/"+pOffreId+"/");
        $("#candidatureOffreForm").submit();
    }
}

function launchFbIdent()
{$.ajax({type:"POST",url:"/action/login.html",data:'action=fbident',success:function(data){$('#leftindentzone').html(data);}});}
function deIdent()
{$.ajax({type:"POST",url:"/action/login.html",data:'action=logout',success:function(data){$('#leftbloc').html(data);launchRedirect('/index.html');}});}
function deFbIdent()
{$.ajax({type:"POST",url:"/action/login.html",data:'action=logout',success:function(data){$('#leftbloc').html(data);launchFbRedirect('/index.html');}});}



function launchFbRedirect(sUrl)
{var ReferURL=URLencode(sUrl);FB.Connect.logoutAndRedirect(ReferURL);}

function launchRedirect(sUrl)
{var ReferURL=URLencode(sUrl);location.href=ReferURL;}
function setRedirect(sUrl)
{location.href=sUrl;}
function URLencode(sStr)
{return escape(sStr).replace(/\+/g,'%2B').replace(/\"/g,'%22').replace(/\'/g,'%27');}
function urlopen(surl,popinname)
{window.open(surl,popinname);}
function submitInscription()
{var bIchk=document.PostInscr['vcgu'].checked;document.PostInscr.submit();}
function submitAssociationInscription(){document.AssociationInscr.submit();}
function doNavigatePerm(sStr)
{var sUrl='/annonces/voir.html?id='+URLencode(sStr);location.href=sUrl;}
function doNavigateLink(sStr)
{var sUrl=URLencode(sStr);location.href=sUrl;}
function submitPwd()
{document.PostMdp.submit();}
function resetThis(elem)
{if(elem.value=='Votre email')
elem.value='';else if(elem.value=='Votre message')
elem.value='';else if(elem.value=='Votre recherche')
elem.value='';else if(elem.value=='Votre mot de passe')
elem.value='';}
function getUTScreen(url,size)
{if(url===null){return"";}
size=(size===null)?"big":size;var vid;var results;results=url.match("[\\?&]v=([^&#]*)");vid=(results===null)?url:results[1];if(size=="small"){return"http://img.youtube.com/vi/"+vid+"/2.jpg";}else{return"http://img.youtube.com/vi/"+vid+"/0.jpg";}}
function addUrlSearchParam(sBaseUrl,Origine)
{var sUrl='/'+sBaseUrl+'/';var sIndexCategorie=document.FormAffine.sscat.options[document.FormAffine.sscat.selectedIndex].value;var sIndexRayon=document.FormAffine.cat.options[document.FormAffine.cat.selectedIndex].value;var sIndexRegion=document.FormAffine.region.options[document.FormAffine.region.selectedIndex].value;var sSearch=document.PostSearch.rch.value;if(sSearch=='Votre recherche')
sSearch='';switch(Origine)
{case"region":case"categorie":if(sIndexCategorie!=''&&sIndexCategorie!='0')
sUrl+=sIndexCategorie+'/';if(sIndexRegion!=''&&sIndexRegion!='0'&&sSearch!='')
{sUrl+=URLencode(sIndexRegion)+'|'+URLencode(sSearch)+'.html';}else if(sIndexRegion!=''&&sIndexRegion!='0'){sUrl+=URLencode(sIndexRegion)+'|.html';}else if(sSearch!=''){sUrl+='|'+URLencode(sSearch)+'.html';}
break;case"univers":if(sIndexRayon!=''&&sIndexRayon!='0')
sUrl+=sIndexRayon+'/';if(sSearch!='')
sUrl+='|'+URLencode(sSearch)+'.html';break;}
location.href=sUrl;}
function sendSearch()
{var sUrl='/recherche-occasions/';var sCateg=document.PostSearch.sscat.options[document.PostSearch.sscat.selectedIndex].value;var sSearch=document.PostSearch.rch.value;if(sSearch=='Votre recherche')
sSearch='';if(sCateg!=''&&sCateg!='0')
sUrl+=sCateg+'/';if(sSearch!='')
sUrl+='|'+URLencode(sSearch)+'.html';location.href=sUrl;}
function showHide(elId){var oEl=document.getElementById(elId);if(oEl.className=="show_smenu"){oEl.className="hide_smenu";}else if(oEl.className=="hide_smenu"){oEl.className="show_smenu";}}
function showHideTipTop(elId){var oRootUl=document.getElementById("catMenu");var oUls=oRootUl.getElementsByTagName("ul");for(i=0;i<oUls.length;i++){if(oUls[i].id==elId)
oUls[i].className="show_smenu";else
oUls[i].className="hide_smenu";}}
function showPermDiag(oForm){oForm.submit();}
function removeElement(divelt){var d=document.getElementById('recherche');var olddiv=document.getElementById(divelt);d.removeChild(olddiv);}
function removeInner(divelt){var olddiv=document.getElementById(divelt);olddiv.innerHTML='';}
function checkFacebook(oEl,bHasPerm){}
