 var activeElement = null;
 var anchors;
// Loop through all images, check if they contain the class roll
 anchors=document.getElementsByTagName('A'); 

 for(i=0;i<anchors.length;i++) { 
  anchors[i].onfocus = focusHandler;  
   if ( (anchors[i].href).indexOf("www.monroecounty.gov") == -1 ) {
     if ((anchors[i].href).indexOf("http:") == 0) {
     
      if ((anchors[i].id).indexOf("rssb-feed-link") != 0) { 
       if (anchors[i].className == '') {
      anchors[i].className='external';
      }
      }
      }
      }          
 if (anchors[i].onclick == null )  { 
  if ((anchors[i].href).indexOf("mailto:") != 0) {
       if(anchors[i].className != 'not-external') {
      anchors[i].onclick=function(){return  popupleavingmc("AnyURL");};  
    } }
   }
     
 }  
 function focusHandler(evt) {
	var e = evt ? evt : window.event;
	if (!e) return;
	if (e.target)
		activeElement = e.target;
	else if(e.srcElement) activeElement = e.srcElement;
  
}

function popupleavingmc(url)
{   
   
    var oActiveElement = activeElement;
    if (oActiveElement.tagName == "A")  {
       if ( (oActiveElement.href).indexOf("www.monroecounty.gov") != -1 ) {
            return;
      }
      if ( (oActiveElement.href).indexOf("www.mapquest.com") != -1 ) {
            return;
      }
      if ( (oActiveElement.href).indexOf("www.clerk.co.monroe.ny.us") != -1 ) {
            return;
      }
      }
    tstring = new String(oActiveElement.href);
    myRE = new RegExp("javascript", "i")
    results = tstring.match(myRE)
    if (results == null) { 
        window.location='/leavingmc.php?' + oActiveElement.href + "&" +  window.location.href;
	    return false;     }
}
function popuppark()
{
	trytoopen('/apps/reservationapp.php','','toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=0,width=785,height=540,top=' + Math.round(( screen.height - 540 ) / 2) + ',left=' + Math.round(( screen.width - 785 ) / 2));
	return false;
}
function popupwedding()
{
	trytoopen('/apps/weddingapp.php','','toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=0,width=785,height=540,top=' + Math.round(( screen.height - 540 ) / 2) + ',left=' + Math.round(( screen.width - 785 ) / 2));
	return false;
}
function popupflights()
{
	trytoopen('/apps/flightapp.php','','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=774,height=540,top=' + Math.round(( screen.height - 540 ) / 2) + ',left=' + Math.round(( screen.width - 774 ) / 2));
	return false;
}
function popupproperty()
{
	trytoopen('/apps/propertyapp.php','','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=770,height=540,top=' + Math.round(( screen.height - 540 ) / 2) + ',left=' + Math.round(( screen.width - 770 ) / 2));
	return false;
}
function popupvoter()
{
	trytoopen('/apps/voterapp.php','','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=770,height=540,top=' + Math.round(( screen.height - 540 ) / 2) + ',left=' + Math.round(( screen.width - 770 ) / 2));
	return false;
}
function popupprocurement()
{
	trytoopen('/apps/procurementapp.php','','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=770,height=540,top=' + Math.round(( screen.height - 540 ) / 2) + ',left=' + Math.round(( screen.width - 770 ) / 2));
	return false;
}
function popupclerk()
{
	trytoopen('/apps/clerkapp.php','','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=770,height=540,top=' + Math.round(( screen.height - 540 ) / 2) + ',left=' + Math.round(( screen.width - 770 ) / 2));
	return false;
}

function popupworker()
{
	trytoopen('/apps/findworkerapp.php','','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=220,height=500,top=' + Math.round(( screen.height - 500 ) / 2) + ',left=' + Math.round(( screen.width - 220 ) / 2));
	return false;
}

function popuptracker(q)
{
	trytoopen('/airport/tracker.php?'+q,'','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=420,height=590');
	return false;
}

// Display an alert if the popup is blocked.
function trytoopen(url, name, opts) {
	var w = window.open(url, name, opts);
	if(String(w).indexOf('bject') == -1) {
		alert('You have popup windows blocked. Please disable your popup blocker to use this feature.');
	}
}