function toggleInput(obj, hasFocus, txt) {
	if (hasFocus && obj.value == txt) {
		obj.value = '';
	} else if (!hasFocus && obj.value == '') {
		obj.value = txt;
	}
}
function toggleFuzzyInput(obj, hasFocus, txt) {
	// return if the value 'contains' text
	if (hasFocus && obj.value.indexOf(txt) > -1) {
		obj.value = '';
	} else if (!hasFocus && trim(obj.value) == '') {
		obj.value = txt;
	}
}

function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   myfield.form.submit();
   return false;
   }
else
   return true;
}

function highlight(obj, doHighlight) {
	obj.style.backgroundColor = doHighlight ? "#fafafa" : "#eee"; 
}

function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

function preloadImages()
{
  if(document.images)
  {
    if(!document.imageArray) document.imageArray = new Array();
    var i,j = document.imageArray.length, args = preloadImages.arguments;
    
    for(i=0; i<args.length; i++)
    {
      if (args[i].indexOf("#")!=0)
      {
        document.imageArray[j] = new Image;
        document.imageArray[j++].src = args[i];
      }
    }
  }
}

function switchImage(imgName, imgSrc) 
{
  if (document.images)
  {
    if (imgSrc != "none")
    {
      document.images[imgName].src = imgSrc;
    }
  }
}

function showArea(id) {
	var area = document.getElementById(id);
	
	if (area.style.display == 'block')
		area.style.display = 'none';
	else
		area.style.display = 'block';
}

function openInfoPage(id) {
	window.open('infopage.php?id=' + id, '', 'scrollbars=yes, menubar=no, height=550, width=700, resizable=yes, toolbar=no, location=no, status=no');
}
