
function setDays(day, month, year) {
	var cell_highlight = false;
	var cell_text = '';
	var cell_css_class = '';
	
	if (otherDays != null) {
		for (i = 0; i < otherDays.length; i++) {
			if ((day == otherDays[i][0]) && (month == otherDays[i][1] - 1) && (year == otherDays[i][2])) {
				cell_highlight = true;
				cell_text = cell_text ? cell_text + ', ' + otherDays[i][3] : otherDays[i][3];
				cell_css_class = 'other';
				//return result;
				//break;
			}
		}
	}
	
	
	if (enabledDays != null) {
		for (i = 0; i < enabledDays.length; i++) {
			if ((day == enabledDays[i][0]) && (month == enabledDays[i][1] - 1) && (year == enabledDays[i][2])) {
				cell_highlight = true;
				cell_text = cell_text ? cell_text + ', ' + enabledDays[i][3] : enabledDays[i][3];
				cell_css_class = 'first';
				//return result;
				//break;
			}
		}
	}
	
	/*
	if( enabledDays != null ){
		for (i = 0; i < enabledDays.length; i++) { 
			if($.inArray((month+1) + '-' + day + '-' + year,enabledDays) != -1) { 
				result = [true, '', '']; 
				return result;
				//break;
			} 
		}
	}
	*/
	return [cell_highlight, cell_css_class, cell_text];
}

function disableDates(date) 
{ 

				var day = date.getDate(); //entre 1 et 31
				var month = date.getMonth(); // entre 0 et 11
				var year = date.getFullYear(); // 4 chiffres
				
				/*
				If you don't want the weekends to appear at all, simply:
				
				th.ui-datepicker-week-end, td.ui-datepicker-week-end {
					display: none;
				}
				*/
				/*var noWeekend = $.datepicker.noWeekends(date); //samedi et dimanche !
				*/
				//if (noWeekend[0]) {
					return setDays(day, month, year);
				/*} else {
					return noWeekend;
				}*/

  /*
  var m = date.getMonth(), d = date.getDate(), y = date.getFullYear(); 
  
  for (i = 0; i < enabledDays.length; i++) { 
    if($.inArray((m+1) + '-' + d + '-' + y,enabledDays) != -1) { 
      return [true]; 
    } 
  } 
  return [false]; 
*/
} 


