function swapImgRestore() { //v3.0
  var i,x,a=document.AA_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.AA_p) d.AA_p=new Array();
    var i,j=d.AA_p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.AA_p[j]=new Image; d.AA_p[j++].src=a[i];}}
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.AA_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.AA_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function 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=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function OnLoadInit(){ 
};

function ShowPhoto(Photo,WidthWin,HeightWin)
{
// ????????? ????????? ????
param = "Width=" + WidthWin + ","            ;
param = param + "Height=" + HeightWin + ","  ;
param = param + "Top=0,"             ;
param = param + "Left=0,"            ;
param = param + "Toolbar=0,"         ;
param = param + "Status=0,"          ;
param = param + "Menubar=0,"         ;
param = param + "location=0,"        ;
param = param + "Scrollbars=0,"      ;
param = param + "Resizable=1"        ;

// ??????? ????? ????
myWin=window.open("", "Photo", param); 

// ??????? ?????? document ??? ??????????? ?????? 
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();
myWin.focus(); 
}

function ShowPhoto1(Photo,WidthWin,HeightWin)
{
// ????????? ????????? ????
param = "Width=" + WidthWin + ","            ;
param = param + "Height=" + HeightWin + ","  ;
param = param + "Top=0,"             ;
param = param + "Left=0,"            ;
param = param + "Toolbar=0,"         ;
param = param + "Status=0,"          ;
param = param + "Menubar=0,"         ;
param = param + "location=0,"        ;
param = param + "Scrollbars=1,"      ;
param = param + "Resizable=1"        ;

// ??????? ????? ????

myWin=window.open("", "Photo", param); 

// ??????? ?????? document ??? ??????????? ?????? 
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();
myWin.focus(); 
}


//################# Image Selector
// Cameron Gregory - http://www.bloke.com/
// http://www.bloke.com/javascript/Random/
// This line and about must remain .. then you can use it for free...
//
// ChangeLog
//
// Usage:
//  RandomImage(images)
//  RandomImageLong(images,iparams)
//  RandomImageLink(images,urls)
//  RandomImageLinkLong(images,urls,iparams,hparams)
//  RandomImageLinkLongTarget(images,urls,iparams,hparams)
//     images		is space or comma separated file list
//     urls		is space or comma separated list of url's
//     iparams		params to add to <img>
//     hparams		params to add to <a href..>

function RandomImageLong(images,iparams)
{
/* si: start index 
** i: current index
** ei: end index
** cc: current count
*/
 si = 0; 
 ci=0;
 cc=0;
 imageSet = new Array();
 ei = images.length;
  for (i=1;i<ei;i++) {
    if (images.charAt(i) == ' ' || images.charAt(i) == ',') {
      imageSet[cc] = images.substring(si,i);
      cc++;
      si=i+1;
      }
    }
  ind = Math.floor(Math.random() *cc);
  document.write("<img "+iparams+" src="+imageSet[ind]+" alt=\""+imageSet[ind]+"\">");
}

function RandomImage(images)
{
  RandomImageLong(images," ");
}

function RandomImageLinkLongTarget(images,urls,iparams,hparams)
{
/* si: start index 
** i: current index
** ei: end index
** cc: current count
*/
 imageSet = new Array();
 urlSet = new Array();
 si = 0; 
 ci=0;
 cc=0;
 ei = images.length;
  for (i=1;i<ei;i++) {
    if (images.charAt(i) == ' ' || images.charAt(i) == ',') {
      imageSet[cc] = images.substring(si,i);
      cc++;
      si=i+1;
      }
    }
  ind = Math.floor(Math.random() *cc);
 si = 0; 
 ci=0;
 cc=0;
 ei = urls.length;
  for (i=1;i<ei && cc <=ind ;i++) {
    if (urls.charAt(i) == ' ' || urls.charAt(i) == ',') {
      urlSet[cc] = urls.substring(si,i);
      cc++;
      si=i+1;
      }
    }

  //document.write("<img "+iparams+" src="+imageSet[ind]+" alt=\""+imageSet[ind]+"\">");
  document.write("<a "+hparams+" href=\""+urlSet[ind]+"\"><img "+iparams+" src="+imageSet[ind]+" alt=\""+imageSet[ind]+"\"></a>");
}

function RandomImageLinkLong(images,urls,iparams)
{
  RandomImageLinkLongTarget(images,urls,iparams,"");
}

function RandomImageLink(images,urls)
{
  RandomImageLinkLongTarget(images,urls,"border=0","");
}

