function CheckUser(UserId)
{
	var form = document.getElementById("Form1");
	with (form)
	{
		if ( cmbTitle.value == "" )
		{
			alert("Please complete Title to proceed");
			cmbTitle.focus();
		}
		else if ( txtFName.value == "" )
		{
			alert("Please complete Name to proceed");
			txtFName.focus();
		}
		else if ( txtLName.value == "" )
		{
			alert("Please complete Surname to proceed");
			txtLName.focus();
		}
		else if ( cmbRole.value == "" )
		{
			alert("Please complete Role to proceed");
			cmbRole.focus();
		}
		else if ( txtEMail.value == "" )
		{
			alert("Please complete Email Address to proceed");
			txtEMail.focus();
		}
		else if (!blnCheckEmail(txtEMail.value))
		{
			alert("Please complete Email Address to proceed");
			txtEMail.focus();
		}
		else if ( txtUsername.value == "" )
		{
			alert("Please complete Username to proceed");
			txtUsername.focus();
		}
		else if ( UserId == "-1" && txtPassword.value == "" )
		{
			alert("Please complete Password to proceed");
			txtPassword.focus();
		}
		else if ( UserId == "-1" && txtPasswordCfm.value == "" )
		{
			alert("Please confirm the password to proceed");
			txtPasswordCfm.focus();
		}
		else if ( UserId != "-1" && txtPassword.value != "" && txtPasswordCfm.value == "" )
		{
			alert("Please confirm the new password to proceed");
			txtPasswordCfm.focus();
		}
		else
		{
			return true;
		}
	}
	return false;
}
//-----------------------------------

function CheckBranch()
{
	var form = document.getElementById("Form1");
	with (form)
	{		
		if ( txtName.value == "" )
		{
			alert("Please enter Name");
			txtName.focus();
		}
		else if ( txtAddress.value == "" )
		{
			alert("Please enter address");
			txtAddress.focus();
		}
		else if ( txtPhone.value == "" )
		{
			alert("Please enter Phone Number");
			txtPhone.focus();
		}
		else
		{
			return true;
		}
	}
	return false;
}
//-----------------------------------

function CheckCaseCat()
{
	var form = document.getElementById("Form1");
	with (form)
	{		
		if ( txtName.value == "" )
		{
			alert("Please enter name");
			txtName.focus();
		}
		else
		{
			return true;
		}
	}
	return false;
}
//-----------------------------------

function CheckNewsCase()
{
	var form = document.getElementById("Form1");
	with (form)
	{		
		if ( cmbCat.value == "" )
		{
			alert("Please enter Category");
			cmbCat.focus();
		}
		else if ( txtName.value == "" )
		{
			alert("Please enter name");
			txtName.focus();
		}
		else if (txtDescription.value == "")
		{
			alert("Please enter Description");
			txtDescription.focus();
		}
		else if (txtNewsDate.value == "")
		{
			alert("Please enter News Date");
			txtNewsDate.focus();
		}
		else if (txtExpDate.value == "")
		{
			alert("Please enter Expire Date");
			txtExpDate.focus();
		}
		else
		{
			return true;
		}
	}
	return false;
}
//-----------------------------------

function CheckProduct()
{
	var form = document.getElementById("Form1");
	with (form)
	{		
		if ( txtName.value == "" )
		{
			alert("Please enter Name");
			txtName.focus();
		}
		else if ( txtText.value == "" )
		{
			alert("Please enter Description");
			txtText.focus();
		}
		else
		{
			return true;
		}
	}
	return false;
}
//-----------------------------------

function CheckCase()
{
	var form = document.getElementById("Form1");
	with (form)
	{		
		if ( cmbCat.value == "" )
		{
			alert("Please enter Name");
			txtName.focus();
		}
		else if ( txtText.value == "" )
		{
			alert("Please enter Text");
			txtText.focus();
		}
		else if ( ffPic1.value == "" && ffPic2.value == "" && ffPic3.value == "")
		{
			alert("At least one file should be attached.");
			ffPic1.focus();
		}
		else
		{
			return true;
		}
	}
	return false;
}
//-----------------------------------

function CheckFAQ()
{
	var form = document.getElementById("Form1");
	with (form)
	{		
		if ( txtName.value == "" )
		{
			alert("Please enter Name");
			txtName.focus();
		}
		else if ( txtQuestion.value == "" )
		{
			alert("Please enter Question");
			txtQuestion.focus();
		}
		else if ( txtAnswer.value == "" )
		{
			alert("Please enter Answer");
			txtAnswer.focus();
		}
		else
		{
			return true;
		}
	}
	return false;
}
//-----------------------------------

