var domain = "http://www.journaliste-web.be/";

$(document).ready(function(){
	cufcuf();
	//menu();
	//ipod();
	services();
	fleche();
	ouverture();
	a();
	tags();
	agrandir();
	bordre();
});

function cufcuf(){
	Cufon.replace(".cufon",{fontFamily: 'Calisto MT'});
  Cufon.replace(".cufon1 ", {fontFamily: 'Eras Light ITC'});
  
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
 var ieversion=new Number(RegExp.$1); // capture x.x portion and store as a number
 if (ieversion>=8){
  
  }
 else if (ieversion>=7){

   }
 else if (ieversion>=6 || ieversion>=5){
  
 
  
  /*var exHeight = $('.sousTitre').parent('li').find('a').height();
  $('.sousTitre').parent('li').find('a').height(exHeight);*/
 }
 else {

}}else
 {

}



	var classMenu = $('#nav').attr('class');
	if (classMenu == 'anime'){
		$("#nav").animate({marginLeft:0+"px"},{
    duration: 500, 
    specialEasing: {
       marginLeft: 'easeOutBounce'
	   }
    });
	
	$('li a.selected').animate({paddingLeft:125+"px"},{
    duration: 500, 
    specialEasing: {
       paddingLeft: 'easeOutBounce'
	   }
    });
	
	}else if (classMenu == 'left'){
		$("#nav").css({marginLeft:0+"px"});
	
		$('li a.selected').css({paddingLeft:125+"px"});
	
	}
	
	
	
	$('.photo img').each(function(){
		//$(this).css({opacity:0.5});
	
	
	});
	
	$('.photo img').hover(function(){
		//$(this).animate({opacity:1},200);
		$(this).addClass('full');
	},function(){
		$(this).removeClass('full');
	});
	
	$('.photo').click(function(){
		doTransition($(this).attr('rel'));
		$('.photo img').each(function(){
			$(this).removeClass('active');
		});
		$(this).find('img').addClass('active');
	});
}

function menu(){
 $('#menu li a').hover(function(){
 $(this).parent().css("background", 'url('+domain+'files/design/menu_on.jpg)');
 });
 $('#menu li a').mouseout(function(){
 $(this).parent().css("background", 'url('+domain+'files/design/menu_off.jpg) no-repeat');
 
 });
}

function  ipod(){
    	// BUTTONS
    	$('.fg-button').hover(
    		function(){ $(this).removeClass('ui-state-default').addClass('ui-state-focus'); },
    		function(){ $(this).removeClass('ui-state-focus').addClass('ui-state-default'); }
    	);
    	
    	// MENUS    	
		$('#flat').menu({ 
			content: $('#flat').next().html(), // grab content from this page
			showSpeed: 400 
		});
		
		$('#hierarchy').menu({
			content: $('#hierarchy').next().html(),
			crumbDefaultText: ' '
		});
		
		$('#hierarchybreadcrumb').menu({
			content: $('#hierarchybreadcrumb').next().html(),
			backLink: false
		});
		
		// or from an external source
		$.get('files/design/menuContent.html', function(data){ // grab content from another page
			$('#flyout').menu({ content: data, flyOut: true });
		});
    }
	
function services(){
	$('.icone a').hover(function(){
	$(this).find('img').animate({
		top: 20+'px'
	}, 100, '');
	}, function(){
		$(this).find('img').animate({
		top: 33+'px'
	}, 400, '');
	});
	
}

function fleche(){
$('.fleche').click(function(){
	$('#testHandle'+$(this).find('a').attr('rel')).trigger("click");
	});
}

function ouverture(){
	$('#hierarchybreadcrumb').trigger("click");
}

function a(){
$('.handle a');
return false;
}

function tags(){
$('#tags').tagSphere({
        height: 268,
        width: 350,
        slower: 0.65,
        radius: 50,
        timer: 50,
		tagCSSOver: {
            border: 'solid 0px blue',
            color: 'blue'
        }
      });
}
function agrandir(){

	/* var fenetre=$(window).height();
	var footer=248;
	var milieu=$("#content_bas").height();
	var haut=$("#container_top").height();
	var addition=footer+milieu+haut;
	console.log (addition);
	console.log(fenetre);
	if(fenetre>addition){
	console.log("je suis ds le si");
		 var soustraction=fenetre-addition;
		 console.log(soustraction);
		 $("#footerDegrader").height(soustraction);
	}
	 $(window).resize(function(){
	 //alert("djk");
	 var fenetre2=$(window).height();
	 //if(fenetre2>addition){
	 //console.log("je susis ds l autre si");
		 var soustraction=fenetre2-addition;
		 if(soustraction>248){
		 $("#footerDegrader").height(soustraction);
	}else{$("#footerDegrader").height(0);}
	 }); */
	
	var height = $(document).height();
	
		
	if (height>$(window).height()){
		$('#footer').css({position:'relative'});
		
	}else{
		$('#footer').css({position:'absolute',bottom:0});
		// var win=$(window).height();
		// var haut=win-412;
		// $('#footer').css({top:haut})
		
		
	}
	
	 $(window).resize(function(){
		
		// console.log($(document).height());
		var height = $(document).height();
		// $('body').height(height);
		if ($('#footer').css('position')=='absolute'){
			// height+=$('#footer').height();
		}
		
		
		if (height>$(window).height()){
			// if (height-656<$(window).height()){
				$('#footer').css({position:'relative'});
			// }
		}else{
			$('#footer').css({position:'absolute',bottom:0});
		}		
	});  
	
}
function bordre(){
$(".infos:last").attr("id","dernierSlide");
}




