var ie=(document.all)?1:0;

function gosearch(searchurl) 
{ 
	var search;
	var mf = GetMainFormName(); 
	if (mf==null) return; 
	
	// Get the search element
	search = GetElement('search', mf);

	if (search)
	{
		document.forms[mf].action = searchurl + '&search=' + search.value;
	}
	//alert(document.forms[mf].action);
	document.forms[mf].target = "_self";
	document.forms[mf].type = "get";
	document.forms[mf].submit(); 
}

function gosearchonkeydown(searchurl)
{
    if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
    {
		gosearch(searchurl);
	}
}

function recharge(){
	if(!ie){
		if(navigator.appVersion.indexOf("4.0")<0)self.location.reload()
	}
}

// ouverture pop estrat
function estrat(){
	var haut = (document.all) ? 610 : 500
	var large = (document.all) ? 760 : 740
	eval('regalMap = window.open("http://www.e-strat.loreal.com/loreal.html","estrat","width='+large+',height='+haut+'scrollbars=yes,resizable=yes,menubar=yes,directories=yes,status=yes,location=yes,toolbar=yes,top=0,left=0,status=1")')
}

// popup
function sesamus(url){
window.open(url,"LOreal","width=650,height=500,top=20,left=20,scrollbars=yes");
}

function sesame(url,name,param){
window.open(url,name,param);
}

function init()
{
	for (i=0; i<document.images.length; i++) document.images[i].onmousedown = noclick;
}

// zoom sur les fotos
function popimage(url)
{
	var largeur=640;
	var hauteur=480;
	//window.open(url,"image","top=100,left=100,width="+largeur+",height="+hauteur+",scrollbars=0");
	
html = '<html><head><title>Invitroskin</title></head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 bgcolor="#FFFFFF"><table border=0 cellpadding=0 cellspacing=0 width=document.imageZoom.width><tr><td align=center><img src="/img/identical/identical/dot.gif" width=1 height=10><br><a href=javascript:self.close();><img src="'+url+'" border=0 name=imageZoom onLoad="window.resizeTo(document.imageZoom.width+50,document.imageZoom.height+90)"></a><br><span style="font-family:Arial; font-size:10px; color:#00546F"></font></td></tr></table></body></html>';
popupImage = window.open("","_blank","top=100,left=100,width="+largeur+",height="+hauteur+",menubar=no,scrollbars=yes,statusbar=no");
popupImage.document.open();
popupImage.document.write(html);
}

// zoom sur les flashs
function popflash(url,w,h)
{
	var largeur=w;
	var hauteur=h;
	var bg="#ffffff";
	var top=(screen.height-largeur)/2;
	var left=(screen.width-hauteur)/2;
	
flash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH='+w+' HEIGHT='+h+' id="mouvi" ALIGN="center"><param name=movie value=/img/db/topic/'+url+'><param name=quality value=high><param name=bgcolor value='+bg+'><embed src=/img/db/topic/'+url+' quality=high bgcolor='+bg+' width='+w+' height='+h+' name=exemple1 align="center" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';

html = '<html><head><title>Hair Science</title></head><body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">'+flash+'</body></html>';

popupFlash = window.open("","_blank","top="+top+",left="+left+",width="+largeur+",height="+hauteur+",menubar=no,scrollbars=no,statusbar=no");
popupFlash.document.open();
popupFlash.document.write(html);
}

function popLien(url,param)
{
	window.open(url,"lien","top=50,left=50,width=640,height=480,menubar=yes,scrollbars=yes,statusbar=yes,resizable=yes");
}

// ONMOUSEOVER="glosse(1);" ONMOUSEOUT="ClearLyrDrag(1);" 
function glosse(num, gauche){
	if(arguments.length<2) gauche=0;
	LyrDrag("def"+num, true, 'both', -20, 20, gauche);
	setTimeout("dlib.layers('def"+num+"').visible(true)", 5);
}

function ClearLyrDrag(num){
	LyrDrag('def'+num, false, 'both', -20, 20);
	dlib.layers('def'+num).visible(false);
	dlib.layers('def'+num).left(0);
	dlib.layers('def'+num).top(0);
}

