<!--
/**
 * JavaScrits
 *
 * @author Marius Kazemekaitis a.k.a cOdH <marius@advanced.lt>
 * @package SkemtaTVS
 * @version v3.0/2006 
 */

var Cookie = {
  set: function(name, value, daysToExpire) {
    var expire = '';
    if (daysToExpire != undefined) {
      var d = new Date();
      d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire)));
      expire = '; expires=' + d.toGMTString();
    }
    return (document.cookie = escape(name) + '=' + escape(value || '') + expire);
  },
  get: function(name) {
    var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + '=([^;\\s]*)'));
    return (cookie ? unescape(cookie[2]) : null);
  },
  erase: function(name) {
    var cookie = Cookie.get(name) || true;
    Cookie.set(name, '', -1);
    return cookie;
}};

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function focus_to_login() {	
	if(document.getElementById("username"))
	{
		document.getElementById("username").focus();
	}	
}

function changeIt(object)
{
	obj = document.getElementById(object);
	if(obj.disabled==false)
	{
		obj.disabled = true;
	}else{
		obj.disabled = false;
	}
}

function disableInput(object)
{
	obj = document.getElementById(object);
	if(obj.disabled==false)
	{
		obj.disabled = true;
		obj.style.backgroundColor = "#F6F6F6";
		obj.style.border = "0";
		obj.value = "";
	}else{
		obj.disabled = false;
		obj.style.backgroundColor = "#FFFFFF";
		obj.style.border = "1px solid #4E6172";
		obj.value = "1";
	}
}

function changeUploadForm(object)
{
	obj = document.getElementById(object);
	changeIt(object);
}

function authChange(field0, field1, field2) {
    var field0 = document.getElementById(field0);
    var field1 = document.getElementById(field1);
    var field2 = document.getElementById(field2);
    if (field0.checked) {
        field1.disabled = false;
        field2.disabled = false;
    } else {
        field1.disabled = true;
        field2.disabled = true;
        field1.value = '';
        field2.value = '';
    }
}

function openWnd(width, height, url, scrollbars) {
  winName = "_blank";
  page_height = (height != '')?height:600;
  page_width = (height != '')?width:500;
  page_top = Math.round((screen.height-page_height)/2);
  page_left = Math.round((screen.width-page_width)/2);
  size = "width="+page_width+",height="+page_height+",top="+page_top+",left="+page_left;
  features = 'status=yes,toolbar=no,scrollbars='+scrollbars+',resizable=no,'+size;
  newWnd = window.open(url, winName, features);
  newWnd.focus();
}

function submitEnter(myfield, e, mode) {
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;

    if (keycode == 13) {
        doSearch(mode);
    return false;
    }
    else
    return true;
}

function focusInput(id, value)
{
	if($(id).value==value) {
		$(id).value = "";
	}
}

function blurInput(id, value)
{
	if($(id).value.length==0) {
		$(id).value = value;
	}
}


function showTab(tabNr)
{
	$('tab1').className='fl tabas';
	$('tab2').className='fl tabas';
	$('tab3').className='fl tabas';		
	$('tab' + tabNr).className='fl tabActyv';
	
	$('tabBody1').className='wb hidden';
	$('tabBody2').className='wb hidden';
	$('tabBody3').className='wb hidden';
	$('tabBody' + tabNr).className='wb block';
}

updateUri = function(title, target) {

	new Ajax.Request('admin;pages;urlfromtitle', {
		method: 'get',
		parameters: { title: title },
		
		onSuccess: function(transport) {
			$(target).value = transport.responseText;
		}
	});	
}

function inputText(field, text)
{
	if (field.value == text)
	{
		field.style.fontSize = 12;
		field.value = "";
	}
}

function defaultText(field, text)
{
	if (field.value == "")
	{
		field.value = text;
		field.style.fontSize = 9;
	}
}


//-->
