function getElementWithId(id)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		return document.getElementById(id);
	}	
	else if (document.all)
	{
	// this is the way old msie versions work
		return document.all[id];
	}	
	else if (document.layers)
	{
	// this is the way nn4 works
		return document.layers[id];
	}	
}

function hideItem(id)
{
	getElementWithId(id).style.display = "none"				
}

function showItem(id)
{
	getElementWithId(id).style.display = ""
}

function sortDataField(name)
{
	oldSortFieldValue = document.dataFieldForm.sortField.value;
	oldSortOrderValue = document.dataFieldForm.sortOrder.value;
	
	
	if(oldSortOrderValue == "ASC" && oldSortFieldValue == name)
	{
		newSortOrderValue = "DESC";
	}
	else if(oldSortOrderValue == "DESC" && oldSortFieldValue == name)
	{
		newSortOrderValue = "ASC";	
	}
	else
	{	
		newSortOrderValue = "ASC";		
	}
	document.dataFieldForm.sortOrder.value = newSortOrderValue;
	document.dataFieldForm.sortField.value = name;
		
	document.dataFieldForm.submit();
}

function checkConfirmation(msg, link)
{
	if (confirm(msg))
	{
		window.location.replace(link);		
	}
	else
	{
		return false;
	}
}

function isValidEmail(str) 
{
  	return (str.indexOf("@") > 0);
}

function isEmpty(str) 
{
  	return trimString(str).length == 0;
}

function trimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}
	
