function CheckFeedback()
{
	var form = document.getElementById("Form1");
	with (form)
	{		
		if ( txtName.value == "" )
		{
			alert("Please complete your name to proceed");
			txtName.focus();
		}
		else if ( txtEmail.value == "" )
		{
			alert("Please complete your email to proceed");
			txtEmail.focus();
		}
		else if (!blnCheckEmail(txtEmail.value))
		{
			alert("Please select a correct email address");
			txtEmail.focus();
		}
		else if ( txtText.value == "" )
		{
			alert("Please complete your feedback to proceed");
			txtText.focus();
		}
		else
		{
			return true;
		}
	}
	return false;
}
//-----------------------------------

function ModuleHideShow(ctrl1, ctrl2)
{
	if(_gel(ctrl1) && _gel(ctrl2))
	{
		if(_gel(ctrl1).className == 'module collapsed')
		{
			_gel(ctrl1).className = 'module expanded';
		}
		else
		{
			_gel(ctrl1).className = 'module collapsed';
		}

		if(_gel(ctrl2).style.display == 'none')
		{
			_gel(ctrl2).style.display = '';
		}
		else
		{
			_gel(ctrl2).style.display = 'none';
		}
	}		
}
//-----------------------------------

function CheckProfRef()
{
	var form = document.getElementById("Form1");
	with (form)
	{
		if ( cmbTitle.value == "" )
		{
			alert("Please enter patient's title to proceed");
			cmbTitle.focus();
		}
		else if ( txtUPFNAme.value == "" )
		{
			alert("Please enter patient's name to proceed");
			txtUPFNAme.focus();
		}
		else if ( txtUPLName.value == "" )
		{
			alert("Please enter patient's surname to proceed");
			txtUPLName.focus();
		}
		else if (txtUPEMail.value != "" && !blnCheckEmail(txtUPEMail.value))
		{
			alert("Please enter a correct email address");
			txtUPEMail.focus();
		}
		else if ( txtUPTel.value == "" )
		{
			alert("Please enter patient's telephone number to proceed");
			txtUPTel.focus();
		}
		else if ( txtUPDOB.value == "" )
		{
			alert("Please enter patient's date of birth to proceed");
			txtUPDOB.focus();
		}
		else if ( cmbUPBranch.value == "" )
		{
			alert("Please enter patient's preferred branch to proceed");
			cmbUPBranch.focus();
		}
		else if ( txtUPDue.value == "" )
		{
			alert("Please enter patient's preferred date to proceed");
			txtUPDue.focus();
		}
		else if ( cmbUPTime.value == "" )
		{
			alert("Please enter preferred time to proceed");
			cmbUPTime.focus();
		}
		else
		{
			return true;
		}
	}
	return false;
}
//-----------------------------------

function CheckSelfRef()
{
	var form = document.getElementById("Form1");
	with (form)
	{
		if ( cmbTitle.value == "" )
		{
			alert("Please enter your title to proceed");
			cmbTitle.focus();
		}
		else if ( txtPFName.value == "" )
		{
			alert("Please enter your name to proceed");
			txtPFName.focus();
		}
		else if ( txtPLName.value == "" )
		{
			alert("Please enter your surname to proceed");
			txtPLName.focus();
		}
		else if (txtPEmail.value != "" && !blnCheckEmail(txtPEmail.value))
		{
			alert("Please enter a correct email address");
			txtPEmail.focus();
		}
		else if ( txtPTel.value == "" )
		{
			alert("Please enter your telephone number to proceed");
			txtPTel.focus();
		}
		else if ( txtPDOB.value == "" )
		{
			alert("Please enter your date of birth to proceed");
			txtPDOB.focus();
		}
		else if ( txtPDueD.value == "" )
		{
			alert("Please enter your preferred date to proceed");
			txtPDueD.focus();
		}
		else if ( cmbPTime.value == "" )
		{
			alert("Please enter preferred time to proceed");
			cmbPTime.focus();
		}
		else if ( cmbPBranch.value == "" )
		{
			alert("Please select the preferred branch to proceed");
			cmbPBranch.focus();
		}
		else if ( cmbFindUs.value == "" )
		{
			alert("Please enter how you found us to proceed");
			cmbFindUs.focus();
		}
		else
		{
			return true;
		}
	}
	return false;
}
//-----------------------------------

