//utf8 é//
nav=detnav();

function detnav() {
	var p,nav,ver; // variables locales
	var result = new Array();
	with(navigator.userAgent){
		switch(navigator.appName){
		case "Microsoft Internet Explorer" :
			nav='IE'; p=indexOf("MSIE"); ver= parseFloat(substring(p+5,p+9));
			if (indexOf("Opera")>-1){
				nav='Opera'; p=indexOf("Opera"); ver= parseFloat(substring(p+6,p+10));
			}
			break;
		case "Netscape" :
			nav='Netscape'; ver= parseFloat(substring(8,12));
			if (indexOf("Opera")>-1){nav='Opera'; p=indexOf("Opera"); ver= parseFloat(substring(p+6,p+10));}
			if (indexOf("Gecko")>-1){nav='Mozilla'; p=indexOf("rv:"); ver= parseFloat(substring(p+3,p+7));}
			if (indexOf("Netscape6")>-1){nav='Netscape6'; p=indexOf("Netscape6"); ver= parseFloat(substring(p+10,p+14));}
			if (indexOf("Firefox")>-1){nav='Firefox'; p=indexOf("Firefox"); ver= parseFloat(substring(p+8,p+12));}
			break;
		case "Opera" :
			nav='Opera'; p=indexOf("/"); ver= parseFloat(substring(p+1,p+5));
			break;
			default :
			nav='inconnu'; ver='';
		}
	}
	result[0]=nav; result[1]=ver;
	return result;
}

function windowCenter(myId) {
	//result=returnSize();
	result=getPageSize();
	var myWidth=result[2]; 
	var myHeight=result[3];
	var elementWidth=$("div#"+myId).width();
	//alert(elementWidth);
	var elementHeight=$("div#"+myId).height();
	var myScrollLeft=document.body.scrollLeft;
	var myScrollTop= document.body.scrollTop;
	var my_scroll =getPageScroll()
	var myScrollTop = my_scroll[1];
	var posX=myScrollLeft+myWidth-myWidth/2-elementWidth/2
	var posY=myScrollTop+myHeight-myHeight/2-elementHeight/2;
	$("div#"+myId).css({ 'left': posX+'px',  'top': posY+'px'}); 
}

function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		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
		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 = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}

// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
// Code by Lokesh Dhakar
function getPageScroll(){
	var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',yScroll)
	return arrayPageScroll;
}

function findPos(obj) {
	var curleft = obj.offsetLeft || 0;
	var curtop = obj.offsetTop || 0;
	while (obj = obj.offsetParent) {
		curleft += obj.offsetLeft
		curtop += obj.offsetTop
	}
	return {x:curleft,y:curtop};
}

//POUR LE RTE//
function fileBrowserCallBack(field_name, url, type, win) {
	var connector = "../../filemanager/browser.html?Connector=connectors/php/connector.php";
	var enableAutoTypeSelection = true;
	
	var cType;
	tinyfck_field = field_name;
	tinyfck = win;
	
	switch (type) {
	case "image":
		cType = "Image";
		break;
	case "flash":
		cType = "Flash";
		break;
	case "file":
		cType = "File";
		break;
	}
	
	if (enableAutoTypeSelection && cType){
		connector += "&Type=" + cType;
	}
	
	window.open(connector, "tinyfck", "modal,width=600,height=400");
}

//EQUIVALENT RETURN FALSE IE 6//
function suppr_event_ie6(){
	var event = event || window.event;
	if (event){if(!event.preventDefault){event.returnValue = false;}}
}

function verif_mail(_mail){
	var verif = /^[a-zA-Z0-9\._-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,3}$/
	if (verif.exec(_mail) == null){
		return false;
	}
	else{
		return true;
	}
}

function add_panier(_ref){
	Overlay.display_from_url('/popup/panier-add.html?ref='+ _ref);
	
	//on cache le bouton fermer de base//
	$('#popup #close').hide();
}

function nom_web(str){
	str= str.replace(/é/g,'e'); // 145 91
	str= str.replace(/è/g,'e'); // 145 91
	str= str.replace(/ê/g,'e'); // 145 91
	str= str.replace(/É/g,'e'); // 145 91
	str= str.replace(/È/g,'e'); // 145 91
	str= str.replace(/Ê/g,'e'); // 145 91
	
	return str.toLowerCase();;
}