// Decision code for uk.match.com

var opLoc = document.location.toString();
var topLoc = top.location.toString();

// Need cookies
function opCreativeSetCookieA(n, v, d, e){var de = new Date;de.setTime(de.getTime() + e * 1000);document.cookie = n + "=" + escape(v) + ((e==null) ? "" : ("; expires=" + de.toGMTString())) + "; path=/" + ((d==null) ? "" : (";domain=" + d));}
function opCreativeGetDocumentSLD(){var sld = document.domain;var dp = sld.split(".");var l = dp.length;if (l < 2) sld = null;else if (!isNaN(dp[l-1]) && !isNaN(dp[l-2])) sld = null;else sld = "." + dp[l-2] + "." + dp[l-1];return sld;}


//------------ Home page experiment --------------
if (   opLoc == 'http://uk.match.com'
	|| opLoc == 'http://uk.match.com/'
	|| opLoc == 'https://uk.match.com'
	|| opLoc == 'https://uk.match.com/'
	|| opLoc.indexOf('uk.match.com/index.php') == 0
	|| opLoc.indexOf('http://uk.match.com?') == 0
	|| opLoc.indexOf('http://uk.match.com#') == 0
	|| opLoc.indexOf('http://uk.match.com/?') == 0
	|| opLoc.indexOf('http://uk.match.com/#') == 0
	|| opLoc.indexOf('https://uk.match.com?') == 0
	|| opLoc.indexOf('https://uk.match.com#') == 0
	|| opLoc.indexOf('https://uk.match.com/?') == 0
	|| opLoc.indexOf('https://uk.match.com/#') == 0
	|| (opLoc.indexOf('uk.match.com/signup/landing_g.php') !=-1 && opLoc.indexOf('visu=')==-1)
	|| opLoc.indexOf('uk.match.com/signup/landing_a.php') !=-1
	)  {
	var opHomePageExp = new OpExperiment('http://by.optimost.com/trial/567/p/homepage.c05/2/content.js','main');
	
	opHomePageExp.run();
}

//------------ Next Step counter --------------
if ( opLoc.indexOf('uk.match.com/signup/ons_v5_2.php') != -1 ) {
	opNextStepCounter = new OpCounter('counter/567/-/17/event.js');
	opNextStepCounter.run();
	 function opCreativeSetCookieA(n, v, d, e){var de = new Date;de.setTime(de.getTime() + e * 1000);document.cookie = n + "=" + escape(v) + ((e==null) ? "" : ("; expires=" + de.toGMTString())) + "; path=/" + ((d==null) ? "" : (";domain=" + d));}
	opCreativeSetCookieA('opUserSignup', 'true', opCreativeGetDocumentSLD(), '31536000');
}

//------------- Logged in pages ---------------
if ( topLoc.indexOf('uk.match.com/scheduler.php') != -1 ) {

	// Cookie function
	function opGetCookie(cookieName){
	var _opcookies = new Object;
	if (document.cookie.length > 0) { var _ca = document.cookie.split("\;");
	for (var i=0; i < _ca.length; i++) { var _cv = _ca[i].split("=");
	while (_cv[0].substring(0, 1) == " ") _cv[0] = _cv[0].substring(1, _cv[0].length);
	_opcookies[_cv[0]] = unescape(_cv[1]); } }
	if(_opcookies[cookieName] != null) {return _opcookies[cookieName];}
	else {return null;} 
	}
	
	// User just completed signup?
	if(opGetCookie('opUserSignup')=='true') {
		// Counter
		opBasketCounter = new OpCounter('counter/567/-/2/event.js');
		opBasketCounter.run();	
		// Remove signup tracker
		opCreativeSetCookieA('opUserSignup', 'false', opCreativeGetDocumentSLD(), '0');
	}

}

