var ns = (document.layers)? true:false;
var ie = (document.all)? true:false;
var doc = (ie)? document.all : document;

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// var verticalpos="fromtop";
var verticalpos="frombott";
function JSFX_FloatTopDiv() {
    var startX = 205;   // X
        startY = 350;  // from bottom
    var ns = (navigator.appName.indexOf("Netscape") != -1);
    var d = document;
    function ml(id) {
       //  var el=document.getElementById ? document.getElementById(id) : document.all ? document.all[id] : document.layers[id];
       	var el=MM_findObj(id);
	    if(document.layers) el.style=el;
		el.sP=function(x,y){this.style.left=x;this.style.top=y;};
        el.x = startX;
        if (verticalpos=="fromtop")
        	el.y = startY;
        else{
        	el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
        	el.y -= startY;
        }
        return el;
    }
    window.stayTopLeft=function() {
        if (verticalpos=="fromtop"){
        	var pY = ns ? pageYOffset : document.body.scrollTop;
        	ftlObj.y += (pY + startY - ftlObj.y)/8;
        } else {
        	var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
			ftlObj.y += (pY - startY - ftlObj.y)/8;
        }
		var pp = (ftlObj.y < startY) ? 280 : ftlObj.y;
		ftlObj.sP(ftlObj.x, pp);
        setTimeout("stayTopLeft()", 15);
    }
    ftlObj = ml("toolbar");
    stayTopLeft();
}

function toolbox_show(component1, component2) {
	search_box_init(component2);
	var obj=MM_findObj(component1);
	var obj2=MM_findObj(component2);
	if (obj.style.display =="none") {
	  obj.style.display = "block";
	  obj2.focus();
	} else {
	  obj.style.display = "none";
	}
}
function search_box_init(component) {
	var obj=MM_findObj(component);
	obj.value="";
}
function table_on(what, hide) {
 var obj=document.getElementById(what); 
 var obj2=document.getElementById(hide); 
 obj.style.top = 50+document.body.scrollTop;
 obj.className='table_on';
 if(obj2) obj2.className='table_off';
}
function table_off(what, hide) {
 var obj=document.getElementById(what); 
 var obj2=document.getElementById(hide); 
 obj.className='table_off';
  if(obj2) obj2.className='table_on';
}
function Clickheretoprint(what, align__, lang) {
	var align_ = "";
 if(align__) {
	align_ = align__;
 } else {
	align_ = 'left';
 }
 
 var pechat = "";
 if (lang) 	
 	{ 
		if (lang=='ru')
			{
				pechat = "Ýòîò äîêóìåíò ÿâëÿåòñÿ  ÷àñòüþ âåá – ñàéòà ÅÐÀÒÎ ÕÎËÄÈÍÃ www.erato.bg"; 
			}
		else 
			{
				pechat = "This document is a part from the website of ERATO HOLDING www.erato.bg";
			}
	}
 else 
 	{ 
		pechat = "Òîçè äîêóìåíò å ÷àñò îò óåá-ñàéòà íà ÅÐÀÒÎ ÕÎËÄÈÍÃ  www.erato.bg"; 
	}

		var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
		    disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25, resizable=yes"; 
		var content_value = document.getElementById(what).innerHTML; 
		
		var docprint=window.open("","",disp_setting); 
			docprint.document.open(); 
			docprint.document.write('<html><head><title>Inel Power System</title>'); 
			docprint.document.write('<style type="text/css">.bold {font-weight: 800}; body,tr,td {font-family:Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size:11px; color:#3b3b3b;}</style>');
			

			docprint.document.write('</head><body onLoad="self.print()" style="font-face: Arial, Helvetica, sans-serif; font-size: 11pt"><center>');
			docprint.document.write('<div align="'+align_+'">'+content_value+'</div>');    
			docprint.document.write('<p align="left"><b>'+pechat+'<b></p>');          
			docprint.document.write('</center></body></html>'); 
			docprint.document.close(); 
			docprint.focus(); 
}
var ie=document.all;
var nn6=document.getElementById&&!document.all;
var isdrag=false;
var x,y;
var dobj;

var DragHandler = {


	// private property.
	_oElem : null,


	// public method. Attach drag handler to an element.
	attach : function(oElem) {
		oElem.onmousedown = DragHandler._dragBegin;

		// callbacks
		oElem.dragBegin = new Function();
		oElem.drag = new Function();
		oElem.dragEnd = new Function();

		return oElem;
	},


	// private method. Begin drag process.
	_dragBegin : function(e) {
		var oElem = DragHandler._oElem = this;

		if (isNaN(parseInt(oElem.style.left))) { oElem.style.left = '0px'; }
		if (isNaN(parseInt(oElem.style.top))) { oElem.style.top = '0px'; }

		var x = parseInt(oElem.style.left);
		var y = parseInt(oElem.style.top);

		e = e ? e : window.event;
		oElem.mouseX = e.clientX;
		oElem.mouseY = e.clientY;

		oElem.dragBegin(oElem, x, y);

		document.onmousemove = DragHandler._drag;
		document.onmouseup = DragHandler._dragEnd;
		return false;
	},


	// private method. Drag (move) element.
	_drag : function(e) {
		var oElem = DragHandler._oElem;

		var x = parseInt(oElem.style.left);
		var y = parseInt(oElem.style.top);

		e = e ? e : window.event;
		oElem.style.left = x + (e.clientX - oElem.mouseX) + 'px';
		oElem.style.top = y + (e.clientY - oElem.mouseY) + 'px';

		oElem.mouseX = e.clientX;
		oElem.mouseY = e.clientY;

		oElem.drag(oElem, x, y);

		return false;
	},


	// private method. Stop drag process.
	_dragEnd : function() {
		var oElem = DragHandler._oElem;

		var x = parseInt(oElem.style.left);
		var y = parseInt(oElem.style.top);

		oElem.dragEnd(oElem, x, y);

		document.onmousemove = null;
		document.onmouseup = null;
		DragHandler._oElem = null;
	}

}

function getVars(varName) {
	var _srch = window.location.search.substr(1);
	var _vars = _srch.split("&");
	for (var k = 0; k < _vars.length; k++) {
		var _v = _vars[k].split("=");
		if (_v[0] == varName) {
			return _v[1];
			break;
		}
	}
	return "NONE";
}
function check(form_,pole_)  {
 var obj=document.getElementById(form_); 
 var obj2=document.getElementById(pole_); 
    if (obj2.value!="") obj.submit();	
}	



function sh_div(what) {
	 var i=0;
	 var coll = [];
	 while (document.getElementById('d'+ i)) {
	  coll[i] = document.getElementById('d'+ i);
		i++;
	 }
 obj = document.getElementById(what);
 var i=0;
 if (obj.className == 'off') {
	 while (coll[i]) {
		coll[i].className = 'off';
		i++;
		} 
	obj.className = 'on';
 } else {
	obj.className = 'off';
 }
}
