// links that require leaving this domain will be opened in a new window

function outLinks() 
{
//	var outLink;
var dbg = 0;
	if (document.getElementsByTagName('a')) 
	{
//		for (var i = 0; (anchor = document.getElementsByTagName('a')[i]); i++)
		var a = document.getElementsByTagName("a");
		for (var i = 0; i < a.length;i++) 
		{
			anchor = a[i];

			// leave mailto: and tel: links alone!
			if ( (anchor.href.indexOf("mailto:") != -1) || (anchor.href.indexOf("tel:") != -1) ) continue;

			
			if ( ("default" == "mobile") && (window.navigator.standalone == false) )
			{
				
				anchor.setAttribute('onclick', 'window.location = this.getAttribute("href"); return false;');
			}

			
			else if (
				( (anchor.href.indexOf("nopalitosf.") == -1)  && (anchor.href.substr(0,1) != "/") /* && (anchor.href.indexOf("fcgrx") == -1) */ )
				|| (anchor.getAttribute("rel") == "external") 
				|| (anchor.href.indexOf(".pdf") != -1) 
			   )
			{

				anchor.setAttribute('target', '_blank');
				anchor.setAttribute('onclick', 'event.cancelBubble=true;');
			}
			
			

			else if ( ("default" == "mobile") && (window.navigator.standalone == true) )
			{
// if (dbg == 0) {dbg=1; alert ("links3"); }
				
				anchor.setAttribute('onclick', 'window.location = this.getAttribute("href"); return false;');
			}
		}
	}
}

window.onload = function() {outLinks();}
