
/* URL Checker
 * by NightLion (www.nightlion.net)
 * function displayURL will output your desired url into the 'pasteContainer' div. 
 */

function displayURL() 
{
	var el = document.getElementById('myURL');			
	urlCheck = isUrl(el.value); 
	
	document.getElementById('pasteContainer').style.display = 'block';
	
	if (urlCheck == true) {
		document.getElementById('pasteContainer').innerHTML = '<a href="'+el.value+'">'+el.value+'</a>'; 
	}
	else {
		document.getElementById('pasteContainer').innerHTML = 'Not a Valid URL';
	}
}				

/*
 * RegEx URL Validator
 * Function will check the inputted url to see if it has a valid markup. 
 * Thanks to DZone Code Snippits: http://snippets.dzone.com/ 
 */	
function isUrl(s) {
	var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	return regexp.test(s);
}