$(document).ready(function(){

//switch language
$('#switch-language').hover(function() {
	$(this).animate({height:'40px'}, 100);
}, function() {
	$(this).animate({height:'15px'}, 200);
});

//menu primary
$('#menu-primary ul li').hover(function(){
	$('ul',this).stop(true, true).slideDown(100);
}, function(){
	$('ul',this).stop(true, true).slideUp(200);
});

//search
//place holder
$('input[type=text]#s').focus(function(){ 
	if($.trim($(this).val()) == $(this).attr('defaultValue'))
	{
	  $(this).val('');
	  $(this).css('color','#333333');
	}
});

$('input[type=text]#s').blur(function(){
	if($.trim($(this).val()) == '')
	{
	  $(this).val($(this).attr('defaultValue'));
	  $(this).css('color','#999999');
	} 
});
//search action
$('#search-form').submit(function() {
	var search_value = $.trim($('#s').val());
	if(search_value == '' || search_value == 'Rechercher' || search_value == 'Search')
	{
		alert('Please type something');
		return false;
	} else {
		//alert(search_value);
		//do something as callback ajax => php
		return true;
	}
});

//banner slider
var changeEvery = 7;
var itvl = setInterval(function(){autoAdvance()},changeEvery*1000);
var totWidth=0;
var positions = new Array();

$('#banner-slider .slide-banner').each(function(i){
	positions[i]= totWidth;
	totWidth += $(this).width();	
});

$('#banner-slider').width(totWidth);
$('#banner-thumb ul li a').click(function(e,keepScroll){
	var pos = $(this).parent().prevAll('.slideItem').length;
	$('#banner-slider').stop().animate({marginLeft:-positions[pos]+'px'},500);
	e.preventDefault();
	if(!keepScroll) clearInterval(itvl);
});

var current=1;
function autoAdvance(){
	if(current==-1) return false;
	$('#banner-thumb ul li a').eq(current%$('#banner-thumb ul li a').length).trigger('click',[true]);
	current++;
}

//banner thumb
$('#banner-thumb ul li').hover(function() {
	$(this).siblings().stop().animate({opacity: 0.5}, 'fast');
}, function() {
	$(this).siblings().stop().animate({opacity: 1.0}, 'fast');
});

//breadcrumbs
var chrlist = '> ';
$('#banner-default ul li:not(:first)').each(function(){
	$(this).prepend(chrlist);
});

//logo slider
$('#logo-slider ul').bxSlider();
$('#logo-mini-slider ul').bxSlider();

//clients-slider
$('#col-clients td').each(function(){
	$(this).find('ul').bxSlider({
		mode: 'vertical'
	});
});
  
 
//position footer
$(function(){positionFooter(); 
	function positionFooter(){
	
	var margin_top = $("#content-footer").css("margin-top").replace("px", "");
	var page_height = $(document.body).height() - margin_top;
	var window_height = $(window).height();
	var difference = window_height - page_height;
	if (difference < 0) 
		difference = 0;
	
	$("#content-footer").css({
		margin: difference + "px 0 0 0"
	})
	}

	$(window).resize(positionFooter)
});


//content menu 
$('#content-menu ul li:last-child a').css('width','100%');


//sidebar slid toggle
$('.sidebar-bloc ul li:first-child ul').show();

$('.sidebar-bloc ul li').click(function(){
	$(this).find('ul').toggle(300);
});


//disable right click
/* $(document).bind("contextmenu",function(e){
    return false;
}); */

        
});//end document

