//********************************************************************************************//
//                                       common.js                                            //
//********************************************************************************************//

function openGD(strURL)
{
	var winGD = window.open(strURL, 
	                        'GD',
				'top=0,left=0,scrollbars=yes,resizable=yes,toolbar=yes,status=yes,width=' + (window.screen.availWidth - 10) + ',height=' + (window.screen.availHeight - 30));
	winGD.focus();
}

function openMain(strURL)
{
	if (!window.top.opener)
	{
		window.opener.document.location = strURL;
		window.opener.focus();
	}
	else
	{
		winMain = window.open(strURL,
		                      'objMain',
		                      'width=780,height=550,top=0,left=0,menubar=yes,location=yes,scrollbars=yes,resizable=yes,toolbar=yes,status=yes');
		winMain.focus();
	}
}

function openHelp()
{
	var winHelp = window.open('../help/help.asp', 
	                          'objHelp',
	                          'width=750,height=500,scrollbars=yes,resizable=yes,top=0,left=0');
	winHelp.focus();
}

function openWin(strURL)
{
	winNew = window.open(strURL,
                         'objNewWindow',
                         'width=750,height=500,scrollbars=yes,resizable=yes,top=0,left=0');
	winNew.focus();
}

function isNumeric(strValue)
{
	var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;

	//check for numeric characters
	return objRegExp.test(strValue);
}

function isInteger(strValue)
{
	var objRegExp  = /(^-?\d\d*$)/;

	return objRegExp.test(strValue);
}

function isEmail(strValue)
{
	var objRegExp  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	return objRegExp.test(strValue)
}

function isBlank(strMyString)
{
	var chrMyChar;
	
	for (i=0; i < strMyString.length; i++)
	{
		if ((chrMyChar != ' ') && (chrMyChar !='\n') && (chrMyChar != '\t'))
		{
			return false;
		}
	}
	
	return true;
}

function showMessage(strMessage, objFormObject)
{
	alert(strMessage);
	objFormObject.focus();
	return false;
}

function isDate(str)
{
	var re = /^\d{1,2}\/\d{1,2}\/\d{4}$/
	if (re.test(str)) 
	{
		var dArr = str.split("/");
		var dd = parseInt(dArr[0]);
		var mm = parseInt(dArr[1])-1;
		var yyyy = parseInt(dArr[2]);
		var d = new Date(yyyy,mm,dd);
		var dateGood = d.getDate() == dd && d.getMonth() == mm && d.getFullYear() == yyyy;
		if (dateGood == false)
		{
			alert("This is an invalid date");
			return false;
		}
	}
	else 
	{
		alert("This is an invalid date");
		return false;
	}          

}