
/*----------------------GESTION MENU------------ */

function init_menu(page)  {
  $("#nav").droppy();
  //temp trame
  resizeBackground();
  
  $(window).resize(function(){
    resizeBackground();
  });
  //fin temp trame
  switch(page)  {
  
    case "accueil" :
    /*
      $("#anim_swf").flash({ src: "media/anim_accueil.swf", width : "240px", height : "180px", bgcolor : "#333333", wmode:"transparent" });
      */
    break;
    
  }
  
}

/*---------------------------------- Affiche un élement ------------------------------*/
function montrer(id_elmt)  {
  $(".elmt_visible").removeClass("elmt_visible");
  $(".gras").removeClass("gras");
  $("#titre"+id_elmt).addClass("gras");
  $("#txt"+id_elmt).addClass("elmt_visible");
}
/*----------------------------------Mise en Gras du menu ------------------------------*/

function AffPage(idmenu)  {
  $("#menu"+idmenu).addClass("gras");
}
/*----------------------------------Mise en Gras du Sousmenu ------------------------------*/

function AffSsrub(idssrub)
{
 //alert("ok AffSsrub "+idssrub);
	//Si nav respectant le DOM
	if(document.getElementById)
	 	{
	 	document.getElementById('ssrub_'+idssrub).style.textDecoration="underline"; 
	 	document.getElementById('ssrub_'+idssrub).style.color="#001A53";
	 	document.getElementById('ssrub_'+idssrub).style.fontWeight="bold";
	 	}	//fin if
}

/*---------------------Redirection formulaire inscription------------*/
function rediriger()	{
	window.location.replace("index.php");
}

function retour()	{
	history.back();
}
/*------- FERMER LA FENETRE--------*/
function fermer()	{
	window.close();
}
/*------- AFFICHER UN MESSAGE--------*/
function message(message)	{
	window.alert(message);
}

function view(id)	{
	//alert('ok view');
	window.open('visu_marche.php?id='+id+'', '', 'resizable=no, location=no, width=400, height=400, left=150, top=150, menubar=no, status=no, scrollbars=no, menubar=no');
}
/*-------------AFFICHAGE DES IMAGE EN POPUP---------------*/
function visu(url, largeur, hauteur)	{
	window.open('visu_img.php?url='+url+'', '', 'resizable=no, location=no, width='+largeur+', height='+hauteur+', left=150, top=150, menubar=no, status=no, scrollbars=no, menubar=no');
}
/*------------VERIFICATION DU FORMULAIRE DE CONTACT-----------------------------------*/
function verif_formContact()	{
/*Nom*/
if(document.formContact.nom.value == "")  {
   alert("Veuillez entrer votre nom !");
   document.formContact.nom.focus();
   return false;
  }
 if(document.formContact.prenom.value == "") {/*Prenom*/
   alert("Veuillez entrer votre prénom !");
   document.formContact.prenom.focus();
   return false;
  }
/*Email*/
 if(document.formContact.email.value == "") {
   alert("Veuillez entrer votre email !");
   document.formContact.email.focus();
   return false;
  }
 if(document.formContact.email.value.indexOf('@') == -1) {
   alert("Veuillez entrer un email valide !");
   document.formContact.email.focus();
   return false;
  } 
  if(document.formContact.sujet.value == "") {
      alert("Veuillez entrer un sujet !");
      document.formContact.sujet.focus();
      return false;
  }
   if(document.formContact.question.value == "") {
       alert("Veuillez entrer votre question !");
       document.formContact.question.focus();
       return false;
  }
}
 
 /* Fonction qui vérigie si le form recherh est bien remplie par o moin un mot*/
