// fonctions javascript communes aux pages du site.

// ensemble des fonctions du menu principal
var bool_recherche=false;
function valid_recherche(){
	form_recherche=document.forms['recherche'];
	form_recherche.submit();
}

function clear_recherche(){
	if(bool_recherche==false){
		bool_recherche=true;
		document.getElementById("s").value="";
	}
}

function affiche_home(lang){
	if(lang=="FR"){
		document.location="index.php";
	}
	else{
		document.location="index_en.php";
	}
}

function english(){
	document.location="index_en.php";
}

function francais(){
	document.location="index.php";
}

// ensemble des fonctions du menu mobile.
//..........................................................
var windowHeight=0;


function getWindowHeight() {
	windowHeight=0;
    if (typeof(window.innerHeight)=='number') {
        windowHeight=window.innerHeight;
    }
    else {
     if (document.documentElement&&
       document.documentElement.clientHeight) {
         windowHeight = document.documentElement.clientHeight;
    }
    else {
     if (document.body&&document.body.clientHeight) {
         windowHeight=document.body.clientHeight;
      }
     }
    }
    return windowHeight;
}

function setMenuMobile() {
        windowHeight=getWindowHeight();
		var footerElement=document.getElementById('menu_mobile');
        if (windowHeight>150) {     
            footerElement.style.position='fixed';
            footerElement.style.top=(windowHeight-30)+'px';
        }
        else {
            footerElement.style.position='absolute';
		}
	  footerElement.style.visibility="visible";
}

function ouvre_menu_mobile(){
	var footerElement=document.getElementById('menu_mobile');
	var footerFond=document.getElementById('fond_menu');
	footerFond.style.backgroundImage="url('images/fond_menu_bas_actif.gif')";
	footerElement.style.top=(windowHeight-151)+'px';
}

function ferme_menu_mobile(){
	 var footerElement=document.getElementById('menu_mobile');
	 var footerFond=document.getElementById('fond_menu');
	 footerFond.style.backgroundImage="url('images/fond_menu_bas.gif')";
	 footerElement.style.top=(windowHeight-30)+'px';
}

window.onresize = function() {
        setMenuMobile();
}

function resizeFrame(laframe) {
	f=document.getElementById(laframe);
	f.style.height=0;
	f.style.height = (f.contentWindow.document.body.scrollHeight+0) + 'px';
}


// gestion des popup sur fond grisé
//.......................................................................................
function ferme_popup_grise(thepopup){
	var popupElement=document.getElementById(thepopup);
	popupElement.style.visibility="hidden";
}

function ouvre_popup_grise(thepopup){
	var popupElement=document.getElementById(thepopup);
	popupElement.style.visibility="visible";
	document.forms["form_donner_avis"].header.value=document.location;
	document.forms["form_faire_connaitre"].header.value=document.location;
	
}

function partager(url,titre){
	ouvre_popup_grise("partager");
	rempli_liste_reseau("http://www.auctionartparis.com/"+url,titre);
	lien="<a href='http://www.auctionartparis.com/"+url+"'>"+url_site+url+"</a>";
	document.forms["form_partager_mail"].header.value=url_site+url;	
	document.forms["form_partager_mail"].sujet.value="vous recommande "+titre;
	document.forms["form_partager_mail"].lien.value=lien;	
}

//...................................................................................


// fonctions communes
//...................................................................................;
function verifiermail(mail) {
     if ((mail.indexOf("@")>=0)&&(mail.indexOf(".",mail.indexOf("@")+2)>=0) && (mail.length>(mail.indexOf(".",mail.indexOf("@")+2)+2))) {
         return true ;
      } 
	  else {
         return false;
      }
   }
   
function affiche_lots(idvente){
	 document.location.href="liste_lots.php?idvente="+idvente;
 }
 
function affiche_lots_2(idvente){
	 document.location.href="liste_2_lots.php?idvente="+idvente;
 }
 
function affiche_lien(lien){
	 if(lien!=""){
	 	document.location.href="http://www.auctionartparis.com/actualite.php?wp/"+lien;
	 }
 }
 
function inscription_mews(){
	 ouvre_popup_grise("newsletter");
	 document.forms["form_newsletter"].header.value=document.location;
 }
 
