//<script language="JavaScript" type="text/javascript">
//<!--
// some constants:
var thumbpath='thumbnails/';
var imagepath='images/';
var imagetag='<img src="'
var imagetagclose='" border=0 alt="Click me">';
var altrag='<a href="content.htm?pixname=' ;
var alttagclose='" target="content">';
var alttagend="</a>";


var pixlist=pix.split(',');
var	L=pixlist.length;



function SearchAndReplace(Content, SearchFor, ReplaceWith) {

	var tmpContent = Content;
	var tmpBefore = new String();   
	var tmpAfter = new String();
	var tmpOutput = new String();
	var intBefore = 0;
	var intAfter = 0;

	if (SearchFor.length == 0)
		return;


	while (tmpContent.toUpperCase().indexOf(SearchFor.toUpperCase()) > -1) {
	
		// Get all content before the match
		intBefore = tmpContent.toUpperCase().indexOf(SearchFor.toUpperCase());
		tmpBefore = tmpContent.substring(0, intBefore);
		tmpOutput = tmpOutput + tmpBefore;

		// Get the string to replace
		tmpOutput = tmpOutput + ReplaceWith;


		// Get the rest of the content after the match until
		// the next match or the end of the content
		intAfter = tmpContent.length - SearchFor.length + 1;
		tmpContent = tmpContent.substring(intBefore + SearchFor.length);

	}

	return tmpOutput + tmpContent;

                          }


function drawPicture() {	
	var queryString = location.search.substring(1);
	var args = queryString.split('&');
	var pixname="images/loading.jpg"
	var fponame=pixname;
 	if (queryString) {
		//document.write(queryString);
		for (var a = 0; a < args.length; a++) {
			var field = args[a].split('=');
			var fieldName = unescape(field[0]);
			if (fieldName == 'pixname')
   				{   pixname = SearchAndReplace(unescape(field[1]),"+"," ") }
			}
	}
	
	document.write('<IMG SRC="' + pixname + '" ALT="Sample image" NAME="sampleimage" lowsrc="' + fponame + '">');
//	alert(pixname);
	
	temp=pixname.split("/");
	whichsection=temp[0];
//	alert(whichsection);
	document.write('<style type="text/css">');
	document.write('<!--');
	document.write ( "a." + pixname + "{ color: black; text-style: underline; border: 1px; border-color: black;}" );
	document.write('-->');
	document.write('</style>');
	changeColor(whichsection,'black');
}






// -- pickrandom

function pickrandom() {
		var LL = Math.round(Math.random()*L);
		if (parent.frames.content) {parent.frames.content.location="content.htm?pixname=" + catpath + imagepath + pixlist[LL]}
		
	
	}


// -- thumbnail drawing for bottom frame:
function drawthumbs() {
 	for (i=0; i<L; ++i ) 	{
		document.write("<td>");
		document.write(altrag +   catpath + imagepath + pixlist[i] + alttagclose   );
		document.write(imagetag + catpath + thumbpath + pixlist[i] + imagetagclose );
		document.write(alttagend + " ");
		document.write("</TD>");
		}
	}
		
		
		
// allow access to client areas:
function checkclient() {
	d=prompt("Enter your username (all lower-case):","");
	parent.top.location="http://www.edmalitsky.com/" + d
	
}

// from
//http://www.quirksmode.org/js/cross_dhtml.html
// these are the scripts that are called in the links.

var DHTML = (document.getElementById || document.all || document.layers);

function invi(flag)
{
	if (!DHTML) return;
	var x = new getObj('text');
	x.style.visibility = (flag) ? 'hidden' : 'visible'
}

var texttop = 400;

function move(amount)
{
	if (!DHTML) return;
	var x = new getObj('text');
	texttop += amount;
	x.style.top = texttop;
}


function changeCol(col)
{
	if (!DHTML) return;
	var x = new getObj('text');
	x.style.color = col;
}

function changeStyle(style)
{
	if (!DHTML) return;
	var x = new getObj('text');
	x.style.fontStyle = style;
}

function changeFamily(family)
{
	if (!DHTML) return;
	var x = new getObj('text');
	x.style.fontFamily = family;
}


function getObj(name)
{
	//alert("object name: " + name );
	
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function changeColor(what,col)
{
	if (!DHTML) return;
	var x = new getObj(what);
	x.style.color = col;
}




// -->
//</script>
