var DDSPEED = 5;
var DDTIMER = 10;

// main function to handle the mouse events //
function ddMenu(id,dir) {
  var head = document.getElementById(id + '-ddheader');
  var cont = document.getElementById(id + '-ddcontent');
  clearInterval(cont.timer);
  if(dir == 1) {
    clearTimeout(head.timer);
    if(cont.maxh && cont.maxh <= cont.offsetHeight) {
      return;
    } else if(!cont.maxh) {
      cont.style.display = 'block';
      cont.style.height = 'auto';
      cont.maxh = cont.offsetHeight;
      cont.style.height = '0px';
    }
    cont.timer = setInterval("ddSlide('" + id + "-ddcontent', 1)", DDTIMER);
  } else {
    head.timer = setTimeout('ddCollapse(\'' + id + '-ddcontent\')', 50);
  }
}

// collapse the menu //
function ddCollapse(id) {
  var cont = document.getElementById(id);
  cont.timer = setInterval("ddSlide('" + id + "', -1)", DDTIMER);
}

// cancel the collapse if a user rolls over the dropdown content //
function cancelHide(id) {
  var head = document.getElementById(id + '-ddheader');
  var cont = document.getElementById(id + '-ddcontent');
  clearTimeout(head.timer);
  clearInterval(cont.timer);
  if(cont.offsetHeight < cont.maxh) {
    cont.timer = setInterval("ddSlide('" + id + "-ddcontent', 1)", DDTIMER);
  }
}

// incrementally expand/contract the dropdown and change the opacity //
function ddSlide(id,dir) {
  var cont = document.getElementById(id);
  var currheight = cont.offsetHeight;
  var dist;
  if(dir == 1) {
    dist = (Math.round((cont.maxh - currheight) / DDSPEED));
  } else {
    dist = (Math.round(currheight / DDSPEED));
  }
  if(dist <= 1) {
    dist = 1;
  }
  cont.style.height = currheight + (dist * dir) + 'px';
  cont.style.opacity = currheight / cont.maxh;
  cont.style.filter = 'alpha(opacity=' + (currheight * 100 / cont.maxh) + ')';
  if((currheight < 2 && dir != 1) || (currheight > (cont.maxh - 2) && dir == 1)) {
    clearInterval(cont.timer);
  }
}

 function ChangeImg()
    {
     if(document.images)
       {

eval("document."+ChangeImg.arguments[0]+".src=('"+ChangeImg.arguments[1]+"')");
       }
     }

    function preload()
     {
      if (document.images)
        {
         var imgsrc = preload.arguments;
         arr=new Array(imgsrc.length);
         for (var j=0; j<imgsrc.length; j++)
           { arr[j] = new Image; arr[j].src = imgsrc[j]; }
        }
     }
function ShowPhoto(Photo,WidthWin,HeightWin)
{

param = "Width=" + WidthWin + ","            ;
param = param + "Height=" + HeightWin + ","  ;
param = param + "Top=100,"             ;
param = param + "Left=100,"            ;
param = param + "Toolbar=0,"         ;
param = param + "Status=0,"          ;
param = param + "Menubar=0,"         ;
param = param + "location=0,"        ;
param = param + "Scrollbars=0,"      ;
param = param + "Resizable=0"        ;


myWin=window.open("", "Photo", param); 

 
myWin.document.open();

 
myWin.document.write("<html><head><title>Клубная карта</title></head>");
myWin.document.write("<body topmargin='0' leftmargin='0'>");

myWin.document.write("<IMG src=" + Photo + 
               " border='0' align='' valign='' hspace='0' vspace='0'>"); 

myWin.document.write("</body></html>");
 
myWin.document.close(); 
}