// JavaScript Document
function MM_openBrWindow(theURL,winName,features) { //v2.0
	var w = window.open(theURL,winName,features);
	w.focus();
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

/**
 *  << JavaScript Functions [Utilities] File >>
 *  CopyRight Netways 2003 
 *  Please do not distribute
 *
 *  Author: Fadi Chamieh
 *  =======
 */
function trimSpaces ( str ) {

	var trimmed = '';
	var start_edge = 0;
	var end_edge = 0;

	// Detect start edge
	for(var i = 0; i < str.length; i++)
		if (str.charAt(i) != ' ') {
			start_edge = i;
			break;
		}
	// Detect end edge
	for(i = str.length - 1; i > 0; i--)
		if (str.charAt(i) != ' ') {
			end_edge = i;
			break;
		}
	// Get what's between edges
	for(i = start_edge; i <= end_edge; i++)
		trimmed += str.charAt(i);

	if (trimmed == ' ') trimmed = '';

	return trimmed;

} // end function trimSpaces


function areCharsIn( checkStr, validCharsStr ){

	var checkOK = validCharsStr;
	var allValid = true;
	checkStr += '';

	// if empty return false
	if (checkStr == '') return false;

	for (i = 0;  i < checkStr.length;  i++)	{

		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;

		if (j >= checkOK.length) {
			allValid = false;
			break;
		}
	}
	return ( allValid );
}

function isAlphaNumeric( checkStr ) {
	return areCharsIn(checkStr, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_");
}

function isNumeric( checkStr ) {
	return areCharsIn(checkStr, "0123456789.+-");
}

function noneChecked (oForm, strName) {
	var flag = true;
	for (var i = 0; (i < oForm.elements.length) && (flag == true); i++) {
		var chk = oForm.elements[i];
		var chkName = chk.name;
		if (chkName.indexOf(strName) >= 0 && chk.checked) {
			flag = false;
		}
	}
	return flag;
}

function isValidEmail( testEmail ) {
	if (testEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
		return false;
	else
		return true;
}

function checkItems( item, baseName )
{
	var frm = item.form;
	for(var i = 0; i < frm.elements.length; i++)
	{
		var el = frm.elements[i];
		if (el.name.indexOf(baseName) == 0)
			el.checked = item.checked; 
	}
}

 
// Check if a form input is empty, also checks for emails
function isEmptyField( formItem, display, strMessage )
{
	strMessage = (strMessage) ? strMessage : "Please fill-in the " + display;
	
	var canFocus = (formItem.type.toLowerCase().indexOf("hidden") >= 0) ? false : true;
	
	if(trimSpaces(formItem.value) == "")
		{
			alert(strMessage);
			if(canFocus) formItem.focus();
			return true;
		}
	else if(display.toLowerCase().indexOf("email") >= 0)
		{
			if (! isValidEmail(formItem.value))
			{   alert(strMessage);
				if(canFocus) formItem.focus();
				return true;
			}
		}
	else if(display.toLowerCase().indexOf("year") >= 0)
	    {
	        if(! isValidYear(formItem.value))
	        {   alert(strMessage + " " + display);
				if(canFocus) formItem.focus();
				return true;
	        }
	    }
	return false;
}





//-->

