/* OAS MJX [ configuration ] */

/* : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : set variables
- get domain info + create a base url [ hostname = "alias.domain.com" ]
- [note]: currently base is centralized in [oascentral.discovery.com] rather then w/in a specific network
*/
var baseOAS = "http://oascentral.discovery.com/RealMedia/ads/";
var theDomain = window.location.hostname.toLowerCase();
var theDomainAlias = theDomain.split(".");
if (theDomain.indexOf("stage") != -1) { var stageFlag = "yes"; }
if (theDomain.indexOf("media") != -1) { var mediaFlag = "yes"; }

var theLocalPath = window.location.pathname;
var theLocalSearch = window.location.search;

/* If the LocalPath is a sub-hompage, add index.html to the string */
if (theLocalPath.indexOf("html") == -1) { theLocalPath = window.location.pathname + "index.html"; }

/* : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : set variables
- create a random number
*/
var aNumber = new String(Math.random());
var theOASNumber = aNumber.substring(2, 11);

/* : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : tests [ if ]
- set switch case default and run tests for other case(s)
*/
/* default */
var targetOASDomain = "default";

/* d.com homepage */
if ((theLocalPath.length < 2) && (theDomain.indexOf("discovery.com") != -1)) { targetOASDomain = "homepage"; }


/* : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : functions [ case ]
- use case, set above, to establish a path for OAS
*/
switch (targetOASDomain) {
	case "homepage" :
		if (stageFlag == "yes") { var pathForOAS = theDomainAlias[0] + "." + theDomainAlias[2] + "." + theDomainAlias[3] + "/index.html"; }
		else { var pathForOAS = theDomain + "/index.html"; }
		break;
	default : 
		if (mediaFlag == "yes") { var pathForOAS = theDomainAlias[1] + "." + theDomainAlias[2] + "." + theDomainAlias[3] + theLocalPath; }
		else if (stageFlag == "yes") { var pathForOAS = theDomainAlias[0] + "." + theDomainAlias[2] + "." + theDomainAlias[3] + theLocalPath; }
		else { var pathForOAS = theDomain + theLocalPath; }
		break;
}

/* END OAS */