function verif_formRecherche()	{
	if(document.form_recherche.mots_cles.value == "")  {
	   alert("Veuillez entrer un où plusieurs mots à rechercher !");
	   document.form_recherche.mots_cles.focus();
	   return false;
	}
}
/*------------VERIFICATION DU FORMULAIRE fond aide-----------------------------------*/
function verif_form_fon()	{
/*Nom*/
if(document.formHD.nom.value == "")  {
   alert("Veuillez entrer votre nom !");
   document.formHD.nom.focus();
   return false;
  }
 if(document.formHD.prenom.value == "") {/*Prenom*/
   alert("Veuillez entrer votre prénom !");
   document.formHD.prenom.focus();
   return false;
  }
   if(document.formHD.societe.value == "") {
     alert("Veuillez entrer votre societe !");
     document.formHD.societe.focus();
     return false;
  }
  if(document.formHD.adresse.value == "") {
      alert("Veuillez entrer votre adresse !");
      document.formHD.adresse.focus();
      return false;
  }
   if(document.formHD.telephone.value == "") {
       alert("Veuillez entrer votre numéro de telephone !");
       document.formHD.telephone.focus();
       return false;
  }
/*Email*/
 if(document.formHD.email.value == "") {
   alert("Veuillez entrer votre email !");
   document.formHD.societe.focus();
   return false;
  }
 if(document.formHD.email.value.indexOf('@') == -1) {
   alert("Veuillez entrer un email valide !");
   document.formHD.email.focus();
   return false;
  }
   
}

 
 /* Fonction qui vérigie si le form recherh est bien remplie par o moin un mot*/
function verif_formRecherche()	{
	if(document.form_recherche.mots_cles.value == "")  {
	   alert("Veuillez entrer un où plusieurs mots à rechercher !");
	   document.form_recherche.mots_cles.focus();
	   return false;
	}
}
/*---------------------------fct qui ouvre un popup grand avec une url---------------------------------*/
function popupG(url)	{
	//alert("ok fct popupG");
	window.open(''+url+'', '', 'resizable=no, location=no, width=800, height=700, left=150, top=100, menubar=no, status=no, scrollbars=no, menubar=no');
}

/*----------------------------------SURBRILLANCE DES ARTICLES PUSH------------------------------*/
 function aff_push(element)	{
 //alert("ok roll aff");
    if(document.getElementById)
       {
       document.getElementById(element).style.border = "1px solid #B0CBEE";
       document.getElementById(element).style.backgroundColor = "#E9EFF5";
       }
    else if(document.all)
       {
       document.all[element].style.border = "1px solid #B0CBEE";
       document.all[element].style.backgroundColor = "#E9EFF5";
       }
 
 }
 
 function mask_push(element)	 {
// alert("ok roll mask");
    if(document.getElementById)
       {
       document.getElementById(element).style.border = "1px solid #D9E0E9";
       document.getElementById(element).style.backgroundColor = "#EFF3F7";
       }
    else if(document.all)
       {
       document.all[element].style.border = "1px solid #D9E0E9";
        document.all[element].style.backgroundColor = "#EFF3F7";
       }
 
 }
 
/*----------------------------------REDIRECTION JS POUR DIV CLIQUABLE------------------------------*/
function redirectlien(url)	 {
	 window.location.href=url;
}

/*----------------------------------affBlock -- Affiche le 1er, masque le deuxième------------------------------*/
function affBlock(id1, id2)	 {
/*alert("ok affBlock  >  "+id1);*/
	if(document.getElementById)	{
			
		obj1 = document.getElementById(id1);
		obj2 = document.getElementById(id2);
		
		obj1.style.display='block';
		obj1.style.visibility='visible';
		
		obj2.style.display='none';
		obj2.style.visibility='hidden';
	}
}


/*----------------------------------Vérification du formulaire de log------------------------------*/

function verif_form_log()	{
/*Email Login*/
 if(document.formLogin.login.value == "") {
   alert("Votre identifiant n'est pas correct !");
   document.formLogin.login.focus();
   return false;
  }
 if(document.formLogin.login.value.indexOf('@') == -1) {
   alert("Votre identifiant n'est pas correct !");
   document.formLogin.login.focus();
   return false;
  }
  
  
if(document.formLogin.mdp.value == "")  {
   alert("Veuillez entrer votre mot de passe !");
   document.formLogin.mdp.focus();
   return false;
  }
}
/*----------------------------------Ouverture fermeture infos_master----------------------------*/
function visibilite_infos(val)  {
      document.getElementById("infos_master").style.display = val;
}