function CheckNewsCat()
{
	var form = document.getElementById("Form1");
	with (form)
	{		
		if ( txtName.value == "" )
		{
			alert("Please enter Title");
			txtName.focus();
		}
		else if ( txtDescription.value == "" )
		{
			alert("Please enter Description");
			txtDescription.focus();
		}
		else
		{
			return true;
		}
	}
	return false;
}
//-----------------------------------

function CheckStaff()
{
	var form = document.getElementById("Form1");
	with (form)
	{		
		if ( cmbTitle.value == "" )
		{
			alert("Please enter Title");
			cmbTitle.focus();
		}
		else if ( txtFName.value == "" )
		{
			alert("Please enter First Name");
			txtFName.focus();
		}
		else if ( txtLName.value == "" )
		{
			alert("Please enter Surname");
			txtLName.focus();
		}
		else if ( v.value == "" )
		{
			alert("Please enter Degree");
			txtDegree.focus();
		}
		else
		{
			return true;
		}
	}
	return false;
}
//-----------------------------------

function CheckLink()
{
	var form = document.getElementById("Form1");
	with (form)
	{		
		if ( txtURL.value == "" )
		{
			alert("Please enter URL");
			txtURL.focus();
		}
		else
		{
			return true;
		}
	}
	return false;
}
//-----------------------------------

function CheckNewsGroup()
{
	var form = document.getElementById("Form1");
	with (form)
	{		
		if ( txtFrom.value == "" )
		{
			alert("Please enter Mail From");
			txtFrom.focus();
		}
		else if (!blnCheckEmail(txtFrom.value))
		{
			alert("Please enter a valid Email for From Mail");
			txtFrom.focus();
		}
		else if ( txtSubject.value == "" )
		{
			alert("Please enter Subject");
			txtSubject.focus();
		}
		else if (txtBCC.value != "" && !blnCheckEmail(txtBCC.value))
		{
			alert("Please enter a valid Email for BCC");
			txtBCC.focus();
		}
		else if ( txtText.value == "" )
		{
			alert("Please enter Mail Body");
			txtText.focus();
		}
		else
		{
			return true;
		}
	}
	return false;
}
//-----------------------------------

function RefType()
{
	if (_gel("rdoType_0").checked)
	{
		_gel("pnlPatient").className = "Hide";
		if (_gel("lblIsLogin").innerHTML == "false")
			_gel("pnlLogin").className = "";
		else
			_gel("pnlDoctor").className = "";
	}
	else
	{
		_gel("pnlPatient").className = "";
		_gel("pnlDoctor").className = "Hide";
		_gel("pnlLogin").className = "Hide";
	}
	return false;
}
//-----------------------------------

function update_enabled_daterangform(simple) 
{
	var f = document.getElementById("Form1");
    if (f) 
    {          
		f["cmbPeriod"].disabled = !simple;
        f["cmbBeginYear"].disabled = simple;
        f["cmbBeginMonth"].disabled = simple;
        f["cmbBeginDay"].disabled = simple;
        f["cmbEndYear"].disabled = simple;
        f["cmbEndMonth"].disabled = simple;
        f["cmbEndDay"].disabled = simple;
    }
}
//-----------------------------------

function update_enabled_daterangform1(simple) 
{
	var f = document.getElementById("Form1");
    if (f) 
    {          
		f["timePeriod"].disabled = !simple;
        f["beginYear"].disabled = simple;
        f["beginMonth"].disabled = simple;
        f["beginDay"].disabled = simple;
        f["endYear"].disabled = simple;
        f["endMonth"].disabled = simple;
        f["endDay"].disabled = simple;
    }
}
//-----------------------------------

//-----------------------------------

function addDisplay()
{
	_gel("PanelAddLine").className="addbox_start";
	_gel("PanelAdd").className="addbox_after";
	return false;
}
//-----------------------------------

function onlyNumeric()
{
	if ((event.keyCode < 48) || (event.keyCode > 57)) event.returnValue = false;
}
//-----------------------------------

function onlyMoney()
{
	if ((event.keyCode < 48 && event.keyCode != 46) || (event.keyCode > 57)) event.returnValue = false;
}
//-----------------------------------

function onlyAlphabetic()
{
	if ((event.keyCode == 32) || (event.keyCode>64 && event.keyCode<91) || (event.keyCode>96 && event.keyCode<123)) event.returnValue = true;
	else event.returnValue = false;
}
//-----------------------------------

