function a() {
//	setTimeout("this.window.navigate('#pagetp')", 1);
	this.window.navigate('#pagetp');
}

//################ STARTING FROM the TOP OF PAGE
function topstart() {
	var b = document.write;
	document.open();
b('<A NAME=\"pagetp\"></A><BR>');
	document.close();
}

// ################### APDATED ################### 
function updated() {
	document.open();
	var a = this.document.lastModified;
	var upd = document.write(a.substring(0, 10));
	document.close();
}

// ################### cursor over TABLE ###################
 function tblover(a) {
	a.style.borderColor='white';
}
// ================== cursor out of TABLE ================== 
 function tblout(a) {
	a.style.borderColor='#AAAAAA';
}
// ================== cursor over PICTURE ==================
 function picover(a) {
	a.style.borderColor='white';
}
// ================== cursor out of PICTURE ==================
 function picout(a) {
	a.style.borderColor='#AAAAAA';
}
// ================== click over table in MENU ==================
 function golink(a) {
	window.parent.main.location.href=a;
}

//################ TRACKER ARTFETCH #####################
function tracker() {
	var a = document.write

	document.open();
	a("<IFRAME src=\"tracker.htm\" WIDTH=\"1\" HEIGHT=\"1\" SCROLLING=\"no\" FRAMEBORDER=\"0\" MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\" ></IFRAME>");
	document.close();
}

//################ CREATE PICTURES DATABASE #####################
// pp[i][p] --- p= 0-no, 1-name, 2-[width x height x deapth], 3-price

var pp=new Array();

function piclist() {  
  for (var i=1; i < piclst.length; i++) {                                
    pp[i]=new Array();   // ----------  WORKS!!!
    pp[i][0] = piclst[i].substring(0, piclst[i].indexOf('_')); 
    pp[i][1] = piclst[i].substring(4, piclst[i].lastIndexOf('_')).toUpperCase(); // ----------  WORKS!!!
      if (pp[i][1].indexOf('--') != -1) {
	pp[i][1] = pp[i][1].replace(/--/g, " ");
          if (pp[i][1].indexOf(' ') > 6) {  // ####### after that many letters make a new line FUFLO!=>??
            pp[i][1] = pp[i][1].replace(/ /, "<BR>");
          }
          if (pp[i][1].length - pp[i][1].lastIndexOf(' ') > 7) {  // ####### if LAST word is too long FUFLO!=>??
//            pp[i][1] = pp[i][1].replace(/ /, "<BR>");  // WORKS but i don't need it much
              if (pp[i][1].indexOf(" ") != -1)  {
pp[i][1] = pp[i][1].substring(0, pp[i][1].lastIndexOf(' '))+"<BR>"+pp[i][1].substring(pp[i][1].lastIndexOf(' '), pp[i][1].length);  // changes space from the end on <BR> -- NOT BAD!
              }
          }
      }
    pp[i][2] = piclst[i].substring(piclst[i].lastIndexOf('_')+1, piclst[i].indexOf('-$'));
    pp[i][3] = piclst[i].substring(piclst[i].indexOf('-$')+1, piclst[i].length-4);

  }
//alert(pp[i][1]);
}


//################ GROUP MULTIPLE PAGES #####################
var picsPerPage = 9; // ------------------------------------------------------------------- THE NOMBER OF PICTURES PER PAGE display

function pppage() {
noOfPages=Math.ceil((pp.length-1)/picsPerPage); // the total number of pages in the site
//alert(noOfPages);
return noOfPages;
}

//################ DRAWING PAGES # AT THE BOTTOM #####################
var currentPage = 1;

function drawPagesNo() {
//alert(pppage());
  var a = document.write

  if(pppage() > 1) {
    document.open();
        a("<CENTER><BR>pages | ");
    for (var p=1; p <= pppage(); p++) {  
        a("<A href=\"index.htm\" class=\"my\" target=\"_new\" onClick=\"repage("+p+"); return false;\" TITLE=\"CLICK\n  and\n go to\n  the\n page\n   #"+p+"\">");  
        a(" "+p+"</a> |");
    }
        a("</CENTER>");
    document.close();
  }
}

//################ TRY TO REPAGE #####################
function repage(p) {
//alert(p);
this.window.location.href="index.htm?"+p;   // adds the # of chosen page to the new URL
}

