<!--
function moveMenu(item_list, key, keys, direction, ln, php_ext)
{
  var str='';
	
	for (i=0; i<keys.length; i++)
	{
	  str = "";
		if (keys[i] != key) dir = 'out';
		else
		{
  		if ('out' == direction) dir = 'in';
  		else dir = 'out';
		}
    var kk = keys[i];
		var img_ret = '';
		if (dir == 'out') img_ret = 'plus';
		else img_ret = 'minus';
  	str += "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
  	str += "<tr><td width=\"19\"><a href=\"javascript:moveMenu(menu_list, '"+kk+"', menu_keys, '"+dir+"', '"+ln+"', '"+php_ext+"')\"><img src=\"images/"+img_ret+".gif\" alt=\""+item_list[kk][0]['alt']+"\" width=\"19\" height=\"11\" vspace=\"1\" border=\"0\"></a></td>";
    str += "<td width=\"176\" class=\"MainNav\"><a href=\"javascript:moveMenu(menu_list, '"+kk+"', menu_keys, '"+dir+"', '"+ln+"', '"+php_ext+"')\" title=\""+item_list[kk][0]['alt']+"\">"+item_list[kk][0]['title']+"</a></td>";
  	str += "</tr><tr><td colspan=\"2\"><img src=\"images/blank.gif\" width=\"1\" height=\"8\"></td></tr>";
	  if (keys[i] != key || direction == 'in')
		{
    	str += "</table>";
      document.getElementById('menu_'+kk).innerHTML = str ;	
		}
		else
		{
    	for (var j=1; j<item_list[key].length; j++)
    	{
    	  str += "<tr valign=\"top\"><td><img src=\"images/arrow01.gif\" width=\"19\" height=\"11\" vspace=\"1\"></td>";
    		str += "<td class=\"MainNav\"><a href=\""+ln+"."+php_ext+"?id="+item_list[key][j]['id']+"\" title=\""+item_list[key][j]['alt']+"\">"+item_list[key][j]['title']+"</a></td></tr>";
    	}
    
      str += "<tr><td colspan=\"2\"><img src=\"images/blank.gif\" width=\"1\" height=\"8\"></td></tr>";
    	str += "</table>";
      document.getElementById('menu_'+key).innerHTML = str ;	
		}
	}
	
}

function openCopyrightWindow( lang, ext )
{
  var url = "popup_index."+ext+"?lang="+lang+"&type=copyright";
  h=480;
  w=657;
  newWindow = window.open(url,'','width='+w+',height='+h+',top='+(screen.height-h)/2+',left='+(screen.width-w)/2+',location=no,directories=no,status=no,menuBar=no,scrollBars=yes,resizable=no');
  newWindow.focus();
	return false;
}

function checkIfVote( f, anser, demog_type )
{
  var radio_val = "";
  for (var i=0; i<f.elements.length; i++)
	{
	  if (f.elements[i].name == anser && f.elements[i].checked)
		  radio_val = f.elements[i].value;
	}
	if (radio_val == '') { alert("Nurodykite savo balsą"); return false; }
	
	if (demog_type == '1')
	{
	  var gender_checked = 0;
    for (var i=0; i<f.elements.length; i++)
  	{
  	  if (f.elements[i].name == "gender" && f.elements[i].checked)
  		  gender_checked = 1;
  	}
	  if (gender_checked == 0) { alert("Nurodykite savo lytį"); return false; }
	  if (f.age_group.options[f.age_group.selectedIndex].value == "0") { alert("Nurodykite savo amžių"); return false; }
	}
	return true;
}

function validateForm( f )
{
  if (!f.search_query.value)
	{
	  alert( 'Įveskite paieškos užklausą' );
		return false;
	}
	return true;
}

function validateQuestionForm( f )
{
  if (!f.name.value)
	{
	  alert( 'Įveskite savo vardą' );
		return false;
	}
	else if (!f.question.value) {
	  alert( 'Įveskite klausimą' );
		return false;
	}
	return true;
}

function validateGameForm( f )
{
  if (!trim(f.title.value))
	{
	  alert( 'Įveskite siūlomą pavadinimą' );
		return false;
	}
	else if (!trim(f.why_title.value)) {
	  alert( 'Nurodykite priežąstis, kodėl toks pavadinimas' );
		return false;
	}
	else if (!trim(f.name_surname.value)) {
	  alert( 'Įveskite savo vardą' );
		return false;
	}
	else if (!trim(f.phone.value)) {
	  alert( 'Nurodykite savo telefono numerį' );
		return false;
	}
	return true;
}

