function keistiLygi() {
	document.getElementById("lygis_select").style.display = 'block';
	document.forma.keisti.disabled = 'disabled';
	document.forma.keista.value = '1';
	document.forma.issaugoti.disabled = false;
	return true;
}
function validateUserEdit() {
	if (document.forma.keista.value == "1") {
		index1 = document.forma.lygisId.selectedIndex;
		if (index1 == 0) {
			alert("Pasirinkite vartotojo lygį");
			return false;
		}
		return true;
	}
	return false;
}
function validateSearch() {
	value = document.paieska.query.value;
	if (value == "") {
		alert("Įveskite paieškos frazę");
		return false;
	}
	return true;
}
function submitSearch() {
	document.paieska.submit();
}
function validate() {
	index1 = document.forma.temosId.selectedIndex;
	if (index1 == 0) {
		alert("Pasirinkite temą");
		return false;
	}
	index2 = document.forma.potemesId.selectedIndex;
	if (index2 == 0) {
		alert("Pasirinkite potemę");
		return false;
	}
	if (document.forma.title.value == "") {
		alert("Įveskite straipsnio antraštę");
		return false;
	}
	if (document.forma.text.value == "") {
		alert("Įveskite straipsnio tekstą");
		return false;
	}
	return true;
}
function validate2() {
	text = document.updateArticle.text.value;
	if (text == "") {
		alert("Įveskite straipsnio tekstą");
		return false;
	}

	return true;
}
function arTrintiApklausas() {
	return confirm("Ar tikrai norite trinti apklausą(-as).  OK?");
}
function arTrinti(){
	return confirm("Ar tikrai norite trinti straipsni(-ius).  OK?");
}

function arTvirtinti() {
	return confirm("Ar tikrai norite tvirtinti straipsni(-ius).  OK?");
}
function arGrazinti() {
    return confirm("Ar tikrai norite grąžinti straipsni(-ius).  OK?");
}
function arBlokuoti() {
	return confirm("Ar tikrai norite blokuoti vartotoją/us.  OK?");
}
function arAtblokuoti() {
	return confirm("Ar tikrai norite atblokuoti vartotoją/us.  OK?");
}
function validateEdit() {
	if (document.forma.keista.value == 1) {
		index1 = document.forma.ctlTemos.selectedIndex;
		if (index1 == 0) {
			alert("Pasirinkite temą");
			return false;
		}
		index2 = document.forma.ctlPotemes.selectedIndex;
		if (index2 == 0) {
			alert("Pasirinkite potemę");
			return false;
		}
	}
	title = document.forma.title.value;
	if (title == "") {
		alert("Įveskite straipsnio antraštę");
		return false;
	}
	text = document.forma.tekstas.value;
	if (text == "") {
		alert("Įveskite straipsnio tekstą");
		return false;
	}
	nuoroda = document.forma.nuoroda.value;
	if (nuoroda == "") {
		alert("Įveskite nuoroda");
		return false;
	}
	return true;
}
function paspaudimas(e) {
var keynum

	if(window.event) // IE
	{
		keynum = e.keyCode
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which
	}

	if(keynum == 13) {
		return kurtiPoteme();
	}
}

function generateAnswers() {
    index = document.forma.ats_sk.selectedIndex;
    value = document.forma.ats_sk[index].value;

    result = "";

    for(i = 0; i < value; i++)
        result = result + "<p style=\"margin-left:0px\"><input type=\"text\" name=\"ats_" + i + "\" value=\"\" /></p>";

    var newdiv = document.createElement("div");
    newdiv.innerHTML = result;
    var container = document.getElementById('answers');
    container.innerHTML = newdiv.innerHTML;
}

function confirmAction(fun,message) {
    if (confirm(message)) {
        eval(fun);
    }
    else
        return false;
}

function noEnter(e)
{
	var keynum;
	var keychar;
	var numcheck;

	if(window.event) // IE
	  {
	  keynum = e.keyCode;
	  }
	else if(e.which) // Netscape/Firefox/Opera
	  {
	  keynum = e.which;
	  }
	if (keynum == 13)
		return false;
	else
		return true;
}

