var scroll_body;
spacer=new Image(); spacer.src="/images/frame/spacer.gif";

b_kubok_open_ovr=new Image(126,11); b_kubok_open_ovr.src="/images/buttons/kubok_open_ovr.gif";
b_kubok_open_out=new Image(126,11); b_kubok_open_out.src="/images/buttons/kubok_open.gif";

b_about_ovr=new Image(60,9); b_about_ovr.src="/images/buttons/about_ovr.gif";
b_about_out=new Image(60,9); b_about_out.src="/images/buttons/about.gif";

b_trace_ovr=new Image(41,9); b_trace_ovr.src="/images/buttons/trace_ovr.gif";
b_trace_out=new Image(41,9); b_trace_out.src="/images/buttons/trace.gif";

b_rules_ovr=new Image(51,9); b_rules_ovr.src="/images/buttons/rules_ovr.gif";
b_rules_out=new Image(51,9); b_rules_out.src="/images/buttons/rules.gif";

b_price_ovr=new Image(30,11); b_price_ovr.src="/images/buttons/price_ovr.gif";
b_price_out=new Image(30,11); b_price_out.src="/images/buttons/price.gif";

b_anons_ovr=new Image(49,9); b_anons_ovr.src="/images/buttons/anons_ovr.gif";
b_anons_out=new Image(49,9); b_anons_out.src="/images/buttons/anons.gif";

b_report_ovr=new Image(43,10); b_report_ovr.src="/images/buttons/report_ovr.gif";
b_report_out=new Image(43,10); b_report_out.src="/images/buttons/report.gif";

b_forum_ovr=new Image(41,9); b_forum_ovr.src="/images/buttons/forum_ovr.gif";
b_forum_out=new Image(41,9); b_forum_out.src="/images/buttons/forum.gif";


function Movr(imageName){
if(document.images){
     document[imageName].src=eval(imageName + "_ovr.src");
}}
function Mout(imageName){
 if(document.images){
     document[imageName].src=eval(imageName+"_out.src");
}}

 function light_on(targetId)
 {
   var targetElement;
       targetElement = document.getElementById(targetId);

      targetElement.style.display="";
 }

 function light_off(targetId)
 {
   var targetElement;
       targetElement = document.getElementById(targetId);

      targetElement.style.display="none";
 }

function show_pic(dir,name)
{

  scroll_body=document.body.scrollTop;

  if(scroll_body<380)
  {
   popup("../show_pic.php?dir="+dir+"&pic="+name,200,200,420-scroll_body,15);
  }
  else
  {

   popup("../show_pic.php?dir="+dir+"&pic="+name,200,200,25,15);
  }

}


function popup(url, width, height, top, left) {

        iframe = document.getElementById('FM~popupIFRAME');
        div = document.getElementById('FM~popupDIV');
        iframeDIV = document.getElementById('FM~iframeDIV');
        iframeDIV.innerHTML = '<iframe height="100%" width="100%" name=popframe id="FM~popupIFRAME" frameborder="0" style="width:'+width+'px;height:'+height+'px" src="'+url+'" style="display:none;background-color:white;" onload="this.style.display=\'block\'"></iframe>';
        iframeDIV.style.width=width;
        iframeDIV.style.height=height;
        div.style.width=width;
        div.style.height=height;
        div.style.left=-(-left-findScrollLeft());
        div.style.top=-(-top-findScrollTop());

        div.style.display='block';
        div.style.visibility='visible';

}

function closePopup() {
        div = document.getElementById('FM~popupDIV');
        iframeDIV = document.getElementById('FM~iframeDIV');
        div.style.display='none';
        iframeDIV.innerHTML = "";
}


 function normalize_size()
 {
  height = frames['FM~popupIFRAME'].document.body.scrollHeight;

  if(height>768)
  {
   height=500;
  }

  width = frames['FM~popupIFRAME'].document.body.scrollWidth;
  iframe = document.getElementById('FM~popupIFRAME');

  iframe.style.height=height;
  iframe.style.width=width;

 }

 function resize_preview_to_width(width)
 {
//  height = frames['FM~popupIFRAME'].document.body.scrollHeight;
//  width = frames['FM~popupIFRAME'].document.body.scrollWidth;
  iframe = document.getElementById('FM~popupIFRAME');
//  iframe.style.height=200;
  iframe.style.width=width;
 }


 function resize_preview_to_height(height)
 {
  iframe = document.getElementById('FM~popupIFRAME');
  iframe.style.height=height;
 }


 function loaded()
 {
  iframe = gId('FM~popupIFRAME');
  iframe.style.display='block';
  iframe.style.visibility='visible';
 }

 function loading()
 {
  iframe = document.getElementById('FM~popupIFRAME');
  iframe.style.visibility='hidden';
  resize_preview_to_width(100);
  resize_preview_to_height(100);
 }

 function set_popup_title(title)
 {
  iframe_title = gId('popupTitle');
  iframe_title.innerHTML = title;
 }

 function gId(obj_id)
{
        return document.getElementById(obj_id);
}

function fadeandclose(obj)
{
        opacity(obj.id, 100, 0, 600);
        setTimeout("gId('"+obj.id+"').style.display = 'none';", 805);
        obj.onclick = null;
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = gId(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}