function OnKeyPress_EmailAddress()
{
	switch (window.event.keyCode)
	{
		case 32:		// space
		case 126:
		case 33:
		case 35:
		case 32:
		case 36:
		case 37:
		case 38:
		case 94:
		case 42:
		case 40:
		case 41:
		case 43:
		case 61:
		case 123:
		case 125:
		case 91:
		case 93:
		case 92:
		case 124:
		case 63:
		case 60:
		case 62:
		{
			window.event.keyCode = 0;
			break;
		}
	}
}

function OnKeyPress_UserID()
{
	switch (window.event.keyCode)
	{
		case 32:		// space
		case 126:
		case 33:
		case 35:
		case 32:
		case 36:
		case 37:
		case 38:
		case 94:
		case 42:
		case 40:
		case 41:
		case 43:
		case 61:
		case 123:
		case 125:
		case 91:
		case 93:
		case 92:
		case 124:
		case 63:
		case 60:
		case 62:
		case 64:
		{
			window.event.keyCode = 0;
			break;
		}
	}
}

function OnKeyPress_Integer()
{
   // block all non-numeric keys
   if (window.event.keyCode < 48 || window.event.keyCode > 57)
      window.event.keyCode = 0;
}

function OnKeyPress_Date()
{
	if (window.event.keyCode == 45 || window.event.keyCode == 46 || window.event.keyCode == 92)
		window.event.keyCode = 47;

	// block all non-numeric keys
	if ((window.event.keyCode < 48 || window.event.keyCode > 57) && window.event.keyCode != 47)
		window.event.keyCode = 0;
}

function OnKeyPress_Decimal()
{
   // block all non-numeric and non-decimal keys
   if ((window.event.keyCode < 48 || window.event.keyCode > 57) && window.event.keyCode != 46)
      window.event.keyCode = 0;
}

function OnKeyPress_Telephone()
{
	// translate alpha-letters (a-z and A-Z) to the corresponding
	// numbers on a telephone
	switch(window.event.keyCode)
	{
		case 65: // A
		case 97:
		case 66: // B
		case 98:
		case 67: // C
		case 99:
		{
			window.event.keyCode = 50;		// 2
			break;
		}
		case 68: // D
		case 100:
		case 69: // E
		case 101:
		case 70: // F
		case 102:
		{
			window.event.keyCode = 51;		// 3
			break;
		}
		case 71: // G
		case 103:
		case 72: // H
		case 104:
		case 73: // I
		case 105:
		{
			window.event.keyCode = 52;		// 4
			break;
		}
		case 74: // J
		case 106:
		case 75: // K
		case 107:
		case 76: // L
		case 108:
		{
			window.event.keyCode = 53;		// 5
			break;
		}
		case 77: // M
		case 109:
		case 78: // N
		case 110:
		case 79: // O
		case 111:
		{
			window.event.keyCode = 54;		// 6
			break;
		}
		case 80: // P
		case 112:
		case 81: // Q
		case 113:
		case 82: // R
		case 114:
		case 83: // S
		case 115:
		{
			window.event.keyCode = 55;		// 7
			break;
		}
		case 84: // T
		case 116:
		case 85: // U
		case 117:
		case 86: // V
		case 118:
		{
			window.event.keyCode = 56;		// 8
			break;
		}
		case 87: // W
		case 119:
		case 88: // X
		case 120:
		case 89: // Y
		case 121:
		case 90: // Z
		case 122:
		{
			window.event.keyCode = 57;		// 9
			break;
		}
	}

	if (window.event.keyCode < 48 || window.event.keyCode > 57)
		window.event.keyCode = 0;
}

function OnChange_Telephone(strName)
{
   var strPart1 = document.getElementById(strName + "_1").value.toString() + "    ";
   var strPart2 = document.getElementById(strName + "_2").value.toString() + "    ";
   var strPart3 = document.getElementById(strName + "_3").value.toString() + "    ";
   var strNumber = strPart1.substring(0,3) + strPart2.substring(0,3) + strPart3.substring(0,4);
   document.getElementById(strName).value = strNumber;
}

function OnChange_Telephone_WithExtension(strName)
{
   var strPart1 = document.getElementById(strName + "_1").value.toString() + "    ";
   var strPart2 = document.getElementById(strName + "_2").value.toString() + "    ";
   var strPart3 = document.getElementById(strName + "_3").value.toString() + "    ";
   var strPart4 = document.getElementById(strName + "_4").value.toString() + "      ";
   var strNumber = strPart1.substring(0,3) + strPart2.substring(0,3) + strPart3.substring(0,4) + strPart4.substring(0,6);
   document.getElementById(strName).value = strNumber;
}

function OnClickDateCalendar(strName)
{
	var varWindow = window.open("CalendarPopup.aspx?From=" + strName + "&SelDate=" + document.getElementById(strName).value, "", "width=200; height=200; scrollbar=no, statusbar=no, menubar=no, toolbar=no");
	varWindow.creator = this;
}

//
//(<input type=TEXT size=3 maxlength=3 name="Q4_3_1" id="Q4_3_1" value="" onchange="Q4_3_savechange()" onFocus="if (this.value.length==3) {this.select();magic=false;}else{magic=true;}" onKeyPress="magic=true;" onKeyUp="if (this.value.length==3 && magic) {document.getElementById('Q4_3_2').focus();}">) <input type=TEXT size=3 maxlength=3 name="Q4_3_2" id="Q4_3_2" value="" onchange="Q4_3_savechange()" onFocus="if (this.value.length==3) {this.select();magic=false;}else{magic=true;}" onKeyPress="magic=true;" onKeyUp="if (this.value.length==3 && magic) {document.getElementById('Q4_3_3').focus();}"> - <input type=TEXT size=4 maxlength=4 name="Q4_3_3" id="Q4_3_3" value="" onchange="Q4_3_savechange()">
//

function ShowLetter(strLang, strID)
{
	window.open("_pdf/pdf_" + strLang + "_letter" + strID + ".pdf", "", "top=0, left=0, resizable=yes");
}

function KindOfPatientAccounts()
{
	window.open("PatientAccountKinds.htm", "", "top=0,left=0,width=600,height=500,scrollbars=yes,resizable=yes, statusbar=no, menubar=no, toolbar=no");
}


function ShowHideOtherPMS()
{
    var obj;
    obj=document.getElementById('cmbPatientManagementSystem');
    var pnl;
    pnl=document.getElementById('rowOther');
    var txt;
    txt=document.getElementById('txtOtherPMS');
    if (obj.value == 'OTHR')
    {
        pnl.style.visibility='visible';
        txt.focus();
    }
    else
    {
        pnl.style.visibility='hidden';
    }
}

function PageQuery(q)
{
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q) 
	{
		for(var i=0; i < this.q.split("&").length; i++) 
		{
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() 	{ return this.keyValuePairs; }
	this.getValue = function(s) 
	{
		for(var j=0; j < this.keyValuePairs.length; j++) 
		{
		if(this.keyValuePairs[j].split("=")[0] == s)
			return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() 
	{
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) 
		{
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; } 
}

function queryString(key)
{
	var page = new PageQuery(window.location.search); 
	return unescape(page.getValue(key)); 
}