var url=eval('"'+self.document.location+'"');
var domaine=url.substring(7,url.indexOf("/",7));
if (domaine=="localhost"){
	var domaine="http://"+domaine+'/A_GLOBAL_V10';
}else{
	var domaine="http://"+domaine;
}

/*MAJ fond de page*/
/*function fd_page(){
	fixH2('colplein1','col1','col2','content');

}*/
//--------------------------------------------------------------------------------------------------------------------
//rafraichit hauteur colonne pour le fond de page
function mainmenu(){
	$("#menuh ul").css({display: "none"}); // Opera Fix
	$("#menuh li").hover(function(){
		
			//window.console && console.log(' ', $(this).parent().parent().parent().find('a:first').html() );
			//$(this).parent().parent().find('a:first').addClass('restehover');
			$(this).parent().parent().parent().find('a:first').addClass('restehover');
			$(this).find('ul:first').css({visibility: "visible",display: "none"}).show();

			if($.browser.msie) {
				v=parseInt($(this).height()); 
			}else {
				v=parseInt($(this).find('a:first').css('height'));
			}
			//Si vertical
			//h=parseInt($(this).width());
			//$(this).find('ul:first').css({"margin-top":-v,"margin-left":h});

		},function(){
			//$(this).parent().parent().parent().find('a:first').removeClass('restehover');
			$(this).find('ul:first').css({visibility: "hidden"});
		});
}

//============================================================================================================

function alertinfo(val){}


/* Ouverture d'un fiche dans une popup simulée */
function to_speudo_popup(url,data) {
    $('#masque').toggle();
	$("#pseudo_popup").animate({'height': 'toggle','opacity': 'toggle'}, "slow"); 
	$.ajax({type:'POST', url:url, data:data, success:function(msg) {	
			$('#contenu_popup').html(msg);
			var height=$('#contenu_popup').height()/2;
			$('#pseudo_popup').css({"margin-top":"-"+height+"px","top": "50%"});
		}
	});
			

	//$("#contenu_popup").load(url+'?'+data);

}



function in_div(div,url,data,objetid) {
	if (div=="contenu_popup"){
		$.ajax({type:'POST', url:url, data:data,  success:function(msg) {	
			$('#contenu_popup').html(msg);
			this.cycleTimeout = 0;	this.cycleTimeout = setTimeout(function() { continu();	}, 500);
			function continu(){	$("#pseudo_popup").centerInClient({ container: window, forceAbsolute: true });	clearTimeout(this.cycleTimeout);	}
			}
		});
	}else{
		$('#'+div+''+objetid).load(url+'?'+data);
	}
}









function frmsubmit(func) {
	// recalcule Caddie avec click sur formulaire
	frm = document.entryform;
	frm.func.value = func;
	frm.submit();
}

function JOpenWn(Address,WnName,la,h) { 
	var fenetre_1;
	var L = (screen.width - la) / 2;
	var H = (screen.height - h) / 2;
	fenetre_1=window.open(Address,WnName, "menubar=no, status=no, scrollbars=no, menubar=no, left="+L+",top="+H+", width="+la+", height="+h+"");
	fenetre_1.focus();
}


// Gestion du PNG ==========================================================================
var ua=navigator.userAgent;
var isIE=ua.indexOf("MSIE")>1;
var isFF=ua.indexOf("Firefox")>1;
var isOther=!(isIE||isFF);
function GetBrowserVer(){
    if (isIE){ return parseFloat(ua.split("MSIE")[1]); }
	else if(isFF) { return parseFloat(ua.split("Firefox/")[1]); }
}
var islt7IE=isIE&&GetBrowserVer()<7;
function FillPNG(obj,img){
    if (islt7IE) {  obj.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img+"',sizingMethod='crop')";   }
	else { obj.style.backgroundImage="url("+img+")";  }
}