/*----------------------------------Vérification du formulaire de master------------------------------*/
function verif_form_master()  {

  if(document.form_master.nom.value == "")  {
    alert("Veuillez entrer votre nom !");
    document.form_master.nom.focus();
    return false;
  }
  if(document.form_master.prenom.value == "") {/*Prenom*/
    alert("Veuillez entrer votre prénom !");
    document.form_master.prenom.focus();
    return false;
  }
  if(document.form_master.email.value == "") {
    alert("Veuillez entrer votre email !");
    document.form_master.email.focus();
    return false;
  }
  if(document.form_master.email.value.indexOf('@') == -1) {
    alert("Veuillez entrer un email valide !");
    document.form_master.email.focus();
    return false;
  }
  if(document.form_master.festival.value == "") {
    alert("Veuillez entrer votre nom de  festival!");
    document.form_master.festival.focus();
    return false;
  }
}
/*----------------------------------Vérification du formulaire d'inscription------------------------------*/

function verif_form_inscr()	{
if(document.formInscription.nom.value == "")  {
   alert("Veuillez entrer votre nom !");
   document.formInscription.nom.focus();
   return false;
  }
 if(document.formInscription.prenom.value == "") {/*Prenom*/
   alert("Veuillez entrer votre prénom !");
   document.formInscription.prenom.focus();
   return false;
  }
  
 if(document.formInscription.email.value == "") {
   alert("Veuillez entrer votre email !");
   document.formInscription.societe.focus();
   return false;
  }
 if(document.formInscription.email.value.indexOf('@') == -1) {
   alert("Veuillez entrer un email valide !");
   document.formInscription.email.focus();
   return false;
  }

 if(document.formInscription.mdp.value != document.formInscription.mdp2.value) {
     alert("Veuillez entrer deux mots de passe identiques !");
     document.formInscription.mdp.value = "";
     document.formInscription.mdp2.value = "";
     document.formInscription.mdp.focus();
     return false;
  }
  
   if(document.formInscription.societe.value == "") {
     alert("Veuillez entrer votre societe !");
     document.formInscription.societe.focus();
     return false;
  }
  if(document.formInscription.telephone.value == "") {
       alert("Veuillez entrer votre numéro de telephone !");
       document.formInscription.telephone.focus();
       return false;
  }
  
  var numTel = document.formInscription.telephone.value;
  
  var anum=/(^\d+$)|(^\d+.\d+$)/
  if (anum.test(numTel) && numTel.length>9)	{
  	testresult=true;
  }
  else{
        alert("Veuillez entrer un numéro de telephone valide !");
        document.formInscription.telephone.focus();
        return false;
  }
 }
 
 



function resizeBackground() {

    $("#trame").height(0);
    $("#trame").width(0);
    
    
    
  if($(document).height()>$(window).height()){
    
    $("#trame").height($(document).height());
  } else {
    $("#trame").height($(document).height());
  }
  if($(document).width()>$(window).width()){
    $("#trame").width($(document).width());
  } else {
    $("#trame").width($(document).width());
  }
  /*
  var windowH = $(document).height();
  var windowW = $(document).width();
  
  if(windowW > windowH){
    $("#background img").width(windowW);
    var proportion = savImgW/savImgH;
    $("#background img").height($("#background img").width()*proportion);
  } else {
    $("#background img").height(windowH);
    var proportion = savImgH/savImgW;
    $("#background img").width($("#background img").height()*proportion);  
  }
  var docW = $(document).width();
  var conW = $("#conteneur").width();
  var marG = (docW - conW)/2;
  marG = Math.round(marG);
  if(marG>0){
    $("#trame").css("backgroundPosition", marG+"px 0px");
  }else {
    $("#trame").css("backgroundPosition", "0px 0px");
  }
  */
}
  /*
   if ( isNaN(document.formInscription.telephone.value) || document.formInscription.telephone.value != 10 ) {
        alert("Veuillez entrer un numéro de telephone valide !");
        document.formInscription.telephone.focus();
        return false;
  }
  */

/*Email
 if(document.formInscription.email.value == "") {
   alert("Veuillez entrer votre email !");
   document.formInscription.societe.focus();
   return false;
  }
 if(document.formInscription.email.value.indexOf('@') == -1) {
   alert("Veuillez entrer un email valide !");
   document.formInscription.email.focus();
   return false;
  }

}
function checknumber(){
var x=document.checknum.pnum.value
var anum=/(^\d+$)|(^\d+.\d+$)/
if (anum.test(x))
testresult=true
else{
alert("Entrez un nombre valide")

*/
