// JavaScript Document
function isEmailAddr(email)
{
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function validEmail(formField,fieldLabel,required)
{
	var result = true;
	if (required && !check_input(formField,fieldLabel))
		result = false;
	if (result && ((formField.value.length < 3) || !isEmailAddr(formField.value)) )
	{
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		formField.focus();
		result = false;
	}
  return result;
}

function check_input(obj,name)
{
	if(!obj.value.length)
	{
		alert('WARNING : Please provide '+name+ ' in the form');
		obj.focus();
		return false;
	}
	return true;
}

function check_date_field(obj,name,value)
{
	if(!obj.value.length || obj.value==value)
	{
		alert('WARNING : Please provide '+name+ ' in the form');
		obj.value='';
		obj.focus();
		return false;
	}
	return true;
}


function check_select(obj,name)
{
	if(!obj.options.selectedIndex)
	{
		alert('WARNING : Please select '+name+ ' from Pop-Down list');
		obj.focus();
		return false;
	}
	return true;
}

function check_radio(obj,name,count)
{
	var flag=0;
	for(var i=0;i<count;i++)
	{
		if(obj[i].checked)
		{
			return true;
		}
	}
	alert('WARNING : Please select '+name);
	obj[0].focus();
	return false;
}

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{

  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }

  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}
