PopIn = function(){
	var url;
	var DivHtmlMsg;
	var divs_transparentDiv;
	var divs_content;
	var iframe;
	var layoutCss;
	var width;
	var height;
	var existingBodyOverFlowStyle;
	var dynContentObj;
	var CssMsg;
	var DivVisibility;
	var shadowOffset;
	var MSIE;
	this.MSIE = false;if(navigator.userAgent.indexOf('MSIE')>=0) this.MSIE = true;
	}
PopIn.prototype = {ContenuPopIn : function(newHtmlContent){this.DivHtmlMsg = newHtmlContent;},DimensionPopIn : function(width,height){if(width)this.width = width;
	if(height)this.height = height;},displayBlock : function(){if(!this.divs_transparentDiv){this.DivHtmlCreation();}this.divs_transparentDiv.style.display='block';
	this.divs_content.style.display='block';
	this.divElement.style.display='block';
	if(this.MSIE)this.iframe.style.display='block';
	this.RedimensionDiv();
	window.refToThisModalBoxObj = this;
	setTimeout('window.refToThisModalBoxObj.RedimensionDiv()',150);
	this.DivHtml();},close : function(){this.divs_transparentDiv.style.display='none';
	this.divs_content.style.display='none';
	this.divElement.style.display='none';
	if(this.MSIE)this.iframe.style.display='none';},addEvent : function(whichObject,eventType,functionName,suffix){ 
	 if(!suffix)suffix = ''; if(whichObject.attachEvent){ 
	    whichObject['e'+eventType+functionName+suffix] = functionName; 
	    whichObject[eventType+functionName+suffix] = function(){whichObject['e'+eventType+functionName+suffix]( window.event );} 
	    whichObject.attachEvent( 'on'+eventType, whichObject[eventType+functionName+suffix] ); 
	  } else whichObject.addEventListener(eventType,functionName,false); 	    
	},DivHtmlCreation : function(){
		this.divs_transparentDiv = document.createElement('DIV');
		this.divs_transparentDiv.className='css_filtre_opaque';
		this.divs_transparentDiv.style.left = '0px';
		this.divs_transparentDiv.style.top = '0px';
		document.body.appendChild(this.divs_transparentDiv);
		this.divs_content = document.createElement('DIV');
		this.divs_content.className = 'css_popin';
		this.divs_content.style.zIndex = 30000;
		if(this.MSIE){this.iframe = document.createElement('<IFRAME src="about:blank" allowTransparency="yes" frameborder=0>');
		this.iframe.style.zIndex = 20000;
		this.iframe.style.position = 'static';
		document.body.appendChild(this.iframe);}	
		document.body.appendChild(this.divs_content);
		this.divElement = document.createElement('DIV');
		this.divElement.className = 'css_popin_shadow';
		this.divElement.style.zIndex = 24000;
		document.body.appendChild(this.divElement);	
		window.refToModMessage = this;
		this.addEvent(window,'scroll',function(e){ window.refToModMessage.DivHtmlOpacity() });
		this.addEvent(window,'resize',function(e){ window.refToModMessage.DivHtmlOpacity() });
	},NavigateSize : function(){
    	var bodyWidth = document.documentElement.clientWidth; var bodyHeight = document.documentElement.clientHeight;
		var bodyWidth, bodyHeight;
		if (self.innerHeight){
			bodyWidth = self.innerWidth;
			bodyHeight = self.innerHeight;
			} 
		else if (document.documentElement && document.documentElement.clientHeight) {
			bodyWidth = document.documentElement.clientWidth;
			bodyHeight = document.documentElement.clientHeight;
		} else if (document.body) {
			bodyWidth = document.body.clientWidth;
			bodyHeight = document.body.clientHeight;
		} 
		return [bodyWidth,bodyHeight];},RedimensionDiv : function(){ var topOffset = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		if(this.CssMsg) this.divs_content.className=this.CssMsg;
		else this.divs_content.className='css_popin';
		if(!this.divs_transparentDiv)return;
		var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		var sl = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);	
    	window.scrollTo(sl,st);	setTimeout('window.scrollTo(' + sl + ',' + st + ');',10);
		this.DivHtmlOpacity();var brSize = this.NavigateSize();var bodyWidth = brSize[0];
		var bodyHeight = brSize[1];
		this.divs_content.style.backgroundColor="transparent";
		this.divs_content.style.width = this.width + 'px';
		this.divs_content.style.height= this.height + 'px';
    	this.divs_content.style.left = Math.ceil((bodyWidth - this.divs_content.offsetWidth) / 2) + 'px';
		this.divs_content.style.top = (Math.ceil((bodyHeight - this.divs_content.offsetHeight) / 2) +  topOffset) + 'px'; 	
 		if(this.MSIE){
		this.iframe.style.left = this.divs_content.style.left;
		this.iframe.style.top = this.divs_content.style.top;
		this.iframe.style.width = this.divs_content.style.width;
		this.iframe.style.height = this.divs_content.style.height;}		
    	this.divElement.style.left = (this.divs_content.style.left.replace('px','')/1 + 5) + 'px';
		this.divElement.style.top = (this.divs_content.style.top.replace('px','')/1 + 5) + 'px';
		this.divElement.style.height = this.divs_content.offsetHeight + 'px';
		this.divElement.style.width = this.divs_content.offsetWidth + 'px';
		if(!this.DivVisibility)this.divElement.style.display='none';	
    },DivHtmlOpacity : function(){
		this.divs_transparentDiv.style.top = Math.max(document.body.scrollTop,document.documentElement.scrollTop) + 'px';
		this.divs_transparentDiv.style.left = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft) + 'px';
		var TabSize = this.NavigateSize();
		this.divs_transparentDiv.style.width = TabSize[0] + 'px';
		this.divs_transparentDiv.style.height = TabSize[1] + 'px';},DivHtml : function(){this.divs_content.innerHTML = this.DivHtmlMsg;}		
}


