function checkLogForm(aaa)	{
	if ((aaa.username.value != "" || aaa.pswd.value != "") && (aaa.lname.value != "" && aaa.fname.value != "" && aaa.email.value != ""))		{
		alert("Please provide your username and password; or first name, last name and e-mail address to login to www.jcenonline.com.")
		return false;
	}
}
function setSelect(param1, param2)	{
var i
for (i=0; i < param1.length; i++)	{
	if (param1.options[i].value == param2)	{
		param1.selectedIndex = i;
		break;
	}
}
}

function setChecked(param1, param2)	{
var i
for (i=0; i < param1.length; i++)	{
	if (param1[i].value == param2)	{
		param1[i].checked = true;
		break;
	}
//	else	{alert(param1[i].value + " -- " + param2)}
}
}	

function checkElem(elem, msg)	{
	if ((elem.value == "") || (elem.value.length == 0))	{
		alert("Please fill in the '" + msg + "' field.");
		elem.focus();
		return false;
	}
	if (!checkBadSmb(elem, msg))	{ return false;	}
	return true;
}

function checkState(elem1, elem2)	{
if ((elem1.selectedIndex == 224) && (elem2.selectedIndex == 0 || elem2.selectedIndex > 52)) {
		alert("If you have selected USA, please select the \"State\".");
		elem2.focus();	return false;	}
if ((elem1.selectedIndex == 39) && (elem2.selectedIndex < 53)) {
		alert("If you have selected CANADA, please select the \"Province\".");
		elem2.focus();	return false;	}	
	//alert(elem1.selectedIndex + "\n" + elem2.selectedIndex)
	return true;
}

function flashState(elem1, elem2)	{
	if (elem1.selectedIndex != 224 && elem2.selectedIndex != 0)	{
		elem2.selectedIndex = 0
	}
}

function checkBadSmb(elem, msg)	{
var regexp = /(\s{2,})|(\|)|(\*)|(\_)|(\@)|(\!)|(\^)|(\<)|(\>)|(\+)|(\%)|(\;)/g
	if (regexp.test(elem.value))	{
		alert("Invalid symbols or too many whitespaces are in the " + msg + " field."); elem.focus(); return false;
	}
	if (elem.value.indexOf('"') != -1)	{
		for (var i=0; i < elem.value.length; i++)	{
			elem.value = elem.value.replace('"',"'");
		}
	}
	return true;
}

function checkPhone(elem, msg)	{
	var regex = /^(\(?\+?[0-9]*\)?)?[0-9_\- \(\)]*$/;
	if ((!regex.test(elem.value)) || (elem.value.length < 2))	{
		alert("Please enter " + msg +" number.");
		elem.focus();
		return false;
	}
	return true;
}

function checkEmail(elem) {
var regex = /^([\w\-\.]+)@((\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([\w\-]+\.)+)([a-zA-Z]{2,4}))$/
	if (elem.value.length < 6)	{
		alert("Please enter your e-mail address.");elem.focus(); return false;
	}	
	if (!regex.test(elem.value))	{
			alert("Please enter your e-mail address.");	elem.focus(); return false;
	}
	return true;
}

function checkSelect(elem, msg)	{
	if (elem.selectedIndex == 0)	{
		alert("Please select " + msg);
		elem.focus()
		return false;
	}
	return true
}

function checkCBox(param1, param2)	{
var i, aaa
aaa = eval("document.userForm." + param1.name)
	for (i=0; i < aaa.length; i++)	{
		if (i != param2)	{ 	aaa[i].checked = false;	}
	}
}

function isCBoxChecked(elem, msg)	{
var i 
var tmpFlag = 0
	for (i=0; i < elem.length; i++)	{
		if (elem[i].checked == true)	{	
			tmpFlag = 1
			break
		}
	}
	if (tmpFlag == 0) { 
		alert("Please select " + msg)
		elem[0].focus();
		return false; 
	}
	return true;
}

function addAuthorFromList(source, target)	{
if ( source.selectedIndex > -1)	{
var tmpVal = source.options[source.selectedIndex].text
	if (target.value == "")	{ 
		target.value = tmpVal
	}
	else	{
		if ( target.value.indexOf(tmpVal) == -1 )	{
			target.value = target.value + "; " + tmpVal;
		}
	}
}
}

function addAuthorNew(aaa)	{
var tmpVal1 = aaa.autFName.value + " " + aaa.autMName.value + " " + aaa.autLName.value + " " + aaa.autSffx.value + ", " + aaa.autDegree.value
var tmpVal2 = aaa.autTitle.value + "|" + aaa.autFName.value + "|" + aaa.autMName.value + "|" + aaa.autLName.value
tmpVal2 = tmpVal2  + "|" + aaa.autSffx.value + "|" + aaa.autDegree.value + "|" + aaa.autSpec.value + "|" + aaa.autBio.value + "*"

if (aaa.autFName.value != "" && aaa.autLName.value != "")	{
	if (aaa.resourceAddInfo.value == "")	{ 
		aaa.resourceAddInfo.value = tmpVal1
		aaa.newAuthors.value = (aaa.newAuthors.value == "")? tmpVal2 : aaa.newAuthors.value + tmpVal2
	}
	else	{
		if ( aaa.resourceAddInfo.value.indexOf(tmpVal1) == -1 )	{
			aaa.resourceAddInfo.value = aaa.resourceAddInfo.value + "; " + tmpVal1;
			aaa.newAuthors.value = (aaa.newAuthors.value == "")? tmpVal2 : aaa.newAuthors.value + tmpVal2;
		}
	}
}
aaa.autFName.value = ""; aaa.autMName.value = ""; aaa.autLName.value = ""; 
aaa.autSffx.value = "";
aaa.autTitle.value = ""; aaa.autDegree.value = ""; aaa.autSpec.value = ""; aaa.autBio.value = "";

tmpVal1 = ""
tmlVal2 = ""
}

function sendFormTo(aaa,url, target)	{
	aaa.action = url;
	if (target != "")	{ aaa.target = target }
	aaa.submit();

}

function checkForEmailMatch(elem1, elem2) {
	if (elem1.value != elem2.value)	{
		alert("Your email addresses do not match.  Please confirm your Email Address.");
		elem2.focus();
		return false;
	}
	return true;
}

/*------------check for pasting into email box--------------------*/
function checkForPaste(evt)
 {
	var textBox = getObject('emailConfirm');
	var charCode = (evt.which) ? evt.which : event.keyCode
	
	if (charCode == 17) { 		//  ctrl
		alert('Please do not attempt to paste your email.  Instead, please retype it into the Confirm Email textbox.');
		return false;
	}
	return true;
 }
 
function getObject(obj)
  {
	  var theObj;
	  if (document.all) {
		  if (typeof obj=='string') {
			  return document.all(obj);
		  } else {
			  return obj.style;
		  }
	  }
	  if (document.getElementById) {
		  if (typeof obj=='string') {
			  return document.getElementById(obj);
		  } else {
			  return obj.style;
		  }
	  }
	  return null;
  }
/*-----END check for pasting into email box--------------------------*/