
	
	
	

//projectX



var projectXData={

							
							phase:				4,

							
							net:					"16276",

							
							netTargets:		"11492",
							
							
							targetVal:			1,
							
							
							consoleLogOn	:	false
};



(function(){

	function consoleLog(_msg){
		try{
			if(projectXData.consoleLogOn && console && console.log){
				console.log(_msg);
			}
		}
		catch(e){}
	}
	
	function getQueryStringAsObject(){
		var qs = location.search;
		var string = (qs.indexOf('?') > -1)? qs.split('?')[1] : qs;
		var qArray = string.split("&");
		var retVal = {};
		for(var x = 0, len = qArray.length; x < len; x++){
			var pairs = qArray[x].split("=");
			retVal[pairs[0]] = pairs[1];
		}
		return retVal;
	}

	function setPhaseOverride(_phase){
		_phase = parseInt(_phase);
		if(!isNaN(_phase) && _phase >= 0){
			try{
				projectXData.phase = _phase;
			}
			catch(e){
				consoleLog("### error ### in setPhaseOverride()");
			}
		}
	}

	function setNetOverride(_net){
		if(_net){
			try{
				projectXData.net = _net;
			}
			catch(e){
				consoleLog("### error ### in setNetOverride()");
			}
		}
	}

	function setConsoleLogOverride(_consoleLogOn){
		if(_consoleLogOn){
			try{
				projectXData.consoleLogOn = _consoleLogOn;
			}
			catch(e){
				consoleLog("### error ### in setConsoleLogOverride()");
			}
		}
	}

	function getOverrides(){
		var qObj = getQueryStringAsObject();
		try{
			if(qObj.px_phase){
				setPhaseOverride(qObj.px_phase);
			}
			if(qObj.px_net){
				setNetOverride(qObj.px_net);
			}
			if(qObj.px_console){
				setConsoleLogOverride(qObj.px_console);
			}
		}
		catch(e){
			consoleLog("### error ### in getOverrides()");
		}
	}

	function getNetTargets(){
		var retVal = null;
		try{
			retVal = projectXData.netTargets;
		}
		catch(e){
			consoleLog("### error ### in getNetTargets()");
		}
		return retVal;
	}

	function getTargetVal(){
		var retVal = null;
		try{
			retVal = parseInt(projectXData.targetVal);
		}
		catch(e){
			consoleLog("### error ### in getTargetVal()");
		}
		if(isNaN(retVal)){
			
			retVal = null;
		}
		return retVal;
	}

	function getPhase(){
		var retVal = 0;
		try{
			retVal = parseInt(projectXData.phase);
		}
		catch(e){
			consoleLog("### error ### in getPhase()");
		}
		if(isNaN(retVal)){
			
			retVal = 0;
		}
		return retVal;
	}

	function getNet(){
		var retVal = null;
		try{
			retVal = projectXData.net;
		}
		catch(e){
			consoleLog("### error ### in getNet()");
		}
		return retVal;
	}

	function isNetMatch(){
		var retVal = false;
		try{
			var targetNets = getNetTargets();
			if(targetNets.match(getNet())){
				retVal = true;
			}
		}
		catch(e){
			consoleLog("### error ### in isNetMatch()");
		}
		return retVal;
	}

	function outputProjectX(){
		consoleLog("* * * * * * *");
		consoleLog("*** phase: "+getPhase()+" ***");
		if(getPhase() > 0){
			consoleLog("*** targeted nets ***");
			consoleLog(getNetTargets());
			if(isNetMatch()){
				try{
					var targetVal = getTargetVal();
					if(targetVal != null){
						consoleLog("*** net match found: "+getNet()+" ***");
						consoleLog("*** targetVal: " + targetVal + " ***");

						
						if(!window.MTVN) window.MTVN = {};
						if(!window.MTVN.config) window.MTVN.config = {};
						if(!window.MTVN.config.btg) window.MTVN.config.btg = {};
						if(!window.MTVN.config.btg.DoubleClick) window.MTVN.config.btg.DoubleClick = {};

						
						window.MTVN.config.projectX = {};
						window.MTVN.config.projectX.phase = getPhase();
						window.MTVN.config.projectX.targetVal = targetVal;
						window.MTVN.config.projectX.net = getNet();

						
						var keyVals = "px_phase=" + getPhase() + ";px_target=" + targetVal + ";";
						consoleLog("*** targeted key values: " + keyVals + " ***");

						if(typeof window.MTVN.config.btg.DoubleClick.keyValues == "string"){
							window.MTVN.config.btg.DoubleClick.keyValues  += ";" + keyVals;
						}else{
							window.MTVN.config.btg.DoubleClick.keyValues = keyVals;
						}
						
						window.MTVN.config.btg.enablePOE = true;
					}
					else{
						consoleLog("*** targeting value is: " + targetVal + ", projectX NOT targeted ***");
					}
				}
				catch(e){
					consoleLog("### error ### if(isNetMatch())...");
				}
			}
			else{
				consoleLog("*** no net match for " + getNet() + " found, projectX NOT targeted ***");
			}
		}
		else{
			consoleLog("*** phase is not >0, projectX NOT targeted ***");
		}
	}

	getOverrides();
	outputProjectX();

})();


function getPxData(){
	var retVal = null;
	try{
		if(typeof MTVN === "object" && typeof MTVN.config === "object" && typeof MTVN.config.projectX === "object"){
			retVal = MTVN.config.projectX;
		}
	}
	catch(e){}
	return retVal;
}

//End of projectX