//p1 => init pos in data array //p2 => end pos... function news(p1, p2) { j = 1; //count steps coefStepY_news = (max_[0] - min_[0]) / chart_height; for( var i = p1; i < p2; i++ ) { if ( data_news[i] ) //if we have news in current date { //if for current date NO quotations (no dot is drawn on the curve) if ( !data_close_0[i] ) { j++; continue; } //create var new_div = document.createElement("div"); //set class (css) new_div.className ="news"; //add in document (or in a element) document.getElementById('priceGraph').appendChild(new_div); //set pos var pos = stepX * j - stepX - 5; //5 => half of triangle image stepY_news = (max_[0] - data_close_0[i]) / coefStepY_news - 20 ;//10px above the point new_div.style.left = pos + 'px'; new_div.style.top = stepY_news + 'px'; //set id => equal to pos in data_news array !!! new_div.id = i; //append functions new_div.onclick = function(){ parent.location.href = 'http://www.webdisclosure.com/actualite.html?id=' + data_news[ this.id ][1] ; }; new_div.onmouseover = function() { //alert ( (this.style.left).replace('px','') ); if ( eval( (this.style.left).replace('px','') ) > (chart_width / 2) ){ var l_ = eval( (this.style.left).replace('px','') ) - 100 - 10; //100 => width of news div } else { var l_ = eval( (this.style.left).replace('px','') ) + 20; } document.getElementById('news_info').style.left = l_ + 'px'; document.getElementById('news_info').style.top = 25 + 'px'; document.getElementById('news_info_txt').innerHTML = date_eu(data_date[ this.id]) + '
' + data_news[ this.id ][0]; document.getElementById('precCell').style.visibility = 'hidden'; document.getElementById('news_info').style.visibility = 'visible'; }; new_div.onmouseout = function() { document.getElementById('news_info').style.visibility = 'hidden'; document.getElementById('precCell').style.visibility = 'visible'; }; } j++; } }