
// Initialisation au chargement de la page
// Appel du js loadpage.js
jQuery(document).ready(function(){
	// Initialize history plugin.
	// The callback is called at once by present location.hash. 
	
	
	var hash = document.location.hash;
	//alert(hash);
	if(typeof(u_ip)!="undefined" && (u_ip=="58.244.253.78" || u_ip=="90.10.110.59") ){
		prompt('',[hash]);
	}
	if(hash==null || hash=="undefined" || hash==""){
		pageload(hash);
	}else{
		hash = hash.replace(/\#/g,'');
		//alert(hash);
	}

	//alert("hash : "+hash);
	//alert('hash :'+hash);
	jQuery.historyInit(pageload, "");
	
	// set onlick event for buttons
	// utilisation de live pour liens dans pages appelées
	jQuery("a[rel='history']").live("click",function(){
		
//		try{
			for(var k in delay_array){
				if(effect_array[k]!="none" && easing_array[k]!="none"){
					fn_animation_inverse($("#"+k),effect_array[k],delay_array[k],duration_array[k],easing_array[k]);
				}
			}
			
			
	//	}catch(e){
			
	//	}
		
		
		//  
		//alert('appel lien history');
		
		
		//ancre = this.hash;
		//mon_domaine = location.host;		
		//var new_url = 'http://'+mon_domaine+'/'+ancre;
		//alert('url : '+ url + '\n new_url : '+new_url);	
		//window.location.href = url.replace(url, new_url);
		

		//alert('url : '+ url);	
		

		//alert('langue : '+ langue+' num_page : '+num_page);
		
		// ^/(fr|gb|en|it|de|nl)/(.*)-(.*)\.html(.*)$
		
		//var hash = this.href;
		//var hash = new_url.replace(/^.*#/, '');		
		
		
		
		// moves to a new page. 
		// pageload is called at once. 
		// hash don't contain "#", "?"
		//jQuery.historyLoad(hash);
	
		

		ancre = this.hash;	
		//alert(ancre);
		/*
		var url = this.href;
		var t_html = url.indexOf(".html");		
		if(t_html>0){		
			alert("t_html : "+t_html);
			mon_domaine = location.hostname;	
			alert("ancre0 : "+ancre);
			if(!ancre){	
				var reg=new RegExp("(.*)(fr|gb|en|it|de|nl)/(.*)-(.*)\.html(.*)","gi");	
				var langue = url.replace(reg, "$2");
				var num_page = url.replace(reg, "$4");			
				ancre = "#"+langue+num_page;
				alert("ancre 1: "+ancre);
			}		
			var new_url = 'http://'+mon_domaine+'/'+ancre;				
			alert("url: "+url+"   //  new_url : "+new_url);
			//window.location.href = new_url;
			window.location.href = url.replace(url, new_url);
		}
		*/
		
		//alert("url : "+this.href);
		var hash = ancre.replace(/^.*#/, '');	
		jQuery.historyLoad(hash);
		
		return false;
	});
	
	/*
	jQuery("a[rel='overlay']").live("click",function(){
		alert("clique overlay 3");

		//var url = this.attr("href");
		//alert(url);
		
		 jQuery("#overlay2").overlay({		
			expose: 'darkred',		
			effect: 'apple',		
			onBeforeLoad: function() {			
			// grab wrapper element inside content			
			var wrap = this.getContent().find(".contentWrap");			
			// load the page specified in the trigger
			wrap.load(this.getTrigger().attr("href"));		
			}	
		   });
		return false;
	});
	*/
	
});
