/**
* This file is the key in establishing a functional basis of services.
* Due to its links are converted into asynchronous request calls.
* This class (cAjax) is responsible for all types and sizes of charts plotting.
*
* @author Viachaslau Lyskouski
* @copyright Copyright (c) 2012 Interactive Data Managed Solutions Ltd.
*/
/**
* Function extends the base class "document" to searching items by class name
*/
document.getElementsByClassName = function(cl) {
var retnode = [];
var myclass = new RegExp('\\b'+cl+'\\b');
var elem = this.getElementsByTagName('*');
for(var i = 0; i < elem.length; i++) {
var classes = elem[i].className;
if(myclass.test(classes))
retnode.push(elem[i]);
}
return retnode;
};
/**
* Function that formats number
*
* @param number c - the number of decimal points
* @param string d - the separator for the decimal point
* @param string t - the thousands separator
* @return string - The function returns a formatted version of number
*/
Number.prototype.formatMoney = function(c, d, t){
var n = this,
s = n < 0 ? "-" : "",
i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
j = (j = i.length) > 3 ? j % 3 : 0;
c = isNaN(c = Math.abs(c)) ? 2 : c;
d = d === undefined ? "," : d;
t = t === undefined ? "." : t;
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};
/**
* Function that collapse/expand content
*
* @param string clip - the selector of the content
* @param string icon - the selector of the image
* @return void
*/
function toggleBody(clip, icon) {
var tbody = $(clip);
var img = $(icon);
if (tbody.css('display') == 'none') {
tbody.show();
$(icon).attr('src','images/nzz_collapse.gif');
if (navigator.userAgent.indexOf("MSIE")==-1)
tbody.css('display') = 'table-row-group';
else
tbody.css('display') = 'block';
} else {
tbody.hide();
$(icon).attr('src','images/nzz_expand.gif');
tbody.css('display') = 'none';
}
}
/**
* Function prepares the numbers in accordance with the special format:
* N.NNNN, NNNN, NN'NNN
*
* @param number val - the specified number
* @param number sz - the number of decimal points
* @return string - the function returns a formatted version of number
*/
function fFloat(val, sz){
if(val == undefined)
return 0;
try{var i = val.split("'").join('').split(',').join('.');val = i;}
catch(e){}
sz = sz || 1;
sz = Math.pow(10, sz);
val = Math.round(val*sz)/sz;
return val != NaN ? val : 0;
}
/**
* Statistical function
*
*/
function NETMX(){
//var trackingPath = parent.location.pathname;
//if (trackingPath) {
//trackingPath = document.referrer;
//if (trackingPath) {
// trackingPath = trackingPath.replace(/http:\/\/[\w\.]*/gi, "");
//} else {
trackingPath = "/finanzen/charts";
//}
//}
var sNETMX="http://nzz.wemfbox.ch/cgi-bin/ivw/CP/nzzonline" + trackingPath;
$('#metrix').append("");
}
/**
* Class implementation with different modules for navigation and style formation.
* oAjax = new cAjax();
* It sets the values of environment variables to default states
*
* @param boolean vInit - the option for initialization function cAjax.init(), defalt - true
* @return void
*/
function cAjax(vInit){
if(vInit == undefined)
vInit = true;
this.ini_type = '';
this.o;
this.bRedirect = true;
this.vScrollStep = 21;
this.vScrollHeight = 100;
this.bScroll = false;
this.vToScroll = '';
this.gScrollIni = false;
if(vInit)
this.init();
if($('.segel').length)
this.showTooltip();
}
/**
* Function from cAjax class for buttons formation (conversion links into buttons with asynchronous requests)
*
* @param string cType - the class name of block with links for menu navigation
*/
cAjax.prototype.init = function(cType){
cType = cType || '.menu';
// links reconfiguring
var obj = $(cType+" a");
for(var i in obj)
if(obj[i].href && obj[i].href.indexOf('#') == -1)
obj[i].href="#"+obj[i].href;
// -elements preparing
$(cType+" a").click(function(e) {
NETMX();
if(this.href.indexOf('#') != -1){
// button colorizing
if(this.href.indexOf('notch=hold') == -1){
$(cType+" .notch").remove();
this.innerHTML = '' + this.innerHTML;
}
if(this.innerHTML.indexOf('Kapitalschutz') != -1)
this.className = 'active blue0';
else if(this.innerHTML.indexOf('Renditeoptimierungs') != -1 || this.innerHTML.indexOf('Renditeopt.') != -1)
this.className = 'active green0';
else if(this.innerHTML.indexOf('Partizipation') != -1)
this.className = 'active orange0';
else if(this.innerHTML.indexOf('Hebel') != -1)
this.className = 'active red0';
else
this.className = 'active';
var obj = $(cType+" a");
for(var i in obj)
if(this != obj[i])
obj[i].className = '';
// content loading
// // from hidden div
if(this.href.indexOf('##') != -1){
$('#Content div').css('z-index', '1');
$('#'+this.href.split('##')[1]).css('z-index', '2');
if(this.href.indexOf('/ajax/') != -1 && $('#'+this.href.split('##')[1].replace('pnC', 'idC')).html().length < 60){
$('#'+this.href.split('##')[1].replace('pnC', 'idC')).html('