function filesize (url) {
	// http://kevin.vanzonneveld.net
	// +   original by: Enrique Gonzalez
	// +      input by: Jani Hartikainen
	// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   improved by: T. Wild
	// %        note 1: This function uses XmlHttpRequest and cannot retrieve resource from different domain.
	// %        note 1: Synchronous so may lock up browser, mainly here for study purposes. 
	// *     example 1: filesize('http://kevin.vanzonneveld.net/pj_test_supportfile_1.htm');
	// *     returns 1: '3'
	
	var req = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
	if (!req) throw new Error('XMLHttpRequest not supported');
	
	req.open ('HEAD', url, false);
	req.send (null);
	
	if (!req.getResponseHeader) {
	    try {
	        throw new Error('No getResponseHeader!');
	    } catch(e){
	        return false;
	    }
	} else if (!req.getResponseHeader('Content-Length')) {
	    try {
	        throw new Error('No Content-Length!');
	    } catch(e){
	        return false;
	    }
	} else {
	    return req.getResponseHeader('Content-Length'); 
	}
}

// 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();

function call_tinybox() {
	// main settings
    tb_settings = {
    	closeImg: "../../images/i_lightbox/closelabel.gif",
    	loadingImg: "../../images/i_lightbox/loading.gif",
		nextImg: "../../images/i_lightbox/nextlabel.gif",
    	prevImg: "../../images/i_lightbox/prevlabel.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);
    });
} // call_tinybox

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
	call_tinybox();
		
	// jQFR -> jQuery Flash Remplacement
	/* jQuery("#body_layout h2:first").jQFR(
        {src: '../../includes/jQFR/optima.swf', 
         flashvars: { 
             css: [
                 '* { color: #666666; }',
                 'a { color: #0099CC; text-decoration: none; }',
                 'a:hover { text-decoration: underline; }'
             ].join(' ')
    }});
	
	jQuery("#menu_top ul li").jQFR(
        {src: '../../includes/jQFR/optima.swf', 
         flashvars: { 
             css: [
                 '* { color: #666666; }',
                 'a { color: #cccccc; text-decoration: none; }',
                 'a:hover { color: #ffffff; text-decoration: none; }',
                 'a.active { color: #ffffff; text-decoration: none; }'
             ].join(' ')
    }}); */
	
	// number control in form
	if( jQuery("div.form_inline_elt#number_control input").size() ) {
		jQuery("div.form_inline_elt#number_control input").keypress(function(e) {
			if( e.which == 44 && jQuery(this).val().indexOf(",") != -1 ) {
				return false;
			}
			switch(e.which) {
				case 0:
				case 8:
				case 44:
				case 48:
				case 49:
				case 50:
				case 51:
				case 52:
				case 53:
				case 54:
				case 55:
				case 56:
				case 57:
					return true;
				default:
					return false;
			}
		});
		jQuery("div.form_inline_elt#number_control input").change(function(e) {
			if( isNaN( parseFloat(jQuery(this).val(),10) ) ) jQuery(this).val("");
		});
	}	
});
