function validateContactInput(){

	var validContactName = 0;
	var validContactEmail = 0;
	var validContactMessage = 0;
	var contactEmail = document.getElementById('contactEmail').value;	
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if(document.getElementById('contactName').value != '') {validContactName = 1;}
	if(document.getElementById('contactMessage').value != '') {validContactMessage = 1;}
	if(filter.test(contactEmail)) { validContactEmail = 1; }

	if(validContactName == 1 && validContactEmail == 1 && validContactMessage == 1) {return true;} 
	
	else {

	var errorMessage = '';

	if(validContactName == 0)  { errorMessage += '- Your Name.\n';  }
	if(validContactEmail == 0) { errorMessage += '- Your Email Address.\n'; }
	if(validContactMessage == 0) { errorMessage += '- Your Message.\n'; }
	
	alert("Please complete the following fields:\n\n" + errorMessage);
	return false;
	}
}

function validateEmailItInput(){

	var validSendersName = 0;
	var validSendersEmail = 0;
	var validFriendsEmail = 0;
	var sendersEmail = document.getElementById('sendersEmail').value;
	var friendsEmail = document.getElementById('friendsEmail').value;	
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if(document.getElementById('sendersName').value != '') {validSendersName = 1;}
	
	if(filter.test(sendersEmail)) { validSendersEmail = 1; }
	if(filter.test(friendsEmail)) { validFriendsEmail = 1; }
	if(validSendersName == 1 && validSendersEmail == 1 && validFriendsEmail == 1) {return true;} 
	
	else {

	var errorMessage = '';

	if(validSendersName == 0)  { errorMessage += '- Your Name.\n';  }
	if(validSendersEmail == 0) { errorMessage += '- Your Email Address.\n'; }
	if(validFriendsEmail == 0) { errorMessage += '- Your Friend\'s Email Address.\n'; }
	
	alert("Please complete the following fields:\n\n" + errorMessage);
	return false;
	}
}


var parseUri = function (source) {
	var o = parseUri.options,
		value = o.parser[o.strictMode ? "strict" : "loose"].exec(source);
	
	for (var i = 0, uri = {}; i < 14; i++) {
		uri[o.key[i]] = value[i] || "";
	}
	
	uri[o.q.name] = {};
	uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
		if ($1) uri[o.q.name][$1] = $2;
	});
	
	return uri;
};

parseUri.options = {
	strictMode: false,
	key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
	q: {
		name: "queryKey",
		parser: /(?:^|&)([^&=]*)=?([^&]*)/g
	},
	parser: {
		strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
		loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
	}
};

function get_service_name(input) {
	
	output = input.replace('www.', '');
	output = output.replace('.com', '');
	output = output.replace('.net', '');
	output = output.replace('.org', '');
	output = output.replace('.co.uk', '');
	output = output.replace('rss.', '');
	return output;
}