
	function reciprocalLinkValid(frm){

		//Reciprocal link must be hosted at the same domain as url provided
		var url = frm.url.value;
		var link = frm.reciprocal_link.value;

		//Remove 'http://' from the string and trim it
		//url = trim2( url.toLowerCase().replace('http://', '') );
		//link = trim2( link.toLowerCase().replace('http://', '') );

		var urlDomain, linkDomain;
		urlDomain = getDomainName(url);
		linkDomain = getDomainName(link);

		//alert(urlDomain + '| |' + linkDomain);

		//if url and reciprocal url domains are not empty, check them for equality
		if( ( urlDomain.length > 0 && linkDomain.length > 0 ) && (urlDomain != linkDomain) ){

			//if user chooses to ignore invalid reciprocal link, return true anyway so that the rest of the info on the page will be recorded
			if( confirm("Your reciprocal link doesn't appear to be from your website\nClick 'OK' to Proceed (your reciprocal link will be cleared)\nClick 'Cancel' to enter a valid reciprocal link") ){
				frm.reciprocal_link.value = 'http://';
				return true;
			}else{
				return false;
			}
		}

		return true;
	}

	function getDomainName2(url){
		//strip http or https out of the link
		url = trim2( url.toLowerCase().replace('http://', '') );
		url = trim2( url.toLowerCase().replace('https://', '') );

		//strip www
		url = trim2( url.toLowerCase().replace('www', '') );

		//strip .co.uk
		url = trim2( url.toLowerCase().replace('co.uk', '') );

		var endPos = url.indexOf('/');

		if(endPos == -1)
			endPos = url.length;

		//extract string between 'http://' and first forward slash
		url = url.substring(0, endPos);



		//now we need to extract root domain only, without subdomains.
		//loop backwards through url backwards until we have reached second dot
		//in the case of .co.uk, the domain would look like domainname. (since we already stripped co.uk)
		var dotCount = 0, startPos = -1;
		for(var i = url.length; i >= 0; i--){

			if( url.substring(i, i + 1) == '.' )
				dotCount++;

			if(dotCount == 2){
				startPos = i;
				i = -1;
			}
		}

		return url.substring(startPos, url.length);
	}

	function getDomainName(url){
		//strip http or https out of the link
		url = trim2( url.toLowerCase().replace('http://', '') );
		url = trim2( url.toLowerCase().replace('https://', '') );

		//strip www
		url = trim2( url.toLowerCase().replace('www.', '') );

		var endPos = url.indexOf('/');

		if(endPos == -1)
			endPos = url.length;

		return url.substring(0, endPos);
	}

	function validateUrl(obj){
		var url = trim2(obj.value); //trim has issues. It strips out ".", ":", and "/" from the string

		//if url is not empty but doesn't contain 'http://' then add it.
		if( url.length > 0 && url.indexOf('http://') == -1 ){
			url = 'http://' + url;
			obj.value = url;
		}
	}