var zoomIs = 0;
var maxZoom = 11;
var minZoom = 0;
function initTextZoom()
{
	// On définit la zone du contenu de l'article
	var contents = document.getElementsByTagName('DIV');
	var contentmid;
	
	for(var i=0; i<contents.length; i++){
		var content = contents[i];
		if(content.className.search("contentmid") > -1)
		{
			contentmid = content;
		}
	}
	
	var zoomers = document.getElementsByTagName('a');
	
	for(var i=0; i<zoomers.length; i++){
		var zoomer = zoomers[i];
		if(zoomer.className.search("btnplus") > -1)
		{
			zoomer.onclick = function(){
				if(zoomIs<=maxZoom-1){	
					zoomIs++;	
					if(zoomIs>0)
					{
						contentmid.className = 'contentmid zoomIs_'+(zoomIs-1);
					}
					contentmid.className = 'contentmid zoomIs_'+(zoomIs);
				}
				return false;
			}
		}
	}
	
	for(var i=0; i<zoomers.length; i++){
		var zoomer = zoomers[i];
		if(zoomer.className.search("btnmoin") > -1)
		{
			zoomer.onclick = function(){
				if(zoomIs>minZoom){	
					zoomIs--;	
					if(zoomIs>0)
					{
						contentmid.className = 'contentmid zoomIs_'+(zoomIs+1);
					}
					contentmid.className = 'contentmid zoomIs_'+(zoomIs);
				}
				return false;
			}
		}
	}
}
function ajouterFavoris(urlAddress,pageName) {
   if (document.all) {
   window.external.AddFavorite(urlAddress,pageName);
   }
   else if (window.sidebar) {
   window.sidebar.addPanel(pageName, urlAddress, "");
   }
   else {
   alert("Désolé! Votre navigateur ne supporte pas cette fonction.");
   }
} 
function showhideMenu(obj,mstring){
  if(document.getElementById('limenuhover'+obj)!=null){
    document.getElementById('limenuhover'+obj).style.display=mstring
  }
}
function validateSearch(obj){
  if(obj.query.value==""){
    alert('Veuillez indiquer votre recherche')
    obj.query.focus();
    return false;
  }
  return true;
}
function lightbox(){
   $("img.imgcontent").each(function(){
      $(this).replaceWith("<a href=\""+$(this).attr('src')+"\" class=\"inline\" rel=\"gallery\"><img src=\""+$(this).attr('src')+"\" class=\"imgcontent\" align=\"left\" title=\""+$(this).attr('title')+"\" alt=\""+$(this).attr('alt')+"\"/></a>");
     }
     );
     
    $("blockquote").each(function(){
      content=$(this).html();

      /*
      //on recherche le noeud precedent ayant le texte
      myobj=$(this).prev();
      if(myobj.html()!=null){
        contentin=myobj.html().replace(/^\s+/g,'').replace(/\s+$/g,'');
        while(contentin.substring(contentin.length-1,contentin.length)==">"){
          myobj=myobj.find("*:last-child");
          contentin=myobj.html().replace(/^\s+/g,'').replace(/\s+$/g,'');
        }
        myobj.replaceWith(myobj.html().replace(/^\s+/g,'').replace(/\s+$/g,'')+" <a href=\"#\" class=\"accordeon\"><img src=\"/tpl/images/block.jpg\" title=\"Plus d'information\"></a><br><div class=\"divaccordeon\">"+content+"</div>");
        $(this).replaceWith("");
      }
      */
      $(this).replaceWith("<br><a href=\"#\" class=\"accordeon\"><img src=\"/tpl/images/block.jpg\" title=\"Plus d'information\"></a><br><div class=\"divaccordeon\">"+content+"</div>");
     }
     );
   $("a.inline").fancybox({
    'overlayOpacity'	:	0.7,
		'overlayColor'		:	'#000',
		'hideOnContentClick': false,
		'showCloseButton':true
	   });
  $("a.group").fancybox({
    'overlayOpacity'	:	0.7,
		'overlayColor'		:	'#000',
		'hideOnContentClick': false,
		'showCloseButton':false,
		'frameWidth':315,
		'frameHeight':270
	   });
	  $("a.flash").fancybox({
    'overlayOpacity'	:	0.7,
		'overlayColor'		:	'#000',
		'hideOnContentClick': false,
		'showCloseButton':false,
		'frameWidth':479,
		'frameHeight':340,
		'callbackOnShow':insideflash
	   });
	   $("a.mp3").fancybox({
    'overlayOpacity'	:	0.7,
		'overlayColor'		:	'#000',
		'hideOnContentClick': false,
		'showCloseButton':false,
		'frameWidth':200,
		'frameHeight':20,
		'callbackOnShow':insideflash
	   });
     $("a.forgotpassword").fancybox({
    'overlayOpacity'	:	0.7,
		'overlayColor'		:	'#000',
		'hideOnContentClick': false,
		'showCloseButton':false,
		'frameWidth':355,
		'frameHeight':150
	   });      
    $(".exterieur").tooltip({position: "center right", effect: "fade", tip:"#extdiv"});
    $(".accordeon img").tooltip({position: "top right", effect: "fade", tip:"#extdiv"});
    $(".accordeon").toggle(function() {
      //$(this).find('.divaccordeon').show('slow');
      //alert($(this).next().next().html());
      $(this).next().next().show('slow');
      //alert($(this).html())
      //alert('First handler for .toggle() called.');
    }, function() {
      //$(this).find('.divaccordeon').hide('slow');
      $(this).next().next().hide('slow');
      //alert('Second handler for .toggle() called.');
      //alert($(this).html())
    });
}
function alert2(){
  alert('ok')
}
function insideflash(){
    $("#fancy_div div").html(contentflash);
}

