$(document).ready(function() {
	// atgal
	$('a.back').click(function() {
		history.back();
		return false;
	});
	
	// i virsu
	$('a.top').click(function() {
		$("html, body").animate({scrollTop:0},"slow");
		return false;
	});
	
	// forma
	$('#searchForm :input').focus(function() {  
        if (this.value == this.defaultValue){  
            this.value = '';  
        }  
        if(this.value != this.defaultValue){  
            this.select();  
        }
	});
	
	$('#forma-paieska a').click(function() {
		$("#forma-paieska").submit();
		return false;
	});
	
	$('#forma a').click(function() {
		processForma();
		return false;
	});

	// tabai
	var tabai1 = $('.tabbernav a');
	var tabai1li = $('.tabbernav li')
	tabai1.click(function () {
		$('.tabbertab').hide().filter(this.hash).show();
		tabai1li.removeClass('tabberactive');
		$(this).parent().addClass('tabberactive');
		return false;
	}).filter(':first').click();

});

/*
	FUNKCIJOS -------------------------------------------------------------------------
*/

// img popup
function activatecmsShowImagePopup(url,title,width,height){
	var narsykle = window.opera || ( document.layers && !navigator.mimeTypes['*'] ) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled ) || ( window.ScriptEngine && ScriptEngine() == 'JScript' && navigator.platform == 'Win32' && window.ActiveXObject && !navigator.__ice_version );
	var left=window.screen.width/2-width/2;
	var top=window.screen.height/2-height/2;
	var langas = window.open( ( narsykle ? '' : 'about:blank' ), 'nuotraukos', "height="+(height+2)+",width="+width+",left="+left+",top="+top+',location=0,menubar=0,scrollbars=0,status=0,toolbar=0' );
	html='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
	html+='<html xmlns="http://www.w3.org/1999/xhtml" lang="lt" xml:lang="lt">';
	html+='<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />';
	html+='<title>'+title+'<\/title>';
	html+='<style type="text/css">body{margin:0;padding:0;border:0;}<\/style>';
	html+='<\/head>';
	html+='<body>';
	html+='<a href="#" onclick="window.close()"><img src="'+unescape(url)+'" border="0"/><\/a>';
	html+='<\/body>';
	html+='<\/html>';
	
	langas.document.open();
	langas.document.write(html);
	langas.document.close();
	langas.focus();
	return false;
}

function processForma() {
	var geri = true;
	$('#forma :input').each(function() {
		if($(this).val() == '') geri = false;
	});
	if(geri) {
		$('#forma').submit();
	} else {
		alert('Užpildykite visus laukelius');
	}
}