jQuery(document).ready(function() 
{
	$('#selLang').change(function(){
		xajax_changeLang($(this).val());
	});
	
	$('#btnSubscribe').click(function(){
		xajax_subscribe($('#txtEmail').val());
		return false;
	});
	
	old_val = $('#txtEmail').val();
	
	$('#txtEmail').focus(function(){
		if( $(this).val() == old_val )
		{
			$(this).val('');
		}
	});
	
	$('#txtEmail').blur(function(){
		if( $(this).val() == '' )
		{
			$(this).val(old_val);
		}
	});
	
	$('#txtEmail').live("keydown", function(e) { var c = e.which ? e.which : e.keyCode; if( c==13 ){jQuery.Event(e).preventDefault();xajax_subscribe($('#txtEmail').val());} });
	
	$('input[name="btnVote"][type="button"]').each(function(){
		$(this).click(function(){
			if( $(this.form['rating']).val() )
			{
				xajax_addVote($(this.form['item_id']).val(), $(this.form['rating']).val());
			}
		});
	});
	$('input[name="btnVote"][type="image"]').each(function(){
		$("#ratings").children().not("select").hide();
	
		// Create target element for onHover titles	
		$("#ratings").stars({
			inputType: "select",
			cancelShow: false,
			//captionEl: $caption, // point to our newly created element
			callback: function(ui, type, value)
			{
				//alert($('input[name="item_id"]').val()+", "+value);
				xajax_addVote(value, $('input[name="item_id"]').val());
				//$.post("demo2.php", {rate: value}, function(data)
				//{
					//$("#ajax_response").html(data);
				//});
			}
	
		});

		// Make it available in DOM tree
		//$caption.appendTo("#ratings");
														   
														   
														   
														   
														   
		/*$(this).click(function(){
			if( $(this.form['rating']).val() )
			{
				alert($(this.form['item_id']).val()+" > "+$(this.form['rating']).val());
				xajax_addVote($(this.form['item_id']).val(), $(this.form['rating']).val());
			}
			return false;
		});*/
	});
	

	// MENUS    	
	$('#lgSelect').menu({ 
		content: $('#lgContent').html()
	});
	
	$('.btnShowContent').click(function(){
		$(this).parent().parent(".hideContent").toggleClass("hideContent").toggleClass("showContent");
	});
	$('.btnHideContent').click(function(){
		$(this).parent().parent(".showContent").toggleClass("showContent").toggleClass("hideContent");
	});
	
	$(".menu ul li:last-child").addClass("last");
	$(".menu ul li:first-child").removeClass("last");
	$(".menu ul li:first-child").addClass("first");
	
	var widthAllSubMenu = 0;
	var numElementSubMenu = $(".menu ul > li").not(".menu ul li li").length;
	$(".menu ul > li").not(".menu ul li li").each(function() {
		widthAllSubMenu += $(this).outerWidth( true );
	});	
	if (widthAllSubMenu<958) {
		var widthPadding = Math.floor(((958 - widthAllSubMenu)/$(".menu ul > li").not(".menu ul li li").length)/2);
		$(".menu ul li a").not(".menu ul li li a").css({ paddingRight: widthPadding+20, paddingLeft: widthPadding });;
	}
	
	
	$(".breadcrumb a:contains(Services)").each(function(){$(".menuSec li:eq(0)").addClass("on")});
	$(".breadcrumb a:contains(Logiciels)").each(function(){$(".menuSec li:eq(1)").addClass("on")});
	$(".breadcrumb a:contains(Materiels)").each(function(){$(".menuSec li:eq(2)").addClass("on")});
	$(".menu .open[href$='/index.php?&page=hometuc']").each(function(){$(".menuSec li:eq(0)").addClass("on")});
	
	$(".siteMap a[href$='/index.php?&page=hometuc']").parent().parent().parent().parent().append($(".siteMap a[href$='/index.php?&page=hometuc']").parent());
	
	
	
	$(".caseIntro").append("<div class='clear'>&nbsp;</div>");
	
	if ($(".menu ul li").length==0) {$("body").addClass("withoutMenu");}
	
	$("a[href$='/index.php?&page=services']").attr({ href: "/index.php?&page=Solutionsmetiers"});
	
	/*Maxime Changement du 04/02 */
	
	//pour pointer le bouton Lociciel vers la page Architecture
	$("a[href$='/index.php?&page=logiciels']").attr({ href: "/index.php?&page=Architecture"});
	
	// pour mettre le bouton news en select
	$(".breadcrumb a[href$='/index.php?&page=nnews']").each(function(){
		$(".colLeft .menu a[href$='/index.php?&page=nnews']").addClass("open").parent().addClass("open");
	});
	$(".breadcrumb a[href$='/index.php?&page=nevents']").each(function(){
		$(".colLeft .menu a[href$='/index.php?&page=nevents']").addClass("open").parent().addClass("open");
	});
	$(".breadcrumb a[href$='/index.php?&page=neventstase']").each(function(){
		$(".colLeft .menu a[href$='/index.php?&page=neventstase']").addClass("open").parent().addClass("open");
	});
	$(".breadcrumb a[href$='/index.php?&page=narchives']").each(function(){
		$(".colLeft .menu a[href$='/index.php?&page=narchives']").addClass("open").parent().addClass("open");
	});
	
	/**/
	
	
	$("a[href$='/index.php?&page=materiels']").attr({ href: "/index.php?&page=Autre"});
	$(".siteMap a[href$='/index.php?&page=contact']").attr({ href: "/index.php?&page=apropos#fragment-5"});
	/*$(".menu li").mouseover(function() {
		$(this).toggleClass("menuOver");
	});
	$(".menu li").mouseout(function() {$(this).removeClass("menuOver");});*/
	
	
	$(".menu li").not(".menu ul li li").hover(function(){
		$(this).addClass("menuOver");
		$(".menu ul li ul ul").css({ left: $(".menu ul li ul ul").parent().width()+20 });
		$(".menu ul li:last-child ul ul").css({left: "inherit", borderLeft: "0px", borderRight: "1px solid #CCC", right: $(".menu ul li ul ul").parent().width()+20 });
	},function(){
		$(this).removeClass("menuOver");
	});
	
	
	$("#productSlideContent").easySlider();
	if ($(".apropos").length) {
		var $tabs = $('#tab_buttons').tabs(); // first tab selected
	
		$('.btnFrag1').click(function() { // bind click event to link
			$tabs.tabs('select', 0); // switch to third tab
			return false;
		});
		$('.btnFrag2').click(function() { // bind click event to link
			$tabs.tabs('select', 1); // switch to third tab
			return false;
		});
		$('.btnFrag3').click(function() { // bind click event to link
			$tabs.tabs('select', 2); // switch to third tab
			return false;
		});
		$('.btnFrag4').click(function() { // bind click event to link
			$tabs.tabs('select', 3); // switch to third tab
			return false;
		});
		$('.btnFrag5').click(function() { // bind click event to link
			$tabs.tabs('select', 4); // switch to third tab
			return false;
		});
	}
	/*if ($("#tab_buttons").length!=0) {
		//$("#tab_buttons li").width((657/$("#tab_buttons li").length)-11);
		var widthAllTab = 0;
		$("#tab_buttons li").each(function() {
			widthAllTab += $(this).outerWidth( true );
		});
		var widthPaddingTab = Math.floor(((657 - widthAllTab)/$("#tab_buttons li").length)/2);
		$("#tab_buttons li a").css({ paddingRight: widthPaddingTab+10, paddingLeft: widthPaddingTab });
	}*/
});

