
//Requires
//<script type="text/javascript" src="/Common/Custom/Cookies.js"></script>


//This is function is obsolete, but its definition is left in until we're sure it's not being called anywhere.
// References should only appear in endis.com and churchinsight.com - UK and US variants - and once these are gone, this can be removed.
function GetLocation() {
	return '';
}

function ChangeSite(location) {
	var strHost = document.location.host;
	
	if (strHost.indexOf('endis.co') >= 0) {
		//endis.co catches endis.co.uk and endis.com.
		//Note that due to cross-domain security the cookie can only be set if we're coming from endis.com
		Set_Cookie('GeoLocation', location, 365, '/', 'endis.com', '');
		switch(location) {
			case 'UK' :
				document.location.href = 'http://uk.endis.com';
				break;
			default :
				document.location.href = 'http://us.endis.com';
				break;
		}
	}
	else if (strHost.indexOf('churchinsight.co') >= 0) {
		//churchinsight.co catches churchinsight.co.uk and churchinsight.com.
		//Note that due to cross-domain security the cookie can only be set if we're coming from churchinsight.com
		Set_Cookie('GeoLocation', location, 365, '/', 'churchinsight.com', '');
		switch(location) {
			case 'UK' :
				document.location.href = 'http://www.churchinsight.com';
				break;
			default :
				document.location.href = 'http://us-sales.churchinsight.com';
				break;
		}
	}
	else if (strHost.indexOf('endisinsight.co') >= 0) {
		//endisinsight.co catches endisinsight.co.uk and endisinsight.com.
		switch(location) {
			case 'UK' :
				document.location.href = 'http://www.endisinsight.co.uk';
				break;
			default :
				document.location.href = 'http://us.endisinsight.com';
				break;
		}
	}
	else if (strHost.indexOf('shareinsight.') >= 0) {
		//shareinsight. catches all shareinsight sites
		if (strHost.indexOf('shareinsight.org') >= 0) {
			Set_Cookie('GeoLocation', location, 365, '/', 'shareinsight.org', '');
			switch(location) {
				case 'US' :
					document.location.href = 'http://us.shareinsight.org';
					break;
				default :
					document.location.href = 'http://uk.shareinsight.org';
					break;
			}
		}
		else {
			if (strHost.indexOf('shareinsight.info') >= 0) {
				Set_Cookie('GeoLocation', location, 365, '/', 'shareinsight.info', '');
			}
			switch(location) {
				case 'US' :
					document.location.href = 'http://us.shareinsight.info';
					break;
				default :
					document.location.href = 'http://uk.shareinsight.info';
					break;
			}
		}
	}
}

