function blindDiv(divId,container,contentClass)
	{
				//el=$(container).getElementsByClassName(contentClass);
				el=$('.'+contentClass);
				var noAction=false;
				el.each(function(e)
				{
							if($(el[e]).is(':visible') && $(el[e])[0]!= $("#"+divId)[0])
							{
								$(el[e]).hide();
							}
										
				});
				if(!$("#"+divId).is(':visible'))
					$("#"+divId).show(500);
				                    
	}
var fci = null;

(function($) {
    var timer = null;
    var currentItem = null;
     
    function displayMenu(e) {
        if(timer)
        {
            clearTimeout(timer);
            timer = null;
        }
        if(currentItem == this)
            return;
        currentItem = this;
        var t = $(this);
        
        $('.smenu .jsEvent').removeClass('over').next().removeClass('nextover');;
        $('.smenu .jsEvent > ul').hide();
        
        t.addClass('over').next().addClass('nextover');
        t.children('ul.menu').show();
    }
    
    function hideMenu(e) {
     
        var self = $(this);
        timer = setTimeout(function() {
            self.removeClass('over').next().removeClass('nextover');
            self.children('ul.menu').slideUp(250);
            currentItem = null;
        }, 125);
    }
    
    $.ibaMenu = {
        init: function() {
            timer = null;
           
            currentItem = null;
           $('.smenu .jsEvent').hover(displayMenu, hideMenu);
           $('.smenu .jsEvent > ul').hide();
       }
    }
    
})(jQuery);

