(function($){
		
		/******************** detection de l'hote ***************************/
		 $.hote = function() {	
		 var hote = window.location.host;
			
			// url rewriting
			function local(){
			var regexp = /pc-david|localhost/ ;	
				if (hote.match(regexp))	return true;
				else return false;
			}
			
			
			// url du site
			if (local()) root = 'http://'+hote+'/LOOM/';	
			else root = 'http://'+hote+'/';
			return root;
		 }
	

	


		/********** redimensionnement automatique *****************************/
		function callback(e) { 
		
		if (!e.ref) { return false; } 
		

			function resize(){
				var largeurWindow = $(window).width();
				var hauteurWindow = $(window).height();
				flash["_resize"](largeurWindow,hauteurWindow );
			}
	
			
			function waiting(){ 
				if ( typeof e.ref["_resize"] == "function" ) {
					flash = e.ref; 		
					$(window).bind('resize', resize); // force le focus
					resize();
					
					return false;    // Arrête la récursivité
				} 	
				setTimeout(waiting, 2);
				}; 
				
				
		waiting(); // Premier appel de la fonction 

			
		}
		
		
		/**********************************************************************/
	
	
	
	
		/************* flash *************************************************/
		$.flash = function(){
				
				var fn = function() {    
				var now = new Date(); // creation du timestamp
				var unique = "" + now.getTime();
					 
				var url = root+"common/swf/loom.swf";
				var id = "content";           
				var width = "100%";
				var height = "100%";
				var flversion = "10"; 
				//var expressInstall = "common/swf/expressInstall.swf";
				var expressInstall = false;
				var flashvars = { racine:root};
				var params = { menu:false, wmode:'opaque', "allowFullScreen":true };    
				var attributs = { id:'content' };    
		
		swfobject.embedSWF(url, id, width, height, flversion, expressInstall, flashvars, params, attributs, callback);
		$("#"+id).show();

	};        
	
	swfobject.addDomLoadEvent(fn); 
	
			/*
			var flashvars = {};
			var params = {};
			params.allowscriptaccess = "always";
			var attributes = {};
			attributes.id = "content";
			swfobject.embedSWF("common/swf/loom.swf", "alternate", "100%", "100%", "11.0.0", "common/swf/expressInstall.swf", flashvars, params, attributes);
			*/
	}
	/**********************************************************************/

})($);



$(window).ready(function(){		
	var root = $.hote();
	$.flash();
});

