<!--

Prototype.Browser.IE6 = Prototype.Browser.IE && parseInt(
navigator.userAgent.substring 
(navigator.userAgent.indexOf("MSIE")+5))==6;

function getPageScroll() {
	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}

function getPageSize() {
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function updateHeaderCartInfo() {
	new Ajax.Request('/mod/boutique/update_header_cart.php', {
		encoding: 'iso-8859-1',
		onSuccess: function(transport) {
			json = transport.responseText.evalJSON(true);
			//$('cartInfoCountProducts').update(json.count_cart_products);
			$('cartInfoSumProducts').update(json.sum_cart_products);
			
			if ($('cartInfo').getStyle('display') == 'none') {
				$('cartInfo').setStyle({ display: 'block' });
			}
		}
	});
}

function updateInfoDiscountCode(message) {
	new Ajax.Request('/mod/boutique/update_info_discount_code.php', {
		encoding: 'iso-8859-1',
		onSuccess: function(transport) {
			json = transport.responseText.evalJSON(true);
			$('discountInfo').update(json.info);
		}
	});
}

function addToCartModalBox(url, formEl, width, height) {
	if ($('overlay').getStyle('display') == 'block') {
		new Effect.Fade('overlay');
		new Effect.Fade('overlay_content', { duration: 0, afterFinish: function() { $('overlay_content').update('') } });
	} else {
		if (width != '') $('overlay_content').setStyle({ width: width +'px', marginLeft: '-' + width/2 + 'px' });
		if (height != '') $('overlay_content').setStyle({ height: height +'px' });
		
		var arrayPageSize = getPageSize();
		var arrayPageScroll = getPageScroll();
		var boxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
		$('overlay').setStyle({ height: arrayPageSize[1] +'px' });
		if (Prototype.Browser.IE6) {
			$('overlay_content').setStyle({ top: boxTop +'px' });
		}
		
		$('overlay_content').addClassName('loading');
		
		new Effect.Appear('overlay', { duration: 0, from: 0.0, to: 0.6 });
		new Effect.Appear('overlay_content');
		
		new Ajax.Updater('overlay_content', url, {
			encoding: 'iso-8859-1',
			method: 'post',
            parameters: $(formEl).serialize(),
            evalScripts: true,
			onComplete: function() {
				updateHeaderCartInfo();
				$('overlay_content').removeClassName('loading');
			}
		});
	}
}

function addToCart(quantity, form) {
	if (parseInt(quantity) > 0) {
		addToCartModalBox('/mod/boutique/add_to_cart.php', form, '650', '250');
	} else {
		alert("Veuillez sélectionner une quantité");
	}
}

function updateLicencePrice(form) {
	$('priceLicence').update('--');
	new Ajax.Request('/mod/boutique/update_licence_price.php', {
		encoding: 'iso-8859-1',
		method: 'post',
		parameters: $(form).serialize(),
		onSuccess: function(transport) {
			json = transport.responseText.evalJSON(true);
			$('priceLicence').update(json.price_licence);
		}
	});
}

function displayModalBox(url, type, width, height) {
	if ($('overlay').getStyle('display') == 'block') {
		new Effect.Fade('overlay');
		new Effect.Fade('overlay_content', { duration: 0, afterFinish: function() { $('overlay_content').update('') } });
	} else {
		if (width != '') $('overlay_content').setStyle({ width: width +'px', marginLeft: '-' + width/2 + 'px' });
		if (height != '') $('overlay_content').setStyle({ height: height +'px' });
		
		var arrayPageSize = getPageSize();
		var arrayPageScroll = getPageScroll();
		var boxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
		$('overlay').setStyle({ height: arrayPageSize[1] +'px' });
		if (Prototype.Browser.IE6) {
			$('overlay_content').setStyle({ top: boxTop +'px' });
		}
		
		$('overlay_content').addClassName('loading');
		
		new Effect.Appear('overlay', { duration: 0, from: 0.0, to: 0.6 });
		new Effect.Appear('overlay_content');
		
		if (type == 'ajax') {
			new Ajax.Updater('overlay_content', url, { encoding: 'iso-8859-1', evalScripts: true, onComplete: function() { $('overlay_content').removeClassName('loading'); } });
		} else if (type == 'iframe') {
			if (width == '') width = '100%';
			if (height == '') height = 480;
			var iframe = document.createElement('iframe');
			iframe.setAttribute('width', width-10);
			iframe.setAttribute('height', height-10);
			iframe.setAttribute('frameborder', '0');
			iframe.setAttribute('border', '0');
			iframe.setAttribute('src', url);
			iframe.setAttribute('id', 'iframe');
			$('overlay_content').appendChild(iframe);
			$('iframe').src = url;
			$('overlay_content').removeClassName('loading');
		}
	}
}

//openwindow simple : sans scroll sans menu
function openwindow(newURL, newWidth, newHeight) {
    //declaration des variables du coin de la nouvelle fenetre
    var calcLeft = 100;
    var calcTop = 100;

    if (parseInt(navigator.appVersion) >= 4) {
        calcTop = screen.availHeight / 2 - newHeight /2;
        calcLeft = screen.availWidth /2 - newWidth / 2;
	}

    remoteWindow = window.open(newURL, 'remote', 'status=no,toolbar=no,menubar=no,location=no,scrollbars=no,width=' + newWidth + ',height=' + newHeight + ',left=' + calcLeft + ',top=' + calcTop + ',resizable=no');
}

function favoris(){
	var thePage = location.href;
	if(thePage.lastIndexOf('#')!=-1){
		thePage = thePage.substring(0,thePage.lastIndexOf('#'));
	}			
	if ( navigator.appName != 'Microsoft Internet Explorer' ) {
		window.sidebar.addPanel('PERMIBATO',thePage,"");
	} else { 
		window.external.AddFavorite(thePage,'PERMIBATO');
	}
}

function scrollContent(direction, el) {
	var contenu = document.getElementById(el);
	if (direction == 2) {
		contenu.scrollTop += 1;
		scrolldelay = setTimeout("scrollContent(2, '"+ el +"')", 1);
	}
	if (direction == 1) {
		contenu.scrollTop -= 1;
		scrolldelay = setTimeout("scrollContent(1, '"+ el +"')", 1);
	}
	return false;
}

function stopScroll() {
	clearTimeout(scrolldelay);
}

function handle(delta) {
	var contenu = document.getElementById('editoScroll');
	if (delta < 0)
		contenu.scrollTop += 7;
	else
		contenu.scrollTop -= 7;
}

function wheel(event){
	var delta = 0;
	if (!event) event = window.event;
	if (event.wheelDelta) {
		delta = event.wheelDelta/120; 
		if (window.opera) delta = -delta;
	} else if (event.detail) {
		delta = -event.detail/3;
	}
	if (delta)
		handle(delta);
}

function testEdito() {
	if ($('editoScroll').firstDescendant().getHeight() > $('scrollingContent').getHeight()) {
		$('goUp').show();
		$('goDown').show();
	}
}

function clearValue(object) {
	if (object.value == object.defaultValue) {
		object.value = '';
	}
}

function restoreValue(object) {
	if (object.value == '') {
		object.value = object.defaultValue; 
	}
}

-->