//===================================================================================================
/*
function active(ong,nbre){
	for(i=1;i<=nbre;i++){
		if(i!=ong){
			 ongActif=document.getElementById("ong"+i);
			 ongActif.className="onglet_off";
			 pgActive=document.getElementById("pg"+i);
			 pgActive.className="page_off";
		}
	}
	ongActif=document.getElementById("ong"+ong);
	ongActif.className="onglet_on";
	pgActive=document.getElementById("pg"+ong);
	pgActive.className="page_on";	
 }
*/
//------------------------------------------------------------------------------------------------------------------


/*
function divi(val,tot,image) {
  	for (var i=1; i<=tot; i++) {
		if(i==val) {
			$('#tb_'+i).fadeIn('slow');
			$('#li_'+i).addClass("on");
			$('#tb2_'+i).hide();
			if(image){$('#tb3_'+i).fadeIn();}
		}else{
			$('#tb_'+i).hide();
			$('#li_'+i).removeClass("on");
			$('#tb2_'+i).show();
			if (image){$('#tb3_'+i).hide();}
		}
	}
	//Termine pour rachrarichir la hauteur des colonnes pour le fond de page
	fd_page();
}
*/


function SetAllCheckBoxes(FormName, FieldName){
	var CheckValue;
	if(document.forms[FormName]){
		var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes){	return;}
	else if(objCheckBoxes.length) { 
		
		var countCheckBoxes = objCheckBoxes.length;
		
		if (objCheckBoxes[0].checked==true){ CheckValue=false;	}
		else{CheckValue=true;}

		if(!countCheckBoxes){objCheckBoxes.checked = CheckValue;}
		else{	
			if (countCheckBoxes>0){
				for(var i = 0; i < countCheckBoxes; i++){	objCheckBoxes[i].checked = CheckValue;	}
			}else {
				objCheckBoxes[0].checked = CheckValue;
			}
		}
	}}

}

function posting(ou,msg,val,formName,fenetre){
	if (msg!=''){
		
		if(confirm(msg)){
			if (fenetre=="opener"){
				window.opener.document.getElementById(ou).value=val;
				eval('window.opener.document.'+formName+'.submit()');	
			}else if (fenetre=="parent"){
				parent.document.getElementById(ou).value=val;
				eval('parent.document.'+formName+'.submit()');	
			}else{
				document.getElementById(ou).value=val;
				eval('document.'+formName+'.submit()');	
			}
			return true;
		}
	}else{
		if (fenetre=="opener"){	window.opener.document.getElementById(ou).value=val;	eval('window.opener.document.'+formName+'.submit()');		}
		else if (fenetre=="parent"){	parent.document.getElementById(ou).value=val;	eval('parent.document.'+formName+'.submit()');	}
		else{document.getElementById(ou).value=val; eval('document.'+formName+'.submit()');		}
		return true;
	}
	return false;
}


// Gestion des images
function image_upd_ap(nn,chemin,anc) {
	var newWindow;
	var props = 'scrollBars=no,resizable=no,toolbar=no,status=no,menubar=no,location=no,directories=no,width=700,height=550,top=100,left=150';
		myText2 = window.open("res_add_media_upload.php?nn="+nn+"&chemin="+chemin+"&anc="+anc, 'Télécharger2', props);
	if (!myText2.opener) myText2.opener = self;
}

// Gestion des images
function image_upload_ap(nn,chemin,anc) {
	var newWindow;
	var props = 'scrollBars=no,resizable=no,toolbar=no,status=no,menubar=no,location=no,directories=no,width=350,height=250,top=100,left=150';
		myText3 = window.open("res_add_media_upload.php?nn="+nn+"&chemin="+chemin+"&anc="+anc, 'Télécharger3', props);
	if (!myText3.opener) myText3.opener = self;
}



(function ($) {
	$.fn.hAlign = function() {
		return this.each(function(i){
			var w = $(this).width();
			var ow = $(this).outerWidth();
			var ml = (w + (ow - w)) / 2;
			$(this).css("margin-left", "-" + ml + "px");
			$(this).css("left", "50%");
			$(this).css("position", "absolute");
			});
		};
})(jQuery);

