var pickArr = new Array();
var im=new Array();
var imsmall=new Array();
var flash=new Array();
var count=0;
var doFlag=false;
var iterations=0;
var flash_num = 3;
var max_img=0;
var flash_op=new Array();

function setIndex(index){
 flash_op[0] = flash[pickArr[index-1]][0];
 flash_op[1] = flash[pickArr[index-1]][1];
 flash_op[2] = flash[pickArr[index-1]][2];
 flash_op[3] = flash[pickArr[index-1]][3];
}

function setBanner(src,type,width,height,pos,mx){ 
 flash[pos] = new Array();
 flash[pos][0]=src;
 flash[pos][1]=type;
 flash[pos][2]=width;
 flash[pos][3]=height;
 max_img=mx;
}

function setImage(src,num,size){ 
  if (size=='small'){imsmall[num]=src;}
  else{im[num]=src;}
}

function setValue(fname,cnt){eval(fname + '_height =' + cnt*21);}

function popup(link, width, height) {
   var params = "toolbar=no,menubar=no,location=no,scrollbars=yes";
   var scrheight = screen.height;
   if (width > 0) { params += ",width=" + width; }
   if (height > 0) { params += ",height=" + height; } 
   else { params += ",height=" + (scrheight - 100); }
   window.open(link,'popup_window',params);
}

function MM_openBrWindow(theURL,winName,features) {
    window.open(theURL,winName,features);
}

function ShowImgBig(image) {
  pos=image.lastIndexOf(".");
  ImgBig = image.substr(0, pos) + "_big." + image.substr(pos+1);
  settings = "height=180,width=230,scrollbars=true,resizable";
  win = window.open("/ShowImgBig.htm?"+ImgBig,"ImageBig",settings);
}

function pickNums(nums){
 iterations+=1;
 var currNum = Math.round(Math.random() * (max_img - 1));
 if(count!=0) {
  for(var i=0; i<pickArr.length; i++) {
   if(currNum==pickArr[i]) {
    doFlag=true;
    break;
    }
  }
 }
 if(!doFlag) {
  pickArr[count]=currNum;
  count+=1;
 }
 if(iterations<(max_img*3)) {
  if((count<nums)) {pickNums(nums);}
 }
 else {location.reload();}
}

function open_phone(oPhones) {
  var phone = eval('document.phoneFrm.' + oPhones);
  var href = phone.options[phone.selectedIndex].value;
  if (href.length > 0)
    window.location.href = href;
}

function randomMainCellBG(){
  var max_img = im.length-1;
  var rnd = Math.round(Math.random() * (max_img - 1)) + 1;
  var obj = MM_findObj('main_cell');
  var height = document.body.clientHeight;
  obj.style.backgroundImage = (height > 600) ? 'url(' + im[rnd] + ')' : 'url(' + imsmall[rnd] + ')';
}

function repositionMenu()
{
	repositionMenuItem(menu_pr)
	repositionMenuItem(menu_ve)
	repositionMenuItem(menu_ex)
	repositionMenuItem(menu_om)
	repositionMenuItem(menu_pe)
	repositionMenuItem(menu_se)
	repositionMenuItem(menu_sep)
	repositionMenuItem(menu_as)
	
}

function repositionMenuItem(item)
{
     var objA = MM_findObj(item.id+"Actuator");
     if (objA){
	var right = parseInt(getAbsOffsetLeft(MM_findObj(item.id+"Right")));
	var newLeft = parseInt(getAbsOffsetLeft(objA));
	var newTop = parseInt(getAbsOffsetTop(objA)) + 20;
	//var newTop = parseInt(getAbsOffsetTop(objA)) - item.initheight;  keiciamas meniu pasirodymo aukstis
	var newWidth = right - newLeft - 15;
	menu_pr.container.style ? item.container.style.width = newWidth + "px" : item.container.width = newWidth;
	menu_pr.container.style ? item.container.style.left = newLeft + "px" : item.container.left = newLeft;
	menu_pr.container.style ? item.container.style.top = newTop + "px" : item.container.top = newTop;
     }
}
 
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function getAbsOffsetLeft( obj )
{
	if ( obj.offsetParent.tagName == "BODY" )
		return obj.offsetLeft;
	else
		return obj.offsetLeft + getAbsOffsetLeft( obj.offsetParent );
} 		

function getAbsOffsetTop( obj )
{
	if ( obj.offsetParent.tagName == "BODY" )
		return obj.offsetTop;
	else
		return obj.offsetTop + getAbsOffsetTop( obj.offsetParent );
} 		

function showSavitarnaLinks(show)
{
	var obj_links = MM_findObj('savitarna_links');
	var obj_text_td = MM_findObj('savitarna_text_td');	
	obj_links.style.display = show ? '' : 'none';
	obj_text_td.style.color = show ? '#93BFEB' : '#005EB5';
}