(function($) {

    var currentPanel = null;
    
    function showPanel(event) {
       
       
        var h = this.href.match(/#.*/);
        if($('#bid').length > 0)
        {
        	$('#bid')[0].value="";
        }
        if($('#bid').length > 0 && $(this).attr('bid'))
        {
        	$('#bid')[0].value=$(this).attr('bid');
        }
        if(h)
	    {
	        event.preventDefault();
	        var hfci = null;
	        if(currentPanel) {
	            $(currentPanel).removeClass('hover');
	            hfci = currentPanel.href.match(/#.*/);
	            $(hfci[0]).slideUp("fast");
	            addCaptchaInContent();
	        }
	        if(hfci && hfci[0] == h[0]) {
	            currentPanel = null;
	            $('#closeSticky').hide();
	            return;
	        }
	        currentPanel = $("#footer .center .block a[href$='"+$(this).attr("href")+"']")[0];
	     
	        $("#footer .center .block a[href$='"+$(this).attr("href")+"']").addClass('hover');
	        $(h[0]).slideDown("fast");
	     	$('#closeSticky').show();
	        
	        if($('#footer '+h[0]+' form .RCcontainer').length > 0)
	        {
	        	addCaptcha($('#footer '+h[0]+' form .RCcontainer')[0]);
			}
	       	else
	       		 addCaptchaInContent();
	      
        }
        
    }
    
    $.ibaFooter = 
	{
        init: function() {
            $('#footer .bcontent').hide().appendTo('#footer .panel-holder');
            $('#footer .center .block a').click(showPanel);
            var el = $('#content a');
            el.each(function(e)
			{
			
				var hreflength=($(el[e]).attr("href")).length - 7;
				if($(el[e]).attr("href") && ($(el[e]).attr("href")).substr(0,1)=='#')
				{
					
					var divLinkId = ($(el[e]).attr("href")).substr(1,(($(el[e]).attr("href").length) - 9));
					if($("#footer .center .block a[href$='"+$(el[e]).attr("href")+"']").length > 0 && $('#footer #'+divLinkId+' a').attr("href") == $(el[e]).attr("href"))
					{
						$(el[e]).click(showPanel);
					}
					else if($(el[e]).attr('bid'))
					{
						var ahref=$(el[e]).attr("href");
						var bid = $(el[e]).attr('bid');
						
						if($('#footer #'+divLinkId).length > 0 )
							$(el[e]).attr("href","/more-resources/download-area/"+bid);
					}
					else 
					{
						$(el[e]).attr("href",$('#footer .center #'+divLinkId+' a').attr("href"));
					}
					//($(el[e]).attr("href")).substr(1,(($(el[e]).attr("href").length) - 7))
						
				}
			});
			if($.urlParam('sf_panel')=="contact" && $('#block-block-21-content').length !=0)
			{
				$('#block-block-21 a').addClass('hover')
				$('#block-block-21-content').show();
				currentPanel = $('#block-block-21 a')[0];
			}
			if($.urlParam('sf_panel')=="contact" && $('#block-views-contact_us-block_1').length !=0)
			{
				$('#block-views-contact_us-block_1 a').addClass('hover')
				$('#block-views-contact_us-block_1-content').show();
				currentPanel = $('#block-views-contact_us-block_1 a')[0];
			}
		
        },
		
		open:function()
		{
			$('#block-views-contact_us-block_1 a').addClass('hover')
			$('#block-views-contact_us-block_1-content').show();
			$('#closeSticky').show();
			if($('#block-block-14 a'))
			{
				$('#block-block-13 a').removeClass('hover');
				$('#block-block-13-content').slideUp("fast");
				currentPanel = $('#block-block-14 a')[0];
				$('#block-block-14 a').addClass('hover');
				$('#block-block-14-content').slideDown("fast");
			
			}
			
		},
		
		open2:function()
		{
			$('#block-block-14 a').addClass('hover');
			$('#block-block-14-content').slideDown("fast");
			currentPanel = $('#block-block-14 a')[0];
			$('#closeSticky').show();
			if ($('#block-block-13 a'))
			{
				$('#block-block-13 a').removeClass('hover');
				$('#block-block-13-content').slideUp("fast");
			}
		},
		open3:function()
		{
			if(currentPanel) {
	            $(currentPanel).removeClass('hover');
	            hfci = currentPanel.href.match(/#.*/);
	            $(hfci[0]).slideUp("fast");
	           
	        }
			$('#block-block-21 a').addClass('hover');
			$('#block-block-21-content').slideDown("fast");
			currentPanel = $('#block-block-21 a')[0];
			$('#closeSticky').show();
		},
		openBrochure:function()
		{
			$('#block-block-14 a').removeClass('hover');
			$('#block-block-14-content').slideUp("fast"); 
			
			currentPanel = $('#block-block-13 a')[0];
			$('#block-block-13 a').addClass('hover');
			$('#block-block-13-content').slideDown("fast");
		},
		closePanel:function()
       	{
        	if(currentPanel) {
	            $(currentPanel).removeClass('hover');
	            hfci = currentPanel.href.match(/#.*/);
	            $(hfci[0]).slideUp("fast");
	            currentPanel = null;
				$('#closeSticky').hide();
	        }
        }
    }
})(jQuery);

(function($) {
    var timer = null;
    var open = false;
    
    function showBUSelector(e) {
        if(timer)
        {
            clearTimeout(timer);
        }
        timer = null;
        if(open)
            return;
        open = true;
        $('.leftMenu').show();
    }
    
    function hideBUSelector(e) {
        if(timer)
            return;
        timer = setTimeout(function() {
            $('.leftMenu').hide();
            timer = null;
            open = false;
        }, 125);
    }
    
    $.ibaBU = {
        init: function() {
            $('.currentBU, .leftMenu').hover(showBUSelector, hideBUSelector);
        }
    }
})(jQuery);

(function($) {

   var currentBox = null;
    
    function showBox(event) {
        event.preventDefault();
        var h = this.href.match(/#.*/);
        var hfci = null;
        if(currentBox)
        {
            $(currentBox).removeClass('hover');
            hfci = currentBox.href.match(/#.*/);
            $(hfci[0]).slideUp("fast");
        }
        if(hfci && hfci[0] == h[0]) {
            currentBox = null;
            return;
        }
        currentBox = this;
        var children = $('#box-footer').children();
        var elementIndex=children.index(currentBox);
        var topBgPos = ((children.length-1) * 39) - (elementIndex * 39);
        $('#box-footer').css({backgroundPosition: 'right -'+topBgPos+'px'});
        $(currentBox).addClass('hover');
        $(h[0]).slideDown("fast");
    }
    
    $.ibaHeaderBox = {
        init: function() {
       		$('.box-link').click(showBox);
       		$('#header-right .box a.close').click(showBox);
        }
    }
})(jQuery);

(function($) {

   var isIe6 = false;
   function moveFooter() {
	         if(isIe6){
					
	           	$('#footer').css({top: document.documentElement.clientHeight+$(window).scrollTop()-$('#footer').height()+'px'})
	       }
        }
   $.fixedFooter = {
        init: function() {
		
         	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
    		if(jQuery.browser.msie && ie6)
    		{
         		$(window).scroll(moveFooter);
         		$('#footer').resize(moveFooter);
         		isIe6=true;
         		if(!$.cookie('IE_WARNING'))
			    {
					
			        var date = new Date();
			        date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));
			                
			        // set cookie by number of days
			        $.cookie('IE_WARNING', true, { path: '/', expires: date});
					
					$.modal("<h2>ATTENTION: YOU ARE USING INTERNET EXPLORER 6 (IE6)</h2><p>Please note that this website has been optimized for IE7, IE8, Mozilla Firefox, Google Chrome and Safari.<br />As you are using IE6, you might encounter problems viewing our website correctly. We are sorry for the inconvenience it may cause.<br />If you wish to improve your web experience, we suggest you to install <a href='http://www.mozilla-europe.org/en/firefox/'>Firefox</a> or <a href='http://www.google.com/chrome/'>Google Chrome</a> which are free and easy to install.<br /><br />Thank you for your understanding<br /><br />The IBA Team.</p>",
					{
						overlayId: 'osx-overlay',
						containerId: 'osx-container',
						closeHTML: '<div class="close"><a href="#" class="simplemodal-close">Close x</a></div>',
						minHeight:150,
						minWidth: 900,
						opacity:60, 
						position:['0',],
						overlayClose:true
					});
				}
         		
         	}
         	
        }
       
        
    }
})(jQuery);
(function($) {

   
   $.citationRotator = {
    	i: 0,
    	c : 0,
        init: function() {
         this.c = $('.citationContener').length;
         this.i = 0;
         if(this.c > 0)
         {
         	setInterval("jQuery.citationRotator.rotate()", 12000);
         }
         	
        },
       rotate: function() {
	        
	        currentI=this.i;
	        this.i++;
	        if(this.i >= this.c)
	        	this.i=0;
	        
	        $($('.citationContener')[currentI]).fadeOut(400,function(){
	     	   $($('.citationContener')[jQuery.citationRotator.i]).fadeIn(600);
	        });
	        
        }
        
    }
})(jQuery);

(function($) 
{
	$.tabBar = 
	{
		i: 0,
		c : 0,
		init: function() 
		{
			$('.toHide').hide();
		},
		
		show:function (id, item)
		{
			var el = $('.bloc-radiotherapy');
			var i = 0;
			el.each(function(e)
			{
				if (i == id)
					$(el[e]).show();
				else
					$(el[e]).hide();
				i++;
			});
			
			el = $('.link-bloc');
			i = 0;
			el.each(function(e)
			{
				if (i == id && i == 0)
					$(el[e]).parent().parent().addClass('first-active');
				else
					$(el[e]).parent().parent().removeClass('first-active');
				
				/*if (i == id && i == el.length -1)
					$(el[e]).parent().parent().addClass('last');
				else
					$(el[e]).parent().parent().removeClass('last');
				*/
				$(el[e]).parent().parent().removeClass('active');
				i++;
			});
			
			$(item).parent().parent().addClass('active');
		}
	}
})(jQuery);
(function($) {

   
   $.contentLoader = {
         init: function() {
         	if($('#blockNews').length !=0)
         	{
         		jQuery.get("/ajax.php?method=getNews", {}, this.displayNews);
         	}
         	if($('#blockNewsletters').length !=0)
         	{
         		jQuery.get("/ajax.php?method=getNewsletters", {}, this.displayNewsletters);
         	}
         	if($('#blockEvents').length !=0)
         	{
         		jQuery.get("/ajax.php?method=getEvents", {}, this.displayEvents);
         	}
         	if($('#blockTestimony').length !=0)
         	{
         		jQuery.get("/ajax.php?method=getTestimony", {}, this.displayTestimony);
         	}
         

         	
        },
        displayNews: function (texte, erreur, requete){
        
        	var obj= $.json.decode(texte);
        	var wide = false;
        	if($('#blockNews').hasClass("wide"))
        	{
        		var t = $.template('<div class="bloc-date">${date}</div><div class="bloc-description"><a href="/news-and-press">${titleWide}</a></div><div class="separator"></div>');
        		wide = true;
        	}
        	else
        	{
        		var t = $.template('<p class="title-News">${date}</p><p class="description-News"><a href="/news-and-press">${title}</a></p><div class="separate"></div>');
        	}
        	$('#newsContent').html("");
        	$(obj).each(function(e,elem){
        		if(wide)
        			elem.titleWide= elem.title.substring(0,25)+'...';
        		$('#newsContent').append( t , elem);
        	});
        	
        },
        displayNewsletters: function (texte, erreur, requete){
             var obj= $.json.decode(texte);
             var t = $.template('<div class="infos-newsletters"><a href="${link}" >${title}</a></div><div class="separator"></div>');
        	 $('#newslettersContent').html("");  	
             $(obj).each(function(e,elem){
        		$('#newslettersContent').append( t , elem);
        	});         	
        },
        displayEvents: function (texte, erreur, requete){
             var obj= $.json.decode(texte);
             var t = $.template('<p class="date-events">${date}</p><div class="separator"></div><p class="infos-events">${title}</p>');
        	 $('#eventContent').html("");  	
             $(obj).each(function(e,elem){
        		$('#eventContent').append( t , elem);
        	});
        },
         displayTestimony: function (texte, erreur, requete){
             var obj= $.json.decode(texte);
             var t = $.template('<div class="panel"><div class="panel-wrapper"><p class="testimony-author">${node_data_field_t_display_in_random_block_field_author_value}</p><div class="separator"></div><p class="testimony-content"><img src="${file}" height="118" width="200" />${node_revisions_body}</p></div></div>');
        		$('#coda-slider-1').html("");  	
             $(obj).each(function(e,elem){
        		$('#coda-slider-1').append( t , elem);
        	});
        	$('#coda-slider-1').codaSlider({
        	autoSlide: true,
			autoSlideInterval: 8000,
			dynamicArrows: false,
			dynamicTabs: false
			});
        	

        }
        
    }
})(jQuery);

(function($) 
{
 	function gaPageTracker(event) {
 	   	pageTracker._link(this.href);
   }
   function gaDownloadTracker(event) {
 	   	pageTracker._trackPageview(this.href);
   }
   $.gaScript = {
         init: function() {
         	var el = $('a.gaTracker');
            el.each(function(e,elem)
			{
				$(elem).click(gaDownloadTracker);
			});
			var dm = $('#header .leftMenu a');
         	dm.each(function(e,elem)
			{
				if($(elem).attr('target') != '_blank')
					$(elem).click(gaPageTracker);
			});
        }
    }
})(jQuery);

$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
if(results && results[1])
	return results[1];
else
	return 0;

}
function addCaptcha(elem)
{
	var captchaTPL = '<div class="captchaTPL" id="recaptcha_custom_theme_widget"><label><a class="rcBtn" href="javascript:Recaptcha.reload()">Get another CAPTCHA</a><br><a class="rcBtn" href="javascript:Recaptcha.showhelp()">Help</a></label><div><span id="recaptcha_image"></span></div><div><label class="recaptcha_only_if_image">Enter the words above:</label><input type="text" class="form-text required" id="recaptcha_response_field" name="recaptcha_response_field" /></div></div>';
	//remove captcha
	$(".captchaTPL").remove();
	//insert captchaTPL
	$(elem).html(captchaTPL);
	Recaptcha.create(rcPubKey,elem.id,RecaptchaOptions );

}
function addCaptchaInContent()
{
	if($('#content #recaptcha_image').length == 0)
	{
		$("#content .RCcontainer").each(function(e,elem){addCaptcha(elem);});
	}
}
$(document).ready(function(){
     
     jQuery.ibaMenu.init();
   	 jQuery.ibaFooter.init();
  	 jQuery.ibaBU.init();
     jQuery.ibaHeaderBox.init();
     jQuery.fixedFooter.init();
     jQuery.citationRotator.init();
	 jQuery.tabBar.init();
	 jQuery.contentLoader.init();
	 jQuery.gaScript.init();
     $('.hf').hide();
      addCaptchaInContent();
    

      
});