//################ GET REPAGE #####################
function getpage() {
        b=this.window.location.href;
	if (b.indexOf('?') != -1) {
		var p = b.substring(b.indexOf('?')+1, b.length);  // read the # of chosen page from the just loaded URL
//	alert(p);
        return p;

        }else{
        return 1;
        }
}

//################ DRAW ALL TABLES ##################### ------ works for one page
function drawtbl() { 
// alert(getpage());   // from i=(getpage()-1)*picsPerPage+1 to getpage()*picsPerPage+1 || pp.length ---- doesnt work for some reason
  var a = document.write
  document.open();

  for (var i=(getpage()-1)*picsPerPage+1; i < (getpage()*picsPerPage+1); i++) {
    if (i >= pp.length) {drawPagesNo(); return false;}

  a("<table border=\"0\" class=tbls align=\"left\" onMouseOver=\"tblover(document.all[this.sourceIndex])\" onMouseOut=\"tblout(document.all[this.sourceIndex])\">");
  a("<tr><td><img src=\"0_15x15_lup.gif\"></td><td background=\"0_ruler_up.gif\"></td><td><img src=\"0_15x15_rup.gif\" align=\"right\" HSPACE=\"0\"></td></tr> ");
  a("");
  a("<tr><td background=\"0_ruler_left.gif\"></td><td><A HREF=\"");
  a(pp[i][0]+"b"+piclst[i].substring(3, piclst[i].length)); // ########## link to the big picture 
  a("\" onClick=\"return false;\"><img src=\"");
  a(piclst[i]); // ########## picture in the table
  a("\" alt=\""+pp[i][3]+"-[negotiable]\" "); // ########## ALT text for pictures ($price)
  a("border=\"1\" onMouseOver=\"picover(document.all[this.sourceIndex])\" ");
  a("onMouseOut=\"picout(document.all[this.sourceIndex])\" ");
  a("onClick=\"picwindow(this.alt,document.all[this.sourceIndex-1].href)\"></A></td> <td class=note >");
//  a(piclst[i].substring(4, piclst[7].lastIndexOf('_')).toUpperCase()); // ########## the name of suvenir - WORKS!
  a(pp[i][1]); // ########## the name of suvenir
  a("<HR>");
  a(pp[i][2]); // ########## 3 dementions
  a("mm<BR>");
  a(pp[i][3]); // ########## $price 
  a("<BR></td></tr> ");
  a("");
  a("<tr><td><img src=\"0_15x15_ldn.gif\"></td><td></td><td><img src=\"0_15x15_rdn.gif\" align=\"right\" HSPACE=\"0\"></td></tr></table> ");
  }
    drawPagesNo();
  document.close();
}

// ###################### year #######################
function year() {
now= new Date();
yr=now.getYear();
//alert(now.getYear());
document.open();
document.write("-"+yr);
document.close();
}

//##### random MUSIC #################
function rndmusic() {
muslist=
[
"0m_axelfouly.mid",
"0m_cyganka.mid",
"0m_gtrsolo.mid",
"0m_masha.mid",
"0m_mozart.mid",
"0m_natives.mid",
"0m_nomemory.mid",
"0m_quartet.mid",
"0m_roma.mid"
];

music=muslist[Math.round(Math.random()*(muslist.length-1))]; // music=0 to # of the last file in the Array muslist
	var a = document.write
	document.open();
a('<BGSOUND loop=infinite src=\"'+music+'\">');
	document.close(); 
}

// ############ PAGING for content's files #############
function head() {piclist(); getpage()} // {mystle(); return true;}
function bodytop() {topstart();}  // {home();}
function bodybot() {tracker(); a(); piclist(); rndmusic();}  // {scrn(); piclist(); }
function myload() {return true;}
function myexit() {return true;}