function validateRegistrationForm( f )
{
  if (!trim(f.username.value))
	{
	  alert( 'Įveskite pasirinktą vartotojo vardą' );
		return false;
	}
  if (!trim(f.password.value))
	{
	  alert( 'Įveskite pasirinktą slaptažodį' );
		return false;
	}
  if (!trim(f.repassword.value))
	{
	  alert( 'Pakartotinai įveskite slaptažodį' );
		return false;
	}
  if (trim(f.password.value) != trim(f.repassword.value))
	{
	  alert( 'Slaptažodis ir pakartotinis slaptažodis turi sutapti' );
		return false;
	}
  if (!trim(f.name.value))
	{
	  alert( 'Įveskite savo vardą' );
		return false;
	}
  var gender_checked = 0;
  for (var i=0; i<f.elements.length; i++)
	{
	  if (f.elements[i].name == "gender" && f.elements[i].checked)
		  gender_checked = 1;
	}
  if (gender_checked == 0) { alert("Nurodykite savo lytį"); return false; }
  if (!trim(f.age.value))
	{
	  alert( 'Nurodykite savo amžių' );
		return false;
	}
  if (!trim(f.email.value) || !emailCheck(trim(f.email.value)))
	{
	  alert( 'Įveskite savo el. paštą' );
		return false;
	}	
}

function validateProfileForm( f )
{
  if (!trim(f.name.value))
	{
	  alert( 'Įveskite savo vardą' );
		return false;
	}
  var gender_checked = 0;
  for (var i=0; i<f.elements.length; i++)
	{
	  if (f.elements[i].name == "gender" && f.elements[i].checked)
		  gender_checked = 1;
	}
  if (gender_checked == 0) { alert("Nurodykite savo lytį"); return false; }
  if (!trim(f.age.value))
	{
	  alert( 'Nurodykite savo amžių' );
		return false;
	}
  if (!trim(f.email.value) || !emailCheck(trim(f.email.value)))
	{
	  alert( 'Įveskite savo el. paštą' );
		return false;
	}	
return true;		
}

function validateStarQAForm( f )
{
  if (!trim(f.question.value))
	{
	  alert( 'Užduokite savo klausimą' );
		return false;
	}
  return true;		
}

function validatePassForm( f )
{
  if (!trim(f.password.value))
	{
	  alert( 'Įveskite pasirinktą slaptažodį' );
		return false;
	}
  if (!trim(f.repassword.value))
	{
	  alert( 'Pakartotinai įveskite slaptažodį' );
		return false;
	}
  if (trim(f.password.value) != trim(f.repassword.value))
	{
	  alert( 'Slaptažodis ir pakartotinis slaptažodis turi sutapti' );
		return false;
	}
	return true;
}


function emailCheck (emailStr) {
    var emailPat=/^(.+)@(.+)$/
    var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
    var validChars="\[^\\s" + specialChars + "\]"
    var quotedUser="(\"[^\"]*\")"
    var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
    var atom=validChars + '+'
    var word="(" + atom + "|" + quotedUser + ")"
    var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
    var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


    var matchArray=emailStr.match(emailPat)
    if (matchArray==null) {
        return false
    }
    var user=matchArray[1]
    var domain=matchArray[2]

    if (user.match(userPat)==null) {
        return false
    }

    var IPArray=domain.match(ipDomainPat)
    if (IPArray!=null) {
          for (var i=1;i<=4;i++) {
            if (IPArray[i]>255) {
                return false
            }
        }
        return true
    }

    var domainArray=domain.match(domainPat)
    if (domainArray==null) {
        return false
    }

    var atomPat=new RegExp(atom,"g")
    var domArr=domain.match(atomPat)
    var len=domArr.length
    if (domArr[domArr.length-1].length<2 ||
        domArr[domArr.length-1].length>4) {
       return false
    }

    if (len<2) {
       return false
    }

    return true;
} 
function validateMessage( f, topic )
{
  if (topic == '1')
	{
	  if (!f.topic.value)
		{
		  alert('Įveskite temos pavadinimą');
			return false;
		}
	}
	if (!f.text.value)
	{
	  alert( 'Įveskite žinutę' );
		return false;
	}
	return true;
}

function imgpop(url_name,width,height)  
{
  var winwidth=width+20;
	var winheight=height+20;
	window.open("popup_index.php4?path="+url_name+"&lang=lt&type=image&width="+width+"&height="+height, 'kas','toolbar=0,location=0,status=1,menubar=0,scrollbars=0,resizable=0,width=' + winwidth + ',height=' + winheight );
}  

function countIndex()
{
  var f = document.windex;
  var weight = f.weight.value;
	var height = f.height.value;
	
	var str = "";
	if (!IsNumeric(weight) || !IsNumeric(height) || weight+1-1==0 || height+1-1==0)
	{
	  str = "";
	}
	else
	{
	  height_m = height * 0.01;
	  index_w = weight / (height_m*height_m);
		index_w = index_w * 10;
		index_w = Math.round(index_w);
		index_w = index_w * 0.1;
    str = "  Jūsų kūno masės indeksas: <B>"+index_w+"</B>";
	}
  document.getElementById('weight_index').innerHTML = str ;	
}

function IsNumeric(strString)
//  check for valid numeric strings	
{
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
   {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
      {
        blnResult = false;
      }
   }
   return blnResult;
}

function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

-->