function setVerrou()
{
	var rep = file('/include/ajax/verrouNotification.php?action=set&valeur=3');
}

function unsetVerrou()
{
	var rep = file('/include/ajax/verrouNotification.php?action=set&valeur=0');	
}

function checkVerrou()
{
	var rep = file('/include/ajax/verrouNotification.php');
	return rep;
}

function checkClinDoeils(){
	var verrou = checkVerrou();
    if( verrou != 1){
      rep = file('/include/ajax/checkNotificationClinDoeil.php');
        if( rep > 0 ){
        
         writediv("notificationClinDoeils",file('/include/ajax/getClinDoeilANotifier.php'));
   		$(document).ready(function(){
			setVerrou();
			centerPopupClinDoeil();
			//load popup
			loadPopupClinDoeil();
			$("#son_chat").html('<iframe frameborder="0" name="player_son" src="oeil_mp3.php"></iframe>');

			$("#popupContactCloseClinDoeil").click(function(){
				disablePopupClinDoeil();
				unsetVerrou();
			});
			
			$("#popupValidationClinDoeil").click(function(){
				disablePopupClinDoeil();
				unsetVerrou();
			});
			
			$("#backgroundPopupClinDoeil").click(function(){
				disablePopupClinDoeil();
				unsetVerrou();

			});
			
			$(document).keypress(function(e){
				if(e.keyCode==27 && popupStatus==1){
				disablePopupClinDoeil();
				unsetVerrou();
			}
			});
			
		});
    }
   }
    window.setTimeout(function() {checkClinDoeils();}, 10000);
}

function checkFlashs(){
	var verrou = checkVerrou();
        if(  verrou != 1 ){
            rep = file('/include/ajax/checkNotificationFlash.php');
            if( rep > 0 ){
                writediv("notificationFlashs",file('/include/ajax/getFlashsANotifier.php'));
   		$(document).ready(function(){
			setVerrou();
	   		centerPopupFlash();
			//load popup
			loadPopupFlash();
			$("#son_chat").html('<iframe frameborder="0" name="player_son" src="flash_mp3.php"></iframe>');
					
			$("#popupContactCloseFlash").click(function(){
				disablePopupFlash();
				unsetVerrou();
			});
			
			$("#popupValidationFlash").click(function(){
				disablePopupFlash();
				unsetVerrou();
			});
			
			$("#backgroundPopupFlash").click(function(){
				disablePopupFlash();
				unsetVerrou();
			});
			
			$(document).keypress(function(e){
				if(e.keyCode==27 && popupStatus==1){
					disablePopupFlash();
					unsetVerrou();
				}
			});
			
		});		
           }
        }
        window.setTimeout(function() {checkFlashs();}, 11000);
}

function checkVisites(){
	var verrou = checkVerrou();
   if ($("#notificationVisites").is(":hidden") && verrou != 1){
		// we dont want to do anything if the previous notification has not been closed
	   	$.get("/include/ajax/checkNotificationVisites.php?checkNum=1", function(data){
		// check if there is new notifications to display
		if(data!="0"){
			setVerrou();
	   		$("#notificationInVisites").load("/include/ajax/checkNotificationVisites.php"); // load the text
			$("#notificationVisites").slideDown("slow"); // display the box
			$("#son_chat").html('<iframe frameborder="0" name="player_son" src="visite_mp3.php"></iframe>');
			
		}
		});
  }
  window.setTimeout(function() {checkVisites();}, 9000);
}

function checkDemandeAutorisation(){
   var verrou = checkVerrou();
   if ($("#notificationDemandeAutorisation").is(":hidden") && verrou != 1){
		// we dont want to do anything if the previous notification as not been closed
	   	$.get("/include/ajax/checkNotificationDemandeAutorisation.php?checkNum=1", function(data){
		// check if there is new notifications to display
		if(data!="0"){
			setVerrou();
	   		$("#notificationInDemandeAutorisation").load("/include/ajax/checkNotificationDemandeAutorisation.php"); // load the text
			$("#notificationDemandeAutorisation").slideDown("slow"); // display the box
			$("#son_chat").html('<iframe frameborder="0" name="player_son" src="demande_autorisation_mp3.php"></iframe>');
			
		}
		});
  }
  window.setTimeout(function() {checkDemandeAutorisation();}, 12000);
}

