function bindPage(){
	$(".popup").live('click', function(){
		window.open($(this).attr("href"));
		return false;
	});
	$(".ticketFermer").live('click', function(){
		var agree=false;
		agree=confirm("Souhaitez vous vraiment fermer le ticket ?");
		if ( agree ){
			$('#ticketFermerForm').attr("value",$(this).attr("id"));
	  		$('#ticketRouvrirForm').attr("value",'');
			$("form#list").submit();
		}
		else {
		  	return false;
		}
	});
	$(".ticketRouvrir").live('click', function(){
		var agree=false;
		agree=confirm("Souhaitez vous vraiment le rouvrir le ticket ?\nLe cas écheant, précisez le problème rencontré.");
		if ( agree ){
	  		$('#ticketRouvrirForm').attr("value",$(this).attr("id"));
			$('#ticketFermerForm').attr("value",'');
			$("form#list").submit();
		}
		else {
		  	return false;
		}
	});
	// MENU HAUT DE PAGE
	$(".nav").children("li").each(function() {
		var current = "nav current-" + ($(this).attr("class"));
		var parentClass = $(".nav").attr("class");
		if (parentClass != current) {
			$(this).children("a").css({backgroundImage:"none"});
		}
	});	

	// create events for each nav item
	attachNavEvents(".nav", "philosophie");
	attachNavEvents(".nav", "services");
	attachNavEvents(".nav", "portfolio");
	attachNavEvents(".nav", "contacts");

	function attachNavEvents(parent, myClass) {
		$(parent + " ." + myClass).mouseover(function() {
			$(this).append('<div class="nav-' + myClass + '"></div>');
			$("div.nav-" + myClass).css({display:"none"}).fadeIn(150);
		}).mouseout(function() {
			$("div.nav-" + myClass).fadeOut(500, function() {
				$(this).remove();
			});
		}).mousedown(function() {
			$("div.nav-" + myClass).attr("class", "nav-" + myClass + "-click");
		}).mouseup(function() {
			$("div.nav-" + myClass + "-click").attr("class", "nav-" + myClass);
		});
	}
    $('.fadeThis').append('<span class="hover"></span>').each(function () {
      var $span = $('> span.hover', this).css('opacity', 0);
      $(this).hover(function () {
        $span.stop().fadeTo(400, 1);
      }, function () {
        $span.stop().fadeTo(400, 0);
      });
    });
	
	$('.fade').fadeTo(2000, 1.0).fadeTo(4000, 0.0);
	
	$("#datepicker").datepicker({
		dateFormat: 'dd/mm/yy',
		monthNames: ['Janvier','F&eacute;vrier','Mars','Avril','Mai','Juin','Juillet','Aout','Septembre','Octobre','Novembre','D&eacute;cembre'],
		dayNames: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'],
		dayNamesMin: ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa'],
		prevText: 'Mois pr&eacute;c&eacute;dent',
		nextText: 'Mois suivant',
		firstDay: 1,
		minDate:0,
		duration: 'fast'});
}

function PortfolioEdit(id,wwwroot){
	if (!wwwroot) { wwwroot = 'page/'; } 
	Fenetre = window.open(wwwroot+'portfolio_edit.php?id='+id,'admin','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=750,height=520');
	Fenetre.focus();
}
function PortfolioServices(id,wwwroot){
	if (!wwwroot) { wwwroot = 'page/'; } 
	Fenetre = window.open(wwwroot+'portfolio_services.php?id='+id,'admin','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=630,height=520');
	Fenetre.focus();
}
function ajax_page_advanced(ele,msg,url){
	//$(ele).slideUp("slow", function(){
	        //$(ele).html(msg).show("slow", function(){
	                $(ele).load(url+" "+ele, null, function(){
	                        var tampon = $(ele).html();
	                        //$(ele).html(msg).hide("slow",function(){
	                                $(ele).html(tampon);
	                                $(ele).slideDown("slow");
	                        //});
	                });
	        //});
	//});
}
function ajax_page(ele,msg,url){
	$(ele).html(msg).load(url+" "+ele);
}
$(document).ready(function(){
	bindPage();
	$(".NewsD2lLink").live('click', function(){
		ajax_page_advanced('#NewsD2lDiv','<p style="text-align: center">Chargement ...</p>',this.href);
		return false;
     });
	$(".NewsLink").live('click', function(){
		ajax_page_advanced('#NewsDiv','<p style="text-align: center">Chargement ...</p>',this.href);
		return false;
     });
});



