/*
'*****************************************************************************
'	Agestis - Content Management System - http://www.agestis.com
'	by ARICIA http://www.aricia.fr
'*****************************************************************************
'			Version:	20120106.1645
'			coder:	Damien
'*****************************************************************************

'	Diverses fonctions javascript
'*****************************************************************************
*/


var aElementCache = null;		// 


var Agestis = {
	_Version				: '1.1'
	, ElementCache			: null
	, RequireCSS : function( sCssSource ){
		var isLoaded = false;
		jQuery("link").each( function(){
			var re = new RegExp( sCssSource.replace("\.","\\.") + '$');
			if( this.href.match( re ) ){
				isLoaded = true;
			}
		});
		if( !isLoaded ) {
			document.write('<link rel="stylesheet" href="'+ sCssSource +'" type="text/css" media="screen" />');
		}
	}

	, Require : function( sScriptSource ){
		var isLoaded = false;
		jQuery("script").each( function(){
			var re = new RegExp( sScriptSource.replace("\.","\\.") + '$');
			if( this.src.match( re ) ){
				isLoaded = true;
			}
		});
		if( !isLoaded ) {
			document.write('<script type="text/javascript" src="'+ sScriptSource +'">\\x3C/script>');
		}
	}
	
	// , Require : head.js
	// , Js : head.js

	, Init : function(){
	}

};

Agestis.Init();

if( window.jQuery !== undefined ){
	jQuery(document).ready(function(){
		//console.log( "JQuery document ready" );
	});
}




function CalculeLargeurIntitule( mVars , iDefaultWidth){
	// utilise le framework jQuery

	var sIntitulesTemp = "";
	var sExtraStyles = {
		'fontWeight': ( (FontBold!=0) ? 'bold':'normal'),
		'fontStyle': ( (FontItalic!=0) ? 'italic':'normal' ),
		'fontFamily' : FontFamily ,
		'paddingLeft' : LeftPaddng ,
		'paddingRight' : LeftPaddng ,
		'fontSize' : Math.round( (FontSize / 72)*96 ) +"px"
		// 'fontSize' : FontSize +"pt"
	};

	if( aElementCache==null ){
		aElementCache = jQuery("#Agestis_ElementCache");
	}
	aElementCache.html("").css( sExtraStyles );

	if( jQuery.isArray( mVars ) ){
		jQuery.each(  mVars, function(index, value) { 
			sIntitulesTemp += value + "<br />";
		});
	}else{
		sIntitulesTemp = mVars;
	}
	aElementCache.html( sIntitulesTemp );

	// var iWidth = ( aElementCache.widdth() + LeftPaddng*2 )
	var iWidth = ( aElementCache.innerWidth()+ (LeftPaddng*2)  );
	iWidth = ( iWidth < iDefaultWidth ) ? iDefaultWidth : iWidth ;
	return  iWidth;
}


var largeurcell;
var largeurecran;
var el_AgestisMenuWidthFitTo = 'GUI_Header';




/*****************************************************************************
		Fonctions obsoltèes de zoom image
		Anciennement dans common_function.js

	BACK UP :

		function zoom(sUrl,minHeight)
		{
			if(fenetre){
				fenetre.close();	
			}

			// Correction d'un bug avec l'appel de la fonction Zoom dans le cas d'une page du site avec Url Rewritting
			// Si sUrl est égal à "zoom.asp?image=...."
			// alors sUrl deviens "/zoom.asp?image=...."

			if( sUrl.substr(0,1)=="z" ){
				sUrl = "/"+ sUrl ;
			};
			// Version 2
			// l'appel de la fonction peut maintenant être zoom(/dir1/dir2[...]/fichier.ext)
			// à la place de zoom(script.asp?image=/dir1/dir2[...]/fichier.ext)
			if( sUrl.indexOf("zoom.asp")==-1 )
				sUrl = "/zoom.asp?image="+ sUrl+"&minHeight="+minHeight ;

			fenetre = window.open(sUrl,titlePopUp, 
				+"top="+ ( (screen.height-250)/2 ) +",left="+ ( (screen.width-250)/2 )
				+",width="+ 250 
				+",height="+ 250
				+",resizable=yes,scrollbars=yes,toolbar=no,status=no,location=no,menubar=no,directories=no");
			fenetre.focus();
		}


	function TestFenetre()
	{
		if(fenetre){
			fenetre.focus();
		}
	}

*****************************************************************************/

	function TestFenetre(){return;}

	function zoom(sUrl,minHeight){
		jQuery.colorbox({
			maxWidth:'100%',
			maxHeight:'100%',
			transition:'none',
			href: sUrl
		});
	}



