$(document).ready(function(){

	/* gestion de la lageur de la div centrale*/
	if($('.siabpanneltwo').size() == 0) {
		$('.siabpannecontent').width(700);
	}
	
	/* main menu */
	$('.siabmainmenu a').addClass('a_border');
	$('.siabmainmenu a:last').removeClass('a_border');
	$('.siabmainmenu li:first').addClass('picto_home');
	$('.sogecap_actualites_content_post:last').css({'background-image' : 'none'});
	$('.siabsubmenu a').addClass('a_border');
	$('.siabsubmenu a:last').removeClass('a_border');
	  
	/* gestion bordure */
	$('#toolbox-print-info').css({'background-image' : 'none'});
	  
	$('.pag_nav').each(function(){
	$('.pag_nav ul li a').addClass('pagnavborder').filter("a:last").removeClass('pagnavborder');
});
 
$('.siabpannelfull ul.alpha_list li a:last').css({'background-image' : 'none'});

/* input champs de recherche */
$('input[type="text"]').focus( function() { if(this.value=='Recherche')this.value='' ;});
 
/* tool box */
function initoolbox () {
	$('.envoyer-block ul li a span').each(function(){
		$(this).hide();
	});
};
initoolbox ()

$('#toolbox-print-info').hover(function() {
$('#toolbox-print-info span').fadeIn(0); },function() { $('#toolbox-print-info span').hide();}); 
 
$('#toolbox-addtofav-info').hover(function() {
$('#toolbox-addtofav-info span').fadeIn(0); },function() { $('#toolbox-addtofav-info span').hide();}); 

$('#toolbox-mailto-info').hover(function() {
$('#toolbox-mailto-info span').fadeIn(0); },function() { $('#toolbox-mailto-info span').hide();}); 

$('#toolbox-contact-info').hover(function() {
$('#toolbox-contact-info span').fadeIn(0); },function() { $('#toolbox-contact-info span').hide();}); 


/* accordeon */
function iniaccordeon () {
	$(".accordeon_content").hide();
//$(".accordeon h3").css({'background-color' :'#ededed'});
	$(".accordeon h3").click(function () {
  if ($(this).next('.accordeon_content').is(":hidden")) {
	$(this).next('.accordeon_content').slideDown("slow");
	$(this).addClass('active').css({'background-color' :'#ededed'});
  } else {
	$(this).next('.accordeon_content').slideUp("Slow");
	$(this).removeClass('active').css({'background-color' :'#ffffff'});
  }
});

} 

iniaccordeon ()
//$('.siabsecnav ul ul').hide();

/* Sub Menu */
function inisiabseNav () {

$('.siabsecnav ul a').click(function() {
  var checkElement = $(this).next();
  if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
	return false;
	}
  
  if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
	$('.siabsecnav ul ul:visible').slideUp('normal');
	checkElement.slideDown('normal');
	return false;
	}
 });
}

//inisiabseNav ()

function smoothFootScroll(){
	$('.top_scroll a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target
			|| $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body')
				.animate({scrollTop: targetOffset}, 1000);
				return false;
			}
		}
	});
}
smoothFootScroll()

/* recherche */
$('ul#select_box ul').hide();

 
 $('ul#select_box').hover(function() {
 
   $('ul#select_box ul').stop().slideDown('slow');},
	function() {
	$("ul#select_box ul").slideUp('slow');
	}); 
	
$('.trie_box ul li a').eq(1).hide();
$('.trie_box ul li a').eq(1).css({'background-image' : 'none'});
		
$('.trie_box ul').hover(function() {
  	$('.trie_box ul li a').eq(1).slideDown(); }, 
	function() {
  	$('.trie_box ul li a').eq(1).slideUp(); 
}); 
	
function mapause(time)
{
   d=new Date();
   diff=0;
    while(diff < time)
    {
      n=new Date();
      diff=n-d;
     } 
}	

/* gestion actus */
setTimeout(slideNews, 1000);
function slideNews(){
    var $active = $('.slide_actulaites .sogecap_actualites_content_post.active');
    if ( $active.length == 0 ) $active = $('.slide_actulaites  .sogecap_actualites_content_post:last');
    var $next =  $active.next().length ? $active.next() : $('.slide_actulaites  .sogecap_actualites_content_post:first');
    $active.addClass('last-active');		
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 0.99}, 2000, function() {
            $active.removeClass('active last-active');
        });
}

function playSlide(){
	$timer = setInterval(slideNews, 6000);
}playSlide();

$('.slide_actulaites .sogecap_actualites_content_post').hover(
	function (){clearInterval($timer)}, function (){playSlide()}
);	

// tabulations
var tabContainers = $('div#tabs > div');
tabContainers.hide().filter(':first').show();
			
$('div#tabs ul a').click(function () {
			
	tabContainers.hide();
 	tabContainers.filter(this.hash).fadeIn(1000, function() { /*Cleartypefonction*/ });
	tabContainers.hide();
	tabContainers.filter(this.hash).show();
	 
		$(this).parent('li').addClass('active').siblings('li').removeClass('active');
		return false;
	}).filter(':first').click();
			
});
 

 
// CLeartypeFonction 
(function($) {
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
})(jQuery);



 


