
CompteTitreLineImage=path+"img/assetallocationline1.gif";CompteTitreName="Compte titre (K&euro;)";AssuranceVieLineImage=path+"img/assetallocationline2.gif";AssuranceVieName="Assurance vie (K&euro;)";PEALineImage=path+"img/assetallocationline3.gif";PEAName="PEA (K&euro;)";SpacerImage=path+"img/assetallocationspacer.gif";var run="GraphSetup( );";function start()
{loaded=true;if(run!='')
{setTimeout(run,0);}}
function GraphSetup()
{if(document.getElementById('here')!=null)
{}
else if(run!='')
{setTimeout(run,0);}}
function YAxisFormat(strNumber)
{return(Math.round(strNumber/1000));}
function DefaultYAxisFormat(strNumber)
{return(Math.round(strNumber));}
function PrepareGraph2()
{var values=new Array();values[0]=new Array(10000,10514,11135,11981,12782,13652,15586,16832,18184,19652,21245);values[1]=new Array(10000,10515,10983,11487,12031,13526,14384,15308,16305,18823,20210);values[2]=new Array(10000,10560,11199,11882,12607,13378,14197,15066,15988,16966,18005);var nams="";PrepareGraph(100,200,values,nams,"AV,PEA","here");}
function PrepareGraph(width,height,values,nams,dots,strDiv)
{var bDrawPEALine=false;if(dots!="")
{var lineNames=dots.split(",");var lineNameCount=lineNames.length;for(var z=0;z<lineNameCount;z++)
{if(lineNames[z]=="PEA")
{bDrawPEALine=true;}}}
var Graph=new GraphGenerator();Graph.strLocationDiv=strDiv;var lineCount=values.length;var compteTitreLine=new Line();compteTitreLine.strImage=CompteTitreLineImage;compteTitreLine.Name=CompteTitreName;for(var i=0;i<values[0].length;i++)
{compteTitreLine.AddData(values[0][i]);}
compteTitreLine.EvaluateData();var assuranceVieLine=new Line();assuranceVieLine.strImage=AssuranceVieLineImage;assuranceVieLine.Name=AssuranceVieName;Graph.AddLine(compteTitreLine);for(var i=0;i<values[1].length;i++)
{assuranceVieLine.AddData(values[1][i]);}
assuranceVieLine.EvaluateData();Graph.AddLine(assuranceVieLine);if(bDrawPEALine==true)
{var PEALine=new Line();PEALine.strImage=PEALineImage;PEALine.Name=PEAName;for(var i=0;i<values[2].length;i++)
{PEALine.AddData(values[2][i]);}
PEALine.EvaluateData();Graph.AddLine(PEALine);}
Graph.NegativeYAxis=false;Graph.SetScaleY(0,0,true,"DefaultYAxisFormat");Graph.DrawLines();VerticalLine("testline0",Graph.absoluteXOriginCoordinate+100,Graph.absoluteYOriginCoordinate-(Graph.ScaleHeight/2),(Graph.Height+(Graph.ScaleHeight/2)),Graph.aLine[1].strImage,true);VerticalLine("testline1",Graph.absoluteXOriginCoordinate+200,Graph.absoluteYOriginCoordinate-(Graph.ScaleHeight/2),(Graph.Height+(Graph.ScaleHeight/2)),Graph.aLine[1].strImage,true);if(bDrawPEALine==true)
{VerticalLine("testline2",Graph.absoluteXOriginCoordinate+50,Graph.absoluteYOriginCoordinate-(Graph.ScaleHeight/2),(Graph.Height+(Graph.ScaleHeight/2)),Graph.aLine[2].strImage,true);VerticalLine("testline3",Graph.absoluteXOriginCoordinate+125,Graph.absoluteYOriginCoordinate-(Graph.ScaleHeight/2),(Graph.Height+(Graph.ScaleHeight/2)),Graph.aLine[2].strImage,true);}}
function SpacerGif(height,width)
{return"<img src=\""+path+"img/assetallocationspacer.gif\" width=\""+width+"\" height=\""+height+"\" border=\"0\"/>";}
function GraphGenerator()
{this.ScaleXMin=0;this.ScaleXMax=0;this.ScaleYMin=0;this.ScaleYMax=0;this.ScaleXAuto=true;this.ScaleYAuto=false;this.ScaleYFormat="DefaultYAxisFormat";this.ScaleXFormat="";this.ScaleX=1;this.ScaleY=1;this.aLine=new Array();this.nLines=0;this.drawXAxis=true;this.drawYAxis=true;this.drawXScale=true;this.drawYScale=true;this.drawLegend=true;this.Height=150;this.ScaleHeight=15;this.ScaleWidth=25;this.AxisColor="#CCCCCC";this.ScaleColor="#000000";this.ScaleXSeparator="";this.ScaleYSeparator="1px solid #DDDDDD";this.NegativeYAxis=false;this.absoluteXOriginCoordinate;this.absoluteYOriginCoordinate;this.yLabels=new Array();this.yLabelStepCount=0;this.strLegendUnits="";this.strLocationDiv="";}
function DrawLines()
{if(this.nLines==0)
{Output("No lines have been setup for the Graph");return;}
if(this.ScaleYAuto)
{this.AutoScaleY();}
if(this.ScaleXAuto)
{this.AutoScaleX();}
if(this.ScaleXMax==0)
{Output("No Data is available to draw the Graph");return;}
if(this.NegativeYAxis)
{this.AxisHeight=this.Height/2;}
else
{this.AxisHeight=this.Height-(this.ScaleHeight/2);}
strGraph="";var graphWidth=(Math.abs(this.ScaleWidth)+1)*(Math.abs(this.ScaleXMax)-1)+(this.ScaleHeight/2);strGraph=strGraph+"<div id=\"lineGraph\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" >";strGraph=strGraph+"<tr>";if(this.drawYScale)
{strGraph=strGraph+"<td>";strGraph=strGraph+"<table width=\"21px\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";for(iScale=this.yLabelStepCount;iScale>=0;iScale--)
{strGraph=strGraph+"<tr height=\""+this.ScaleHeight+"\">";ScaleNumber=this.yLabels[iScale];strGraph=strGraph+"<td width=\"15px\" \
          class=\"graphYScale\" nowrap>"+ScaleNumber+"</td> \
         <td width=\"5px\"></td> \
         <td class=\"graphYScale\" width=\"5px\" align=\"right\"> \
          <font color=\""+this.AxisColor+"\">-</font></td>";strGraph=strGraph+"</tr>";}
if(this.NegativeYAxis)
{for(iScale=1;iScale<=this.yLabelStepCount;iScale++)
{strGraph=strGraph+"<tr height=\""+this.ScaleHeight+"\">";ScaleNumber=(((this.ScaleYMin/this.yLabelStepCount)*iScale)*10)/10;if(this.ScaleYFormat!="")
{ScaleNumber=eval(this.ScaleYFormat+"(\""+ScaleNumber+"\")");}
strGraph=strGraph+"<td \
           class=\"graphYScale\" nowrap>"+ScaleNumber+"&nbsp;</td> \
            <td class=\"graphYScale\" align=\"right\"> \
           <font color=\""+this.AxisColor+"\">-</font></td>";strGraph=strGraph+"</tr>";}}
strGraph=strGraph+"</table>";strGraph=strGraph+"</td>";}
if(this.drawYAxis)
{strGraph=strGraph+"<td class=\"graphAxis\">"+SpacerGif(1,1)+"</td>";}
strGraph=strGraph+"<td>";strGraph=strGraph+"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" >";strGraph=strGraph+"<tr height=\""+((this.ScaleHeight/2)+1)+"\">";strGraph=strGraph+"<td width=\""+graphWidth+"\"></td>";strGraph=strGraph+"</tr>";strGraph=strGraph+"<tr height=\""+this.Height+"\">";strGraph=strGraph+"<td width=\""+graphWidth+"\">";strGraph=strGraph+"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";strGraph=strGraph+"<tr height=\""+this.Height+"\">";var thisLine=null;var cellIdBase="origin";var cellId="";for(X=this.ScaleXMin;X<(this.ScaleXMax-1);X++)
{cellId=cellIdBase+X;strGraph=strGraph+"<td id=\""+cellId+"\" width=\""+this.ScaleWidth+"\" style=\"";if(this.ScaleXSeparator!="")
{strGraph=strGraph+"border-right: "+this.ScaleXSeparator+"; ";}
strGraph=strGraph+"background-color:#ffffff;\">";strGraph=strGraph+"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";for(iLat=0;iLat<this.yLabelStepCount;iLat++)
{strGraph=strGraph+"<tr height=\""+(this.ScaleHeight-1)+"px\">";strGraph=strGraph+"<td width=\""+this.ScaleWidth+"px\" class=\"graphLateral\">"+SpacerGif(1,this.ScaleWidth)+"</td>";strGraph=strGraph+"</tr>";}
strGraph=strGraph+"</table>";var strStyle="";strGraph=strGraph+"</td>";}
strGraph=strGraph+"</tr>";strGraph=strGraph+"</table>";strGraph=strGraph+"</td>";strGraph=strGraph+"</tr>";strGraph=strGraph+"<tr height=\"2px\">";strGraph=strGraph+"<td width=\""+graphWidth+"\" class=\"graphXAxis\"></td>";strGraph=strGraph+"</tr>";strGraph=strGraph+"<tr height=\""+((this.ScaleHeight/2)-2)+"px\">";strGraph=strGraph+"<td width=\""+graphWidth+"px\">"
strGraph=strGraph+"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">";strGraph=strGraph+"<tr height=\""+((this.ScaleHeight/2)-2)+"px\">";for(var itick=0;itick<(this.ScaleXMax-1);itick++)
{strGraph=strGraph+"<td width=\""+(this.ScaleWidth)+"px\"></td><td width=\"1px\" style=\"background-color:#CCCCCC;\"></td>";}
strGraph=strGraph+"</tr>";strGraph=strGraph+"</table>";strGraph=strGraph+"</td>";strGraph=strGraph+"</tr>";strGraph=strGraph+"</table>";strGraph=strGraph+"</td>";strGraph=strGraph+"</tr>";for(iLegend=0;iLegend<this.nLines;iLegend++)
{strGraph=strGraph+"<tr style=\"padding-top: 3px\">";strGraph=strGraph+"<td colspan=\"2\" class=\"graphXScale\">";thisLine=this.aLine[iLegend];strGraph=strGraph+"<img src=\""+thisLine.strImage+"\" width=\"10\" height=\"10\" border=\"0\" />";strGraph=strGraph+"</td>";strGraph=strGraph+"<td class=\"graphXScale\" style=\"text-align: left;\">"+thisLine.Name+"</td>";strGraph=strGraph+"</tr>";}
strGraph=strGraph+"</table><div>";document.getElementById(this.strLocationDiv).innerHTML=strGraph;var graph=new Offset("lineGraph");graph.oElementObject.style.position='absolute';graph.oElementObject.style.top=graph.iElementYOffset+"px";graph.oElementObject.style.left=graph.iElementXOffset+"px";var graphOrigin=new Offset("origin0");this.absoluteXOriginCoordinate=graphOrigin.iElementXOffset-1;this.absoluteYOriginCoordinate=graphOrigin.iElementYOffset;for(var iLine=0;iLine<this.nLines;iLine++)
{var xStart=0;var xEnd=this.ScaleWidth;var yStart=0;var yEnd=0;var strLineId="line";strLineId=strLineId+iLine;var yScaleFactor=(this.ScaleYMax-this.ScaleYMin)/this.Height;var lineElement=document.createElement("div");document.body.appendChild(lineElement);lineElement.id=strLineId;lineElement.style.visibility="hidden";lineElement.style.position="absolute";for(var iPoint=1;iPoint<this.aLine[iLine].DataItems;iPoint++)
{yStart=Math.round(this.Height-((this.aLine[iLine].Data[iPoint-1]-this.ScaleYMin)/yScaleFactor));yEnd=Math.round(this.Height-((this.aLine[iLine].Data[iPoint]-this.ScaleYMin)/yScaleFactor));DrawLineSegment(lineElement,this.aLine[iLine].strImage,this.absoluteXOriginCoordinate+xStart,this.absoluteYOriginCoordinate+yStart,this.absoluteXOriginCoordinate+xEnd,this.absoluteYOriginCoordinate+yEnd,1,"#333333",true,4,"#889955",false,7,"#ffffff");xStart=xEnd;xEnd=xEnd+(this.ScaleWidth);}
this.aLine[iLine].SetDisplayObject(lineElement);this.aLine[iLine].DisplayLine();}}
function VerticalLine(strLineId,xStart,yStart,iLength,strLineImage,bDash)
{var lineElement=document.createElement("div");document.body.appendChild(lineElement);lineElement.id=strLineId;lineElement.style.visibility="hidden";lineElement.style.position="absolute";lineElement.style.left="0px";lineElement.style.top="0px";DrawLineSegment(lineElement,strLineImage,xStart,yStart,xStart,yStart+iLength,1,"#333333",true,4,"#889955",bDash,5,"#ffffff");lineElement.style.visibility="visible";}
function DrawLine(x1,y1,x2,y2,iSize,sColour,bMark,iMarkSize,sMarkColour,bDash,iDashLength,sDashColour)
{var w=Math.abs(x2-x1);var h=Math.abs(y2-y1);var x,y,xInc,yInc;var sOutput="";var iDashCount=0;var sLineColour=sColour;var bDashOn=true;if(w>h)
{xInc=(x1<x2)?1:-1;yInc=(y1<y2)?(h/w):-(h/w);}
else
{yInc=(y1<y2)?1:-1;xInc=(x1<x2)?(w/h):-(w/h);}
x=x1;y=y1;while((xInc>0&&x<=x2)||(xInc<0&&x>=x2)||(yInc>0&&y<=y2)||(yInc<0&&y>=y2))
{sOutput=sOutput+"<span style=\"position: absolute; ";sOutput=sOutput+'left: '+Math.round(x)+'px; top: '+Math.round(y)+'px;';sOutput=sOutput+" \"><img src=\"img/assetallocationcalculatorline1.gif\" height=\"1px\" width=\"1px\" /></span>";x+=xInc;y+=yInc;lineId="";if(bDash==true)
{iDashCount++;if(iDashCount>=iDashLength)
{if(bDashOn==true)
{sLineColour=sDashColour;bDashOn=false;}
else
{sLineColour=sColour;bDashOn=true;}
iDashCount=0;}}}
if(bMark==true)
{sOutput=sOutput+'<span STYLE=\"position: absolute;';sOutput=sOutput+'left: '+Math.round(x1)+'px; top: '+Math.round(y1)+'px;';sOutput=sOutput+'width: '+iMarkSize+'px; height: '+iMarkSize+'px;';sOutput=sOutput+' clip: rect(0 '+iMarkSize+' '+iMarkSize+' 0); background-color: '+sMarkColour+';\"></span>';sOutput=sOutput+'<span STYLE=\"position: absolute;';sOutput=sOutput+'left: '+Math.round(x2)+'px; top: '+Math.round(y2)+'px;';sOutput=sOutput+'width: '+iMarkSize+'px; height: '+iMarkSize+'px;';sOutput=sOutput+' clip: rect(0 '+iMarkSize+' '+iMarkSize+' 0); background-color: '+sMarkColour+';\"></span>';}
var lineElement=document.createElement("<div id=\"line0\" style=\"visibility: hidden; position: absolute;\">");document.body.appendChild(lineElement);lineElement.innerHTML=sOutput;}
var oldXPos=0;function UpdatePositions()
{if(oldXPos!=document.body.clientWidth)
{oldXPos=document.body.clientWidth;var graph=document.getElementById("lineGraph");var here=new Offset("here");if(graph!=null)
{graph.style.top=here.iElementYOffset;graph.style.left=here.iElementXOffset;}
else
{window.alert("Position changed: no line!");}}
setTimeout(UpdatePositions,100);}
function DrawLineSegment(oContainer,strLineImage,x1,y1,x2,y2,iSize,sColour,bMark,iMarkSize,sMarkColour,bDash,iDashLength,sDashColour,scaleWidth)
{var w=Math.abs(x2-x1);var h=Math.abs(y2-y1);var x,y,xInc,yInc,yStart,yEnd,xStart,xEnd;var sOutput="";var iDashCount=0;var sLineImage=strLineImage;var bDashOn=false;if(w>h)
{if(x1<x2)
{xInc=1;xStart=x1;xEnd=x2;}
else
{xInc=1;xStart=-1*x1;xEnd=-1*x2;}
if(y1<y2)
{yInc=(h/w);yStart=y1;yEnd=y2;}
else
{yInc=(h/w);yStart=-1*y1;yEnd=-1*y2;}}
else
{if(y1<y2)
{yInc=1;yStart=y1;yEnd=y2;}
else
{yInc=1;yStart=-1*y1;yEnd=-1*y2;}
if(x1<x2)
{xInc=(w/h);xStart=x1;xEnd=x2;}
else
{xInc=(w/h);xStart=-1*x1;xEnd=-1*x2;}}
strOutput="";for(y=yStart,x=xStart;(y<=yEnd&&x<=xEnd);y+=yInc,x+=xInc)
{sOutput=sOutput+"<span style=\"position: absolute; ";sOutput=sOutput+"left: "+Math.round(Math.abs(x))+"px; top: "+Math.round(Math.abs(y))+"px;";sOutput=sOutput+" \"><img src=\""+sLineImage+"\" height=\""+iSize+"px\" width=\""+iSize+"px\" /></span>";if(bDash==true)
{iDashCount++;if(iDashCount>=iDashLength)
{if(bDashOn==true)
{sLineImage=strLineImage;bDashOn=false;}
else
{sLineImage=SpacerImage;bDashOn=true;}
iDashCount=0;}}}
oContainer.innerHTML=oContainer.innerHTML+sOutput;}
function Offset(strElementId)
{var iElementXOffset=0;var iElementYOffset=0;var oElementObject=document.getElementById(strElementId);var oDocumentBody=document.getElementsByTagName('body')[0];if(oElementObject!=null)
{while(oElementObject.offsetParent)
{if(oElementObject==oDocumentBody)
{break;}
else
{iElementXOffset=iElementXOffset+oElementObject.offsetParent.offsetLeft;iElementYOffset=iElementYOffset+oElementObject.offsetParent.offsetTop;oElementObject=oElementObject.offsetParent;}}
this.iElementXOffset=iElementXOffset;this.iElementYOffset=iElementYOffset;this.strElementId=strElementId;this.oElementObject=document.getElementById(strElementId);}
else
{window.alert("No ID");}}
function SetScaleX(Min,Max,Auto,Format)
{this.ScaleXAuto=Auto;this.ScaleXFormat=Format;if(this.ScaleXAuto==false)
{this.ScaleXMin=Min;this.ScaleXMax=Max;}}
function SetScaleY(Min,Max,Auto,Format)
{this.ScaleYAuto=Auto;this.ScaleYFormat=Format;if(this.ScaleYAuto==false)
{this.ScaleYMin=Min;this.ScaleYMax=Max;}}
function AddBar(objBar)
{this.nBars=this.nBars+1;this.aBar[this.nBars]=objBar;}
function AddLine(objLine)
{this.aLine[this.nLines]=objLine;this.nLines=this.nLines+1;}
function AutoScaleY()
{this.ScaleYMax=this.aLine[0].Max;this.ScaleYMin=this.aLine[0].Min;for(var X2=1;X2<this.nLines;X2++)
{var thisLine=this.aLine[X2];if(this.aLine[X2].Min<this.ScaleYMin)
{this.ScaleYMin=this.aLine[X2].Min;}
if(this.aLine[X2].Max>this.ScaleYMax)
{this.ScaleYMax=this.aLine[X2].Max;}}
var vdiff=Math.abs(this.ScaleYMax-this.ScaleYMin);var nd=Math.round(Math.log(vdiff)/Math.log(10))-1;var dy=Math.pow(10,nd);var start=Math.floor(this.ScaleYMin/dy)*dy;var end=Math.floor(this.ScaleYMax/dy)*dy;var iLabelIndex=0;var ScaleNumber=0;for(var i=start;i<=end;i=i+dy)
{this.yLabels[iLabelIndex]=new String();if(nd>=2&&nd<5)
{ScaleNumber=(Math.ceil(i/100))/10;this.strLegendUnits="K&euro;"}
else if(nd>=5&&nd<8)
{ScaleNumber=(Math.ceil(i/100))/10000;this.strLegendUnits="M&euro;"}
else if(nd>=8)
{ScaleNumber=(Math.ceil(i/100))/10000000;this.strLegendUnits="MD&euro;"}
else
{ScaleNumber=i;this.strLegendUnits="&euro;"}
this.yLabels[iLabelIndex]=""+eval(this.ScaleYFormat+"(\""+ScaleNumber+"\")");iLabelIndex=iLabelIndex+1;}
this.yLabelStepCount=iLabelIndex-1;this.ScaleHeight=Math.round(this.Height/this.yLabelStepCount);}
function AutoScaleX()
{var currentMax=-1;for(var X2=0;X2<this.nLines;X2++)
{var thisLine=this.aLine[X2];if((thisLine.DataItems<currentMax)||(currentMax==-1))
{currentMax=thisLine.DataItems;}}
if(currentMax==-1)
{currentMax=0;}
this.ScaleXMax=currentMax;this.ScaleXMin=0;}
GraphGenerator.prototype.SetScaleX=SetScaleX;GraphGenerator.prototype.SetScaleY=SetScaleY;GraphGenerator.prototype.AddLine=AddLine;GraphGenerator.prototype.AutoScaleY=AutoScaleY;GraphGenerator.prototype.AutoScaleX=AutoScaleX;GraphGenerator.prototype.DrawLines=DrawLines;start();