function checkAutorisationAccepter(){
   var verrou = checkVerrou();
   if ($("#notificationAutorisationAccepter").is(":hidden") && verrou != 1){
		// we dont want to do anything if the previous notification as not been closed
	   	$.get("/include/ajax/checkNotificationAutorisationAccepter.php?checkNum=1", function(data){
		// check if there is new notifications to display
		if(data!="0"){
			setVerrou();
	   		$("#notificationInAutorisationAccepter").load("/include/ajax/checkNotificationAutorisationAccepter.php"); // load the text
			$("#notificationAutorisationAccepter").slideDown("slow"); // display the box
			$("#son_chat").html('<iframe frameborder="0" name="player_son" src="autorisation_accepter_mp3.php"></iframe>');
		}
		});
  }
  window.setTimeout(function() {checkAutorisationAccepter();}, 13000);
}

function checkReponseDemandeContact(){
   if ($("#notificationReponseDemandeContact").is(":hidden") && checkVerrou() != 1){
		// we dont want to do anything if the previous notification as not been closed
	   	$.get("/include/ajax/checkNotificationReponseDemandeContact.php?checkNum=1", function(data){
		// check if there is new notifications to display
		if(data!="0"){
			setVerrou();
	   		$("#notificationInReponseDemandeContact").load("/include/ajax/checkNotificationReponseDemandeContact.php"); // load the text
			$("#notificationReponseDemandeContact").slideDown("slow"); // display the box
			$("#son_chat").html('<iframe frameborder="0" name="player_son" src="reponse_demande_contact_mp3.php"></iframe>');
		}
		});
  }
  window.setTimeout(function() {checkReponseDemandeContact();}, 14000);
}

function checkAnniversaires(){
   if ($("#notificationAnniversaires").is(":hidden")/* && checkVerrou() != 1*/){
		// we dont want to do anything if the previous notification as not been closed
	   	$.get("/include/ajax/checkNotificationAnniversaires.php?checkNum=1", function(data){
		// check if there is new notifications to display
		if(data!="0"){
			setVerrou();
	   		$("#notificationInAnniversaires").load("/include/ajax/checkNotificationAnniversaires.php"); // load the text
			$("#notificationAnniversaires").slideDown("slow"); // display the box
			$("#son_chat").html('<iframe frameborder="0" name="player_son" src="anniversaire_mp3.php"></iframe>');
			}
		});
  }
  window.setTimeout(function() {checkAnniversaires();}, 600000);
}

function checkMessage(){
   if ($("#notificationMessage").is(":hidden") && checkVerrou() != 1){
		// we dont want to do anything if the previous notification as not been closed
	   	$.get("/include/ajax/checkNotificationMessages.php?checkNum=1", function(data){
		// check if there is new notifications to display
		if(data!="0"){
			setVerrou();
	   		$("#notificationInMessage").load("/include/ajax/checkNotificationMessages.php"); // load the text
			$("#notificationMessage").slideDown("slow"); // display the box
			$("#son_chat").html('<iframe frameborder="0" name="player_son" src="message_mp3.php"></iframe>');
			}
		});
  }
  window.setTimeout(function() {checkMessage();}, 15000);
}

function checkContact(){
   if ($("#notificationContact").is(":hidden") && checkVerrou() != 1){
		// we dont want to do anything if the previous notification as not been closed
	   	$.get("/include/ajax/checkNotificationContact.php?checkNum=1", function(data){
		// check if there is new notifications to display
		if(data!="0"){
			setVerrou();
	   		$("#notificationInContact").load("/include/ajax/checkNotificationContact.php"); // load the text
			$("#notificationContact").slideDown("slow"); // display the box
			$("#son_chat").html('<iframe frameborder="0" name="player_son" src="contact_mp3.php"></iframe>');			
		}
		});
  }
  window.setTimeout(function() {checkContact();}, 20000);
}



