/**
	* Function to get an element by it's ID parameter in both IE and Mozilla based browsers.
	*/
function getElement(id)
{
	if(document.all)
	{
		return document.all[id];
	}
	else if(document.getElementById)
	{
		return document.getElementById(id);
	}
	else
	{
		for(iLayer = 1; iLayer < document.layers.length; iLayer++)
		{
			if(document.layers[iLayer].id == id)
			{
				return document.layers[iLayer];
			}
		}
	}
	return null;
}

/**
	* Set an input value
	*/
function setValue(id, value)
{
	var obj = getElement(id);
	obj.value = value;
}

/**
	* Submits a form with the specified ID and action
	*/
function submitForm(form_id, form_action)
{
	var form = getElement(form_id);
	try
	{
		if(form_action != "")
		{
			form.elements.action.value = form_action;
		}
		form.submit();
	}
	catch(error)
	{
		alert("There was an error:\n\n"+error.description);
	}
}

/**
	* Hide or show a block level element
	*/
function toggleVisible(id)
{
	var obj = getElement(id);
	if(obj.style.display == "block")
	{
		obj.style.display = "none";
	}
	else if(obj.style.display == "none")
	{
		obj.style.display = "block";
	}
	else
	{
		obj.style.display = "block";
	}
}

/**
	* Goto the specified URL
	*/
function gotoUrl(url)
{
	document.location.href=url;
}

function showMenu(id)
{
	$(document).ready(function(){
		/*
		var class_name = ($("#"+id+" dt a").attr("class"));
		$("#"+id+" dt a").removeClass();
		$("#"+id+" dt a").addClass(class_name+"_current");
		*/
		//$("#"+id+" dd").slideDown("slow");
		$("#"+id+" dd").show();
	});
}

function clearUsername()
{
	var obj = getElement('UserName');
	if(obj.value == "Username")
	{
		obj.value = "";
	}
}

function clearPassword()
{
	var obj = getElement('PassWord');
	if(obj.value == "Password")
	{
		obj.value = "";
	}
	obj.type = "password"
}

function clearIndexUsername()
{
	var obj = getElement('index_username');
	if(obj.value == "Username")
	{
		obj.value = "";
	}
}

function clearIndexPassword()
{
	var obj = getElement('index_password');
	if(obj.value == "Password")
	{
		obj.value = "";
	}
	obj.type = "password"
}

function checkEnter(event)
{
	return(event.keyCode == 13);
}
