	var elementFocused=null;
	
	function executeForm(idform, task){
		$("#" + idform + " input[name=cas]").val(task);
		$("#" + idform).submit();
	}

	function openCalc(id){
		$("#verrou").css("width",$(document).width() + "px");
		$("#verrou").css("height",$(document).height() + "px");
		windowCenter(id);
		$(document).scrollTop(0);
		$(document).scrollLeft(0);
		$("#verrou").show("Fast");
		$("#"+id).show("Fast");
		cache_select();
		cache_flash();
	}

	function closeCalc(id){
		$("#verrou").hide();
		$("#"+id).hide();
		affiche_select();
		affiche_flash();
	}
	// Cache et affiche les select seulement pour ie 6 !!
	function cache_select() {
		var br = $.browser;
		if(br.msie && br.version < 7) $("select").hide();
	}
	function affiche_select() {
		var br = $.browser;
		if(br.msie && br.version < 7) $("select").show();
	}

	// Cache et affiche les flash !
	function cache_flash() {
		$("object, embed").each(function(){
			$(this).css('display','none');
		});
	}
	function affiche_flash() {
		$("object, embed").each(function(){
			$(this).css('display','block');
		});
	}

	function setFocus(obj) {
		elementFocused=obj;
	}

	function unsetFocus() {
		elementFocused=null;
	}

	function lanceAction(e) {
		var code = (e.keyCode ? e.keyCode : e.which);
		if((elementFocused != null) && (code == 13)) {
			switch(elementFocused.attr("id")) {
				case "r_codepostal" :
				case "r_codeclient" :
					executeForm("client_form","client");
				break;
				default: return;
			}
		}
	}

	function windowCenter(myId) {
		var EcranWidth = $(window).width();
		var EcranHeight = $(window).height();
		
		ElementWidth = $("#" + myId).width();
		ElementHeight = $("#" + myId).height();
		
		if((EcranHeight) < ElementHeight){
			$("#" + myId).height(EcranHeight - 10);
			$("#" + myId).width(ElementWidth + 15);
			$("#" + myId).css("overflow","auto");
			ElementWidth = $("#" + myId).width();
			ElementHeight = $("#" + myId).height();
		}
		
		var posX = parseInt((EcranWidth - ElementWidth)/2);
		var posY = parseInt((EcranHeight - ElementHeight)/2);
		
		$("#" + myId).css("left", posX+"px");
		$("#" + myId).css("top", posY+"px");
		
	}
	
	function goToByScroll(id){
		$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
	}
