// Commmon.js
// Version : 2.0
// Date:15/10/03

function sniffer() 
{
    var agent = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
    this.ns2 = (this.ns && (this.major == 2));
    this.ns3 = (this.ns && (this.major == 3));
    this.ns4b = (this.ns && (this.minor < 4.04));
    this.ns4 = (this.ns && (this.major == 4));
    this.ns6 = (this.ns && (this.major >= 5));
    this.ie   = (agent.indexOf("msie") != -1);
    this.ie3  = (this.ie && (this.major == 2));
    this.ie5  = (this.ie && (this.major >= 4) && (document.getElementById) ) ? true : false ;
    this.ie6  = (this.ie5 && (agent.indexOf('msie 6')!=-1) ) ? true : false ;
    this.ie4  = (this.ie && (this.major >= 4) && !(this.ie5));
    this.op3 = (agent.indexOf("opera") != -1);
    this.win   = (agent.indexOf("win")!=-1);
    this.mac   = (agent.indexOf("mac")!=-1);
    this.unix  = (agent.indexOf("x11")!=-1);
    this.dom = (this.ns6 || this.ie5 );
}

clientIs = new sniffer();

/********************************************************************
*                   Ajout des feuilles de styles                    *
********************************************************************/

function linkCSS(relativePath)
{

	if(relativePath[relativePath.length-1]!='/') relativePath=relativePath+"/";
		if(clientIs.ie|| clientIs.ns6 )
	//if(clientIs.ie )
		{document.write('<link rel="stylesheet" type="text/css" href="'+relativePath+'styleie.css">');}
		 else 
		{document.write('<link rel="stylesheet" type="text/css" href="'+relativePath+'stylens.css">');}

	document.close();
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function FixePuce (nombre, numero,relativePath,layerName)
{
for (i=0;i<nombre;i++)
{
var compte=i+1;
var image = "puce"+layerName+"0"+compte;
var lequel = "puce"+layerName+"0"+numero;
document[image].src = relativePath+"images/shim.gif";
}
document[lequel].src = relativePath+"images/n_1/nav_haut/picto_fleche_sous_nav.gif";

}

function openWin(URL,w,h,resize,scroll,windowName)
{
lAttributes = '';
lAttributes += 'toolbar=0,';
lAttributes += 'Location=0,';
lAttributes += 'directory=0,';
lAttributes += 'status=0,';
lAttributes += 'menubar=0,';
lAttributes += 'scrollbars='+scroll+',';
lAttributes += 'resizable='+resize+',';
lAttributes += 'width='+w+',';
lAttributes += 'height='+h+'';
if(!windowName) windowName="";
winId = window.open(URL,windowName,lAttributes);
}

function switchLanguage()
{
	//return ;

	var domainen = "http://burma.total.com";
	var domainfr = "http://birmanie.total.com";
		
	var lPath = top.document.location.href;
	var locationPathname = top.document.location.pathname ;
	var langue = (lPath.indexOf(domainen)>=0) ? "en" : "fr"  ;

	if (langue=="en")
		{
		newLanguage = "/fr/";
		newDomain = domainfr;
		pos = (locationPathname.indexOf("/en/")) ;
		}
	else
		{	
		newLanguage = "/en/";
		newDomain = domainen;
		pos = (locationPathname.indexOf("/fr/")) ;
		}

	if(pos>=0) 
	{	
		newLocation = newLanguage+locationPathname.substring(4,locationPathname.length);
		newLocation = newDomain+newLocation
	}
	else
	{
		newLocation = newDomain;
	}
	
 /*
 URLow = "http://birmanie.total.com/fr/ow/attente.htm";
 openWin(URLow,468,422,0,1,"");
 return ;
*/
	top.document.location.href = newLocation;

}

/*
function switchLanguage()
{
	//return ;
	var lPath = top.document.location.href;
	var langue = (lPath.indexOf('/en/')>=0) ? "en" : (lPath.indexOf('/fr')>=0) ? "fr" : "xx" ; ;
	var newLanguage = "";
	if (langue=="en")
		{
			lPos = lPath.indexOf('/en/');
			newLanguage = "/fr/";
			inc = newLanguage.length;
		}
	else
		{	
		if (langue=="fr")
			{
				lPos = lPath.indexOf('/fr/');
				newLanguage = "/en/";
				inc = newLanguage.length;
			}
			else
			{
				lPos = lPath.indexOf('_en.htm');
				
				if(lPos<0) top.document.location.href = "index_en.htm";
				else top.document.location.href = "index.htm";
			}
		}
    var startPath = lPath.substring(0,lPos);
	var endPath = lPath.substring(lPos+inc,lPath.length);
	

	top.document.location.href = startPath+newLanguage+endPath;	

}
*/