ObjPopIn = new PopIn();
ObjPopInError = new PopIn();

function afficherReponse(response) {     
    ObjPopIn.ContenuPopIn(response.responseText);
	ObjPopIn.DimensionPopIn(400,400);
	ObjPopIn.displayBlock();
	SetItemsNumber(divItemsNumber);
	SetDiscountsNumber(divDiscountsNumber);
	HPR_LoadAvantages();
	
	//Taggage Eulerian
	EURECA_shoppingcart('eveiletjeux');
} 

function AffichePopIn(id_produit)
{
    var laRequete = new Ajax.Request('http://www.eveiletjeux.com/Basket/Panier/PopInAjoutProduit.aspx', { 
        method: 'get', 
        parameters: 'IDProAdd=' + id_produit, 
        onComplete: afficherReponse
        } );   
}

function AffichePopInGeneral(popIn_url, width, height)
{
    var url = popIn_url;

    var laRequete = new Ajax.Request(url, { 
        onComplete: afficherReponse
        } );
}

function closeMessage()
{
	ObjPopIn.close();	
}

function AffichePopInErreur(title, message, width, height)
{

    var divTitle = document.getElementById('hp_divErrorTitle');
    if(divTitle != null)
        divTitle.innerHTML = title;
    var divMessage = document.getElementById('hp_divErrorMessage');
    if(divMessage != null)
        divMessage.innerHTML = message;
    var divClose = document.getElementById('hp_divErrorClose');
    if(divClose != null)
        divClose.style.left = (width - 25) + 'px';

    var divErreur = document.getElementById('hp_divError');
    
    if(divErreur != null)
    {        
        ObjPopInError.ContenuPopIn(divErreur.innerHTML);
        ObjPopInError.DimensionPopIn(width,height);
        ObjPopInError.displayBlock();
    }
}