// JavaScript Document
if (document.getElementById) {
  if (/data_discovery_portal/.exec(document.location)) {
	document.getElementById("data_discovery_portal").className='p7currentmark';			
  } else if (/online_data_by_theme/.exec(document.location)) {
	  document.getElementById("online_data_by_theme").className='p7currentmark';
  } else if (/data_submission/.exec(document.location)) {
	  document.getElementById("data_submission").className='p7currentmark';
  } else if (/marine_data_standards/.exec(document.location)) {
	  document.getElementById("marine_data_standards").className='p7currentmark';
  } else if (/library/.exec(document.location)) {
	  document.getElementById("library").className='p7currentmark';
  } else if (/about_us/.exec(document.location)) {
	  document.getElementById("about_us").className='p7currentmark';
  } else if (/joining_medin/.exec(document.location)) {
	  document.getElementById("joining_medin").className='p7currentmark';
  } else if (/marine_data_news/.exec(document.location)) {
	  document.getElementById("marine_data_newsletter").className='p7currentmark';
  } else if (/contact_us/.exec(document.location)) {
	  document.getElementById("contact_us").className='p7currentmark';
  } else if (/site_map/.exec(document.location)) {
	  document.getElementById("site_map").className='p7currentmark';
  }
}

var fileLoc = "/extlink/";

function mOver() {
self.status='External Link'; return true;
}
function mOut() {
self.status=''; return true;
}
function mLog(link) {
	if (link.hostname == "www.oceannet.org") {
		_uacct = "UA-8045808-1";
		pageTracker._trackPageview (link.href.replace(/http:\/\/www.oceannet.org/g,''));
	} 
	if (link.hostname == "portal.oceannet.org") {
        _uacct = "UA-8045808-1";
		pageTracker._trackPageview (link.href.replace(/http:\/\/portal.oceannet.org/g,''));
	} 		
    var mydocument = link.href.replace('http://','');
	var document = mydocument.substring(mydocument.indexOf("/"));
	var href=location.href;
	var myreferer = href.replace('http://','');
	var referer = myreferer.substring(myreferer.indexOf("/"));
	var image=new Image(1,1);
   	image.src="log.gif?document="+document+"&referer="+referer;
    image.onload=function() { Void(); }
	return true;
}

function mExtlink(extlink) {
	if(extlink.hostname == "www.oceannet.org") {
		_uacct = "UA-8045808-1";
		pageTracker._trackPageview (extlink.href.replace(/http:\/\/www.oceannet.org\//g,''));
	} 
	if(extlink.hostname == "portal.oceannet.org") {
		_uacct = "UA-8045808-1";
		pageTracker._trackPageview (extlink.href.replace(/http:\/\/portal.oceannet.org\//g,''));
	} 
	var mydocument=extlink.href.replace('http://','');
	var document = mydocument.substring(mydocument.indexOf("/"));
	document = document.replace('/extlink/','');
	document = document.replace('%3A',':');
	var href=location.href;
	var myreferer = href.replace('http://','');
	var referer = myreferer.substring(myreferer.indexOf("/"));
	var image=new Image(1,1);
   	image.src="log.gif?document="+document+"&referer="+referer;
    image.onload=function() { Void(); }
	return true;
}

function Void() { return; }

d = document.links; f = "file:"; j = "javascript:"; m = "mailto:"; t = "extlinks"; p = "ftp:";
for (i = 0; i < (d.length); i++) {
	if (d[i].protocol != f && d[i].protocol != j && d[i].protocol != m && d[i].protocol != p && (/\.pdf/.exec(d[i].href) || /\.exe/.exec(d[i].href) || /\.txt/.exec(d[i].href) || /\.doc/.exec(d[i].href) || /.xls/.exec(d[i].href) || /\.ppt/.exec(d[i].href) || /\.csv/.exec(d[i].href) || /\.kml/.exec(d[i].href) || /\.xml/.exec(d[i].href) || /\.vcf/.exec(d[i].href) || /\.zip/.exec(d[i].href))) {
		d[i].onclick=function(){return mLog(this);}
		d[i].target = Math.random()*4;
		if (/.vcf/.exec(d[i].href)) {d[i].target = null;}
	}	
	if (d[i].protocol != f && d[i].protocol != j && d[i].protocol != m && d[i].hostname != document.domain) {
		d[i].onclick=function(){return mExtlink(this);}
		d[i].title = "External link to " + d[i].href;
		d[i].onmouseover = mOver
		d[i].onmouseout = mOut
		d[i].href = fileLoc + escape(d[i].href);
		if (!d[i].hostname.indexOf("oceannet") {
		   d[i].target = Math.random()*4;
		}
	}
}
