/**********************************************
* Browser definition													*
**********************************************/
if (navigator.userAgent.toLowerCase().indexOf('msie') != -1 && navigator.userAgent.toLowerCase().indexOf('opera') == -1) {
	var isIE = true;
	//get IE version
	if (navigator.userAgent.toLowerCase().indexOf("msie 5.5") != -1) {
		var isIE55 = true;
	} else if (navigator.userAgent.toLowerCase().indexOf("msie 6") != -1)	{
		var isIE6 = true;
	} else if (navigator.userAgent.toLowerCase().indexOf("msie 7") != -1)	{
		var isIE7 = true;
	}
} else if (navigator.userAgent.toLowerCase().indexOf('opera') != -1) {
	var isOp = true;
} else if (navigator.userAgent.toLowerCase().indexOf('firefox') != -1 || 
					 (navigator.userAgent.toLowerCase().indexOf('mozilla') != -1 && (navigator.userAgent.toLowerCase().indexOf('rv:1.7') != -1 || navigator.userAgent.toLowerCase().indexOf('rv:1.8') != -1))) {
						 var isMoz = true;
					 }
/*nom de la fenetre : utilisée pour le retour de paiement de spplus */
self.name="sitecom";

/**
* Add an event on a given object
* @param html object obj, the object to add event on
* @param string evType, the event type to add (click, mouseover, blur, etc.)
* @param string fcn, the function name to call on event
* @return boolean true on success, false on failure
*/
function CMS_addEvent(obj, evType, fcn) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fcn, true);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent("on"+evType, fcn);
		return r;
	} else {
		return false;
	}
	return true;
}

/**
* Get element by id
* @param string id, the element id to get
* @return wanted element or false if not founded
*/
function getE(id) {
	if (e = document.getElementById(id)) { 
		return e;
	} else {
		return false;
	}
}


//check if the next sibling node is an element node
function get_nextsibling(n)
{
	var x=n.nextSibling;
	while (x.nodeType!=1)
	{
		x=x.nextSibling;
	}
	return x;
}

/*add some events on menu for IE compatibility only*/
function startMenu() {
	if (isIE && !isIE7) {
		var liMenu = document.getElementById("menu").getElementsByTagName("LI");
		
		for (var i=0; i<liMenu.length; i++) {
			li = liMenu[i];
			if (li.nodeName=="LI"	&& li.className.indexOf("CMS_lvl2") !==-1) {
				li.onmouseenter=function() { 
					this.className += " over";
				}
					li.onmouseleave=function() {
					this.className = this.className.replace(" over", "");
			}
		}
	}
}
}
	/*
	function startLangue() {
	if (isIE && !isIE7) {
	var div = document.getElementById("lang");
	if(div && div.className == ""){
	div.onmouseenter=function() {
	this.className = "over";
	}
	div.onmouseleave=function() {
	this.className = "";
	}
	}
	}
	}
	*/
	/* add some flash */
	function startFlash() {
	var so = new SWFObject("/swf/accueil.swf", "accueil", "307", "471", "9");
so.addParam("wmode", "transparent");
so.write("goutteHome");
}
	
	CMS_addEvent(window, 'load', function() {
	if(typeof sIFR == "function"){
	// This is the preferred "named argument" syntax
	sIFR.replaceElement(named({sSelector:".titleFocus", sFlashSrc:"/swf/Usuzi.swf", sColor:"#8e837d", sBgColor:"Null", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left", sWmode:"transparent"}));
sIFR.replaceElement(named({sSelector:".titre_h1>h1", sFlashSrc:"/swf/ChollaSansBold.swf", sColor:"#8BAE0A", sBgColor:"Null", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left", sWmode:"transparent"}));
sIFR.replaceElement(named({sSelector:".productsTitle", sFlashSrc:"/swf/Usuzi.swf", sColor:"#82A300", sBgColor:"Null", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left", sWmode:"transparent"}));
}
	if(document.getElementById("goutteHome")){
	startFlash();
}
	startMenu();
//startLangue();

});

$(document).ready(function() {
	// Resize div textproduct	 
	$('.gamme').each(function() {
		var productHeight = $(this).find(".catalog-product .textProduct").height(); 
		$(this).find('.catalog-product .textProduct').each(function() { 
			if($(this).height() > productHeight){
				productHeight = $(this).height();
			}
		}).css({height:productHeight});
	});
	
	//Fix filter ie8
	if((typeof ie != 'undefined') && (ie == "ie8")) {
		$('.textProduct').each(function(){
			$(this).append('<span class="ie8fix"></span>');
		});
	}
});

//before after ie
(function($){
	var patterns = {
		text: /^['"]?(.+?)["']?$/,
		url: /^url\(["']?(.+?)['"]?\)$/
	};
	function clean(content) {
		if(content && content.length) {
			var text = content.match(patterns.text)[1],
					url = text.match(patterns.url);
			return url ? '<img src="' + url[1] + '" />': text;
		}
	}
	function inject(prop, elem, content) {
		if(prop != 'after') prop = 'before';
		if(content = clean(elem.currentStyle[prop])) {
			$(elem)[prop == 'before' ? 'prepend' : 'append'](
				$(document.createElement('span')).addClass(prop).html(content)
			);
		}
	}
	$.pseudo = function(elem) {
		inject('before', elem);
		inject('after', elem);
		elem.runtimeStyle.behavior = null;
	};
	if(document.createStyleSheet) {
		var o = document.createStyleSheet();
		o.addRule('.dummy','display: static;');
		o.cssText = 'html, head, head *, body, *.before, *.after, *.before *, *.after * { behavior: none; } * { behavior: expression($.pseudo(this)); }';
	}
	
})(jQuery);




