// popup.js -- Popup Window Function


//Printer Friendly popup - 1/13/2007 lah scr 10976
function pf_Popup(fname,wname,wwidth,wheight) {

	var newwin = window.open("",wname,"toolbar=yes,directories=no,menubar=no,scrollbars=yes,width=" + wwidth + ",height=" + wheight + ",left=20,top=20,resizable=yes");
	newwin.location = fname;
	newwin.focus();
	return;

}

function popup(fname,wname,wwidth,wheight) {

	var newwin = window.open(fname,wname,"toolbar=no,directories=no,menubar=yes,scrollbars=yes,width=" + wwidth + ",height=" + wheight + ",left=20,top=20,resizable=yes");
	newwin.location = fname;
	newwin.focus();
	return;

}


//popup message for definitions
//jrw - 10/05/2004
//jrw - SCR 9332 add parameter to pass the height of the popup, add event parameter to capture mouse
//		location for display
function OpenPopUp(strText, intHeight,e) {
	// Detect if the browser is IE or not.
	// If it is not IE, we assume that the browser is NS.
	var IE = document.all?true:false;
	// Temporary variables to hold mouse x-y pos.s
	var tempX = 0;
	var tempY = 0;

	var oPopup = window.createPopup();

	var oPopBody = oPopup.document.body;

	// If NS -- that is, !IE -- then set up for mouse capture
	if (!IE) document.captureEvents(Event.MOUSEMOVE);

   if (IE) { // grab the x-y pos.s if browser is IE
     tempX = event.clientX + document.body.scrollLeft;
	 tempY = event.clientY + document.body.scrollTop;
   } else {  // grab the x-y pos.s if browser is NS
     tempX = e.pageX;
     tempY = e.pageY;
   }
	
	//move location over
	tempX = tempX + 50;
	tempY = tempY - 10;
	
   // catch possible negative values
   if (tempX < 0){tempX = 0};
   if (tempY < 0){tempY = 0};
	// setup the popup body characteristics
	
	oPopBody.style.backgroundColor = "#E2EEF9";
	oPopBody.style.color ="Navy";
	oPopBody.style.font = "10pt Arial";
	oPopBody.style.border = "solid";
	oPopBody.style.bordercolor = "Navy";
	oPopBody.style.borderwidth = "0.2cm";
	
	// get size of window needed
	oPopBody.innerHTML = strText;
	//9332oPopup.show(100,100,180,25,document.body);
	oPopup.show(100,100,180,25,document.body);

	//9332oPopup.show(0,0,300,0,strText);
	oPopup.show(0,0,intHeight,0,strText);
	var realHeight = oPopBody.scrollHeight;
	var realWidth = oPopBody.scrollWidth;
	
	//screen location left, top, width, height
	//oPopup.show(575, 380, realWidth+10, realHeight+80, document.body);
	oPopup.show(tempX, tempY, realWidth+10, realHeight+80, document.body);

}

//open the page for a map
//hgutierrez - 11/30/2004 created
//jrw - SCR 9203 add to optima project for find a doc 
//note: may eventually pass in the width and height of the window once
//lah - SCR 10976 added menubar=yes - need a way to print map and directions
//		mapping is finalized
function OpenMap(Address)
{
	window.open('/OptimaHealthWeb/Templates/Public/Mapping/GetMap.aspx?Address='+Address, 'Map', 'width=750, height=550, status=yes, toolbar=no, menubar=yes, top=20, left=20, resizable=yes, scrollbars=yes')
}
//open the page for a map
//jrw - SCR 9203 add to optima project for find a doc 
//note: may eventually pass in the width and height of the window once
//		mapping is finalized
function OpenDirections(Address, AddressFrom)
{
	window.open('/OptimaHealthWeb/Templates/Public/Mapping/GetMap.aspx?Address='+Address+'&AddressFrom='+AddressFrom, 'Map', 'width=750, height=550, status=yes, toolbar=no, top=20, left=20, resizable=yes, scrollbars=yes')
}

//if a vision search is desired then open up the appropriate vision page
//if a medical search is desired submit the search page
//jrwilson - 02/04/2005 created  SCR 9246

