    var time_sleep = 300; 	
	var iswebmaster = false ;
			
	function getXmlHttpRequestObject() {
		if (window.XMLHttpRequest) {
			return new XMLHttpRequest(); //Not IE
		} else if(window.ActiveXObject) {
			return new ActiveXObject("Microsoft.XMLHTTP"); //IE
		} else {
			alert("Your browser doesn't support the XmlHttpRequest object.  Better upgrade to Firefox.");
		}
		return false;
	}	
					
	var receiveReq = getXmlHttpRequestObject();		

	function sendGet(body,actions){
		if ( receiveReq.readyState == 4 || receiveReq.readyState == 0 ) {
			objbody.id=body;
			var parameters = 'bid='+objbody.bid+'&'+objbody.sname+'='+objbody.sid+'&act='+actions;
			receiveReq.open("GET", 'common.php?'+parameters, true);
			receiveReq.onreadystatechange = handleSendReq; 
			receiveReq.send(null);
		}else{
			setTimeout("sendGET('"+body+"','"+actions+"')", time_sleep);
		}
	}

	function sendPost(body,actions,refr){
		refr = typeof(refr) != 'undefined' ? refr : false ;
		if ( receiveReq.readyState == 4 || receiveReq.readyState == 0 ) {
		
				objbody.id=body;
				objbody.refr=refr;
				
				if(document.body){
					//document.body.style.cursor='wait';
				}
				if( document.getElementById(objbody.id) ){
					//document.getElementById(objbody.id).style.cursor='wait';
				}
				var parameters = 'bid='+objbody.bid+'&'+objbody.sname+'='+objbody.sid+'&act='+actions;
				loadingas(1);
if(iswebmaster)alert(parameters);
				receiveReq.open("POST", 'common.php', true);
				receiveReq.onreadystatechange = handleSendReq; 
				//receiveReq.setRequestHeader("Content-Charset", "windows-1257");
				receiveReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				receiveReq.setRequestHeader("Content-length", parameters.length);
				//receiveReq.setRequestHeader("Content-Language", "lt");
				//receiveReq.setRequestHeader("Connection", "close");
				//receiveReq.setRequestHeader("Cache-Control", "no-cache");
				receiveReq.send(parameters);
		}else{
		//alert(receiveReq.readyState);
				setTimeout("sendPost('"+body+"','"+actions+"')", time_sleep);
		}
	}


	
	function handleSendReq() {
		if(receiveReq){
			if (receiveReq.readyState == 4) {
if(iswebmaster)alert(receiveReq.responseText);
				if( eregas( 'offLine 321' , receiveReq.responseText ) ){
					echo0ffline(0);
//alert('as off');
				}else{
					if( receiveReq.responseText == '' ){
						document.getElementById(objbody.id).innerHTML = '&nbsp;';
					}else{
						if( objbody.id=='split' ){
							
							var my_list=receiveReq.responseText;

							var my_array=my_list.split("!1");
							
							for(var ii=0; ii<my_array.length; ii++){
								var myecho = my_array[ii].split("!2") ;
								if( document.getElementById( trim(myecho[0]) ) ){
									var tra = document.getElementById( trim(myecho[0]) ) ;
									tra.innerHTML = trim(myecho[1]);
								}
								//alert( trim(myecho[0])+' '+myecho[1] );
							}
									
						}else if( document.getElementById(objbody.id) ){
						
							document.getElementById(objbody.id).innerHTML = receiveReq.responseText;
						}
						
						
						if( eregas( '<!--<script>' , receiveReq.responseText ) ){
							var arrcomm = receiveReq.responseText.split("<!--<script>");
	//alert(arrcomm.length);
							
								for(var k in arrcomm){
									if( eregas( '</script>-->' , arrcomm[k] ) ){
										var arrscr = arrcomm[k].split("</script>-->");
										if(arrscr.length==2){
											eval(arrscr[0]);
										}
									}
								}
						}
						
					}
					
					
					
					if( objbody.refr ){
						eval(objbody.refr);
					}
					objbody.refr = false;
				}
				loadingas(0);
				if(document.body){
					//document.body.style.cursor='auto';
				}
				if( document.getElementById(objbody.id) ){
					//document.getElementById(objbody.id).style.cursor='auto';
				}
				
				
				
			//receiveReq.abort();
			}else{
				//document.getElementById(objbody.id).innerHTML = receiveReq.readyState +' '+objbody.id;
			}
		}
	}
	
