var global_bDirty;

function global_SetDirty(b)
{
	global_bDirty = b;
}

function global_GoHref(href)
{
	if (global_bDirty == true)
	{
		if (!confirm("Continue without saving changes?"))
			return;
	}

	window.location = href;
}

function global_ValidateFormControl(ctrl, msg, regExp, isReq)
{
	var bRet = true;

	// Check to see if control = text, test if is required and valid		
	if(null != ctrl.type && ("text" == ctrl.type.toLowerCase() || "password" == ctrl.type.toLowerCase()))
	{
		if(null == isReq)
			isReq = true;
		
		var bTextBoxEmpty = /^\s*$/.test(ctrl.value);
		
		if(bTextBoxEmpty && isReq)
			bRet = false;
			
		if(!bTextBoxEmpty && regExp != null)
			bRet = regExp.test(ctrl.value);	
	}
	// if error display alert message			
	if (!bRet)
	{
		ctrl.type ? ctrl.focus() : ctrl[0].focus();
		alert(msg);
	}
	
	return bRet;
}