var txt = "";

function paslink()

{

document.getElementById("beganti_eil").innerHTML = txt

txt=txt.substring(1, txt.length) + txt.substring(0, 1)

setTimeout("paslink()", 100)

}

function ChangeFoto(div_id,coords,href,alt,url){
document.getElementById("for_map").innerHTML='<img src="'+url+'" usemap="#pavinio_namai_map" alt="" />';

document.getElementById(div_id).innerHTML='<area shape="POLY" coords="'+coords+'" href="'+href+'" onmouseout="ChangeFoto_Out(\''+div_id+'\',\''+coords+'\',\''+href+'\',\''+alt+'\',\''+url+'\');"  alt="'+alt+'" />';
}

function ChangeFoto_Out(div_id,coords,href,alt,url){
document.getElementById("for_map").innerHTML='<img src="./include/images/pavilnio_namai_main.gif" usemap="#pavinio_namai_map" alt="" />';
document.getElementById(div_id).innerHTML='<area shape="POLY" coords="'+coords+'" href="'+href+'" onmouseover="ChangeFoto(\''+div_id+'\',\''+coords+'\',\''+href+'\',\''+alt+'\',\''+url+'\');"  alt="'+alt+'" />';
}

function Change(){
document.getElementById("for_map").innerHTML='<img src="./include/images/pavilnio_namai_main.gif" usemap="#pavinio_namai_map" alt="" />';
}

function ChangeFoto_Sp(nr,url_sp,url_ne_sp,style){
document.getElementById("v_foto_"+nr).innerHTML='<img style="'+style+'" onMouseOut="ChangeFoto_Ne_Sp(\''+nr+'\',\''+url_sp+'\',\''+url_ne_sp+'\',\''+style+'\')" src="'+url_sp+'" alt="" />';
}

function ChangeFoto_Ne_Sp(nr,url_sp,url_ne_sp,style){
document.getElementById("v_foto_"+nr).innerHTML='<img style="'+style+'" onMouseOver="ChangeFoto_Sp(\''+nr+'\',\''+url_sp+'\',\''+url_ne_sp+'\',\''+style+'\')" src="'+url_ne_sp+'" alt="" />';
}

function OpenImagePopup(dir,url_orig) {

 window.open(dir+url_orig,'_blank','height=600,width=800,status=yes,toolbar=no,menubar=no,location=no,resizable=yes');
        
}
function OpenImagePopupVieta(dir,wid,hei) {

 window.open(dir,'_blank','height='+hei+',width='+wid+',status=yes,toolbar=no,menubar=no,scrollbar=yes,scrollbars=yes,location=no,resizable=yes');
        
}

function OpenVideoPopup(url, name, width, height) {
		var rnd = (Math.round((Math.random()*999)+1));
        var top=Math.round((screen.height-height)/2);
        var left=Math.round((screen.width-width)/2);
        this.open(url, "plius"+rnd, "top="+top+",left="+left+",width="+width+",height="+height+",buttons=no,scrollbars=no,location=no,menubar=no,resizable=yes,status=no,directories=no,toolbar=no,menubar=no");
}

function makeRequest( url, kitas_elemntas1) {

        kitas_elemntas=kitas_elemntas1;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Runtime Error!');
            return false;
        }
        http_request.onreadystatechange = showContents;
        http_request.open('GET', url, true);
        http_request.send(null);

} 

function showContents() {
  if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			
    document.getElementById(kitas_elemntas).innerHTML=http_request.responseText;
    }
  }
}
   
function Uzkl_pran_vert(){
  if(document.getElementById("uzkl_klaida").innerHTML=="Užklausimas išsiųstas!"){
  document.getElementById("vardas").value="";document.getElementById("el_pastas").value="";document.getElementById("pavarde").value="";document.getElementById("tel").value="";document.getElementById("papildomas").value="";document.getElementById("uzkl_klaida").innerHTML="";
  }
  else {
  var vardas = document.getElementById("vardas").value;
  var pavarde = document.getElementById("pavarde").value;
  var tel = document.getElementById("tel").value;
  var el_pastas = document.getElementById("el_pastas").value;
    if (vardas==''||pavarde==''||tel==''){
    document.getElementById('uzkl_klaida').innerHTML='Užpildykite žvaigždute pažymėtus laukus!';
    }
    else {
    var papildomas = document.getElementById("papildomas").value;
    
    makeRequest('../../../include/uzkl.php?vardas='+encodeURI(vardas)+'&pavarde='+encodeURI(pavarde)+'&tel='+encodeURI(tel)+'&el_pastas='+encodeURI(el_pastas)+'&papildomas='+encodeURI(papildomas),'uzkl_klaida');
    }
  }
}