//---------------------------------- istrinti duomenis is db ir tegus ----------------
	function removeData(actions,confirms){
		var agree=confirm(confirms);
		if (agree){
			//document.getElementById(body).innerHTML = image_wait_middle;
			YESsendPOSTremoveNode(actions);
		}else{
			
		}
	}
	
	

	function sendPostConfirm(body,actions,confirms){
		var agree=confirm(confirms);
		if (agree){
			//document.getElementById(body).innerHTML = image_wait_middle;
			sendPost( body, actions);
		}else{
			
		}
		return false;
	}
	function postSubmitConfirm(forma,bodyId, actions,confirms){
		var agree=confirm(confirms);
		if (agree){
			postSubmit(forma,bodyId, actions );	
		}
		return false;
	}
	
	
	function removeDataSendPost(body,actions,confirms){ // pasenes, sinonimas
		sendPostConfirm(body,actions,confirms) ;
		return false;
	}
	
	
	function YESsendPOSTremoveNode(actions){
		if ( receiveReq.readyState == 4 || receiveReq.readyState == 0 ) {
			//objbody.id=body;
			var parameters = 'bid='+objbody.bid+'&'+objbody.sname+'='+objbody.sid+'&act='+actions;
			receiveReq.open("POST", 'common.php', true);
			receiveReq.onreadystatechange = YESsendPOSTremoveNodeReq; 
			receiveReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			receiveReq.setRequestHeader("Content-length", parameters.length);
			//receiveReq.setRequestHeader("Connection", "close");
			//receiveReq.setRequestHeader("Cache-Control", "no-cache");
			receiveReq.send(parameters);
		}else{
			setTimeout("YESsendPOSTremoveNode('"+actions+"')", time_sleep);
		}
	}
	
	function YESsendPOSTremoveNodeReq() {
		if(receiveReq){
			if (receiveReq.readyState == 4) {
//alert(receiveReq.responseText);
				if(receiveReq.responseText == 'offline'){
					echo0ffline(0);
				}else{	
					if( receiveReq.responseText == '' ){
						//document.getElementById(objbody.id).innerHTML = '&nbsp;';
					}else{

						var my_list=receiveReq.responseText;

						var my_array=my_list.split("|");
						for(var ii=0; ii<my_array.length; ii++){
//alert(my_array[ii]);
							if( document.getElementById(my_array[ii]) ){
								var tra = document.getElementById(my_array[ii]);
								var d = tra.parentNode;
								d.removeChild(tra);
							}
						}	

					}
				}
			//receiveReq.abort();
			}else{
				//document.getElementById(objbody.id).innerHTML = receiveReq.readyState +' '+objbody.id;
			}
		}
	}
//---------------------------- / ----------------------