function contacter_AA(titre,mail,nom){
	ouvre_popup_grise("contact_AA");
	document.forms["form_contact_AA"].header.value=document.location;
	document.forms["form_contact_AA"].input_mail_sujet.value=document.forms["form_contact_AA"].input_mail_sujet.value+" "+titre;
	document.forms["form_contact_AA"].contactAA.value=mail;
}

function rapport_condition(titre_vente,titre_lot,mail){
	ouvre_popup_grise("rapport_condition");
	document.forms["form_rapport_condition"].header.value=document.location;
	document.forms["form_rapport_condition"].input_mail_sujet.value=document.forms["form_contact_AA"].input_mail_sujet.value+" "+titre_vente+" lot n°"+titre_lot;
	document.forms["form_rapport_condition"].contactAA.value=mail;
}

function laisser_ordre_achat(num_lot,idvente){
	if(loggue==true){
		document.location.href="ordres_achat.php?idvente="+idvente+"&num_lot="+num_lot;	
	}
	else{
			var popupElement=document.getElementById('pop_login');
			popupElement.style.visibility="visible";
			document.forms["form_pop_login"].page.value="ordres_achat.php?idvente="+idvente+"&num_lot="+num_lot;
			document.forms["form_pop_login"].header.value="detail_lot.php?idvente="+idvente+"&num_lot="+num_lot;	
	}
}

function suivre_lot(num_lot,idvente){
	if(loggue==true){
		document.location.href="suivi_lot.php?idvente="+idvente+"&num_lot="+num_lot+"&header="+document.location;
	}
	else{
			var popupElement=document.getElementById('pop_login');
			popupElement.style.visibility="visible";
			document.forms["form_pop_login"].page.value="suivi_lot.php?idvente="+idvente+"&num_lot="+num_lot+"&header="+document.location;
			document.forms["form_pop_login"].header.value=document.location;
	}
}

function suivre_vente(idvente){
	if(loggue==true){
		document.location.href="suivi_vente.php?idvente="+idvente+"&header="+document.location;
	}
	else{
			var popupElement=document.getElementById('pop_login');
			popupElement.style.visibility="visible";
			document.forms["form_pop_login"].page.value="suivi_vente.php?idvente="+idvente+"&header="+document.location;
			document.forms["form_pop_login"].header.value=document.location;
	}
}

function mise_en_forme(lepavetitre,lepavesstitre,lepaveestimation){	
	h=document.getElementById(lepavetitre).offsetHeight;
	if(h>30){  // le titre est sur 2 lignes
		document.getElementById(lepavesstitre).style.display="none";
		document.getElementById(lepaveestimation).style.paddingTop="4px";
	}
	else{		
		if( document.getElementById(lepavesstitre).innerHTML==""){
			document.getElementById(lepavesstitre).style.display="none";
			document.getElementById(lepaveestimation).style.paddingTop="25px";
		}
		else{
			document.getElementById(lepaveestimation).style.paddingTop="9px";
		}
	}
}

function mise_en_forme_2(lepavetitre,lepavesstitre,lepaveestimation){	
	h=document.getElementById(lepavetitre).offsetHeight;
	
	if(h>25){
		document.getElementById(lepavesstitre).innerHTML="";
		document.getElementById(lepavesstitre).style.display="none";
		document.getElementById(lepaveestimation).style.paddingTop="3px";
	}
	else{
		
		if( document.getElementById(lepavesstitre).innerHTML==""){
			document.getElementById(lepavesstitre).style.display="none";
			document.getElementById(lepaveestimation).style.paddingTop="23px";
		}
		else{
			document.getElementById(lepaveestimation).style.paddingTop="7px";
		}
	}
	
}

function affiche_lot_par3(idvente){
	document.location.href="liste_lots.php?idvente="+idvente+"&nb_lot_serie=1";
}

function affiche_lot_colonne(idvente){
	document.location.href="liste_2_lots.php?idvente="+idvente+"&nb_lot_serie=1";
}


function affiche_page(str){
	document.location.href="liste_lots.php?"+str;	
}

function affiche_nb_page(str){
	document.location.href="liste_lots.php?"+str;	
}

function affiche_2_page(str){
	document.location.href="liste_2_lots.php?"+str;	
}

function affiche_2_nb_page(str){
	document.location.href="liste_2_lots.php?"+str;	
}