function LyrDrag(LyrNme, Start, lequel, left, top, gauche)
{
	if (lequel.indexOf("l")==0 || lequel.indexOf("t")==0) mve=(lequel.indexOf("l")!=-1)?"l":"t";
	else mve="b";
	if (Start)
	{  
		if (dlib.navigator("NS4")) document.captureEvents(Event.MOUSEMOVE);												  
	   	document.onmousemove=function (e) 
		{ 
		   if (mve=="b" || mve=="t") 
		   {
		   		mousePosTop=(dlib.navigator("IE"))? window.event.y-parseInt(top)+document.body.scrollTop:e.pageY-parseInt(top);
				dlib.layers(LyrNme).top(mousePosTop);
		   }	
		   if (mve=="b" || mve=="l")
		   {
		   		mousePosLeft=(dlib.navigator("IE"))? window.event.x:e.pageX;
				if (gauche) dlib.layers(LyrNme).right(mousePosLeft+parseInt(left));
				else dlib.layers(LyrNme).left(mousePosLeft-parseInt(left));
		   }
		}
	}
	else document.onmousemove=function (e){};			
}

function ouvrePop(page,name,param)
{
	window.open(page,name,param);
}

function GetMainFormName()
	{
		var i;
		for (i=0;i<document.forms.length;i++)
		{
			// Framework v1.0.3705
			if (document.forms[i].name.indexOf("_ServerForm") != -1)
				return document.forms[i].name;
			// Framework v1.1.4322
			if (document.forms[i].name.indexOf("__aspnetForm") != -1)
				return document.forms[i].name;
		}
		return null;
	}
	
	function SaveElement(ElementObject,ElementValue)
	{
		var mf = GetMainFormName();					
		if (mf==null) return;
		var element  = GetElement(ElementObject,mf);
		if (element!=null) 
			element.value = ElementValue;
	}
	
	function GetElementName(n,mf)
	{
		if (n==null || n=="") return null;
		var i, s, j;
		for (i=0;i<document.forms[mf].elements.length;i++)
		{
			if (document.forms[mf].elements[i].name.toLowerCase().indexOf(n.toLowerCase()) != -1)
			{
				var strform = document.forms[mf].elements[i].name.toLowerCase();
			    var strformname = strform.substr(strform.indexOf(n.toLowerCase()),n.length);
				if (strformname == n)
				  return document.forms[mf].elements[i].name;
			}	
		}
		return null;
	}
	
	function GetElement(ElementName, formName)
	{
		return document.forms[formName].elements[GetElementName(ElementName,formName)];
	}	
	

/* definition du pays */
tmp_rootIndex=self.location.href.substring(self.location.href.indexOf("/_"));
if (tmp_rootIndex.indexOf("/_Http")!=-1) tmp_rootIndex=tmp_rootIndex.substring(tmp_rootIndex.indexOf("/_Http")).substring(tmp_rootIndex.indexOf("/_"));
if (tmp_rootIndex.indexOf("/_Files")!=-1) tmp_rootIndex=tmp_rootIndex.substring(tmp_rootIndex.indexOf("/_Files")).substring(tmp_rootIndex.indexOf("/_"));

tmp_rootIndex=tmp_rootIndex.split("/");
document.RootIndex=tmp_rootIndex[1]+"/"+tmp_rootIndex[2]+"/";
document.LangIndex=tmp_rootIndex[2];
/* /definition du pays */

/* variable interne */
ipackage=[];
/* /variable interne */

/* */
function getUrlCountry(){ return "/"+document.RootIndex.split("/")[0]; }
function getUrlLang() {return document.LangIndex;}

function getURLRep(){
	RootIndex=document.RootIndex;
	ShortURL=self.location.href.substring(self.location.href.indexOf(RootIndex)+RootIndex.length);
	return ShortURL;
}

function getUrlRepTable(){
	ShortURL=getURLRep();
	ShortURL=ShortURL.split("/");		
	return ShortURL; }

function GetRootUrl(){
	ShortURL=getUrlRepTable();
	RelativPath="";
	for(i=0; i<ShortURL.length-1; i++) RelativPath+="../";
	return RelativPath;
}