function creatWindows(idname,titl,w,h,t,l,incid){
	w = typeof(w) != 'undefined' ? w : 500;
	h = typeof(h) != 'undefined' ? h : 0;
	t = typeof(t) != 'undefined' ? t : 50;
	l = typeof(l) != 'undefined' ? l : 50;
	incid = typeof(incid) != 'undefined' ? incid : '';
	
	var winfname = 'winform'+idname ;
	
	if( document.getElementById(winfname) ){
		deleteNode( document.getElementById(winfname) );
	}
		var dinc = document.createElement('div');
			dinc.setAttribute('id',winfname);
			dinc.style.position = 'absolute';
			dinc.style.zIndex = 10;
			dinc.style.width = w;
			if(h>0) dinc.style.height = h;
			dinc.style.top = t;
			dinc.style.left = l;
			dinc.style.background = '#FFFFFF';
			//dinc.style.border = '0px solid #CCCCCC';
			//dinc.style.padding = "2px";
			dinc.onmousedown=function(){
				toTop(winfname);
			}
		var dinc1 = document.createElement('div');
			dinc1.style.background = '#FFFFFF';
			dinc.style.border = '1px solid #CCCCCC';
			dinc.style.margin = "5px";
			dinc1.onmousedown=function(){
				toTop(winfname);
			}
			dinc.appendChild(dinc1);
				
		var heads = document.createElement('div');
			heads.onmousedown = function (ev){
				if(dragObject != dinc){
					dragObject = dinc;
					mouseOffset = getMouseOffset( dragObject, ev );
					//toTop(winfname);
				}
			}
			
			
			heads.style.background = '#56BDEA';
			
			dinc1.appendChild(heads);
			heads.style.cursor = "move";
			
		var tit = document.createElement('div');
			tit.innerHTML  = '<div>'+titl+'</div>' ;
			tit.style.width = w-20;
			tit.className = 'winHeadTitle';
			heads.appendChild(tit);
			tit.onmousedown = function (ev){
				if(dragObject != dinc){
					dragObject = dinc;
					mouseOffset = getMouseOffset( dragObject, ev );
					//toTop(winfname);
				}
			}
		var titclos = document.createElement('div');
			titclos.innerHTML  = '<div>X</div>' ;
			titclos.className = 'winHeadClose';
			titclos.onclick = function(){
					deleteNode(dinc);
				}
			heads.appendChild(titclos);
			
		var cclertit = document.createElement('div');
			cclertit.innerHTML  = '&nbsp;' ;
			cclertit.style.fontSize = "0";
			cclertit.style.clear = "both";
			heads.appendChild(cclertit);
				
				
			//heads.style.margin = "5px";

		var incbody = document.createElement('div');
			incbody.setAttribute('id',idname);
			incbody.style.padding = '5px';
			incbody.style.width = '100%';
			dinc1.appendChild(incbody);	
		
			if( incid!='' && document.getElementById(incid) ){
				document.getElementById(incid).appendChild(dinc);
			}else{
				document.getElementsByTagName("body")[0].appendChild(dinc);
			}
		incbody.innerHTML = '<div style="padding:10px;">Kraunasi...<br /><br /><br /><br /><br /><br /><br /></div>';
		
		toTop(winfname);
	
	return idname ;
}

//------------------------------ forma -------------------------------
 	function get(forma) {
 	
 	if( document.getElementById(forma) ){
  		var obj = document.getElementById(forma).getElementsByTagName('INPUT'); //getElementsByTagName
		var getstr = '' ;
			
			for (var i=0; i<obj.length; i++) {
///alert(obj[i].type);
					if ((obj[i].type == "text" && obj[i].getAttribute("disabled") != "disabled" ) || obj[i].type == "hidden" || obj[i].type == "submit" || obj[i].type == "password") {
							getstr += obj[i].name + "=" + htmlentities(obj[i].value) + "&";
					}
					
					if (obj[i].type == "checkbox") {
						if (obj[i].checked) {
							getstr += obj[i].name + "=" + obj[i].value + "&";
						} else {
							getstr += obj[i].name + "=&";
						}
					}
					if (obj[i].type == "radio") {
						if (obj[i].checked) {
							getstr += obj[i].name + "=" + obj[i].value + "&";
						}
					}

			}
		var obj_textarea = document.getElementById(forma).getElementsByTagName('textarea'); //getElementsByTagName	

			for(var it=0; it<obj_textarea.length; it++){
				getstr += obj_textarea[it].name + "=" + htmlentities(obj_textarea[it].value) + "&";
			}
			
			var objSel = document.getElementById(forma).getElementsByTagName('SELECT');
			for (var ise=0; ise<objSel.length; ise++){
			
				var sel = objSel[ise];
				if(sel.options.length>0){
					getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
				}
			}
		return getstr;
		}else{
			alert('nerastas formos objektas '+forma);
		}
		return false;
   	}
	
	
