
$(document).ready(function(){
	
	$("a[href='#']").click(function(){return false;});
	
	$("#rc_lc_block_activite .icon_rss").click(function(){window.location = '/rss_calendrier.asp'});
	$("#rc_lc_block_actualite .icon_rss").click(function(){window.location = '/rss_actualite.asp'});
	
	

	
	$("#btn_search_submit").click(function(){
		$("#form_search").submit();
	});
	
	$("#search_map_form_keyword").submit(function(){
		change_map('motcle');
		window.location = "#map_canvas";
		return false
	});
	
	
	$("#search_lc_wrapper a:eq(0)").mouseover(function (){$(this).parent("#search_lc_wrapper").css("background-position","left -24px")});
	$("#search_lc_wrapper a:eq(0)").mouseout(function (){$(this).parent("#search_lc_wrapper").css("background-position","left top")});
	$("#search_frm_wrapper a:eq(0)").mouseover(function (){$(this).parent("#search_frm_wrapper").css("background-position","left -30px")});
	$("#search_frm_wrapper a:eq(0)").mouseout(function (){$(this).parent("#search_frm_wrapper").css("background-position","left top")});
	
	$("#header_top .logo_donnacona").click(function(){window.location = '/'});	
	
	$("#sAccordion .sAccordion-open-actif").parent("li").addClass("current");
	
	$.wt_accordion({
		container : 'sAccordion', // ID du container
		//activeContent : $("#active_accordion").val(), // Accordeon ouvert par defaut
		speed : 400 // vitesse de l'effet slideToggle ( slow, medium, speed )
	});
	
	/*$.wt_accordion({
		container : 'cal_accordion', // ID du container
		//activeContent : $("#active_accordion").val(), // Accordeon ouvert par defaut
		speed : 400 // vitesse de l'effet slideToggle ( slow, medium, speed )
	});*/
	
	$("#menu_donnacona .sAccordion-content > li>a[href='javascript:;'] + ul").each(function(index){
		if($(this).find(".active_section").size()==0){
			$(this).css("display", "none");
		}
	});
	
	
	
	$("#menu_donnacona .sAccordion-content > li>a[href='javascript:;']").click(function(e){
		$(this).next("ul").slideToggle();															
	});
	
	
	$("a[rel^='prettyPhoto']").prettyPhoto({modal:true});
	
	
	$(".textfield").focusin(function(){
		if($(this).val() == $(this).attr('title'))
		{
			$(this).val('');
		}
	});
	
	$(".textfield").focusout(function(){
		if($(this).val() == '')
		{
			$(this).val($(this).attr('title'));
		}
	});
	
	$('a[href*=".pdf"], a[href*=".doc"], a[href*=".docx"], a[href*=".xsl"], a[href*=".xslx"], a[href*=".ppt"], a[href*=".pptx"], a[href*=".txt"]').each(function(){
		$(this).attr('target','_blank');
	});
	$('a[href*="http://"]').not('a[href*="'+window.location.host+'"]').not('a[href*="youtube.com"]').each(function(){
		$(this).attr('target','_blank');
	});
	
	
	//##################################################################
	//###  Caroussel simili-flash accueil  #############################
	$("#home #header_top_bandeau div:first").css({'display': 'block'});
	
	$("#home #header_top_bandeau").everyTime(7000, function(){
		$(this).children('div:visible').fadeOut(2000).next().fadeIn(2000,function(){
			$(this).prev().clone().appendTo("#home #header_top_bandeau");
			$(this).prev().remove();
		});
	});
	
	/*##################################################################*/
	/*##  Process / Recherche  #########################################*/
	
	$("#resultats ul li:odd").addClass("evenodd_dark");
	$("#right_col_ros table.special_table tr:odd td").addClass("evenodd_dark");

	
});




function isInteger (s){
	var i;
	
	if (isEmpty(s))
	if (isInteger.arguments.length == 1) return 0;
	else return (isInteger.arguments[1] == true);
	
	for (i = 0; i < s.length; i++){
		var c = s.charAt(i);
		if (!isDigit(c)) return false;
	}
	
	return true;
}

function isEmpty(s){
	return ((s == null) || (s.length == 0))
}

function isDigit (c){
	return ((c >= "0") && (c <= "9"))
}

function isCurrency(s){
	var oRegExp = /^-?\d{1,6}(\.\d{2})?$/;
	return oRegExp.test(s);
}

function isEmail(email) {
	var oRegExp = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+$/;
	return oRegExp.test(email);
}

function trim (myString) { 
	return myString.replace(/^\s+/g,'').replace(/\s+$/g,'') 
}

function FormatNumber(number){
        return number.toFixed(2);
}

function currencyFormat(fld, milSep, decSep, e) {
  var sep = 0;
  var key = '';
  var i = j = 0;
  var len = len2 = 0;
  var strCheck = '0123456789';
  var aux = aux2 = '';
  var whichCode = (window.Event) ? e.which : e.keyCode;

  if (whichCode == 13) return true;  // Enter
  if (whichCode == 8) return true;  // Delete
  key = String.fromCharCode(whichCode);  // Get key value from key code
  if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
  len = fld.value.length;
  for(i = 0; i < len; i++)
  if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
  aux = '';
  for(; i < len; i++)
  if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
  aux += key;
  len = aux.length;
  if (len == 0) fld.value = '';
  if (len == 1) fld.value = '0'+ decSep + '0' + aux;
  if (len == 2) fld.value = '0'+ decSep + aux;
  if (len > 2) {
    aux2 = '';
    for (j = 0, i = len - 3; i >= 0; i--) {
      if (j == 3) {
        aux2 += milSep;
        j = 0;
      }
      aux2 += aux.charAt(i);
      j++;
    }
    fld.value = '';
    len2 = aux2.length;
    for (i = len2 - 1; i >= 0; i--)
    fld.value += aux2.charAt(i);
    fld.value += decSep + aux.substr(len - 2, len);
  }
  return false;
}
