<!-- script allows PNG files to show transparency-->

if (document.selection){
		// correctly handle PNG transparency in Win IE 5.5 or higher.

		function correctPNG() {
		
			for(var i=0; i<document.images.length; i++)
			{

				var img = document.images[i]
				var imgName = img.src.toUpperCase()

				if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
				{
					var imgID = (img.id) ? "id='" + img.id + "' " : "";
					var imgClass = (img.className) ? "class='" + img.className + "' " : "";
					var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
					var imgStyle = "display:inline-block;" + img.style.cssText;

					if (img.align == "left") imgStyle = "float:left;" + imgStyle;
					if (img.align == "right") imgStyle = "float:right;" + imgStyle;
					if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;

					var strNewHTML = "<span " + imgID + imgClass + imgTitle
					+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
					+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
					+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
					img.outerHTML = strNewHTML;
					i = i-1;
				}
			}
		}

		window.attachEvent("onload", correctPNG);
}


function displayIndex() {
	CenterWindowAndOpen("popup/IndiceDetails.aspx", "IBEX", 960, 700, ",scrollbars=yes,status=no,resizable=no")
}

function openNewslist(rdvNewMappingId) {
	CenterWindowAndOpen(SitePath + "popup/NewsList.aspx?rdvNewMappingId=" + rdvNewMappingId , "News", 960, 700, ",scrollbars=yes,status=no,resizable=no")
}

function openPlay1() {
	CenterWindowAndOpen(SitePath + "popup/Play1.aspx", "Promotion", 800, 600, ",scrollbars=no,status=no,resizable=no")
}

function disclaimer(){
	CenterWindowAndOpen(SitePath + "popup/disclaimer.aspx", "disclaimer", 795, 600, ",scrollbars=yes,resizable=no,status=no");
}

function contact() {
	CenterWindowAndOpen(SitePath + "popup/contact.aspx", "contact", 795, 595, ",scrollbars=yes,status=no,resizable=no");
}

function apropos() {
	CenterWindowAndOpen(SitePath + "popup/apropos.aspx", "apropos", 650, 570, ",scrollbars=yes,status=no,resizable=no");
}

function faq() {
	CenterWindowAndOpen(SitePath + "popup/faq.aspx", "faq", 870, 600, ",scrollbars=yes,status=no,resizable=no");
}


function ChangeGraph(itemId, folder, name, underlyingid, underlyingName, website_id) {

	//on retire la selection à tous les onglets
	/*
	document.getElementById('_tdIntraday').background= SitePath + 'images/boxtab-off.gif';
	document.getElementById('_td1M').background= SitePath + 'images/boxtab-off.gif';
	document.getElementById('_td6M').background= SitePath + 'images/boxtab-off.gif';
	
	//on met la selection à l'onglet concerné	
	document.getElementById(itemId).background= SitePath + 'images/boxtab-on.gif';
	*/
	//on change le graphique
	if (underlyingid != "") {
	    var graphType;
		switch (name)
		{
		    case "intraday" : 
		        graphType = "ES_Intraday";
		        break;
		    case "1M" :
		        graphType = "ES_History1mois";
		        break;
		    case "6M" :
		        graphType = "ES_History6mois";
		        break;
		}
//		document.getElementById('graph').src= "?Download=" + folder + name + "/"+ name +"_"+ underlyingid + ".gif";
        var img = document.images['graph'];
		img.src = "GraphGeneratorHandler.ashx?mode=" + graphType + "&id=" + underlyingid + "&title=" + underlyingName + "&website_id=" + website_id;
		img.alt= name + " " + underlyingName;
		
		img.style.visibility = 'visible';
	}
}

function WrongPassword(email){
	alert('Usuario/Contraseña incorrectos, inténtelo de nuevo')
	//var w = CenterWindowAndOpen(SitePath + "de/popup/WrongPassword.aspx", "WrongPassword", 500, 210, ",scrollbars=no,resizable=no,status=no");
}


function VerifSearchFrom(productcode, underlying, category)
{
	if (document.getElementById(productcode).value != 'Codigo' && 
		document.getElementById(productcode).value != '')
	{
		return true
	}
	else
	if (document.getElementById(underlying).selectedIndex == 0
		|| document.getElementById(category).selectedIndex == 0)
	{
		alert('El tipo de activo y el subyacente son obligatorios');
		return false;
	}
	else
	{
		return true;
	}
}


function news_details(NewsId)
{
	CenterWindowAndOpen (SitePath + "popup/NewsDetails.aspx?NewsId="+NewsId, "news_" + NewsId, 600, 400, ",scrollbars=yes,status=no,resizable=no");
}


function ForgetPassword(email)
{
    var chaine = '';
    
    if (email != null && email.length > 0)
        chaine = "?email=" + email
       
    CenterWindowAndOpen(SitePath + "popup/SendPassword.aspx" + chaine, "ContrasenOlvidada", 500, 210, ",scrollbars=no,resizable=no,status=no");
}




/*	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 formPressKeyEs(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 changeChapter (chapter, nbchapter) {

	var i;
	for (i=1;i<nbchapter+1;i++) {
			eval("document.getElementById('chapter" + i + "').style.display='none'")
	}
	eval("document.getElementById('chapter" + chapter + "').style.display='block'")
}


/*pour les images*/
function zoom(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(); 
}



/**fonctions d'ajout ou de suppression à un champ*/
function VarAug(field, nbvar)
{
    if (nbvar.length ==0) nbvar = 1;
    
    var valeur = document.getElementById(field).value;
    valeur = parseFloat(valeur.replace(",", ".")) + nbvar;
    valeur = valeur.toString().replace(".", ",")
    
    document.getElementById(field).value = valeur;
    
    if (document.getElementById(field).onchange != null)
    {
        onchange_ref = document.getElementById(field).onchange;
        onchange_ref(); 
    }
    else
    {
        document.getElementById(field).focus();
    }
}

function VarDim(field, nbvar)
{
    if (nbvar.length ==0) nbvar = 1;

    var valeur = document.getElementById(field).value;
    valeur = parseFloat(valeur.replace(",", ".")) - nbvar;
    valeur = valeur.toString().replace(".", ",")
    
    document.getElementById(field).value = valeur;

    if (document.getElementById(field).onchange != null)
    {
        onchange_ref = document.getElementById(field).onchange;
        onchange_ref(); 
    }
    else
    {
        document.getElementById(field).focus();
    }
    
}

function export_excel(CategoryId, UnderlyingId, TypeProductId, Maturity) {
	window.open("popup/ProductListExcel.aspx?CategoryId="+CategoryId+"&UnderlyingId="+UnderlyingId+"&TypeProductId="+TypeProductId+"&Maturity="+Maturity);
}

function WLAddUnderlying(UnderlyingId)
{
	CenterWindowAndOpen(SitePath + "popup/MembersAddWatchList.aspx?UnderlyingId=" + UnderlyingId , "WatchList", 300, 300, ",scrollbars=auto,status=no,resizable=no")
}
