function SetExternalLinks()
{
	var external = false;

	//Load the default excluded sites if the external file is not loaded
	if (!excluded){
		var excluded = new Array("dev.cppschools.com","cppschools.com","javascript:__doPostBack");
	}

	var host = this.location.hostname.replace(/www./, '');	
	var a = document.getElementsByTagName('a');
	
	
	for (i = 0; i < a.length; i++)
	{
		
		//Check if the link is to the current hosted site
		if (a[i].href.indexOf(host) != -1)
		{
			//Valid link
			external = false;
		}
		else{
			//Loop through the excluded sites
			for (x = 0; x < excluded.length; x++)
			{
				if (a[i].href.indexOf(excluded[x]) != -1){
					//Valid link
					external = false;
					break;
				}
				else{
					external = true;
				}
			}

		}

		if (external){
			//External link, so apply popup
			a[i].onclick = function () { checkExternalLink(this); };
		}

	}
}

function checkExternalLink(tmphref) {
     var currentURL = location.href;
     protocolIndex = currentURL.indexOf("://");
     serverIndex = currentURL.indexOf("/", protocolIndex + 4);
     urlResult = currentURL.substring(protocolIndex+3, serverIndex);
    
     
     //Compare the requested URL to the current URL
     if(tmphref.toString().indexOf(urlResult.toString()) == -1)
     {
	alert('The page you have requested is from an external web site. The content displayed is not maintained or endorsed by Comstock Park Public Schools.');  
     }
}
