// dropdown select location change

function selsub(Url) {
  Url=document.subsites.sites[document.subsites.sites.selectedIndex].value;
  document.location = Url;
}

excludeUrls = Array (
			'http://cws.huginonline.com',
            'http://dominoext.novartis.com',
            'http://download.macromedia.com',
            'http://etrials.novartis.com',
            'http://gaia.world-television.com',
            'http://infra.novartis.com',
            'http://ir2.flife.de',
            'http://mfile.akamai.com',
            'http://ncc.novartis.com',
            'http://nibr.novartis.com',
            'http://novcont05.eu.novartis.net',
            'http://qsm3.asp.quartal.com',
            'http://search.novartis.com',
            'http://web.gnf.org',
            'http://www.corporatecitizenship.novartis.com',
			'http://www.gnf.org',
			'http://www.nitd.novartis.com',
            'http://www.novartis.com',
            'http://www.novartisfoundation.org',
            'http://www.novartisoncology.us',
            'http://www.novartisvaccines.com',
            'http://www.novartis-vaccines.com',
            'http://www.petwellness.com',
            'http://www.pharma.us.novartis.com',
            'http://www.thinkwhatspossible.com',
            'http://www.us.cibavision.com',
            'http://www.us.novartis.com',
            'http://www.us.novartisoncology.com',
            'http://www.us.novartisophthalmics.com',
            'http://www.us.sandoz.com'
);

// Urchin tracking code for documents and external links
function setupUrchinTracking() {
	var links       = document.getElementsByTagName('a');

	var setup_link;
	for (var i = links.length; i != 0; i--) {
		setup_link = false;
		var a = links[i-1];
		if (!a.href) continue;
		
		// Track external links
		if(a.href.indexOf('http') != -1 &&
            a.href.indexOf(window.location.hostname) == -1){
			setup_link = true;
		}else{
			// Track documents
			setup_link = isDocument(a.href);
		}
		
		if (setup_link && !a.onclick){
			a.onclick = function() {
                track_url(this.href);
                return true;
            }
            
		}
	}
}

function isDocument(href){
	var track_files = new Array('.pdf', '.doc', '.PDF', '.DOC');
	for(var f = 0; f < track_files.length; f++){
		if(href.indexOf(track_files[f]) == (href.length - track_files[f].length)){
			return true;
		}
	}

	return false;
}

function removeDomain(href){
	if(href.indexOf('http') != -1 && href.indexOf(window.location.hostname) != -1){
		href = href.substring((window.location.hostname.length + 7));
	}
	return href;
}

function removeHTTP(href){
	if(href.indexOf('http') != -1){
		href = href.substring(7);
	}
	return href;
}

function track_url(href) {
	if(window.urchinTracker){
		// If is document, remove http://www.domainname.com
		if(isDocument(href)){
			href = removeDomain(href);
		}else{
		// If is external link, remove http:// and track the link under /external/
			href = '/external/' + removeHTTP(href);
		}
		//alert(href);
		urchinTracker(href);
	}
}