function OpenVision(wwidth,wheight)
{
	var strURL = "";
	var strwname ="";
	var ivalue = "0";
	var strbtn1name = "";
	
	if (document.forms[0].FindADoctor1_rdoRoutine.checked) {
		ivalue="1";
	}
	//alert(document.forms(0).elements["FindADoctor1:VisionOptions"](1).value);
	//strbtn1name = document.forms(0).elements["FindADoctor1:VisionOptions"](1).value;
	//alert(strbtnname);
    //id="FindADoctor1_rdoMedEyeCare" type="radio" name="FindADoctor1:VisionOptions" value="rdoMedEyeCare"
    
	//check to see if SFC button is active
	//if (strbtn1name == "rdoSFCFAMIS"){
	
	//Corrected for PL 13294 - bccallin - 09/16/08
	if (document.getElementById("FindADoctor1_rdoSFCFAMIS") != null) {
	if (document.forms[0].FindADoctor1_rdoSFCFAMIS.checked) {
	ivalue="2";
	}
	}
	
	if (document.forms[0].FindADoctor1_rdoMedEyeCare.checked) {
		ivalue="3";
	}
	//alert(ivalue);
	switch (ivalue)
		{
			case '1':
				//cole vision search
				// SCR11966 - PSC - 07/06/07 strURL = "http://www.colemanagedvision.com/find/default.asp?id=43215";
				strURL = "http://www.eyemedvisioncare.com/memweb/ProviderLocator?ClientId=sentarasl";
				strwname = "eCVL";
				//alert(strURL);
				break;
			case '2':
				//cole vision search for SFC
				// SCR11966 - PSC - 07/06/07 strURL = "http://www.colemanagedvision.com/find/default.asp?id=43216";
				strURL = "http://www.eyemedvisioncare.com/memweb/ProviderLocator?ClientId=sentarasl";
				strwname= "eCVSFCL";
				break;
			case '3':
				//medical search submit the form
				break;
			default:
				alert("An option must be selected");
				return false;
				break;
		}
	history.go(-1);
	//leave thisnext commented out piece for now until process finalized
	//alert(visionid);
	//var obj = document.getElementById("FindADoctor1_pnlVision");
	//obj.visible=false;
	
	//var pnl = document.all["FindADoctor1_pnlVision"];
	//pnl.visible=false;
	//alert(criteriaid);
	//var pnl = document.all["FindADoctor1_pnlCriteria"];
	//pnl.visible=true;
	//document.forms(0).elements[visionid].visible=false;
		
	if (ivalue < 3) {
		popup(strURL,strwname,wwidth,wheight);
		return;
	} else { 
		document.forms[0].submit();
		return;
	}	
	
}

//open the page for pcp membership report
//llbailey - 01/28/2006 - created
//llbailey - 02/08/2006 - included menubar in option to display page
function submitPCPMembership(PCPControl, SearchOption, NewMembers, VendorControl)
{
			
	var varPCPID=document.getElementById(PCPControl).value;
	//KJP 11305 12/5/2006 hard coded the sort since the datgrid will now sort.
	//var varSearchOption = 'MbrID';---VXP 05/07/2007 scr 11740
	var varSearchOption = 'LastName'
	var varNewMembers = document.getElementById(NewMembers).value;
	var varVendorControl = document.getElementById(VendorControl).value;

	if (document.getElementById(NewMembers).checked) {
		var varNewMembers = 1
	} else {
		var varNewMembers = 0
	}
	
	if (varPCPID != "") {
		var varVendorControl = ""
	} 
	
	//open new window
	window.open("/OptimaHealthWeb/Transactions/Provider/PCPMembershipReport/PCPMembershipReport.aspx?VendorID="+varVendorControl+"&PCPID="+varPCPID+"&NewMembers="+varNewMembers+"&SearchOption="+varSearchOption,"PCPMembershipReport","menubar=yes, toolbar=yes, status=yes, location=yes, scrollbars=yes, resizable=yes, height=485, width=700");
}

function MaximizeRedirect(url)
{
window.resizeTo(screen.availWidth,screen.availHeight);
window.location = url
}