//
	// Internal tracking function
	// Also used to open rel="external" links in new windows
	// @author Simon C
//

function internalTracking() {

	// weed out incompatable browsers
	if ( !document.getElementsByTagName)
		return;
            
	// Make an array of the anchors
	var anchors = document.getElementsByTagName("a");
            
	// Loop through all anchors
	for ( var i=0; i < anchors.length; i++ ) {
                
		// Assign each individual vars
		var anchor = anchors[i];

		//Do external windows
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			anchor.setAttribute('target','_blank');
		}
		
		// Check its a link we want to track, look out for rel='internal'
		if ( anchor.getAttribute("href") && anchor.getAttribute("rel") == "internal" ) {
			
			// See if a source already exists - if it does use & instead of ?
			if ( anchor.getAttribute("href").indexOf('?') > 0 ) {
				
				// Modify the href to be &is (internal source) = the value of id
				anchor.setAttribute("href",anchor.getAttribute("href") + '&is=' + anchor.getAttribute("id"));
				
			} else {
				 
				// Modify the href to be ?is (internal source) = the value of id
				anchor.setAttribute("href",anchor.getAttribute("href") + '?is=' + anchor.getAttribute("id"));
			
			}
		}

	}
}
//  window.onload = internalTracking; <- used to load the function