function onlyTel()
{
	if (!((event.keyCode < 48) || (event.keyCode > 57)) || (event.keyCode == 32)) event.returnValue = true;
	else event.returnValue = false;
}
//-----------------------------------

function onlyDate()
{
	if ((event.keyCode < 48 && event.keyCode != 47) || (event.keyCode > 57)) event.returnValue = false;
}
//-----------------------------------

function DateOnKeyUp(ctrl)
{
	switch (_gel(ctrl).value.length)
    {
        case 2: _gel(ctrl).value += "/"; break;
        case 5: _gel(ctrl).value += "/"; break;
    }
}
//-----------------------------------

function _gel(a)
{
	return document.getElementById(a)
}
//-----------------------------------

function monthOnKeyUp(objTxtSortCode, intPart)
{
	var intValue = objTxtSortCode.value;
	if (intValue&&intValue.length==2) 
	{
		_gel(intPart).focus();
		if (intPart.indexOf('txtY') >= 0)
			_gel(intPart).value="19";
	}
}
//-----------------------------------

function monthOnKeyUp20(objTxtSortCode, intPart)
{
	var intValue = objTxtSortCode.value;
	if (intValue&&intValue.length==2) 
	{
		_gel(intPart).focus();
		if (intPart.indexOf('txtY') >= 0)
			_gel(intPart).value="20";
	}
}
//-----------------------------------

function intOnKeyUp(ctrl)
{
	if (!isFinite(_gel(ctrl).value))
	{
		_gel(ctrl).value = "";
		_gel(ctrl).focus();
	}
}
//-----------------------------------

function moneyOnKeyUp(ctrl)
{
	if (!isFinite(_gel(ctrl).value) && (_gel(ctrl).value != '.'))
	{
		_gel(ctrl).value = "";
		_gel(ctrl).focus();
	}
}
//-----------------------------------
		
function yearOnKeyUp(objTxtAccNum, intPart) 
{
	var intValue = objTxtAccNum.value;
	if (intValue&&intValue.length==4) {	
		_gel(intPart).focus();
	}
}
//-----------------------------------

function Trim(StrValue)
{
  var st = StrValue;
  while ((st.length > 0) && (st.charAt(0) == " ")) 
	st = st.substring(1, st.length);
  while ((st.length > 0) && (st.charAt(st.length-1) == " "))    
    st = st.substring(0, st.length-1);  
  return st;
}
//-----------------------------------

function blnCheckEmail(pstrEmail)
{
	var k, intFirstAtSignPos, intFirstDotPos, strLastDomainInAddress
	var strValidChar = new String("abcdefghijklmnopqrstuvwxyz1234567890-_.@");
	pstrEmail = Trim(pstrEmail);
	for (k = 0; k <= pstrEmail.length; k++)
		if (strValidChar.indexOf((pstrEmail.substr(k, 1)).toLowerCase()) == -1) return false;
	if (pstrEmail.indexOf("..") >= 0) return false;		
	intFirstAtSignPos = pstrEmail.indexOf("@")
	if(intFirstAtSignPos < 1) return false;
	if (pstrEmail.indexOf("@", (intFirstAtSignPos+1)) >= 0) return false;
	intFirstDotPos = pstrEmail.indexOf(".")
	if(intFirstDotPos < 0) return false;
	if (pstrEmail.indexOf("_", intFirstAtSignPos) != -1) return false;
	strLastDomainInAddress = pstrEmail.substr((pstrEmail.lastIndexOf(".") + 1))
	if (strLastDomainInAddress.length < 2 || strLastDomainInAddress.length > 4) return false;
	return true;
}
//-----------------------------------

function displayurl(urltxt)
{
	if (urltxt=='*')
	{
		BarToolTip.style.visibility='hidden';
	}
	else
	{
		BarToolTip.innerHTML=urltxt;
		BarToolTip.style.left=event.x-10+document.body.scrollLeft;
		BarToolTip.style.top=event.clientY+10+document.body.scrollTop;
		BarToolTip.style.visibility='';
	}	
}
//-----------------------------------

function SwapIn()
{
	var tempSrc, tempExt
	tempSrc = window.event.srcElement.src;
	tempExt = tempSrc.substring(tempSrc.length-4)
	window.event.srcElement.src = tempSrc.substring(0,tempSrc.length-4) + '01' + tempExt;
}
//-----------------------------------

function SwapOut()
{
	var tempSrc, tempExt
	tempSrc = window.event.srcElement.src;
	tempExt = tempSrc.substring(tempSrc.length-4)
	window.event.srcElement.src = tempSrc.substring(0,tempSrc.length-6) + tempExt;
}
//-----------------------------------
