/*
Title:	linkTo.ja
Author: Dower Chin
Date:	09/17/2008
Description:
	This js library was made to handle calls to the LinkTo application for the new single site
	identity project for the new portal landing pages. 
	The js determines what environment to send the user to based upon the URL of the calling
	page.

	-06/18/2009 - Rich Waltein: Modified top case statement to handle all of the unit test environments correctly.

	-07/02/2009 - Rich Waltein: Modified exstensively for the Security Platform project. Only two methods needed now.
*/
urlBase = "";
preferredcareBase = "";
providerSearchBase = "";
staticContentBase = "";
curBase = location.host;
portalServerBase = "";
isProd = false;

// DEV
if (curBase == "localhost:88"
 || curBase == "localhost:90"
 || curBase == "localhost:100"
 || curBase == "localhost"
 || curBase == "localhost:8988")
{
	urlBase = "http://localhost:9080/";
	preferredcareBase = "http://localhost:8988/";
	staticContentBase = "http://" + location.host + "/";
        portalServerBase = "http://localhost/";
}

// UNIT
else if (curBase == "mdunit:88" 
  	  || curBase == "mdunit:90"
	  || curBase == "mdunit:100"
	  || curBase == "mdunit"
	  || curBase == "wwwtest.preferredcare.org")
{	
	urlBase = "https://sm5ts01/";
	preferredcareBase = "http://wwwtest.preferredcare.org/";
	providerSearchBase = "http://al5cfsch01/";
	staticContentBase = "http://" + location.host + "/";
        portalServerBase = "http://mdunit/";
}

// ITS
else if (curBase == "cfusionx:88" 
	  || curBase == "mdits" 
	  || curBase == "mdits:100"
	  || curBase == "al4cfsch01")
{
	urlBase = "https://sm5ts01:445/";
	preferredcareBase = "http://wwwtest.preferredcare.org/";
	providerSearchBase = "http://al4cfsch01/";
	staticContentBase = "http://" + location.host + "/";
        portalServerBase = "http://mdits/";
}

// ACC
else if (curBase == "mdacc" 
	  || curBase == "mdacc:88"
	  || curBase == "cfusionx" 
	  || curBase == "wwwstage.preferredcare.org:4444")
{
	urlBase = "https://swt.mvphealthcare.com/";
	preferredcareBase = "https://wwwstage.preferredcare.org:4444/";
	providerSearchBase = "http://al3cfsch01/";
	staticContentBase = "http://mdacc:88/";
        portalServerBase = "http://mdacc/";
}

// External ACC
// DZC - 08-11-2009 : added in for external ACC confirmation of level 3 content
else if (curBase == "76.12.47.147")
{
	urlBase = "https://swt.mvphealthcare.com/";
	preferredcareBase = "https://wwwstage.preferredcare.org/";
	providerSearchBase = "http://al3cfsch01/";
	staticContentBase = "http://76.12.47.147/";
        portalServerBase = "http://mdacc/";
}

// PROD
else
{
	urlBase = "https://swp.mvphealthcare.com/";
	preferredcareBase = "https://www.preferredcare.org/";
	staticContentBase = document.location.protocol + "//www.mvphealthcare.com/";
	providerSearchBase = "http://cfusion.mvphealthcare.com/";
	portalServerBase = "https://md.mvphealthcare.com/";
	isProd = true;
}

/*** 
Function: 	linkTo
Author: 	Dower Chin
Date:		09/17/2008
Description:
	function that performs the call to the LinkTo application for Tivoli legacy
	applications. The call can be made normally, but this function was needed
	because we wanted to the call to dynamically determine which server environment 
	to go to.
*/
function linkTo(params)
{
	this.location = urlBase + "legacysso/LinkTo/LinkTo?" + params;
}

/***
Function: 	loadFrame
Author: 	Dower Chin
Date:		09/17/2008
Description:
	This function simple takes tha name of an iframe to load a web page to.
	The function was needed, mainly for dynamically loading the login frame
	from whichever environment was running the app.

	Update: 10/13/2009 - DZC
		Modified the function call to replace the login iFrame
		with a call to a CFM file which does a pre-check of the 
		destination to determine if it's avaiable before 
		actually sending the user there.

		NOTE, I had to make an exception for all environments other than PROD.
		It appears that CF5 doesn't support the CFHTTP method of HEAD...
*/
function loadFrame(frame, target)
{
	if (isProd)
	{
		frames[frame].location.replace("/loginFrame.cfm?dest=" + urlBase + target);
	}
	else
	{
		frames[frame].location.replace(urlBase + target);
	}
}

/*** 
Function: 	goToRegistration
Author: 	Dower Chin
Date:		07/07/2009
Description:
	function that is used to send users to the appropriate registration page for
	Kodak and WWLW.
*/
function goToRegistration(params)
{
	this.location = urlBase + "registration/register/?type=" + params;
}

/***
Function: 	linkToIKA
Author: 	Dower Chin
Date:		09/17/2008
Description:
	Similar function to the others, but used for linking to the various IKA environments.
*/
function linkToIKA()
{
	this.location= urlBase + "init/welcome/redirect.jsp";
}

/***
Function: 	goToProviderSearch
Author: 	Dower Chin
Date:		4/14/2009
Description:
	Function to send user to the appropriate Provider Search based upon environment the client web page is running from.
	The target of this function is for the header "Provider Search" link.
*/
function goToProviderSearch(target)
{
	top.location = providerSearchBase + target;
}


/***
Function: 	goToProviderFunction
Author: 	Dower Chin
Date:		11/5/2008
Description:
	Similar function to the others, but used for linking to the various Provider functions
	in the various environments.
*/
function goToProviderFunction(mvpTarget, pcTarget)
{
	this.location = urlBase + mvpTarget;
}

/*** 
Function: 	welcome
Author: 	sh
Date:		9/17/2009
Description:
	link to a jsp in welcome
*/
function welcome(params)
{
	this.location = urlBase + "init/welcome/" + params;
}

/***
Function: 	loadFrameMD
Author: 	Dower Chin
Date:		12/02/2008
Description:
	This function simple takes tha name of an iframe to load a web page to.
	The function was needed, mainly for dynamically loading the login frame
	from whichever environment was running the app to an MD environment.
	
	04242009 - changed staticContentBase to portalServerBase because ow WellStyles.
*/
function loadFrameMD(frame,target)
{
	frames[frame].location.replace(portalServerBase + target);
}

function goToMVPLocation(target)
{
	top.location = staticContentBase + target;
}

/***
Function: 	goToProviderSearch
Author: 	Dower Chin
Date:		4/14/2009
Description:
	Function to send user to the appropriate Provider Search based upon environment the client web page is running from.
	The target of this function is for the header "Provider Search" link.
*/
function goToProviderSearch(target)
{
	top.location = providerSearchBase + target;
}

/* OLD FUNCTION FOR PC linkTo.js, Adding just in case we need it again */
function setBasePath(base, target)
{
	this.location = base + target;
}