﻿//External Links set to Target Blank
//Note: Prototype Driven
function externalLinks() {
	$$('a[rel="external"]').each(function(link){
		if (link.readAttribute('href') != '' && link.readAttribute('href') != '#') {
			link.writeAttribute('target', '_blank');
		}
	});
}

//Replacement for Window Onload - Loads before images, cross-browser
document.observe("dom:loaded", function() {
	externalLinks();
});



//// Start of scripts that are to be run at the ADAM servers to pass GUID from 1 page to another using session 
//Get Cookie 
function get_cookie(item_name) {
  var name_equals = item_name + "="
  var ret_val = "";
  if (document.cookie.length > 0) {
    off_set = document.cookie.indexOf(name_equals)
    // if cookie exists
    if (off_set != -1) { 
      off_set += name_equals.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", off_set);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      ret_val=unescape(document.cookie.substring(off_set, end))
      }
   }
  return ret_val;
}

function queryStringFromURL() { 
    fullURL = parent.document.URL 
    queryString = fullURL.substring(fullURL.indexOf('?')+1, fullURL.length) 
    return queryString; 
} 

function getGuidFromQuery() {
    guid = ""; 
    if (queryStringFromURL().substring(0, 5) == "guid=") 
        guid = queryStringFromURL().substring(5, queryStringFromURL().length); 
        
    return guid; 
}


// Call this script when going from page to page 
function CheckQueryForGUID() {
    guid = getGuidFromQuery(); 
    document.cookie = "guid=" + guid; 
}
///// End of scripts that are to be run at the ADAM servers to pass GUID from 1 page to another using session 
