// Limiteur de caractère textarea, display des caractères restants
function limiteur(maximum,champ,indic)
{
	if (champ.value.length > maximum) champ.value = champ.value.substring(0, maximum);
	else indic.value = maximum - champ.value.length;
}

function arrondir(nombre, decimales)
{
  if (isNaN(nombre)) return "";
  if (decimales == 0)
  {
     var n = Math.round(nombre);
     return n.toString();
  }
  else if (decimales > 0)
  {
     if (document.all) var undefined; // Netscape 4 ne connaît pas la constante "undefined"
     var p10 = Math.pow(10, decimales);
     var n = Math.round(nombre * p10);
     n = n.toString();
     var point = n.length - decimales;
     if (point >= 0) n = n.substring(0, point) + "." + n.substring(point);
     else n = "0." + formater(n, decimales);
  }
  else
  {
     var p10 = Math.pow(10, -decimales);
     var n = Math.round(nombre / p10) * p10;
     n = n.toString();
  }
  if (nombre.signe_decimal == undefined) return n;
  else return n.replace(".", nombre.signe_decimal);
}

function submitDaForm(URL)
{
	document.SelectProductZoneForm.action = URL;
}

/* jQuery Manipulations */

jQuery.noConflict();

jQuery(document).ready(function() {
	
	/* Cornered Borders 
		// jQuery("div#col-right div.box1").corner("7px top cc:#fff");
		jQuery("#menu_left>ul>li:not(#menu_left>ul>li>ul>li)").corner("7px cc:#fff");
		jQuery(".image_box").corner("7px cc:#fff");
		jQuery(".right_box h2").corner("7px top cc:#fff");
		jQuery("div.right_box .box_content").corner("7px bottom cc:#fff");
		jQuery(".group_block h2").corner("7px cc:#fff");		
		
		jQuery(".jquery-corner").css("zIndex", 50);
	*/
	
	// Tinyboxes insertions 
		// main settings
		tb_settings = {
			closeImg: "../../images/i_tinybox/close.gif",
			loadingImg: "../../images/i_tinybox/loading.gif",
			displayNav: false
		};
		// parsing links
		var sets = new Array();
		jQuery('a[rel^="tinybox"]').each(function() {
			set = jQuery(this).attr("rel").split("|");
			set = set[1];
			sets.pushOnce( set );
		});
		jQuery('a[rel="tinybox"]').each(function() {
			jQuery(this).tinybox(tb_settings);
		});
		jQuery.each(sets, function(ind, elt) {
			tb_settings.set = elt;
			tb_settings.displayNav = true;
			jQuery('a[rel="tinybox|'+elt+'"]').tinybox(tb_settings);
		});
		
	/* jQFR -> jQuery Flash Remplacement
	jQuery("#body_layout h2:first").css("fontSize", 28).css("paddingBottom", 5).jQFR(
       { src: '../../includes/jQFR/optima.swf', 
         flashvars: { 
             css: [
                 '* { color: #f29400; }',
                 'a { color: #666; text-decoration: none; }',
                 'a:hover { text-decoration: underline; }'
             ].join(' ')
    }}); */
	
	if( jQuery("#home_objects").size() ) {
		jQuery("#all_recettes, #month_recette object").css("cursor", "pointer");
		jQuery("#all_recettes").click(function() {
			window.location = jQuery(this).find("a").attr("href");
		});
		jQuery("#month_recette object").click(function() {
			window.location = jQuery(this).parent().find("a").attr("href");
		});
	}
	
});

