var board = JXG.JSXGraph.initBoard("box1", {pan: {enabled:false},boundingbox: [-1,4, 10,-1], axis:true,
withLines:false,
defaultAxes: {
x: { ticks: {visible: true} },
y: { ticks: {visible: true} }
},
showNavigation:false,showCopyright:false});
var board2 = JXG.JSXGraph.initBoard("box2", {boundingbox: [-1, 1.33, 7, -0.5],visible:false, showNavigation:false,showCopyright:false});
//var btn=board.create("button",[1,1],{id:"btn1"});
board.jc = new JXG.JessieCode();
board.jc.use(board);
board.renderer.container.style.backgroundColor='#E5E4E2';
board.dehighlightAll();
board.renderer.container.style.backgroundColor = '#E5E4E2';
board2.renderer.container.style.backgroundColor='#E5E4E2';
board2.dehighlightAll();
board2.renderer.container.style.backgroundColor = '#E5E4E2';
var checkbox = board.create('checkbox', [-0.5, -.5, '']);
JXG.addEvent(checkbox.rendNodeCheckbox, 'change', function() {
if (this.Value()) {
document.getElementById("box2").style.display="block";
} else {
document.getElementById("box2").style.display="none";
;
}
}, checkbox);
cadetBlue="#5F93A0";
venetianRed="#c80815";
grey="#d9d9d6";
mauve="#E2ABBF";
jauneImperial="#FAE22F";
von=true;
vno=false;
var t0 = board.create('text',[-.15,-.15,"$0$"],{visible:von,name:"",highlight:vno,anchorX:"middle"});
var t00 = board.create('text',[9.15,3.6,"$0$"],{visible:von,name:"",highlight:vno,anchorX:"middle"});
var q0 = board.create('point',[0,0],{visible:von,fillColor:cadetBlue,strokeColor:cadetBlue,name:"",highlight:vno});
var q1 = board.create('point',[9,0],{visible:von,fillColor:mauve,strokeColor:mauve,name:"",highlight:vno});
var s0 = board.create('segment',[q0,q1],{visible:vno,fillColor:cadetBlue,strokeColor:cadetBlue,name:"",highlight:vno});
var g0 = board.create('glider',[3,0,s0],{visible:von,fillColor:cadetBlue,strokeColor:"white",name:"",highlight:vno});
var s1 = board.create('segment',[q0,g0],{visible:von,fillColor:cadetBlue,strokeColor:cadetBlue,strokeWidth:5,name:"",highlight:vno});
var s2 = board.create('segment',[g0,q1],{visible:von,fillColor:venetianRed,strokeColor:venetianRed,strokeWidth:5,name:"",highlight:vno});
var t1 = board.create('text',[8.9,-.15,"$\\overline{x}$"],{visible:von,name:"",highlight:vno,anchorX:"middle"});
var t11 = board.create('text',[.15,3.6,"$\\overline{x}$"],{visible:von,name:"",highlight:vno,anchorX:"middle"});
var ts0 = board.create('text',[2.95,-.15,"$x_A$"],{visible:von,name:"",highlight:vno,anchorX:"middle"});
var gr0 = board.create('group',[g0,ts0]);
var ts1 = board.create('text',[3.15,3.65,"$x_B$"],{visible:von,name:"",highlight:vno,anchorX:"middle"});
var gr1 = board.create('group',[g0,ts1]);
var q2 = board.create('point',[0,3.5],{visible:von,fillColor:jauneImperial,strokeColor:jauneImperial,name:"",highlight:von});
var q3 = board.create('point',[9,3.5],{visible:von,fillColor:venetianRed,strokeColor:venetianRed,name:"",highlight:von});
var t2 = board.create('text',[-0.2,3.45,"$\\overline{y}$"],{visible:von,name:"",highlight:vno,anchorX:"middle"});
var t3 = board.create('text',[9.15,0.1,"$\\overline{y}$"],{visible:von,name:"",highlight:vno,anchorX:"middle"});
var s3 = board.create('segment',[q2,q3],{visible:vno,fillColor:cadetBlue,strokeColor:cadetBlue,name:"",highlight:vno});
var g1 = board.create('glider',[3,3.5,s3],{visible:von,fillColor:venetianRed,strokeColor:"white",name:"",highlight:vno});
var s4 = board.create('segment',[q2,g1],{visible:von,fillColor:cadetBlue,strokeColor:cadetBlue,strokeWidth:5,name:"",highlight:vno});
var s5 = board.create('segment',[g1,q3],{visible:von,fillColor:venetianRed,strokeColor:venetianRed,strokeWidth:5,name:"",highlight:vno});
var s6 = board.create('segment',[g0,g1],{visible:von,fillColor:"black",strokeColor:"black",strokeWidth:1,name:"",highlight:vno,dash:2});
g0.on('drag', function() {g1.moveTo([g0.X(), 3.5]);});
g1.on('drag', function() {g0.moveTo([g1.X(), 3.5]);});
var s7 = board.create('segment',[q0,q2],{visible:vno,fillColor:cadetBlue,strokeColor:cadetBlue,name:"",highlight:vno});
var g2 = board.create('glider',[0,1,s7 ],{visible:von,fillColor:cadetBlue,strokeColor:"white",name:"",highlight:vno});
var s8 = board.create('segment',[q0,g2],{visible:von,fillColor:cadetBlue,strokeColor:cadetBlue,strokeWidth:5,name:"",highlight:vno});
var s9 = board.create('segment',[g2,q2],{visible:von,fillColor:venetianRed,strokeColor:venetianRed,strokeWidth:5,name:"",highlight:vno});
var s10 = board.create('segment',[q1,q3],{visible:vno,fillColor:cadetBlue,strokeColor:cadetBlue,name:"",highlight:vno});
var g3 = board.create('glider',[9,1,s10 ],{visible:von,fillColor:cadetBlue,strokeColor:"white",name:"",highlight:vno});
var s11 = board.create('segment',[q1,g3],{visible:von,fillColor:cadetBlue,strokeColor:cadetBlue,strokeWidth:5,name:"",highlight:vno});
var s12 = board.create('segment',[g3,q3],{visible:von,fillColor:venetianRed,strokeColor:venetianRed,strokeWidth:5,name:"",highlight:vno});
var s13 = board.create('segment',[g2,g3],{visible:von,fillColor:"black",strokeColor:"black",strokeWidth:1,name:"",highlight:vno,dash:2});
var ts2 = board.create('text',[-.15,0.95,"$y_A$"],{visible:von,name:"",highlight:vno,anchorX:"middle"});
var gr2 = board.create('group',[g2,ts2]);
var ts3 = board.create('text',[9.2,1.1,"$y_B$"],{visible:von,name:"",highlight:vno,anchorX:"middle"});
var gr3 = board.create('group',[g3,ts3]);
g2.on('drag', function() {g3.moveTo([9,g2.Y()]);});
g3.on('drag', function() {g2.moveTo([9,g3.Y()]);});
var inter0=board.create('intersection', [s6, s13, 0],{strokecolor:"white",fillColor:"white",name:""});
inter0.on("over",function(){this.setName("$\\text{Allocation Initiale}$");});
inter0.on("out",function(){this.setName("$ $");});
var f = function(x){return (inter0.X()*inter0.Y())/x};
var fu = function(x){return ((inter0.X()*inter0.Y())/x)-3.5};
var rootfu = JXG.Math.Numerics.fzero(fu, [0, 1]);
var f1 = function(x){return ((inter0.X()*inter0.Y()-1)/x)};
var f2 = function(x){return ((inter0.X()*inter0.Y()+1)/x)};
var g1 = board.create('functiongraph',
[function(x){ return f(x);}, rootfu, 9],{strokeColor:cadetBlue,strokeWidth:3,name:"$\\overline{U}$"});
var g2 = board.create('functiongraph',
[function(x){ return f(x);}, 0, 10],{strokeColor:cadetBlue,strokeWidth:1,dash:2});
var g3 = board.create('functiongraph',//couleur
[function(x){ return f1(x);}, 0, 10],{strokeColor:cadetBlue,strokeWidth:1,dash:2});
var g4 = board.create('functiongraph',//couleur
[function(x){ return f2(x);}, 0, 10],{strokeColor:cadetBlue,strokeWidth:1,dash:2});
board.addChild(board2);
//////////////