function postSubmit(forma,bodyId, actions ){
//alert(bodyId);
		var formdata = '';
		formdata = get( forma ) ;
		//document.getElementById(bodyId).innerHTML = wait_middle;
		
		sendPost(bodyId,''+actions+'&'+formdata);
		
}
//----------- ajax.js -------------------
function loadingas(i){
	if( i == 1 ){
		var theNew = document.createElement('div');
		with(theNew){
			setAttribute('id','divloading');
			setAttribute('align','center');
			style.backgroundColor = '#F0FFAD';
			style.color = '#CC0001';
			style.zIndex = 10111;
			style.position = 'absolute';
			style.width = 189;
			style.height = 40;
			innerHTML = '<br />  Įkeliama...  ';
		}
	
		var sclLeft =  document.body.scrollLeft ; // scroll patraukimo atstumas
		var sclTop =  document.body.scrollTop ;
		var WinHeight =  document.body.clientHeight ; // matoma body dalis
		var WinWidth =   document.body.clientWidth ;
	
		var kurLEFT = WinWidth / 2 + sclLeft - 100 ;
		//var kurLEFT = WinWidth - 189-6 ;
		var kurTOP =  sclTop ;
		theNew.style.left = kurLEFT;
		theNew.style.top = kurTOP;
	
		document.getElementsByTagName("body")[0].appendChild(theNew);
	}else if(i == 0){
		if( document.getElementById('divloading') ){
			deleteNode( document.getElementById('divloading') );
		}
	}
		return false;
}
//------------- / -------------------------------	
function getValue(str,id,types){
	types = typeof(types) != 'undefined' ? types : '';
	if( document.getElementById(id) ){
	var values ;
	if(types=='int'){
		values = parseInt(document.getElementById(id).value);
	}else if(types=='float' ){
		values = parseFloat(document.getElementById(id).value);
	}else{
		values = document.getElementById(id).value ;
	}
		return str+""+ values ;
	}
	return '';
}
	
	
//----------------------------------- / forma ------------------------------------------
		
function postSubmitEnter( e, forma, bodyId, actions ){
    var key=e.keyCode || e.which;
    if (key==13){
    		postSubmit(forma,bodyId, actions );	
      //alert('ascii');
    }
}	


function htmlentities(str) {

    return str.replace('+','%2B');
}

function strip_tags($text){
 return $text.replace(/<\/?[^>]+>/gi, '');
}

function toTop(topx){
	topx = typeof(topx) != 'undefined' ? topx : 0;
	document.body.scrollTop = topx;
}
	
 function insertAfter( referenceNode, newNode ) {
    referenceNode.parentNode.insertBefore( newNode, referenceNode.nextSibling );
}

function deleteNode2( obj, obj2 ){
	var id = obj.getAttribute('id');
	var id2 = obj2.getAttribute('id');
	var seceff = 100;
	var seceff2 = 100;
	if( 	obj.style.opacity ){
	 	seceff = obj.style.opacity*100;
	 }else if(obj.style.MozOpacity) {
		 seceff = obj.style.opacity*100;
	 }
	 if( 	obj2.style.opacity ){
	 	seceff2 = obj2.style.opacity*100;
	 }else if(obj2.style.MozOpacity) {
		 seceff2 = obj2.style.opacity*100;
	 }
	  obj.seceff= seceff ;
	  obj2.seceff= seceff2 ;
	 
	 var perKiekLaiko = 200;
	 var intervalas = 50;
	 if( seceff2 < seceff ){
	 	perKiekLaiko = perKiekLaiko / 100 * seceff2 ;
	 }else{
	 	perKiekLaiko = perKiekLaiko / 100 * seceff ;
	 }

	 
	 var pominus =  100 / ( perKiekLaiko / intervalas )  ;
	
	setTimeout("effectDeleteNode2( document.getElementById('"+id+"') , document.getElementById('"+id2+"') , "+pominus+" , "+intervalas+"  )" , intervalas );
	return false;
}

