// JavaScript Document
function submit_query(formName, actionName, actionValue) {
	var form_obj = eval("document."+formName);
	eval("window.document."+formName+"."+actionName).value = actionValue;
	return true;
}
function submit_query_prompt(formName, actionName, actionValue, msg) {
	if ((msg != "") && (!window.confirm(msg))) {
		return false;
	}
	return submit_query(formName, actionName, actionValue);
}
function clearInput(formName, inputName) {
	eval("document."+formName+"."+inputName).value = '';
}

function toggleDiv(id){
	obj = document.getElementById(id);
	tmp = obj.style.display;
	if (tmp == 'none') obj.style.display='block';
	else obj.style.display='none';
}

function showhide(arr) {
	if (arr.length > 0) {
		for (var i=0; i<arr.length; i++) {
			toggleDiv(arr[i]);
		}
	}
}
function init() {
//	alert(obj.onload);
}

function enterpriseClick(n) {
//	_manufactur = n

	// Пересчитываем
//	calculate()
}
function responsibilityClick(n) {

	// Пересчитываем
//	calculate()
}

function hideNote()
{
var div = document.getElementById('current_footnote');
div.className = 'footnote_new';
div.style.display = 'none';
return false;
}

function getElementPosition(offsetTrail)
{
var offsetLeft = 0;
var offsetTop = 0;
while(offsetTrail) {
offsetLeft += offsetTrail.offsetLeft;
offsetTop += offsetTrail.offsetTop;
offsetTrail = offsetTrail.offsetParent;
}
return { left:offsetLeft, top:offsetTop }
}


function showNote(img, id, img_src)
{
	var note = document.getElementById(id);
	var div = document.getElementById('current_footnote');
	var o = document.getElementById(img);
	var coords = getElementPosition(o); 
	div.innerHTML = '<a href="#" onclick="return hideNote()"><img src="'+img_src+'" height="13" width="13" border="0" id="x_image" /></a><div style="float: right; width: 17px; height: 17px"></div><div style="padding: 7px">' + note.innerHTML + '</div>';
	div.className = 'footnote_new_active';
	div.style.top = (coords.top + o.offsetHeight) + 'px';
	div.style.left = coords.left + 'px';
	div.style.display = 'none';
	div.style.display = 'block';
	return false;
}

function ttt(evt) {

	alert(evt.clientX+' : '+evt.clientY+"\n"+window.scrollX+" : "+window.scrollY);
}


function delAdvert(id){
		elem1 = document.getElementById('notepad_tbody');
		elem = document.getElementById(id);
		elem1.removeChild(elem);
}

function number_format( number, decimals, dec_point, thousands_sep ) {  
	// Format a number with grouped thousands
    //
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://crestidg.com)
 
    var i, j, kw, kd, km, minus = "";
    
    number = number.replace(",", ".");
    
    if(number < 0){
		minus = "-";
		number = number*-1;
	}
 
    // input sanitation & defaults
    if( isNaN(decimals = Math.abs(decimals)) ){
        decimals = 2;
    }
    if( dec_point == undefined ){
        dec_point = ",";
    }
    if( thousands_sep == undefined ){
        thousands_sep = ".";
    }
 
    
    
    i = parseInt(number = (+number || 0).toFixed(decimals)) + "";
    
 
    if( (j = i.length) > 3 ){
        j = j % 3;
    } else{
        j = 0;
    }
 
    km = (j ? i.substr(0, j) + thousands_sep : "");
    kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep);
    //kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).slice(2) : "");
    kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : "");
 
 
    return minus + km + kw + kd;
}