// #####################################################
// ###################### E-MAIL #######################
function mail(whome) {
  temp_win= open("", "mail", "width=500,height=40,status=0,toolbar=0,menubar=0,location=0,directories=0,scrollbars=0,resizable=0,");
  var a = temp_win.document.write;
  var ad = "ndraw";
  var ad1 = "yahoo.com";
  var ad3 = "ndraw";
  var ad4 = "yandex.ru";
  temp_win.document.open();
  
  a("<html><head><title>E-MAIL</title>");
  a("<META name=\"robots\" CONTENT=\"noindex\">\n");
  a("<META name=\"distribution\" CONTENT=\"iu\">\n");
  a("<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n");
  a("<META HTTP-EQUIV=\"Window-target\" CONTENT=\"_blank\">\n");
  a("<BASE target=\"_blank\">\n");
  a("<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"runstyle.css\">\n"); // ######## file of CCS
//  a("<SCRIPT SRC=\"artfetch.js\">alert(\'ARE YOU SURE THAT YOU ARE WITHIN MY WEBSITE NOW??\'); </SCRIPT>\n");
  a("<script language=\"JavaScript\"> <!-- \n function a() {\n this.window.focus(); \n } \n // --> </script>\n</HEAD>\n");
  a("<BODY BACKGROUND=\"0_zad_tr.gif\" bgcolor=\"#333333\" text=\"#C0C0C0\" link=\"#FFFFFF\" vlink=\"#999077\" alink=\"#FFC15B\">\n");
  a("<script language=\"JavaScript\"> <!-- \n a(); // --> </script>\n");
  a("<center><BR>");
  a("<TABLE WIDTH=\"86%\" ALIGN=\"center\" BORDER=0 CELLSPACING=2 CELLPADDING=0> <TR><TD CLASS=\"BUTTON\">");
  a("<A href=\"mailto:"+ad+"@"+ad1+"?subject=artfetch of MAMMOTH TUSK from "+whome+"&body=PLEASE, DO NOT DELETE THE WORD &quot;artfetch&quot; IN THE SUBJECT LINE!!&bcc="+ad3+"@"+ad4+"\" TITLE=\"Email to " + whome + "\">JUST CLICK HERE TO SEND MAIL &nbsp;@</a></TD></TR></TABLE>");
  a("THIS IS SOME SORT OF PROTECTION FROM SPAMMERS");
  a("</center>");
  a("</body></html>");

  temp_win.document.close();  
}

//################ FOOTER 
function footer() {
	var a = document.write

	document.open();
	a("<CENTER><BR><HR><DIV ALIGN=\"center\"><SMALL>");
	a("<font color=\"#FFFFFF\">This site was established on November 10, 2002 and is maintained by <A HREF=\"javascript:mail()\" onClick=\"mail(\'Webmaster\'); return false;\" TITLE=\"Email the Webmaster\"> <font color=\"#FFFF00\">nDraw<SUP>&#174;</SUP> </font></a><BR>");
	
	a("<P>This page is last time updated ");
	a("<script language=\"JavaScript\"> <!-- \n updated(); // --> </script><BR>");

	a("<A HREF=\"http://nDraw.tripod.com/fr_set.htm\" TARGET=\"_blank\"><font color=\"#FFFF00\">Copyright</A><SUP>&#169;</SUP> </font>1998- by the HTML Writers FROM RUSSIA, nDraw, Inc. </font></SMALL></DIV><HR>");
	
	document.close();
}