/**
 *  author:		Timothy Groves - http://www.brandspankingnew.net
 *	version:	1.0 - 2006-09-25
 *
 *	requires:	nothing
 *
 */

var useBSNns;

if (useBSNns)
{
	if (typeof(bsn) == "undefined")
		bsn = {}
	var _bsn = bsn;
}
else
{
	var _bsn = this;
}





_bsn.Crossfader = function (divs, fadetime, delay )
{
	this.nAct = -1;
	this.aDivs = divs;

	for (var i=0;i<divs.length;i++)
	{
		document.getElementById(divs[i]).style.opacity = 0;
		document.getElementById(divs[i]).style.position = "absolute";
		document.getElementById(divs[i]).style.filter = "alpha(opacity=0)";
	}

	this.nDur = fadetime;
	this.nDelay = delay;

	this._newfade();
}


_bsn.Crossfader.prototype._newfade = function()
{
	if (this.nID1)
		clearInterval(this.nID1);

	this.nOldAct = this.nAct;
	this.nAct++;
	if (!this.aDivs[this.nAct])	this.nAct = 0;

	this.nInt = 50;
	this.nTime = 0;

	var p=this;
	this.nID2 = setInterval(function() { p._fade() }, this.nInt);
}


_bsn.Crossfader.prototype._fade = function()
{
	this.nTime += this.nInt;

	var op = this._easeInOut(this.nTime, 0, 1, this.nDur);
	var ieop = op*100;
	document.getElementById( this.aDivs[this.nAct] ).style.opacity = op;
	document.getElementById( this.aDivs[this.nAct] ).style.filter = "alpha(opacity="+ieop+")";
	if (this.nOldAct > -1)
	{
		document.getElementById( this.aDivs[this.nOldAct] ).style.opacity = 1 - op;
		document.getElementById( this.aDivs[this.nOldAct] ).style.filter = "alpha(opacity="+(100 - ieop)+")";
	}

	if (this.nTime == this.nDur)
	{
		clearInterval( this.nID2 );

		var p=this;
		this.nID1 = setInterval(function() { p._newfade() }, this.nDelay);
	}
}



_bsn.Crossfader.prototype._easeInOut = function(t,b,c,d)
{
	return c/2 * (1 - Math.cos(Math.PI*t/d)) + b;
}

function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	suma = 0;

    if(!document.forms[FormName])
        return false;
    var objCheckBoxes = document.forms[FormName].elements[FieldName];
    if(!objCheckBoxes)
        return false;
    var countCheckBoxes = objCheckBoxes.length;
    if(!countCheckBoxes) {
        objCheckBoxes.checked = true;
    }
    else
        // set the check value for all check boxes
        for(var i = 0; i < countCheckBoxes; i++)
        if (objCheckBoxes[i].checked == false)
            objCheckBoxes[i].checked = true;
        else
            objCheckBoxes[i].checked = false;

    return false;
}

function limitText(textArea, length) {
    if (textArea.value.length > length) {
        textArea.value = textArea.value.substr(0,length);
    } else {
        left = length - textArea.value.length;
        document.getElementById("div_left").innerHTML = "Liko: <b>" + left + "</b>";
    }
}

var newwindow = ''
function showimg(url,width,height,title) {

    newwindow=window.open(url,title,'width=' + width + ',height='+ height + ',resizable=0');
    newwindow.document.write("<html><head>");
    newwindow.document.write("<style>html,body {    margin:0;    padding:0;}</style>");
    newwindow.document.write("<TITLE>" + title + "</TITLE></head><body>");
    newwindow.document.write("<a href=\"javascript:window.close()\"><img src=\"");
    newwindow.document.write(url);
    newwindow.document.write("\" alt=\"\" border=\"0\" height=\""+ height + "\" width=\"" + width + "\" /></a></body></html>");
    newwindow.focus();
}

function tidy() {
if (newwindow.location && !newwindow.closed) {
   newwindow.close(); }
}

function getW(image)
{
    var theImg = new Image;
    theImg.src = image;

    return theImg.width;

}

function getH(image)

{

    var theImg = new Image;
    theImg.src = image;

    return theImg.height;

}
