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;
}

/**
 *  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 swapIt(id, newclass) {
		el = document.getElementById(id);
		el.className = newclass;
		el.style.cursor = (document.all) ? "hand" : "pointer";
}
function getCheckedValue(radioObj) {
    if(!radioObj)
        return "";
    var radioLength = radioObj.length;
    if(radioLength == undefined)
        if(radioObj.checked)
            return radioObj.value;
        else
            return "";
    for(var i = 0; i < radioLength; i++) {
        if(radioObj[i].checked) {
            return radioObj[i].value;
        }
    }
    return "";
}
function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}
function validateCheckBoxes(FormName, FieldName)
{
	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) {
		if (!objCheckBoxes.checked)
			return false;
        else
            return true;
	}
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			if (objCheckBoxes[i].checked == true)
				suma = suma + 1;

	if (suma <= 0)
		return false;
	else
		return true;
}

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

function noEnter(e) {
    var keynum

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

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

function setSimpleAction(action,FormName) {
	if (action && FormName) {
		if (action == 'delete') {
			if(confirm("Ar tikrai norite trinti straipsnį.  OK?")) {
				document.forms[FormName].elements['action'].value = action;
				document.forms[FormName].submit();
				return true;
			} else
				return false;
		}
		if (action == 'confirm') {
			if(confirm("Ar tikrai norite tvirtinti straipsnį.  OK?")) {
				document.forms[FormName].elements['action'].value = action;
				document.forms[FormName].submit();
				return true;
			} else
				return false;
		}
		document.forms[FormName].elements['action'].value = action;
		document.forms[FormName].submit();
 	} else {
		return false;
	}
}

function setAction(action,FormName, FieldName) {
 	if (!validateCheckBoxes(FormName, FieldName)) {
		alert("Pasirinkite nors vieną įrašą");
		return false;
	}
	if (action) {
		document.forms[FormName].elements['action'].value = action;
		document.forms[FormName].submit();
 	} else {
		return false;
	}
}

function deleteAction(action,FormName, FieldName, ListName) {
 	if (!validateCheckBoxes(FormName, FieldName)) {
		alert("Pasirinkite nors vieną "+ListName);
		return false;
	}
	if (confirm("Ar tikrai norite trinti. OK?") && action) {
		document.forms[FormName].elements['action'].value = action;
		document.forms[FormName].submit();
	}
	else
		return false;
}
function selectAllCheckBoxes(FormName, FieldName)
{
    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 showimg(url,width,height) {
    var newwindow = '';

    newwindow=window.open(url,'Nuotrauka','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>Nuotrauka</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();
}