//---------------------------------------
function lenthtextarea(obj, maxsymbol,idkiek){
	var textt;
  	eil = maxsymbol - obj.value.length; 	
  	if (eil < 1 ){   
		textt = obj.value.substr(0,maxsymbol);  
		obj.value =  textt;    
		if (eil <= 0) eil = 0 ; 
   	} 
//document.form.aprashviso.value = eil; 
	document.getElementById(idkiek).value = eil; 
}
  
function chclass(thisid,trclass,paaisk){
	document.getElementById(thisid).className = trclass ;
	
}
function divValue(paaisk){
	
		document.getElementById("paiskinimas").childNodes[0].nodeValue = paaisk;
	
}

function chclass2(thisid,toclass,thisid2,toclass2){
	document.getElementById(thisid).className = toclass ;
	document.getElementById(thisid2).className = toclass2 ;
}

function diplaynone(chboxid,divid){
	var chvalu = document.getElementById(chboxid).checked;
	
	if(document.getElementById(chboxid).checked){
		document.getElementById(divid).style.display="inline";
	}else{
		document.getElementById(divid).style.display="none";
	}

}

var preload=new Image();
preload.src="noras1_failai/present.gif";

function movepic(img_name,img_src) {
document[img_name].src=img_src;
}




function showtime () {
	var now = new Date();
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds()
	var timeValue = hours;
	timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
	timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
	document.getElementById("laikrodis").childNodes[0].nodeValue = timeValue;
	timerID = setTimeout("showtime()",1000);
	timerRunning = true;
}


function checkboxALL(sel) {
    var chbox = document.getElementsByTagName( 'input' );
    //document.getElementById("status").childNodes[0].nodeValue = chbox.length;
    for ( var i = 0; i < chbox.length; i++ ) {
        if ( chbox[i].type == 'checkbox' ) {
            chbox[i].checked = sel;
        }
    } 

    return true;
}

function chclass(thisid,trclass){
	document.getElementById(thisid).className = trclass ;
}

function tourl(url){
	window.location.href=url;
}

function newwin(url,langas){
	a = window.open("", langas);
 	a.location.href  =  url ; 	
}


function createXmlHttpRequestObject() {
	var xmlHttp;
	try
	{
		xmlHttp = new XMLHttpRequest();
	}
	catch(e)
	{
		var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
		"MSXML2.XMLHTTP.5.0",
		"MSXML2.XMLHTTP.4.0",
		"MSXML2.XMLHTTP.3.0",
		"MSXML2.XMLHTTP",
		"Microsoft.XMLHTTP");
		for(var i= 0; i <XmlHttpVersions.length && !xmlHttp; i++){
			try
			{
				xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
			}
			catch(e){}
		}
	}
	
	if(!xmlHttp)
	alert("error creating the XMLHttpRequest object.");
	else 
	return xmlHttp;

}



var objSTR = createXmlHttpRequestObject();
var objbody = new  Object();


function ajax(body,ind,i) {

	   objbody.id = body;
	   
	  // document.getElementById( objSTR.bodyid ).innerHTML = 'kraunasi...';	
        objSTR.open('get', '/ls.php?ajax=' + ind + i); 
        
        objSTR.onreadystatechange = function() {
			if (objSTR.readyState == 4) {
				var strHTML = objSTR.responseText;
				if( objSTR.bodyid =='first' ){
					document.getElementsByTagName('body')[0].innerHTML = strHTML;
				}else{
					document.getElementById( objbody.id ).innerHTML = strHTML;
					
					//document.getElementById( objbody.id ).childNodes[0].nodeValue = strHTML;
				}
				//alert('ok');
			}else{
				//document.getElementById( objSTR.bodyid ).innerHTML = objSTR.readyState;
				
				//alert('error');
			}
		}
        objSTR.send(null);
        
}

	function show_foto(url_foto,titl){
			var urlf  = escape(url_foto);
			//var ttile = escape(titl);
		window.open( 'http://www.krantai.lt/show.php?furl='+urlf+'&titl='+titl ,'image','width=800,height=600,scrollbars=no,toolbar=no,location=no,status=no,resizable=yes,screenX=120,screenY=100');
	
	}
	
	
		 
	function validRegEx2(regepr,inputid){
if (regepr=="asmkodas"  ){ ereg = "^[1234567890]{11}";  }
else if (regepr=="vardas"  ){ ereg = "^([ąčęėįšųūžĄČĘĖĮŠŲŪŽA-Za-z']|[[:alpha:]])+$";  }
else if (regepr=="tel"  ){ ereg = "^[+1234567890](([- ]?)([1234567890]{1,}))+[1234567890]$";  }
else if (regepr=="file_name"  ){ ereg = "^([a-z]+([a-z_]*[.]?[a-z_]+)*)$";  }
else if (regepr=="login"  ){ ereg = "^[a-z_A-Z0-9-]{4,}$";  }
else if (regepr=="skaicius"  ){ ereg = "^[1234567890]+[.,]?[1234567890]*$";  }
else if (regepr=="int"  ){ ereg = "^[0-9]+$";  }
else if (regepr=="url"  ){ ereg = "^(http://|https://)[a-zA-Z0-9\.\-_]+\\.[a-zA-Z0-9]{2,4}(/[^ /]*)*$";  }
else if (regepr=="icq"  ){ ereg = "^[0-9]{5,}$";  }
else if (regepr=="ip"  ){ ereg = "[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}";  }
else if (regepr=="passwd"  ){ ereg = "^[a-zA-Z0-9_-]{6,}$";  }
else if (regepr=="email"  ){ ereg = "^[a-zA-Z0-9_\-]+(([\.]?)([a-zA-Z0-9_-]))+@[a-zA-Z0-9]+(([\.])?([a-zA-Z0-9][a-zA-Z0-9_-])?([a-zA-Z0-9])+)+\\.[a-zA-Z]{2,4}$";  }
else{ ereg = regepr;  }
		
	re = new RegExp(ereg);
	if (!re.test( document.getElementById(inputid).value )){ 
		document.getElementById(inputid).style.background = '#FFB7B7'; 
		tf = false;
	}else{
		document.getElementById(inputid).style.background = '#ffffff';
		tf = true;
	}
	if (document.getElementById(inputid).value == ""){ 
		document.getElementById(inputid).style.background = '#ffffff'; 
		tf = true;
	}
	return tf;
}
