function popupimg(s,t){
	var o=window.open('','w'+new Date().getTime(),'width=200,height=200,toolbar=no,location=no,status=no,resizable=no,left='+(screen.width/2-100)+',top='+(screen.height/2-100));if (o){var d=o.document;d.write('<html><head><meta http-equiv="imagetoolbar" content="no"><title>'+t+'</title></head><body style="margin:0;padding:0;overflow:hidden;height:200px" onblur="o.close()"><script>o=window;b=o.document.body;w=b.offsetWidth;h=b.offsetHeight;function r(x,y){o.resizeBy(x-w,y-h);o.moveBy((w-x)/2,(h-y)/2)}<\/script><img src="'+s+'" onload="r(this.width,this.height)"></body></html>');d.close();}return false;
}

function AccessKeyText(target,tags,underline) {

  var r = d.getElementById(target);
  var l = r.getElementsByTagName(tags);
  var regex = /\[[\w]+\s\+\s[\w]{1}\]/
  
  for (var i=0; i<l.length; i++) {
    if (l[i].hasChildNodes) {
      if (regex.test(l[i].childNodes[1].nodeValue)) {
        l[i].childNodes[1].nodeValue = '';

        if (underline == true) {
          var ak = l[i].childNodes[0].getAttribute('accesskey');
          var txt = l[i].childNodes[0].childNodes[0].nodeValue;
          var kp = txt.indexOf(ak);
          var p1 = txt.substring(0, kp);
          var p2 = txt.substring(kp, kp + 1);
          var p3 = txt.substring(kp + 1, txt.length);
          l[i].childNodes[0].childNodes[0].nodeValue = p1;
          var s = d.createElement('span');
          var span = l[i].childNodes[0].appendChild(s);
          var keyt = d.createTextNode(p2);
          span.appendChild(keyt);
          var lastt = d.createTextNode(p3);
          l[i].childNodes[0].appendChild(lastt);
        }
      }
    }
  }
}    

function operaSearch() {
  
  if (!w.opera) return false;

  var r = d.getElementById('index_search');
  var n = r.getElementsByTagName('form')[0];
  r.removeChild(n);
  var tb = '<form action="" method="post"><table id="oprTable"><tr><th>Šalis</th><th>Tipas</th><th>Data</th><th>&nbsp;</th></tr><tr><td><select><option>asfasF</option><option>asf</option></select></td><td><input type="radio" name="sa" id="sa_plane" /><label for="sa_plane">Lėktuvu</label><br /><input type="radio" name="sa" id="sa_bus" /><label for="sa_bus">Autobusu</label><br /><input type="radio" name="sa" id="sa_other" /><label for="sa_other">Pažintinė</label><br /></td><td><select class="ft"><option>asfasF</option><option>asf</option></select><span>&ndash;</span><select class="ft"><option>asfasF</option><option>asf</option></select></td><td><input type="image" id="sa_submit" src="/images/sa_img.gif" value="submit" alt="Ieškoti" /></td></form></tr></table>';
  r.innerHTML = tb;
}

function swapSearchButton() {

  if (window.opera) return false;
  var t = d.getElementById('s_submit');
  d.forms[0].removeChild(t);

  srch = d.createElement('input');

  with(srch) {
    setAttribute('src', '/images/s_image.gif');
    setAttribute('id', 's_image');
    setAttribute('type', 'image');
    setAttribute('alt', 'Ieškoti');
    setAttribute('title', 'Ieškoti');
  }

  d.forms[0].appendChild(srch);

}

function swapSearchText() {
  
  var t = d.getElementById('s_input');
  t.value = 'Paieška';
  t.onblur = function() { t.value = t.value == '' ? 'Paieška' : t.value; }
  t.onfocus = function() { t.value = t.value == 'Paieška' ? '' : t.value; }

}


function positionFooter() {

  var c = d.getElementById('wrapper');
  var f = d.getElementById('footer');
  var wh = (typeof(w.innerHeight) == 'number') ? w.innerHeight : d.documentElement.clientHeight ? d.documentElement.clientHeight : d.body.clientHeight;
  if (wh > 0) {
    var ch = c.offsetHeight;
    var fh = f.offsetHeight;
    if (wh - (ch + fh) >= 0) {
      f.style.position = 'absolute';
      f.style.top = (wh - fh) + 'px';
    }
    else {
      alert("aaa");
    }
  }
}
    

window.onload = function() { 
  
  d = document;
  w = window;

  if (!d.hasChildNodes || !d.appendChild) return false;
  operaSearch();


  /*AccessKeyText('side-b_travels', 'li', true);
  AccessKeyText('side-b_extra', 'li', false);*/
  /*swapSearchButton();*/
  /*swapSearchText();*/
}

function reminder(linkObj)
{
	window.open(linkObj.href, '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=350,height=150,left='+((window.screen.width-200)/2)+',top='+((window.screen.height-100)/2));
	return false;
}

