function RodykLaukus(){
  if (document.forma.foto[0].checked)	{
  	puse1.style.display = 'none';
  	puse2.style.display = 'none';
    bendra.style.display = 'block'; 
  } else if (document.forma.foto[1].checked) {
  	puse1.style.display = 'block';
  	puse2.style.display = 'block';
    bendra.style.display = 'none'; 
  	} else if (document.forma.foto[2].checked) {
  	puse1.style.display = 'block';
  	puse2.style.display = 'none';
    bendra.style.display = 'none'; 
      } else if (document.forma.foto[3].checked)	{
  	puse1.style.display = 'none';
  	puse2.style.display = 'block';
    bendra.style.display = 'none'; 
        }      
  return true;  
}

function RodykKorta(){
  if (document.forma.tavo_lytis[1].checked)	{ 
  	vyr_korta.style.display = 'none';
  	mot_korta.style.display = 'block';
  } else { 
  	vyr_korta.style.display = 'block';
  	mot_korta.style.display = 'none';  	
  	document.forma.tavo_lytis[0].checked = true; 
  	document.forma.tavo_lytis[1].checked = false;  
  } 
  return true;  
}

function Atsakau(){
  if (document.klausimas.atsakymas.value!=0) {
    if (document.klausimas.atsakymas.value==1) {
      document.klausimas.pirmyn.value='klaida';      
    } else {
      document.klausimas.pirmyn.value='atsakau';
    }
    document.klausimas.submit();
  } else {
    alert("Prašau atsakyti į klausimą");
    void(0);
  }
}

function Pirmyn(veiksmas){
  document.forma.pirmyn.value=veiksmas;
  document.forma.submit();
}

function AtgalForma(){
  history.back();
}

function Nukreipti(failas, posek) {
  setTimeout(location.replace(failas), posek);
  return true;
}

function TikrinkSimbSk(what,limit){
if (what.value.length>=limit)
return false
}

function AutoTekstas() {
  if(document.forma.tavo_vardas.value.length > 0) {
    tavo_vardas = document.forma.tavo_vardas.value;
  } else {
    tavo_vardas = "<Tavo vardas>";
  }
  if(document.forma.tavo_email.value.length > 0) {
    tavo_email = document.forma.tavo_email.value;
  } else {
    tavo_email = "<Tavo el.paštas>";
  }
  if(document.forma.draugo_vardas.value.length > 0) {
    draugo_vardas = document.forma.draugo_vardas.value;
  } else {
    draugo_vardas = "<Draugo vardas>";
  }
  if(document.forma.tavo_tekstas.value.length > 0) {
    toliau_tekstas = " ir sako:";
  } else {
    toliau_tekstas = ".";
  }
  document.forma.auto_tekstas.value = "Labas " + draugo_vardas + ", \n" + tavo_vardas + " (" + tavo_email + ") rekomenduoja tau aplankyti svetainę http://www.kupidonas.lt" + toliau_tekstas;
}

/*
Form field Limiter script- By Dynamic Drive
For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
This credit MUST stay intact for use
*/

var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}


function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='Liko <b><span id="'+theform.toString()+'">'+thelimit+'</span></b> simbolių.'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}


