var imageWin;
function showImg(imgSrc,bplat,baugst,title) {
    var winw = (screen.width - bplat) / 3;
    var winh = (screen.height - baugst) / 3;
    if (imageWin && imageWin.closed==false) {
        imageWin.close();
    }
        imageWin = open("/blank.html", "bilde", "toolbar=no,directories=no,status=no,location=no,resizable=no,scrollbars=no,menubar=no,height="+baugst+",width="+bplat+",top="+winh+",left="+winw+"");
        imageWin.document.open();
        imageWin.document.write("<html><head><title>" + title);
        imageWin.document.write("</title></head><body bgcolor=\'#FFFFFF\' scrolling=no marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>");
        imageWin.document.write("<table width=100% height=100% cellpadding=0 border=0 cellspacing=0><tr><td valign=middle align=center><a href=\'javascript:void(0);\' onclick=\'javascript:window.close();\' title=\'Aizv&#275;rt\'><img src=\'"+imgSrc+"\' width="+bplat+" height="+baugst+" border=0></a></td></tr></table>");
        imageWin.document.write("</body></html>");
        imageWin.document.close();
    return false;
}

function hidediv(id) {
	// atskirigo parluku drosa funkcija, kas pasleps div slanus
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	// atskirigo parluku drosa funkcija, kas paradiis konkreeto div slaani

	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

/* custom lboxis */
function showLbox(layer,wi,he){
  // for IE6.0
  if ((BrowserDetect.browser == "Explorer") && (BrowserDetect.version<7)) {
    if (document.body.clientHeight > document.documentElement.clientHeight ) {
      document.getElementById('lbox_overlay').style.height = document.body.clientHeight;
    } else {
      document.getElementById('lbox_overlay').style.height = document.documentElement.clientHeight;
    }

    if (document.body.clientWidth > document.documentElement.clientWidth ) {
      document.getElementById('lbox_overlay').style.width = document.body.clientWidth;
    } else {
      document.getElementById('lbox_overlay').style.width = document.documentElement.clientWidth;
    }
  }

  if(wi > 0){document.getElementById('lbox_box_'+layer).style.width = wi+"px";}
  if(he > 0){document.getElementById('lbox_box_'+layer).style.height = he+"px";}

  //Show the background overlay and topbox...
  document.getElementById('lbox_overlay').style.visibility = 'visible';
  document.getElementById('lbox_box_'+layer).style.display = 'block';

  //window.onscroll = function() {verticallyCenter('lbox_box_'+layer)};

  //verticallyCenter('lbox_box_'+layer);
}


function closeLbox(layer){
  //Hide the overlay and tobox...
  document.getElementById('lbox_overlay').style.visibility = 'hidden';
  document.getElementById('lbox_box_'+layer).style.display = 'none';
}

function viewportSize(side) {
  var viewportWidth;
  var viewportHeight;

  // for standards compliant browsers (mozilla/netscape/opera/IE7)
  if (typeof window.innerWidth != 'undefined') {
    viewportWidth = window.innerWidth,
    viewportHeight = window.innerHeight
  }
  // IE6 in standards compliant mode (i.e. with a valid doctype)
  else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
   viewportWidth = document.documentElement.clientWidth,
   viewportHeight = document.documentElement.clientHeight
  }
  // older versions of IE
  else {
   viewportWidth = document.getElementsByTagName('body')[0].clientWidth,
   viewportHeight = document.getElementsByTagName('body')[0].clientHeight
  }

  return (side == 'width' ? viewportWidth : viewportHeight);
}

//window.onscroll = function() {verticallyCenter('lbox_box_login')};

function verticallyCenter(id) {
  var elementHeight=document.getElementById(id).offsetHeight;
  var elementWidth=document.getElementById(id).offsetWidth;

  var winScrollPos = document.documentElement.scrollTop;
  if (winScrollPos == 0){
      if (window.pageYOffset)
          winScrollPos = window.pageYOffset;
      else
          winScrollPos = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
  }

  document.getElementById(id).style.top = winScrollPos + (viewportSize('height') - elementHeight)/2+"px";
  document.getElementById(id).style.left = (viewportSize('width') - elementWidth)/2+"px";
}
/* lbox end */


function bildeLoading(){
    document.getElementById('lrgfoto2').innerHTML = '<img src="/img/loading.gif" alt="ielāde..." width="32" height="32" style="padding:20px; background:#FFFFFF;">';
    showLbox('lrgfoto');
}

function ajxLoadingSym(layer){
    document.getElementById(layer).innerHTML = '<div class="ajxLoading"><img src="/img/des/loading.gif" alt="Ielāde.."></div>';
}
function ajxLoadingSymLrg(layer){
    document.getElementById(layer).innerHTML = '<div class="ajxLoading" align="center"><br><br><br><br><img src="/img/des/loading.gif" alt="Ielāde.." width="32" height="32" style="background: #FFFFFF; padding:10px;"></div>';
}
function samazinamGalleryAjaxVietu(){
    document.getElementById('gallery_img').style.height = '80px';
}

function clean4Ajax(id){
 ob = document.getElementById(id);
 var h = ob.value;
 var n = "&"; var r = "[AND]"; var t = h.split(n); ob.value = t.join(r);
}

function ajxboxLoadingSym(){
    ajxLoadingSym('ajxBoxCont');
}
function getajxbox(link,wi,he){
    document.getElementById('lbox_box_ajx').style.backgroundColor = 'white';
    ajxboxLoadingSym(); showLbox('ajx',wi,he); get_ajax(link,'ajxBoxCont');
}
function postajxbox(link,form){
    document.getElementById('lbox_box_ajx').style.backgroundColor = 'white';
    var wi, he; showLbox('ajx',wi,he); post_ajax(link,form,'ajxBoxCont'); ajxboxLoadingSym();
}
function loadajxbox(link){
    ajxboxLoadingSym(); get_ajax(link,'ajxBoxCont');
}
function closeajxbox(){
    ajxboxLoadingSym(); closeLbox('ajx');
}
