﻿function PrintThisPage(title)
{ 
   var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
       sOption+="scrollbars=yes,width=750,height=600,left=100,top=25"; 

   var sWinHTML = document.getElementById('contentstart').innerHTML; 
   
   var winprint=window.open("","",sOption); 
       winprint.document.open(); 
       //<LINK href=../StyleSheets/PrinterFriendly.css rel=Stylesheet>
       winprint.document.write('<html><head><style type="text/css">input, textarea{ border: none; overflow: visible;  }a{ display: none;}</style></head><body>'); 
       winprint.document.write("<div style='FLOAT: none' align='center'>" + title + "</div>");
       winprint.document.write(sWinHTML);          
       winprint.document.write('</body></html>'); 
       winprint.document.close(); 
       winprint.focus();
}

function FormatDate(txtBox)
{
	var DateToFormat;
	DateToFormat = document.getElementById(txtBox).value;
				 
	if (DateToFormat.length == 8 && IsNumeric(DateToFormat))
	{ 
		document.getElementById(txtBox).value = DateToFormat.substring(0,2) + '/' + DateToFormat.substring(2,4) + '/' + DateToFormat.substring(4,8);
	}  
}

function FormatZipCode(txtBox)
{
	var zip;
	zip = document.getElementById(txtBox).value;
					 
	if (zip.length == 9 && IsNumeric(zip))
	{ 
		document.getElementById(txtBox).value = zip.substring(0,5) + '-' + zip.substring(5,9);
	}  
}

function IsDate(value)
{
	var d = value.split("/"); 
	var valid;
	valid = true;
				
	if (d.length != 3) {
		valid = false;
	} 
	else 
	{
		for (var i=0; i<d.length - 1; i++) 
		{
			if (!(d[i].length <= 2 && IsNumeric(d[i]))) {
			valid = false;
			}
		}
	} 
				
	return valid;
}

function IsNumeric(strString)
	//  check for valid numeric strings	
{
	var strValidChars = "0123456789";
	var strChar;
	var blnResult = true;

	if (strString.length == 0) return false;

	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
		{
			blnResult = false;
		}
	}
	return blnResult;
}

function FormatPhoneNumber(txtBox)
{
	var num = document.getElementById(txtBox).value;
				
	if (num.length == 10) 
	{
		document.getElementById(txtBox).value = '(' + num.substring(0,3) + ')' + num.substring(3,6) + '-' + num.substring(6,10);
	}
}
