//-- on sort des frames au cas où
if(top!=self) top.location=self.location;

function Ouvre_Fenetre(url,w,h)
  {  
  var Left=window.screen.width/2-(w/2);
  var Top=50;
  var Configuration="'toolbar=no, menubar=no, location=no, directories=no, status=no, resizeable=no, width=" + w + ", height=" + h + ", left=" + Left + ", top=" + Top;
  window.open(url,'',Configuration);
  }
  
/****************************** fenetre sondage *******************************/
gere_sondage = function()
	{
	var Hauteurfenetre = $(window).height();
	$("#sondage").css({"top": Hauteurfenetre});
	$("#sondage").css({"display": "block"});
	$("#sondage").stop().animate({'top':Hauteurfenetre-100},1500)
	}
ferme_sondage = function()
	{
	$("#sondage").css({"display": "none"});
	}
/****************************** gestion des impressions ***********************/
function imprime(quoi)
	{
	var tmp = quoi.split('|');
	var quoi = tmp[0];
	var qui = tmp[1];
	if(quoi=='agenda')
		{
		window.open('http://www.guide-france.info/imprime_agenda.php' + '?qui=' + qui);
		}
	else if(quoi=='fiche')
		{
		window.open('http://www.guide-france.info/imprime_fiche.php' + '?qui=' + qui);
		}
	else if(quoi=='annonce')
		{
		window.open('http://www.guide-france.info/imprime_annonce.php' + '?qui=' + qui);
		}
	else if(quoi=='interview')
		{
		window.open('http://www.guide-france.info/imprime_interview.php' + '?qui=' + qui);
		}
	}
/************* Partager sur facebook ******************************************/
$("a.facebook").click(
  function()
    {
    var titre = $('title').html();
  	var url = window.location.href;
  	var url_facebook_partage = "http://www.facebook.com/share.php?u=" + url;
  	window.open(url_facebook_partage);
		}
	);
/************* Envoyer à un ami ***********************************************/
$("a.ecrire").click(
  function()
    {
		chaine_mail = "mailto:?subject=" + document.title;
		chaine_mail += "&body= Je recommande cette page : " + document.title; chaine_mail += ". Consultable à l'adresse : " + location.href; location.href = chaine_mail;
		}
	);
/************* ajouter aux favoris ********************************************/
$("a.favori").click(
  function()
    {
    var titre = $('title').html();
  	var url = window.location.href;
  	var msg;
    if($.browser.msie)// CTRL+D
			{
			window.external.AddFavorite( url, titre);
			msg = "IE-->";
			}
		else if($.browser.mozilla)//CTRL+D
			{
			window.sidebar.addPanel(titre, url, "");
			//window.external.AddFavorite("url","titre");
			msg = "FF-->";
			}
		else if($.browser.webkit)//-- opera chrome
			{
			alert('Pour ajouter cette page à vos signets, utiliser le raccourci clavier CTRL+D ');
			msg = "Chrome/opéra-->";
			}
		else
			{
			alert('Pour ajouter cette page à vos favoris, utiliser le menu bookmarks, signets ou favoris de votre navigateur.');
			msg = "Navigateur-Inconnu-->";
			}
		}
	);
/******************************************************************************/




function favoris()
  { 
	if ( navigator.appName != 'Microsoft Internet Explorer' )
    {
		window.sidebar.addPanel(document.title,document.URL,"");
    }
  else
    { 
		window.external.AddFavorite(document.URL,document.title);
    }
  }

//-- gestion des png IE
(function($) {

jQuery.fn.pngFix = function(settings) {

	// Settings
	settings = jQuery.extend({
		blankgif: 'blank.gif'
	}, settings);

	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {

		//fix images with png-source
		jQuery(this).find("img[src$=.png]").each(function() {

			jQuery(this).attr('width',jQuery(this).width());
			jQuery(this).attr('height',jQuery(this).height());

			var prevStyle = '';
			var strNewHTML = '';
			var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
			var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
			var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
			var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
			var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
			var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
			if (this.style.border) {
				prevStyle += 'border:'+this.style.border+';';
				this.style.border = '';
			}
			if (this.style.padding) {
				prevStyle += 'padding:'+this.style.padding+';';
				this.style.padding = '';
			}
			if (this.style.margin) {
				prevStyle += 'margin:'+this.style.margin+';';
				this.style.margin = '';
			}
			var imgStyle = (this.style.cssText);

			strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
			strNewHTML += imgStyle+'"></span>';
			if (prevStyle != ''){
				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
			}

			jQuery(this).hide();
			jQuery(this).after(strNewHTML);

		});

		// fix css background pngs
		jQuery(this).find("*").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
			}
		});
		//fix input with png-source
		jQuery(this).find("input[src$=.png]").each(function() {
			var bgIMG = jQuery(this).attr('src');
			jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
   		jQuery(this).attr('src', settings.blankgif)
		});
	}
return jQuery;
};
})(jQuery);
//-- gere menu déroulant 
$("ul.nav li a") .mouseover(function() { //au survol du titre du menu
  $(this).parent().find("ul.nav_menu").slideDown('fast').show(); // on descend le sous menu
  $(this).parent().hover(function() {
  }, function(){	
  	$(this).parent().find("ul.nav_menu").slideUp('medium'); // on remonte sous menu quand sort survol
  });
  }).hover(function() { 
  	$(this).addClass("subhover");
  }, function(){
  	$(this).removeClass("subhover");
});
//-- gestion ouverture/fermeture des blocs

$(".accordeon h2").click(
  function()
    {
    if ($(this).next(".masque:visible").length != 0)
      {
      $(this).find('h1').removeClass("active");
      $(this).next(".masque").slideUp("slow");
      }
      // Si le sous-menu est cache, on ferme les autres et on l'affiche :
    else
      {
      $(".masque").slideUp("slow");
       $(this).next(".masque").slideDown("slow", function (){
	      //-- je remonte le bloc      
	      var ancre = $(this).offset().top;
	      var maHauteur = $(this).prev('div.titre').height();
	      var bouge =  ancre -  maHauteur - 100;
	      $('html,body').animate({ scrollTop : bouge },'slow');
      });
      }
    });


$(".accordeon2 div.lettre").click(
 function()
  {
   if ($(this).next("div.bloc:visible").length != 0)
     {
	     $(this).next(".masque").slideDown("slow");
     }
    else
     {
      $(".masque").slideUp("slow");
      $(this).next(".masque").slideDown("slow", function (){
	      //-- je remonte le bloc      
	      var ancre = $(this).offset().top;
	      var maHauteur = $(this).prev('div.titre').height();
	      var bouge =  ancre -  maHauteur - 100;
	      $('html,body').animate({ scrollTop : bouge },'slow');
      });
     }
  }
);