//################ make page with BIG PICTURE #####################
function picwindow(price,pic) {
folder=pic.substring(0, pic.lastIndexOf('/'));

if(pic.substring(pic.lastIndexOf('/')+1, pic.lastIndexOf('/')+4).substring(0,1)!='0') i=pic.substring(pic.lastIndexOf('/')+1, pic.lastIndexOf('/')+4).substring(0, 3);
if(pic.substring(pic.lastIndexOf('/')+1, pic.lastIndexOf('/')+4).substring(0,2)!='00') i=pic.substring(pic.lastIndexOf('/')+1, pic.lastIndexOf('/')+4).substring(1, 3); 
else i=pic.substring(pic.lastIndexOf('/')+1, pic.lastIndexOf('/')+4).substring(2, 3); // now i=number of the picture


  pic_win= open("", "picwindow", "width=320,height=200,status=0,toolbar=0,menubar=0,location=0,directories=0,scrollbars=yes,resizable=yes");
  pic_win.window.moveTo(1,1);
  var a = pic_win.document.write;
  var ad = "nDraw";
  var ad1 = "yahoo.com";
  var ad3 = "ndraw";
  var ad4 = "yandex.ru";
  
//  var whome = folder.substring(folder.lastIndexOf('/')+1, folder.length)+"'s "+'artwork #:'+pic.substring(pic.lastIndexOf('/')+1, pic.length-4);
  var whome = "MAMMOTH "+'artwork #:'+pic.substring(pic.lastIndexOf('/')+1, pic.length-4);

  pic_win.document.open();

a("<HTML><HEAD><TITLE>THE ARTWORK</TITLE>\n");
a("\n");
a("<SCRIPT language=\"JavaScript1.2\"> <!-- \n function a() {\n this.window.focus(); \n }");
a(" \n // --> </SCRIPT>\n</HEAD>\n");

a("<BODY background=\"0_zad_tr.gif\" bgcolor=\"#444444\" text=\"#C5C5C5\" link=\"#DDDDDD\" vlink=\"#AAAAAA\" alink=\"#FFC15B\" bgproperties=\"fixed\">\n");
  a("<script language=\"JavaScript1.2\"> <!-- \n a(); // --> </script>\n");
a("\n");
a("<table border=\"0\"><tr><td><table border=\"0\" class=tbls id=\"wintable\"><tr><td>\n");
a("<img src=\"0_15x15_lup.gif\"></td><td></td><td><img src=\"0_15x15_rup.gif\"></td></tr>\n");
a("\n");
a("<tr><td></td><td><img src=\""+pic+"\" style=\"border:1px solid #FFFFFF;\" name=\"bigpic\" ></td><td></td></tr>\n");
a("\n"); // #########################################################################
a("<tr><td><img src=\"0_15x15_ldn.gif\"></td><td></td><td><img src=\"0_15x15_rdn.gif\"></td></tr></table></td><td>\n");

a("");
a("<FONT style=\"FILTER: Shadow(Color=#000000,Direction=135); WIDTH: 100%\">The</FONT><BR>");
a("<B><FONT style=\"font-weight: bold; font-size: 1.6em;\" style=\"FILTER: Shadow(Color=#000000,Direction=135); WIDTH: 100%\">");
a(pp[i][1]); // ######## the NAME of artwork
a("</FONT></B><HR>width x height x depth:<BR><B>");
a(pp[i][2]); // ######## the SIZE
a("mm</B><BR>Price (negotiable): <B>"+pp[i][3]+"</B><BR>\n"); // ######## the PRICE (formerly it was +price+)
a("\n");
a("<HR>Just contact us by e-mail: <BR>\n");
// a("<a HREF=\"javascript:mail()\" onClick=\"mail(\'the Artist\'); return false;\" TITLE=\"Write to the Artist\"><img src=\"0_mail.gif\" border=\"0\" align=\"middle\" style=\"FILTER: Shadow(Color=#000000,Direction=135)\"></a><BR>\n");
  a("<A href=\"mailto:"+ad+"@"+ad1+"?subject=artfetch of the "+whome+"&body=PLEASE, DO NOT DELETE THE WORD &quot;artfetch&quot; IN THE SUBJECT LINE!!&bcc="+ad3+"@"+ad4+"\" TITLE=\"Email about " + whome + "\"><img src=\"0_mail.gif\" border=\"0\" align=\"middle\" style=\"FILTER: Shadow(Color=#000000,Direction=135)\"></a><BR>\n");
a("Please, be sure that the <BR>title of this masterpiece <BR>is in your message<BR>\n");
a("\n");
a("</td></tr></table></body></HTML>\n");

  pic_win.document.close(); 

//alert(pic_win.window.document.getElementsByTagName("table").id);
//alert(pic_win.window.document.tables.wintable.height);
//alert(pic_win.window.wintable.pixelHeight); undefined

	for (var j = 1; j < 20 || pic_win.window.document.images.bigpic.width==0 || pic_win.window.document.images.bigpic.height==0; j++) {
if (pic_win.window.document.images.bigpic.width==0 || pic_win.window.document.images.bigpic.height==0) {
setTimeout("pic_win.window.blur()", 1000);
pic_win.window.resizeTo(pic_win.window.width=pic_win.window.document.images.bigpic.width+275,pic_win.window.height=pic_win.window.document.images.bigpic.height+115);
pic_win.window.focus();
}else{
pic_win.window.resizeTo(pic_win.window.width=pic_win.window.document.images.bigpic.width+275,pic_win.window.height=pic_win.window.document.images.bigpic.height+115);
pic_win.window.focus();
}
	}
//alert(pic_win.wintable.pixelWidth); undefined
}