(function ($) {
	$.fn.vAlign = function() {
		return this.each(function(i){
			var h = $(this).height();
			var oh = $(this).outerHeight();
			var mt = (h + (oh - h)) / 2;
			$(this).css("margin-top", "-" + mt + "px");
			$(this).css("top", "50%");
			$(this).css("position", "absolute");
		});
	};
})(jQuery);



function number_format (number, decimals, dec_point, thousands_sep) {
    // Formats a number with grouped thousands
    //
    // version: 906.1806
    // discuss at: http://phpjs.org/functions/number_format
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://getsprink.com)
    // +     bugfix by: Benjamin Lupton
    // +     bugfix by: Allan Jensen (http://www.winternet.no)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +     bugfix by: Howard Yeend
    // +    revised by: Luke Smith (http://lucassmith.name)
    // +     bugfix by: Diogo Resende
    // +     bugfix by: Rival
    // +     input by: Kheang Hok Chin (http://www.distantia.ca/)
    // +     improved by: davook
    // +     improved by: Brett Zamir (http://brett-zamir.me)
    // +     input by: Jay Klehr
    // +     improved by: Brett Zamir (http://brett-zamir.me)
    // +     input by: Amir Habibi (http://www.residence-mixte.com/)
    // +     bugfix by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: number_format(1234.56);
    // *     returns 1: '1,235'
    // *     example 2: number_format(1234.56, 2, ',', ' ');
    // *     returns 2: '1 234,56'
    // *     example 3: number_format(1234.5678, 2, '.', '');
    // *     returns 3: '1234.57'
    // *     example 4: number_format(67, 2, ',', '.');
    // *     returns 4: '67,00'
    // *     example 5: number_format(1000);
    // *     returns 5: '1,000'
    // *     example 6: number_format(67.311, 2);
    // *     returns 6: '67.31'
    // *     example 7: number_format(1000.55, 1);
    // *     returns 7: '1,000.6'
    // *     example 8: number_format(67000, 5, ',', '.');
    // *     returns 8: '67.000,00000'
    // *     example 9: number_format(0.9, 0);
    // *     returns 9: '1'
    // *     example 10: number_format('1.20', 2);
    // *     returns 10: '1.20'
    // *     example 11: number_format('1.20', 4);
    // *     returns 11: '1.2000'
    // *     example 12: number_format('1.2000', 3);
    // *     returns 12: '1.200'
    var n = number, prec = decimals;
 
    var toFixedFix = function (n,prec) {
        var k = Math.pow(10,prec);
        return (Math.round(n*k)/k).toString();
    };
 
    n = !isFinite(+n) ? 0 : +n;
    prec = !isFinite(+prec) ? 0 : Math.abs(prec);
    var sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep;
    var dec = (typeof dec_point === 'undefined') ? '.' : dec_point;
 
    var s = (prec > 0) ? toFixedFix(n, prec) : toFixedFix(Math.round(n), prec); //fix for IE parseFloat(0.55).toFixed(0) = 0;
 
    var abs = toFixedFix(Math.abs(n), prec);
    var _, i;
 
    if (abs >= 1000) {
        _ = abs.split(/\D/);
        i = _[0].length % 3 || 3;
 
        _[0] = s.slice(0,i + (n < 0)) +
              _[0].slice(i).replace(/(\d{3})/g, sep+'$1');
        s = _.join(dec);
    } else {
        s = s.replace('.', dec);
    }
 
    var decPos = s.indexOf(dec);
    if (prec >= 1 && decPos !== -1 && (s.length-decPos-1) < prec) {
        s += new Array(prec-(s.length-decPos-1)).join(0)+'0';
    }
    else if (prec >= 1 && decPos === -1) {
        s += dec+new Array(prec).join(0)+'0';
    }
    return s;
}
