/* PoleEntreprise Javascript using libs. */
	if(typeof(console) == 'undefined'){var console={log:function(_log){/*alert(_log);/**/}};} /**/ // IE Console (µlite)


	// Adjust elemnent in the page
	//
	var layoutMode = 'full';
	function setLayoutMode(mode){ layoutMode = (mode=='full' || mode=='half')? mode:'full'; }
	function getLayoutMode(){ return layoutMode; }
	
	function getLang(){ return (pageLang!='')? 'fr':pageLang; }
	
	function adjustHTMLElements(data)
	{
		// console.log( $H(data).inspect() );
		layoutMode = data.layoutMode; 

		if(layoutMode == 'full' && $('info_container')){

			$('info_container').setStyle({ height: '100%' });
			if( data._height < $('html_content').getHeight() )
			{
				$('info_container').setStyle({ height: 30 + $('html_content').getHeight() +'px' });
			}

		}

		if(layoutMode == 'half')
		{

			/*
			console.log( "data._height : "+ data._height );
			console.log( "html_content : "+ $('html_content').getHeight() );
			console.log( "info_container : "+ $('info_container').getHeight() );
			/**/
			
			$('info_container').setStyle({ height: '100%' });
			
			if( data._height < $('html_content').getHeight() )
			{
				$('info_container').setStyle({ height: 30 + $('html_content').getHeight() +'px' });
			}

		}

		/* /!\ */	//if($('pagesize')){ $('pagesize').update(data._width+'x'+data._height); } // Screen size ...
		
	}

	


	// Init. specifics components ...
	//
	function swapToLang(codeLang)
	{
		/**/
		console.log( '['+$H(codeLang).inspect()+']' );
		if( codeLang['loadedPage'] == null ){ codeLang['loadedPage']='navListItem_main'; }
		
		url = MENU_RELATIONS[ codeLang['codeLang'] ][ codeLang['loadedPage'] ];
		
		window.document.location = url;
		
	}

	


	// Init. specifics components ...
	//
	function initComponents_DelayedFragments()
	{
		/**/
	}
	


	// Init. specifics components ...
	//
	function initAccordionParticuliers()
	{

		$$('.accordion-pane').each(function(pane){
											
			var handle_pane = pane.down('h3');
			var container_pane = pane.down('.container');

			container_pane.hide();
			
			handle_pane.observe('click', function(event) {
			
				if(handle_pane.hasClassName('active')){}
				else{
				
					collapseAll();
					handle_pane.addClassName('active');
					container_pane.show();

					//initScrollRegion(); // Call Scrollbar init. (adjust height).
					
				}
												
			});
			
			
		});
		
		$$('.accordion-pane')[0].down('h3').addClassName('active');
		$$('.accordion-pane')[0].down('.container').show();
		
	}
	
	function collapseAll(){
	
		$$('.accordion-pane').each(function(_pane){
		
			var _handle_pane = _pane.down('h3');
			var _container_pane = _pane.down('.container');
			_container_pane.hide();
			_handle_pane.removeClassName('active');
		
		
		});
		
	}
	


	// Handle Cookies
	//
	function setCookie(c_name,value,expiredays)
	{
		var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);
		document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	}
	
	function getCookie(c_name)
	{
		if (document.cookie.length>0)
		{
			c_start=document.cookie.indexOf(c_name + "=");
			if (c_start!=-1)
			{ 
				c_start=c_start + c_name.length+1; 
				c_end=document.cookie.indexOf(";",c_start);
				if (c_end==-1) c_end=document.cookie.length;
				return unescape(document.cookie.substring(c_start,c_end));
			}
		}
		return "";
	}



	// Flash|AS/Javascript bridge
	//
	function connectToFlash(swfName,data)
	{
	//	$('').runBridgedCode(pgeName:string, data:jsonobj):result
	//	In Flash : var connection = ExternalInterface.addCallback("runBridgedCode", null, execBridgedCode);
	
		if( !$(swfName) )
		{
			alert("Erreur de connection !\n\nLa tentative de connection au média Flash '"+(swfName).toString()+"' n'a pu être établie.");
		}
		else
		{
			return (!$(swfName).runBridgedCode)? null:$(swfName).runBridgedCode(data);
		}
	}




	function showCoverflowThema(_id_thematique,_category)
	{
		if( $('coverflow') && !isNaN(_id_thematique) )
		{
			
			 var ajax = new Ajax.Request('/coverflow/bloc_coverflow.php', {
					parameters: {
						category: _category,
						id_thematique: _id_thematique
					},
					method: 'get',
					onSuccess: function(transport) { 
						swfHtmlCode = String(" "+ transport.responseText +" ").strip();
						$('coverflow').update( swfHtmlCode );
						// alert( swfHtmlCode );
						delete swfHtmlCode;
					},
					onFailure: function() {
						swfHtmlCode = '<div style="margin:auto; width:100%; height:100%; overflow:hidden; border:0; padding:0;">Impossible d\'obtenir le contenu !<br/>Merci de vérifier que votre page soit actualisée depuis peu.</div>';
						$('coverflow').update( swfHtmlCode );
					}
			 });
			
		
		}
	}
	
	
	// _openBox | Alias openCTKFORMPopup(sURI,sWinName,w,h)
	// from popup.js
	// 19/08/2001
	// http://www.tocra.org
	function _openBox(sURI,sWinName,w,h){
		var FULLSCREEN_const = 'no';
		
		var sh = parseInt(screen.availHeight || screen.width);
		var sw = parseInt(screen.availWidth || screen.height);
		var pH = h;
		var pW = w;
		var hasSB = (arguments.length==5)? arguments[4] :'yes' ;
		return open(sURI,sWinName,'top='+((sh-pH)/2)+',left='+((sw-pW)/2)+',width='+pW+',height='+pH+',scrollbars='+hasSB+',fullscreen='+FULLSCREEN_const);
	};
	

	// 
	// 
	function initOpenShadowBox()
	{
		
		
		if( $('devis') )
		{

			$('devis').observe('click', function(event){
				
				Event.stop(event);
				var link_shadowed = Event.element(event);
				_href = link_shadowed.readAttribute('href');
				_title = link_shadowed.readAttribute('title');
				
				Shadowbox.open({
					player:     'iframe',
					title:      _title,
					content:    _href,
					height:     600,
					width:      500
				});
	
			});

		}
		

		if( $('plan_contact') )
		{

			$('plan_contact').observe('click', function(event){
				
				Event.stop(event);
				var link_shadowed = Event.element(event);
				
				_href = link_shadowed.readAttribute('href');
				_title = link_shadowed.readAttribute('title');
				
				Shadowbox.open({
					player:     'iframe',
					title:      _title,
					content:    _href,
					height:     440,
					width:      800
				});
	
			});
		}

	}
	
	
	
	// Init. overing text ...
	//
	function initOveredTextLayer()
	{

		if( $('box_overtext') )
		{
			
			var box_overtext = $('box_overtext');
			var box_handle = $('box_overtext').down('.box_handle');
			var box_text = $('box_overtext').down('.overtext');
			var img_collector = { 'up':new Image(), 'down':new Image() };
				 img_collector.up.src = "/img/green_arrow_up.gif";
				 img_collector.down.src = "/img/green_arrow_down.gif";
			box_text.hide();
			box_handle.observe('click', function(event){
			
				if( box_text.hasClassName('doubitchoo') )
				{
					box_text.removeClassName('doubitchoo');
					box_text.hide();
					box_handle.src = img_collector.down.src;
				}else{
					box_text.addClassName('doubitchoo');
					box_text.show();
					box_handle.src = img_collector.up.src;
				}
			
			});
		}
	}



	/* coverflow */
	var tmp = 1;
	var id = 1;
	
	// Fonction qui affiche la bonne vignette lors du clic sur un des partenaires
	function synchroThumbPartners()
	{

		/*$$('.gotoPicture').each(function(itm,idx){ 
			itm.observe('click', function(event){
				
				event.preventDefault();
				//selon le navigateur
				if (navigator.appName.indexOf("Microsoft") != -1) {
					id_coverflow = "object_coverflow_partenaires";
				}
				else {
					id_coverflow = "embed_coverflow_partenaires";
				}
				id = event.target.parentNode.parentNode.readAttribute('id'); 
				//alert ("id => "+id);
				deplacement = id - tmp;
				if( deplacement > 0 ){$.goLeft(id_coverflow,deplacement);}
				else{$.goRight(id_coverflow,Math.abs(deplacement));}
				tmp = id;
			}, false);
		});*/
		
	}

	$.goLeft = function(Id,step) { $(Id).deplace_G(step); }
	$.goRight = function(Id,step) { $(Id).deplace_D(step); }
	/* end: coverflow */
	

