var ns4 = (document.layers)? true:false;
var ie4 = (document.all)? true:false;

function CenterWindow (width, height){
  if (document.all)
    var xMax = screen.width, yMax = screen.height;
  else
    if (document.layers)
      var xMax = window.outerWidth, yMax = window.outerHeight;
    else
      var xMax = 640, yMax = 480;
      
  xOffset = (xMax - width)/2;
  yOffset = (yMax - height)/2;
}

function CenterWindowAndOpen (url, winName, width, height, param) {
  CenterWindow (width, height);
  var w = window.open  (url, winName, 
                "width=" + width + ",height=" + height + "," +
                "screenX=" + xOffset + ",screenY=" + yOffset + "," +
                "top=" + yOffset + ",left=" + xOffset + param);
  return w;
}


function refreshOpener()
{
	window.opener.location.reload();
}

function refresh()
{
    window.location.reload(1)
}


/*pour les images*/
function ImgPopup(img) {
    
    w=open("",'image','width=400,height=400,status=no,toolbar=no,scrollbars=no,resizable=no'); 
    w.document.write("<HTML><HEAD><TITLE>BNP Paribas</TITLE></HEAD>"); 
    w.document.write("<SCRIPT language=javascript>function checksize() { if (document.images[0].complete) { window.resizeTo(document.images[0].width+10,document.images[0].height+30); window.focus();} else { setTimeout('checksize()',250) } }</"+"SCRIPT>"); 
    w.document.write("<BODY onload='checksize()' onblur='window.close()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>");
    w.document.write("<TABLE width='100%' border='0' cellspacing='0' cellpadding='0' height='100%'><TR>");
    w.document.write("<TD valign='middle' align='center'><IMG src='"+img+"' border=0>"); 
    w.document.write("</TD></TR></TABLE>");
    w.document.write("</BODY></HTML>"); 
    w.document.close(); 
}





/*****************************************************************************/
/** pour sites  de et  es                                                    */
function testAdrMail(adrEmail) {
	var rgxEMail = new RegExp('^[\\w\\-\\.]+@([\\w\\-]+)(\\.[\\w\\-]+)+$', 'i')
	if ( !rgxEMail.test(adrEmail) ) 
    	return false
  	else
  		return true
}

function changeBackground (obj, newClass) {
	obj.className = newClass;
}


function UnderlyingData_changeUnderlying(Prefix, id, name, imgId, srcImg, altImg, data_spot, data_perf, data_open, data_close, data_high, data_low, data_volume) 
{
		eval("document.getElementById('" + imgId + "').alt = '" + altImg + "'");
		eval("document.getElementById('" + imgId + "').src = '" + srcImg + "'");
		eval("document.getElementById('" + imgId + "').style.visibility='visible'");

		document.getElementById(Prefix + "_Name").innerHTML = name;
		document.getElementById(Prefix + "_Price").innerHTML = data_spot;
		
		data_perf = data_perf.replace(",", ".").replace(" ", "");
		if (parseFloat(data_perf) > 0) {
			data_perf = "+" + data_perf;
			document.getElementById(Prefix + "_Perf").className = "size11 bold Green";
		} else if (parseFloat(data_perf) == 0) {
			document.getElementById(Prefix + "_Perf").className = "size11 bold Blue";	
		} else {
			document.getElementById(Prefix + "_Perf").className = "size11 bold Red";
		}
		document.getElementById(Prefix + "_Perf").innerHTML = data_perf.replace(".", ",") + "%";
		document.getElementById(Prefix + "_Open").innerHTML = data_open;
		document.getElementById(Prefix + "_Close").innerHTML = data_close;
		document.getElementById(Prefix + "_High").innerHTML = data_high;
		document.getElementById(Prefix + "_Low").innerHTML = data_low;
		document.getElementById(Prefix + "_Volume").innerHTML = data_volume;

		document.getElementById(Prefix).style.visibility='visible';
		
}

/*	validation des formulaires	*/
//nom du bouton devant etre validé
var btnToValide = "";

//mise à jour du nom du bouton
function updateBtnToValide(name)
{
	btnToValide = name;
}


//evenement presskey
function formPressKey(evt)
{
	var lastBouton;
	var bouton;
	evt = (evt)? evt : event

    var charCode = (evt.which) ? evt.which : evt.keyCode
    if(charCode == 13)
    {
		if (btnToValide.length > 0)
			bouton = document.getElementById(btnToValide);
			
		if (bouton == null)
		{
			var boutons = document.getElementsByTagName("input")
			for (i=0; i<boutons.length; i++)
			{
				if (boutons[i].type == 'submit')
				{
					bouton = boutons[i]
				}
			}
		}

		bouton.focus();
		bouton.click();
	
    }
}


function GetEnterKey(e, buttonid){
      var evt = e ? e : window.event;
      var bt = document.getElementById(buttonid);
      if (bt){
          if (evt.keyCode == 13){
                bt.click();
                return false;
          }
      }
}

function parentRedirect(url)
{
   principalWindow=window.opener;

   while(principalWindow!=null)
   {
      v1=principalWindow;
      principalWindow=principalWindow.opener;
      if (principalWindow != null)
        v1.close();
   }
   v1.location.href = url;
   window.close();
}


/*****************************************************************************/
/** pour sites  de et  es   -- fin                                           */
