// javascript functions

function changeImage(id,img,doc)
{
	if (typeof(id)=="undefined" || typeof(img)=="undefined" || id==null || img==null) return;
	if (typeof(doc)=="undefined" || doc==null)	doc=document;
	findImage(id,doc).src = preloadImage(img).src;
	return;
}

function show(obj, newleft, newtop, newzindex, doc)
{
	
	if (newleft!=null)
		newleft = Math.round(newleft);
	if (newtop!=null)
		newtop = Math.round(newtop);
	if (doc==null || typeof(doc)=="undefined")	doc=document;
	if (doc.all)
	{
		if (doc.all[obj]==null) return;
		with(doc.all[obj].style)
		{
			visibility="visible";
			if (newleft!=null)
				left = newleft;
			if (newtop!=null)
				top = newtop;
		}
	}
	else if (doc.getElementById)
	{
		if (doc.getElementById(obj)==null) return;
		element=doc.getElementById(obj);
		var style="position: absolute; visibility: visible;";
		if (newleft!=null)
			style+=" left: " + newleft + "px;";
		if (newtop!=null)
			style+=" top: " + newtop + "px;";
		if (newzindex!=null)
			style+=" z-index: " + newzindex + ";";
		element.setAttribute("style",style);
	}
	else if (doc.layers)
	{
		if (doc.layers[obj]==null) return;
		with(doc.layers[obj])
		{
			visibility="show";
			if (newleft!=null)
				left = newleft;
			if (newtop!=null)
				top = newtop;
		}
	}
	return;
}

function hide(obj, doc)
{
	if (doc==null || typeof(doc)=="undefined")	doc=document;
	if (doc.all)
	{
		if (doc.all[obj]==null) return;
		with(doc.all[obj].style)
		{
			visibility="hidden";
		}
	}
	else if (doc.getElementById)
	{
		if (doc.getElementById(obj)==null) return;
		element=doc.getElementById(obj);
		element.setAttribute("style","position: absolute; visibility: hidden;");
	}
	else if (doc.layers)
	{
		if (doc.layers[obj]==null) return;
		with(doc.layers[obj])
		{
			visibility="hide";
		}
	}
	return;
}

/*                                
function show(id, newleft, newtop, newwidth, newheight)
{
	doc=document;
	if (doc.all)
	{
		if (doc.all[id]==null) return;
		with(doc.all[id].style)
		{
			visibility="visible";
			if (newleft!=null)
				left = newleft;
			if (newtop!=null)
				top = newtop;
			if (newwidth!=null)
				width = newleft;
			if (newheight!=null)
				height = newtop;
		}
	}
	else if (doc.layers)
	{
		var nslay=findLayer(id,doc);
		with(nslay)
		{
			visibility="show";
			if (newleft!=null)
				left = newleft;
			if (newtop!=null)
				top = newtop;
		}
	}
	return;
}

function hide(id, doc)
{
	if (doc==null || typeof(doc)=="undefined")	doc=document;
	if (doc.all)
	{
		if (doc.all[id]==null) return;
		with(doc.all[id].style)
		{
			visibility="hidden";
		}
	}
	else if (doc.layers)
	{
		if (doc.layers[id]==null) return;
		with(doc.layers[id])
		{
			visibility="hide";
		}
	}
	return;
}
*/
// find a layer in the document IE, NS and W3C --------------------------------------
function findImage( id, doc )
{
 if (id && id  != null)
 {
  if (!doc || doc == null)
  {
   doc = document;
  }
  var node = null;
  if ( doc.layers )
  {
   node = doc.images[id];
   for( var i=0; !node && i < doc.layers.length; i++)
   { 
  	node = findImage( id, doc.layers[i].document );
   }   
  }
  else
  {
   node = doc.images[id];
  }
  return node;
 }
 return null;
}

// find a layer in the document IE, NS and W3C --------------------------------------
function findLayer( id, doc )
{
 if (id && id  != null)
 {
  if (!doc || doc == null)
  {
   doc = document;
  }
  var node = null;
  if ( doc.all )
  {
   node = doc.all[id];
  }
  else if ( doc.getElementById )
  {
   node = doc.getElementById(id);
  }
  else if ( doc.layers )
  {
   node = doc.layers[id];
   for( var i=0; typeof(node)=="undefined" && doc.layers && i < doc.layers.length; i++)
   { 
  	node = findLayer( id, doc.layers[i].document );
   }   
  }
  return node;
 }
 return null;
}

// preload images
function preloadImage(name)
{
	if (typeof(name)=="string")
	{
		var img=new Image();
		img.src=name;
	}
	else if (typeof(name)=="image" || (typeof(name)=="object" && name.src))
	{
		var img=name;
	}
	else
	{
		return null;
	}
	return img;
}
// preload images
function preloadImages( )
{
  var d=document; 
  if( d.images )
  {
    var parameter = preloadImages.arguments;
	if ( parameter && parameter != null)
	{
     for(i = 0; i < parameter.length; i++)
	 {
	   preloadImage( parameter[i] );
	 }
	}
  }
}