function effectDeleteNode2( obj,obj2, pominus , intervalas ){
//alert(' A* '+  obj.seceff +' ** '+ obj2.seceff+' ** '+pominus+' ** '+ intervalas);
	obj.seceff = obj.seceff - pominus ;
	obj.style.opacity = obj.seceff / 100 ;
	obj.style.MozOpacity = obj.seceff / 100 ;
	obj.style.zoom = 1;
	obj.style.filter  = "alpha(opacity="+ obj.seceff +")";
	obj.style.filter='progid:DXImageTransform.Microsoft.Alpha(Opacity=' + obj.seceff + ')';
	
	obj2.seceff = obj2.seceff - pominus ;
	obj2.style.opacity = obj2.seceff / 100 ;
	obj2.style.MozOpacity = obj2.seceff / 100 ;
	obj2.style.zoom = 1;
	obj2.style.filter  = "alpha(opacity="+ obj2.seceff +")";
	//obj.filters.item("DXImageTransform.Microsoft.Alpha").Opacity= 50 ; 
	obj2.style.filter='progid:DXImageTransform.Microsoft.Alpha(Opacity=' + obj2.seceff + ')';
	
	
	
	
	
	
	
	if( obj.seceff > 0 || obj2.seceff > 0  ){
	//alert(' B* '+ obj.seceff +' ** '+ obj2.seceff);
		var id = obj.getAttribute('id');
		var id2 = obj2.getAttribute('id');
		setTimeout("effectDeleteNode2( document.getElementById('"+id+"') , document.getElementById('"+id2+"') , "+pominus+" , "+intervalas+"  )" , intervalas );
	}else{
	//alert(' C* '+ obj.seceff +' ** '+ obj2.seceff);
		deleteNode(obj) ;
		deleteNode(obj2) ;
	}
	return false;
}



function deleteNode(remobj){
	if( remobj ){
		var d = remobj.parentNode;
		if(d) d.removeChild(remobj);
	}
}

function deleteInfoNode( obj ){
	//var ob = obj;
	var id = obj.getAttribute('id');
	 obj.seceff= 100 ;
	 var perKiekLaiko = 500;
	 var intervalas = 20;
	 var pominus =  100 / ( perKiekLaiko / intervalas )  ;
	
	setTimeout("effectDeleteNode( document.getElementById('"+id+"') , "+pominus+" , "+intervalas+"  )" , intervalas );
	}


function effectDeleteNode(obj, pominus , intervalas   ){
	obj.seceff = obj.seceff - pominus ;
	obj.style.opacity = obj.seceff / 100 ;
	obj.style.MozOpacity = obj.seceff / 100 ;
	obj.style.zoom = 1;
	
	obj.style.filter  = "alpha(opacity="+ obj.seceff +")";
	//obj.filters.item("DXImageTransform.Microsoft.Alpha").Opacity= 50 ; 
	obj.style.filter='progid:DXImageTransform.Microsoft.Alpha(Opacity=' + obj.seceff + ')';
	
	//obj.innerHTML = obj.style.opacity ;
	if( obj.seceff > 0 ){
		var id = obj.getAttribute('id');
		setTimeout("effectDeleteNode( document.getElementById('"+id+"'), "+pominus+" , "+intervalas+"  )" , intervalas );
	}else{
		deleteNode(obj) ;
	}
}
	
	
	//-------------------- pilnai uzdengtas langgas ------------------
