﻿	var menus = new Array(2);
	menus[0] = "rimtai";
	menus[1] = "nerimtai";
	//menus[2] = "draugai";
	//var MenusArraySize=2;	
	
	function ShowThisMenu(id){
			if (document.getElementById){					
						target = document.getElementById(id).style.display;
						if (target == 'none') {ShowSubMenu(id);}
						else {
							//HideSubMenu(id);							
							window.open("index.php","_self","",false);
						}											
			}
	}
	
	function HideThisMenu(id){
			if (document.getElementById){
					if (id!=ActiveMeniu){						
						HideSubMenu(id);
					}
			}
	}
	
	function hideSubMenus(){
		if (document.getElementById){
			for (i = 0; i < menus.length; i++){
				target = document.getElementById(menus[i]+"__");
				if (target) {
					hidediv(menus[i]);										      
					target.innerHTML="<img border=\"0\" src=\"images/meniu_s.gif\" alt=\"\">";
					//target.style.visibility="hidden";				
				}
			}
		}
	}
	function ShowSubMenu(id){
		if (document.getElementById){
				target = document.getElementById(id+"__");	      
				if (target) {
					target.innerHTML="<img border=\"0\" src=\"images/meniu_e.gif\" alt=\"\">";				
					showdiv(id);
				}
		}
	}
	function HideSubMenu(id){
		if (document.getElementById){
				target = document.getElementById(id+"__");	
				if (target) {      
					target.innerHTML="<img border=\"0\" src=\"images/meniu_s.gif\" alt=\"\">";				
					hidediv(id);
				}
		}
	}
	function hidediv(id){
		if (document.getElementById){
			document.getElementById(id).style.display = 'none';
		}
		else {
			if (document.layers) {
				document.id.display = 'none';
			}
			else {
			document.all.id.style.display = 'none';
			}
		}
	}
	function showdiv(id){
		if (document.getElementById) {
			document.getElementById(id).style.display = 'block';
		}
		else {
			if (document.layers) {
				document.id.display = 'block';
			}
			else {
				document.all.id.style.display = 'block';
			}
		}
	}
	function elementById(x) { 
  if (document.getElementById) return document.getElementById(x); 
    else if (document.all) return document.all[x]; 
    else if (document.layers) return document.layers[x];
    else return null;
	}

// Get the HTTP Object
function getHTTPObject(){
   if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
   else if (window.XMLHttpRequest) return new XMLHttpRequest();
   		else {
   			alert("Your browser does not support AJAX.");
   			return null;
   		}
}

//start ajax

function binaryLength_UTF8(str)
{	
	var bytes, charCode, a, len;	
	bytes = 0;
	for (a = 0, len = str.length; a < len; a++)
	{
		charCode = str.charCodeAt(a);
		if (charCode < 128) //2^7
			bytes += 1;
		else if (charCode < 2048) // 2^11
			bytes += 2;
		else if (charCode < 65536) // 2^16
			bytes += 3;
		else
			bytes += 4;
	}	
	return bytes;
}

function create_http_handle(TYPE){
	var http_handle = false;
	if (window.XMLHttpRequest){
		http_handle = new XMLHttpRequest();
		if (http_handle.overrideMimeType){
			if (TYPE == "XML"){
				http_handle.overrideMimeType('text/xml');
			} else {
				http_handle.overrideMimeType('text/html');
			}
		}
	} else if (window.ActiveXObject){
		try {
			http_handle = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_handle = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_handle){
		alert("We are sorry but you are using an outdated browser.  To view this site you must update your browser.");
		return false;
	} else {
		return http_handle;
	}
}

// ONCHANGE - tik pavadinima. +Funkcija turi buti su parametru (xmlhttp)

function sendHTTPrequest(URL, PARAMETERS, ONCHANGE, METHOD, TYPE){
	if (TYPE == "")TYPE = "HTML";
	xmlhttp = create_http_handle(TYPE);	
	if (xmlhttp) {
		//Kill the Cache problem in IE.
		var now = "upid=" + new Date().getTime();
		//PARAMETERS += (PARAMETERS.indexOf("?")+1) ? "&" : "?";
		//PARAMETERS += now;
		PARAMETERS += "&"+now;
	
		if (METHOD == "POST"){		
			//xmlhttp.open('POST', URL + PARAMETERS , true);
			xmlhttp.open('POST', URL, true);
			xmlhttp.setRequestHeader("Content-type", "application/x-www-form-URLencoded");
			xmlhttp.setRequestHeader("Content-length", binaryLength_UTF8(PARAMETERS));
			xmlhttp.setRequestHeader("Connection", "close");
			xmlhttp.onreadystatechange = function() {
				if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					eval(ONCHANGE + '(xmlhttp);');
				}
			}
			xmlhttp.send(PARAMETERS);
		} 
		else {
			xmlhttp.open('GET', URL + PARAMETERS, true);
			xmlhttp.onreadystatechange = function() {
				if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					eval(ONCHANGE + '(xmlhttp);');
				}
			}
			xmlhttp.send(null);
		}
	}
}

// end Ajax



		function Trim(TRIM_VALUE){
		if(TRIM_VALUE.length < 1){
		return"";
		}
		TRIM_VALUE = RTrim(TRIM_VALUE);
		TRIM_VALUE = LTrim(TRIM_VALUE);
		if(TRIM_VALUE==""){
		return "";
		}
		else{
		return TRIM_VALUE;
		}
		} //End Function
		
		function RTrim(VALUE){
		var w_space = String.fromCharCode(32);
		var v_length = VALUE.length;
		var strTemp = "";
		if(v_length < 0){
		return"";
		}
		var iTemp = v_length -1;
		
		while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
		strTemp = VALUE.substring(0,iTemp +1);
		break;
		}
		iTemp = iTemp-1;
		
		} //End While
		return strTemp;
		
		} //End Function
		
		function LTrim(VALUE){
		var w_space = String.fromCharCode(32);
		if(v_length < 1){
		return"";
		}
		var v_length = VALUE.length;
		var strTemp = "";
		
		var iTemp = 0;
		
		while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
		strTemp = VALUE.substring(iTemp,v_length);
		break;
		}
		iTemp = iTemp + 1;
		} //End While
			return strTemp;
		} //End Function



function getStyleObj(id){
var obj = null;
if(document.getElementById){
obj = document.getElementById(id);
}else if(document.all){
obj = document.all[id];
}else if(document.layers){
obj = document.layers[id];
}
return (obj && obj.style) || obj;
}

function GetWindowSize() {
  var myWidth = 0, myHeight = 0;
  var rDimen=new Array();
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  rDimen[0]=myWidth;
  rDimen[1]=myHeight;
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  return rDimen;
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  var rScrol=new Array();
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  rScrol[0]=scrOfX;
  rScrol[1]=scrOfY;
  //return [ scrOfX, scrOfY ];
  return rScrol;
}
