// JavaScript Document
window.onload = function()
{
	tmcontainer = document.getElementById('topmenucontainer');
	if (tmcontainer && tmcontainer.tBodies[0].rows[0].cells.length > 2)
	{
		var items = tmcontainer.tBodies[0].rows[0].cells;
		var count = items.length;
		for (var i=2; i<count; i+=2)
		{
			if (items[i].className == 'menuitem')
			{
				var img = items[i].getElementsByTagName('IMG')[0];
				img.onmouseover = setactive;
				img.onmouseout = setinactive;
			}
		}
	}
}

function setactive()
{
	var index = this.parentNode.parentNode.cellIndex;
	var current = tmcontainer.tBodies[0].rows[0].cells[index].getElementsByTagName('IMG')[0];
	var prev = tmcontainer.tBodies[0].rows[0].cells[index-1].getElementsByTagName('IMG')[0];
	if (this.className != 'activecell')
	{
		current.src = current.src.replace(/\.gif/, 'a.gif');
		prev.src = prev.src.replace(/\.gif/, 'a.gif');
	}
}

function setinactive()
{
	var index = this.parentNode.parentNode.cellIndex;
	var current = tmcontainer.tBodies[0].rows[0].cells[index].getElementsByTagName('IMG')[0];
	var prev = tmcontainer.tBodies[0].rows[0].cells[index-1].getElementsByTagName('IMG')[0];
	if (this.className != 'activecell')
	{
		current.src = current.src.replace(/a\.gif/, '.gif');
		prev.src = prev.src.replace(/a\.gif/, '.gif');
	}
}

function checkform(obj, message, classname)
{
	this.obj = obj;
	this.message = message;
	var thisobj = this;
	this.classtocheck = classname
	
	this.check = function(){
		var elements = thisobj.obj.elements;
		var count = elements.length;
		for (var i=0; i<count; i++)
		{
			if (elements[i].className == thisobj.classtocheck && elements[i].value == '')
			{
				alert(thisobj.message);
				elements[i].focus();
				return false;
			}
		}
		return true;
	}
}

var photos = function(obj, classname)
{
	this.obj = obj;
	this.classname = classname;
	var thisobj = this;
	var images = [];
	
	this.init = function()
	{
		var imgs = this.obj.getElementsByTagName('IMG');
		var count = imgs.length;
		for (var i=0; i<count; i++)
		{
			if (imgs[i].className == this.classname)
			{
				imgs[i].onclick = this.openwindow;
				imgs[i].style.cursor = 'pointer';
				var tmp = new Image();
				tmp.src = imgs[i].src.replace(/images\/photo\/200/, '/images/photo/500/');
				images[imgs[i].src] = tmp;
			}
		}
	}
	
	this.openwindow = function()
	{
		var path = images[this.src].src;
		var width = images[this.src].width;
		var height = images[this.src].height;
		var windowobj = window.open(path, 'newWindow', 'width='+(width + 40)+'px, height='+(height + 30)+'px, status=yes, toolbar=no, menubar=no, location=no, resizable=yes, scrollbars=yes');
		windowobj.document.onclick = function(){windowobj.close();}
	}
}