function wisas(pavad,wi,he){

	pavad = typeof(pavad) != 'undefined' ? pavad : '&nbsp;' ;
	wi = typeof(wi) != 'undefined' ? wi : 1000 ;
	he = typeof(he) != 'undefined' ? he : 0 ;
	
	
	var wisid = 'wisas';
	var langas_wisid = 'win_'+wisid;
	
	var incwsid = 'inc_'+wisid;
	
	
	if(document.getElementById(wisid)){
		removeNode(document.getElementById(wisid));
	}
	var dwisas = document.createElement('div');
		dwisas.setAttribute('id',wisid) ;
		
		
		dwisas.style.width = document.body.scrollWidth ; // clientWidth
		dwisas.style.height = document.body.scrollHeight ;
		
		dwisas.style.backgroundColor = '#DDDDDD';
		dwisas.style.position = 'absolute';
		dwisas.style.zIndex = 1111;
		dwisas.style.top = 0;
		dwisas.style.left = 0;
		
		var  seceff = 85 ;
		
		dwisas.style.opacity = seceff / 100 ;
		dwisas.style.MozOpacity = seceff / 100 ;
		dwisas.style.zoom = 1;
	
		dwisas.style.filter  = "alpha(opacity="+ seceff +")";
	//dwisas.filters.item("DXImageTransform.Microsoft.Alpha").Opacity= 50 ; 
		dwisas.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=' + seceff + ')';
	
		
		
		
		document.getElementsByTagName("body")[0].appendChild(dwisas);
		//dwisas.innerHTML = 'tes-tas';

	if(document.getElementById(incwsid)) removeNode(document.getElementById(incwsid));
	var langaswisid = document.createElement('div');
		langaswisid.setAttribute('id',langas_wisid) ;
		langaswisid.style.width = wi+'px' ;
		langaswisid.style.position = 'absolute';
		langaswisid.style.zIndex = 1115;
		langaswisid.style.top = 20 + document.body.scrollTop;
		var lef = document.body.clientWidth / 2 - (wi/2);
		if(lef<0)lef = 0;
		langaswisid.style.left = lef;
		document.getElementsByTagName("body")[0].appendChild(langaswisid);
		langaswisid.className = 'langas-wisas';
		//langas_wisid.innerHTML = 'as as as as a a as ';
		
		
	var iinc_langas = document.createElement('div'); // css padding:5px
		iinc_langas.className = 'langas-wisas-inc';
		langaswisid.appendChild(iinc_langas); 
		
	var langas_head = document.createElement('div');
		langas_head.className = 'langas-head';
		iinc_langas.appendChild(langas_head);

		//langas_head.innerHTML = 'pavad';	
	
	var langas_head_pavad = document.createElement('div');
		langas_head_pavad.className = 'langas-head-pavad';
		langas_head.appendChild(langas_head_pavad);
		langas_head_pavad.innerHTML = '<div align="left">'+pavad+'</div>' ;
		langas_head_pavad.style.width = (wi-30) + 'px';
		//langas_head_pavad.style.border = '1px solid red';
		
		
		langas_head_pavad.onmousedown = function(){
			incwisas.style.visibility = 'hidden';
			makeDraggable(langaswisid);
		}
		langas_head_pavad.onmouseup = function(){
			incwisas.style.visibility = 'visible';
		}		
		
	var langas_head_close = document.createElement('div');
		langas_head_close.className = 'langas-head-close';
		langas_head.appendChild(langas_head_close);
		langas_head_close.innerHTML = 'X' ;
		langas_head_close.onclick = function(){
			deleteNode2( dwisas , langaswisid );
		}
	
	var langas_head_clear = document.createElement('div');		
		langas_head_clear.style.fontSize = '0px';
		langas_head_clear.style.clear = 'both';
		langas_head_clear.innerHTML = '&nbsp;';
		langas_head.appendChild(langas_head_clear);
			
			
	var incwisas = document.createElement('div');
		incwisas.setAttribute('id',incwsid) ;
		
		
		
		iinc_langas.appendChild(incwisas);
		incwisas.innerHTML = '<br><br><br><br>Kraunasi ...<br><br><br><br><br><br>';	
		
		
		
		
		dwisas.onclick = function(){
			//deleteNode2( this , langas_wisid );
		}
		
	return incwsid;
}
//------------- / -------------------
	
	
	end = true;	