function CheckLogin()
{
	var form = document.getElementById("Form1");
	with (form)
	{
		if (txtUsername.value == "")
		{
			alert("Please enter your Username to proceed");
			txtUsername.focus();
		}
		else if (txtPassword.value == "")
		{
			alert("Please enter your Password to proceed");
			txtPassword.focus();
		}
		else
		{
			return true;
		}
	}
	return false;
}
//-----------------------------------

function CheckRegister(UserId)
{
	var form = document.getElementById("Form1");
	with (form)
	{
		if ( cmbTitle.value == "" )
		{
			alert("Please enter your title to proceed");
			cmbTitle.focus();
		}
		else if ( txtName.value == "" )
		{
			alert("Please enter your Name to proceed");
			txtName.focus();
		}
		else if ( txtSurname.value == "" )
		{
			alert("Please enter your Surname to proceed");
			txtSurname.focus();
		}
		else if ( txtPhone.value == "" )
		{
			alert("Please enter your Phone to proceed");
			txtPhone.focus();
		}
		else if ( txtEmail.value == "" )
		{
			alert("Please enter your Email to proceed");
			txtEmail.focus();
		}
		else if ( txtEmail.value != "" && !blnCheckEmail(txtEmail.value))
		{
			alert("Please enter a valid Email to proceed");
			txtEmail.focus();
		}
		else if ( txtAddress.value == "" )
		{
			alert("Please enter your Address to proceed");
			txtAddress.focus();
		}
		else if ( txtPostcode.value == "" )
		{
			alert("Please enter your Postcode to proceed");
			txtPostcode.focus();
		}
		else if (UserId <= 0 && txtUsername.value == "")
		{
			alert("Please enter your Username to proceed");
			txtUsername.focus();
		}
		else if (UserId <= 0 && txtUsername.value.length <= 5)
		{
			alert("Minimum characters for Username is 6");
			txtUsername.focus();
		}
		else if (UserId <= 0 && txtPassword.value == "")
		{
			alert("Please enter your Password to proceed");
			txtPassword.focus();
		}
		else if (UserId <= 0 && txtPassword.value.length <= 5)
		{
			alert("Minimum characters for Password is 6");
			txtPassword.focus();
		}
		else if (UserId <= 0 && txtConfirm.value == "")
		{
			alert("Please confirm your Password to proceed");
			txtConfirm.focus();
		}
		else if (UserId <= 0 && txtPassword.value != txtConfirm.value)
		{
			alert("Please confirm your Password to proceed");
			txtConfirm.value = "";
			txtConfirm.focus();
		}
		else
		{
			return true;
		}
	}
	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 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;
}
//-----------------------------------

var tic = null;
var zone = new Date().getTimezoneOffset() / 60;

function lz( n ) { return n<=9 ? '0' + n : n; }

function tick() 
{
	var f = _gel("Form1");
	var h = new Date();
	//var i = h.getHours() + zone;
	var i = h.getHours();
	var s = ':' + lz( h.getMinutes() ) + ':' + lz( h.getSeconds() );
	var Postfix = ((i<11) ? 'AM' : 'PM' );
	if (i > 11)
		i = i - 12;
	_gel("lonTime").innerHTML = lz( (i + 0)%24 ) + s + ' ' + Postfix;
	
	tic = window.setTimeout( 'tick();', 400 );	
}

function SetTitleToDoctor()
{
	var form = document.getElementById("Form1");
	with (form)
	{
		if ( cmbTitle.value == "Dr" )
			chkDoctor.checked = true;
		else
			chkDoctor.checked = false;
	}
}

//--------------------------------
//Weather

