var popupWindow=null; 
function DisplayProviderOnlineAccessMessage()
{
	alert("Please print both pages, follow instructions/obtain authorizing signature, & fax to 713-704-0621");
	window.location.href = "docs/forms/Provider Online Access Form.pdf";
}

function CheckTermsOfUse(url)
{
	var val = getCookie("MHealth_TermsOfUse");
	if ('null' != val)
	{
		if(val==0)
		{
			window.open('TermsOfUseDisclaimer.asp?id="' + url + '"','TermsOfUse', 'width=550,height=530,left=150,top=200,toolbar=1,status=1');
		}
		else if (val==1)
		{
			if(url=='Provider Online Access Form.pdf')
			{
				DisplayProviderOnlineAccessMessage();
			}
			else
			{
				window.location.href = url;
			}
		}
		else
		{
			window.open('TermsOfUseDisclaimer.asp?id="' + url + '"','TermsOfUse', 'width=550,height=530,left=150,top=200,toolbar=1,status=1');
		}
	}
}

function loadit(url)
{
	var val = getCookie("MHealth_TermsOfUse");
	//alert(val);
	if ('null' != val)
	{
		if (val==1)
		{
			//alert("val=1");
			if(url=='Provider Online Access Form.pdf')
			{
				//alert("Provider Online Access Form");
				DisplayProviderOnlineAccessMessage();
			}
		}
		else
		{
			//alert("val=null");
			window.showModalDialog('TermsOfUseDisclaimer.asp?id="' + url + '"',window, 'dialogWidth:540px;dialogHeight:480px;scroll:0;');
			parentWindowValue = document.getElementById('parentWindow').value;
			if (parentWindowValue!="Accept")
			{
				
				window.location.href ="default.asp";
			}
		}
	}

}

function load(url)
{
	var val = getCookie("MHealth_TermsOfUse");
	
	//alert(val);
	if ('null' != val)
	{
		if (val==1)
		{
			//alert("val=1");
			if(url=='Provider Online Access Form.pdf')
			{
				//alert("Provider Online Access Form");
				DisplayProviderOnlineAccessMessage();
			}
		}
		else
		{
			//alert("val=null");
			//window.showModalDialog('TermsOfUseDisclaimer.asp?id="' + url + '"',window, 'dialogWidth:540px;dialogHeight:480px;scroll:0;');
			//popupWindow = window.open('TermsOfUseDisclaimer.asp?id="' + url + '"','TermsOfUse', 'width=540,height=480,left=150,top=200,toolbar=0,scrollbars=0,');
			popupWindow = window.open('TermsOfUseDisclaimer.asp?id="' + url + '"','TermsOfUse', 'width=540,height=480,toolbar=0,scrollbars=0,resizable=0');
			//popupWindow.focus();
			/*
			parentWindowValue = document.getElementById('parentWindow').value;
			if (parentWindowValue!="Accept")
			{
				
				window.location.href ="default.asp";
			}
			*/
			
		}
	}

}	

function child_enable()
{
	popupWindow.focus(); 
}

function parent_disable() 
{ 
	if(popupWindow && !popupWindow.closed)
	{
		popupWindow.focus(); 
	}
	
} 

function unload_popup()
{
	var parentWindowValue = window.opener.document.getElementById('parentWindow').value;
	//alert (parentWindowValue);
	if (parentWindowValue!="Accept")
	{
		
		window.opener.location.href ="default.asp";
	}
	//window.opener.location.href ="default.asp";
	//self.close();
}

function Decline()
{
	/*
	window.opener.location.href ="default.asp";
	self.close();
	*/
	window.opener.document.getElementById('parentWindow').value = "Decline";
	//window.opener.location.href ="default.asp";
	self.close();
	/*
	var window_opener2 = window.dialogArguments;
	window_opener2.document.getElementById('parentWindow').value = "Decline";
	self.close();
	*/
}

function Accept(){
	var query = location.search;
	//alert("query: " + query);
	
	if (query.indexOf(".pdf") > -1)
	{
		DisplayProviderOnlineAccessMessage();
		InitializeCookie();
		self.close();
	}
	else
	{
		/*0
		var urlValue = query.substring(query.indexOf("id=") + 4, query.indexOf(".asp"))+".asp";
		if (urlValue.indexOf("22")>-1)
		{
			urlValue = urlValue.substring(urlValue.indexOf("22") + 2);
		}
		window.opener.location.href = urlValue;
		alert('test11');
		*/
		InitializeCookie();
		window.opener.document.getElementById('parentWindow').value = "Accept";
		self.close();
		/*
		InitializeCookie();
		var window_opener1 = window.dialogArguments;
		window_opener1.document.getElementById('parentWindow').value = "Accept";
		self.close();
		*/
		
	}
}


function InitializeCookie()
{
	
	setCookie( "MHealth_TermsOfUse", 1, 180);
	
}


function AcceptMedicalPolicy(){
opener.document.getElementById('lettersDiv').style.display="";
opener.document.getElementById('policiesDiv').style.display="";
opener.document.getElementById('imgMedicalPolicySearch').style.display="none";
self.close();
}

function DeclineMedicalPolicy(){
self.close();
}

