﻿//
function toggleDisabled(el, d) {
	try {
		el.disabled = d;
	}
	catch(E){
	}
	if (el.childNodes && el.childNodes.length > 0) {
		for (var x = 0; x < el.childNodes.length; x++) {
			toggleDisabled(el.childNodes[x], d);
		}
	}
}

function showInfo(key, Event) {
    var pce = $find('info');
    if (pce) {
        pce.populate(key);
        var x = 0;
        var y = 0;
        if (Event.pageX || Event.pageY) {
            var c = document.getElementById("container")
            var pageLeft = c.offsetLeft;
            x = Event.pageX - pageLeft;
            y = Event.pageY;
            if (x > 600) x = 600;
            if (y + 140 > window.innerHeight) y -= 140;
        }
        else if (Event.clientX || Event.clientY) {
            x = Event.clientX + document.body.scrollLeft - document.getElementById("container").offsetLeft;
            y = Event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
            if (x > 600) x = 600;
            if (y + 140 > window.innerHeight) y -= 140;
        }
        pce._popupBehavior.set_x(x + 10);
        pce._popupBehavior.set_y(y + 10);
        pce._popupBehavior.show();
    }
}

function hideInfo() {
    //setTimeout(function(){$find('info').hidePopup();}, 100);
    $find('info').hidePopup();
}
function digit_grouping(nStr){
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}