function printDoc()
	 {
   	if (window.print) {
   		window.print()
   	} else {
   		alert('WARNING: Your browser doesn\'t support this print method')
   	}
	}
	
function openwindow(template)
	    {
	    window.open(template,'new_window','height=500,width=400,top=10,left=500,resizable=1,menubar=0,scrollbars=1');
	 }	
	 
function openPrintWindow(template)
	    {
	    window.open(template,'print_window','height=1,width=1,top=10000,left=10000,resizable=0,menubar=0,scrollbars=0').blur();
	 }	  
function help_popup( helpPage )
    {
     new_window=window.open('help/' + helpPage,'new_window','height=500,width=500,top=10,left=100,resizable=1,menubar=0,scrollbars=1');
  }
function login_window(template,screen_reader)
  {	
  
  if (screen_reader)
  alert("You are about to leave this page. A new window will open up shortly");
		var window2=null;
		w=800 
		h=600 
		if (window.screen)
			{ 
				w = window.screen.availWidth-10; 
				h = window.screen.availHeight; 
			} 
		window2 = window.open(template,'login','status=yes,width='+w+',height='+h+',top=0,left=0,scrollbars=YES,resizable=YES,copyhistory=yes');
		try{
			window2.focus();
			}
		catch (err) 
			{
			location="popup_blocked.cfm"
	    	}				
 }	 
function setWinTitle(title){
	document.title = title;
}
function confirmDelete(object)
{
var agree=confirm("WARNING: The Delete button should only be used for extension clinics that were not, at any time, affiliated with your facility.  This button should not be used for extension clinics that were affiliated with your facility, but are now closed.\n\n Are you sure you wish to Delete this Clinic?");
if (agree)
	return true ;
else
	return false ;
}

function popup( id )
	    {
	    if ( id == "0" )
	      new_window=window.open('help/prov_clinic_form_help.html','new_window','height=500,width=400,top=10,left=500,resizable=1,menubar=0,scrollbars=1');
	    else
	      edit_window=window.open('help/prov_clinic_form_help.html?new=' + id,'edit_window','height=600,width=500,top=200,left=200,resizable=1,menubar=0,scrollbars=1');
	  	}

//limit should be an integer representing max number of characters form element accepts
function formValidation(theForm)
		{
		//alert("inside the form validation");
			if (theForm.C_PFI.value.length < 4)
				{
				//alert("the length of" + object.name + "is:" + object.value.length);
				alert("ERROR: Please enter a 4 digit number for the PFI number");
				theForm.C_PFI.focus();
				return false;
				}
			if (theForm.C_federal_id.value == "")
				{
				//alert("C_npi.value is null" + theForm.C_npi.value);
				//return true;
				}
			else
				{
			//alert("C_npi.value is not null..." + theForm.C_npi.value);
				if(theForm.C_federal_id.value.length < 9)
					{
					alert("ERROR: Please enter a 9 digit number for the Federal ID number");
					theForm.C_federal_id.focus();
					return false;
					}
				else
					{
					//alert("We have a 10 digit number");
					//return true;
					}
			}
			//alert("just before the npi value conditional statement");
			if (theForm.C_npi.value == "")
				{
				//alert("C_npi.value is null" + theForm.C_npi.value);
				//return true;
				}
			else
				{
				//alert("C_npi.value is not null..." + theForm.C_npi.value);
				if(theForm.C_npi.value.length < 10)
					{
					alert("ERROR: Please enter a 10 digit number for the NPI number");
					theForm.C_npi.focus();
					return false;
					}
				else
					{
					//alert("We have a 10 digit number");
					//return true;
					}
				}
		return true;
}





function checkAmp(object){
var AmpChar = "&";
var checkStr = object.value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
		if (ch == AmpChar)
		{
			allValid = false;
			break;
		}
		
}
if (!allValid)
{
alert("ERROR: Do not use the Ampersand (&) character in the clinic name or address fields.");
object.focus();
return (false);
}
}



//<!-- Begin

/*function charCheck(val) {
var mikExp = /[0-9 $\\@\\\%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|]/;
var strPass = val.value;
var strLength = strPass.length;
var lchar = val.value.charAt((strLength) - 1);
if(lchar.search(mikExp) != -1) {
var tst = val.value.substring(0, (strLength) - 1);
val.value = tst;
   }
}*/
/*
// allow ONLY alpha keys, no symbols or punctuation
// 
function charCheck(object){
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -";
var checkStr = object.value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
	for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
		break;
			if (j == checkOK.length)
			{
			allValid = false;
			break;
			}
	}
if (!allValid)
{
alert("Please enter only letter characters.");
object.focus();
return (false);
}
}*/

function charCheck(object){
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.',- ";
var checkStr = object.value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
	for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
		break;
			
			if (j == checkOK.length)
			{
			allValid = false;
			break;
			}
	}
if (!allValid)
{
alert("ERROR: Please enter letters only.");
object.focus();
return (false);
}
}


function numCheck(object){
var checkOK = "0123456789";
var checkStr = object.value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
	for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
		break;
			
			if (j == checkOK.length)
			{
			allValid = false;
			break;
			}
	}
if (!allValid)
{
alert("ERROR: Please enter numbers only.");
object.focus();
return (false);
}
}
/*function doanothercheck(form) {
var mikExp = /[0-9 $\\@\\\%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|]/;
if(form.value.length < 1) {
alert("Please enter something.");
return false;
}
if(form.value.search(mikExp) == -1) {
alert("Correct Input");
return false;
}
else {
alert("Sorry, but only normal characters are allowed");
form.select();
form.focus();
return false;
}
alert("Correct Input");
return false;
} */
//  End -->

/*
var nav = window.Event ? true : false;
if (nav) {
   window.captureEvents(Event.KEYDOWN);
   window.onkeydown = NetscapeEventHandler_KeyDown;
} else {
   document.onkeydown = MicrosoftEventHandler_KeyDown;
}

function NetscapeEventHandler_KeyDown(e) {
  if (e.which == 13 && e.target.type != 'textarea' && e.target.type != 'submit') { return false; }
  return true;
}

function MicrosoftEventHandler_KeyDown() {
  if (event.keyCode == 13 && event.srcElement.type != 'textarea' && event.srcElement.type != 'submit')
    return false;
  return true;
}
*/


//function noenter() {
//  return !(window.event && window.event.keyCode == 13); }

 function noenter(){
  var evt = (event) ? event : ((window.event)?window.event:new Object);
  var keyCode = document.layers ? evt.which : document.all ?  evt.keyCode : evt.keyCode;
 if (keyCode == 13 ) {
 //alert("the keyCode is: " + keyCode);
 return false;
 }
 else{
  //alert("Else code.....the keyCode is: " + keyCode);
  return true;
 }
 }

function ScreenScaleFactorX() {
	//alert("screenDevice XDPI:" + screen.deviceXDPI);
	//alert("logicalDevice XDPI:" + screen.logicalXDPI);
   var nScaleFactor = screen.deviceXDPI / screen.logicalXDPI;
   //alert("nScaleFactor:  " + nScaleFactor);
   return nScaleFactor;
  }
