// Affichage popup alert
function alertViewCustom(type, lang) {
	actionHTTP('alert', '&langue='+lang+'&type='+type, '_content/_ajax/alert.php', '');
	enabledScroolBar();
	
	$('#alert').fadeIn('10');
}

function enabledScroolBar() {
	$("html, body").css("overflow", "visible");
	$("html, body").css("overflow-x", "visible");
	$("html, body").css("height", "100%");
	$("html, body").css("overflow", "hidden");	
}

// Reaffichage scroolbar
function disableScroolBar() {
	$("html, body").css("height", "auto");
	$("html, body").css("overflow", "auto");
	$("html, body").css("overflow-x", "hidden");
	
	$('#alert').fadeOut('10');
}

// Reaffichage à retardement
function FinAlertViewCustom() {
	$('#alert').fadeOut('10');
	
	setTimeout('disableScroolBar()',1000);	
}

function menu_view(id) {
	if(document.getElementById('hidden' + id)) {
		document.getElementById('menu_deroulant' + id).style.visibility = "visible";
		document.getElementById('hidden' + id).value = 1;
	} else {
		document.getElementById('menu_deroulant' + id).style.visibility = "visible";
		document.getElementById('menu_deroulant' + id).innerHTML += "<input type='hidden' id='hidden"+id+"' value='1' />";
	}
}

function menu_hidden(id) {
		document.getElementById('hidden' + id).value = 0;
	setTimeout('cacherMenuDeroulant('+id+');',22);
}
	
// Menu principal - Cacher le menu déroulant
function cacherMenuDeroulant(id) {
	if(document.getElementById('hidden' + id).value != 1) {
		document.getElementById('menu_deroulant' + id).style.visibility='hidden';
	}
}

// Pagination des commentaires - Page produits
function goPageCommentaires(newPage) {
	var PageCommentairesActuelle = document.getElementById('PageCommentairesActuelle').value;
	document.getElementById('divCommentaire' + PageCommentairesActuelle).style.display='none';

	document.getElementById('divCommentaire' + newPage).style.display='block';
	document.getElementById('PageCommentairesActuelle').value = newPage;
}

// Correction bug onglet "Commentaires"
function cacherActuel(value) {
	if(value == 1) { var action = 'visible'; }
	else { var action = 'hidden'; }
	
	var PageCommentairesActuelle = document.getElementById('PageCommentairesActuelle').value;
	document.getElementById('divCommentaire' + PageCommentairesActuelle).style.visibility=action;
}

// Changer d'onglet dans la page produits
function ChangeMenuProduit(numero) {
	var value_menuselected=document.getElementById('current_menuselected').value;
	document.getElementById('current_menuselected').value = numero;

	document.getElementById('affichagecontenu' + value_menuselected).style.visibility='hidden';
	
	document.getElementById('affichagecontenu' + numero).style.visibility='visible';
	if(numero == 5) { cacherActuel('1'); } else { 	cacherActuel('0'); }
}

// Switch images des produits - Miniatures
function switch_smallimg(image,site, taille) {
  document.getElementById('big_img').innerHTML='<img src="http://'+site+'/_content/_ajax/func_miniature.php?img='+image+'&amp;dossier=upload_products&amp;compression=80&amp;w='+taille+'&amp;h='+taille+'" />';	
}

// Switch images des produits - Grand modele
function switch_bigimg(image,site) {
	document.getElementById('mostbig_img').innerHTML='<img src="http://'+site+'/_content/_ajax/func_miniature.php?img='+image+'&amp;dossier=upload_products&amp;compression=80&amp;w=680&amp;h=430" />';	
}

// Ajout aux favoris
function AddFavorites(description) {

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
		}
	]

};
BrowserDetect.init();

if(BrowserDetect.browser == "Explorer") {
	window.external.AddFavorite("http://www.aidoforum.com", "Aidoforum.com");
} else if(BrowserDetect.browser == "Chrome") {
	(function(){var a=window,b=document,c=encodeURIComponent,d=a.open("http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk="+c(b.location)+"&title="+c(b.title),"bkmk_popup","left="+((a.screenX||a.screenLeft)+10)+",top="+((a.screenY||a.screenTop)+10)+",height=420px,width=550px,resizable=1,alwaysRaised=1");a.setTimeout(function(){d.focus()},300)})();
} else if(BrowserDetect.browser == "Firefox") {
	window.sidebar.addPanel("exemple","http://francois.jamart.free.fr/","");
}


}

// Champ de recherche de produits
function search_products(value,condition) {
	if(document.getElementById('recherche').value==condition) {
		document.getElementById('recherche').value=value;
	}
}
