// home page Flash

function getHomeFlash() {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="770" height="253" id="home_open" align="middle"><param name="allowScriptAccess" value="sameDomain"/><param name="movie" value="/flash/home/home_open.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="opaque"><embed src="/flash/home/home_open.swf" quality="high" bgcolor="#ffffff" width="770" height="253" name="home_open" align="middle" allowScriptAccess="sameDomain" wmode="opaque" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/></object>');
	
	// old one
	// document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="770" height="342" id="home_open" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="/flash/home/home_open.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="opaque"><embed src="/flash/home/home_open.swf" quality="high" bgcolor="#ffffff" width="770" height="342" name="home_open" align="middle" allowScriptAccess="sameDomain" wmode="opaque" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}

// dropdown select location change

function selsub(Url) {
  Url=document.subsites.sites[document.subsites.sites.selectedIndex].value;
  document.location = Url;
}


function setupExternalLinks() {
  var links = document.getElementsByTagName('a');
  for (var i = links.length; i != 0; i--) {
    var a = links[i-1];
    if (!a.href) continue;

    if (a.href.indexOf('http') != -1 &&
            a.href.indexOf(window.location.hostname) == -1 &&
      !excludeUrl(a.href)
        ) {
      a.onclick = function() {
                openExternalLink(this.href, this.target);
                return false;
            }

    }
  }
}

function excludeUrl(url){
  var excludeUrls = Array(
	    'http://www.afinitor.com',
		'http://www.glivec.com',
	    'http://www.cmlalliance.net',
		// 'http://www.gipap.org',
		'http://www.us.novartisoncology.com',
		'http://www.novctrd.com',
		'http://www.novartisclinicaltrials.com',
		'http://www.exjade.com',
		'http://www.femarainfo.com',
		'http://www.glivec.com',
		'http://www.gleevec.com',
		'http://www.sandostatin.com',
		'http://www.tasigna.com',
		'http://www.zometa.com',
		'http://www.novartisoncology.com',
		'https://www.novartisoncologyvpo.com',
		'http://www.novartis.com',
		'http://nibr.novartis.com',
		'http://www.novartis.com.cn',
		'http://www.zometa.cn',
		'http://www.glivec.cn',
		'http://www.saslar.cn',
		'http://www.novartis.fr',
		'http://www.novartisoncology.de',
		'http://www.novartis.gr',
		'http://www.novartis.co.jp',
		'http://www.glivec.nl',
		'http://www.exjade.nl',
		'http://www.novartis.nl',
		'http://www.novanurses.nl',
		'http://www.novartisoncology.nl',
		'http://www.novartis.no',
		'http://www.novartisoncology.ch',
		'http://www.novartis-oncology.ch/d/med/exjade/',
		'http://www.novartis-oncology.ch/d/med/glivec/',
		'http://www.novartis-oncology.ch/d/med/sandostatin/',
		'http://www.novartis-oncology.ch/d/med/zometa/produkt/index.aspx',
		'http://www.gleevec.com/',
		'http://www.femara.com/',
		'http://www.us.zometa.com/',
		'http://www.us.sandostatin.com/',
		'http://www.proleukin.com/',
		'http://www.us.exjade.com/',
		'http://www.us.tasigna.com/',
		'http://www.us.novartisoncology.com/info/disease_information/index.jsp',
		'http://www.us.novartisoncology.com/',
		'http://www.exjade.com/',
		'http://www.femarainfo.com/',
		'http://www.femarainfo.com/european/index.jsp',
		'http://www.glivec.com/content/tools/espc.jsp',
		'http://www.glivec.com/',
		'http://www.sandostatin.com/about_sandostatin/novartis_core_summary/index.html',
		'http://www.sandostatin.com/',
		'http://www.tasigna.com/tasigna-product-information.jsp',
		'http://www.tasigma.com/',
		'http://www.zometa.com/',
		'https://www.novartisoncologyvpo.com/',
		'http://www.novartis.com/careers/job-search/brassring/index.shtml',
		'http://www.novartis.com/careers/our-culture/index.shtml',
		'http://www.novartis.com/careers/benefits-and-rewards/index.shtml',
		'http://www.novartis.com/careers/talent-management/index.shtml',
		'http://www.novartis.co.kr/',
		'http://www.glivec.com/',
		'http://www.glivec.com/content/tools/espc.jsp',
		'http://www.novartis.com/newsroom/news/2007-04-17_coartem-africa.shtml',
		'http://www.corporatecitizenship.novartis.com/patients/access-medicines/access-in-practice/leprosy-videos.shtml',
		'http://www.corporatecitizenship.novartis.com/news/2007-01-07_world_tb_day_04.shtml',
		'http://www.novartisfoundation.org/platform/apps/home_e/index.asp?MenuID=209&ID=479&Menu=3&Item=41',
		'http://www.novartisfoundation.org/page/content/index.asp?Menu=3&MenuID=233&ID=520&Item=44.3',
		'http://www.novartisfoundation.org/page/content/index.asp?Menu=3&MenuID=394&ID=1095&Item=44.15',
		'http://www.novartisfoundation.org/platform/apps/home_e/index.asp?MenuID=209&amp;ID=479&amp;Menu=3&amp;Item=41',
		'http://www.novartisfoundation.org/page/content/index.asp?Menu=3&MenuID=237&ID=526&Item=44.6',
		'http://www.novartisfoundation.org/page/content/index.asp?Menu=3&MenuID=234&ID=522&Item=44.4',
		'http://www.novartisfoundation.org/page/content/index.asp?MenuID=240&ID=530&Menu=3&Item=44.8',
		'http://www.novartisfoundation.org/page/content/index.asp?MenuID=242&ID=534&Menu=3&Item=44.10',
		'http://www.novartisfoundation.org/page/content/index.asp?MenuID=268&ID=609&Menu=3&Item=45.9',
		'http://www.novartisfoundation.org/page/content/index.asp?MenuID=368&ID=1021&Menu=3&Item=45.11'
              );

  for(var l = 0; l < excludeUrls.length; l++){
    if(url.indexOf(excludeUrls[l]) == 0){
      return true;
    }
  }

  return false;
}

var pipeline_activeDet = null;

function pipeline_showDet(det_name){
	if(document.getElementById){
		if(pipeline_activeDet){
			pipeline_hideDet(pipeline_activeDet);
		}
		det = document.getElementById(det_name);
		pipeline_activeDet = det_name;
		det.style.display = 'block';
		
	}
}

function pipeline_hideDet(det_name){
	if(document.getElementById){
		if(det_name){
			det = document.getElementById(det_name);
		}else if(pipeline_activeDet){
			det = document.getElementById(pipeline_activeDet);
			pipeline_activeDet = null;
		}
		if(det){
			det.style.display = 'none';
		}
	}
}

var oTopInit = 150;

function getPageScroll(){
     var scrolly = typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement.scrollTop;   
     var scrollx = typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement.scrollLeft;   
	
	var arrayScroll = new Array(scrollx, scrolly);
	return arrayScroll;	
}

function getPageSize() {
	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth;
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = xScroll;
	} else {
		pageWidth = windowWidth;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}

 
function showOverlayer(){
	var size = getPageSize();
	var scroll = getPageScroll();

	var obg = document.getElementById('page-bg');
	obg.style.width = size[0]+'px';
	obg.style.height = size[1]+'px';
	
	var ovr = document.getElementById('overlayer');
	ovr.style.top = oTopInit + scroll[1]+'px';
	
	obg.style.display = 'block';
	ovr.style.display = 'block';
	
}

function hideOverlayer(){
	var obg = document.getElementById('page-bg');
	var ovr = document.getElementById('overlayer');

	ovr.style.display = 'none';
	obg.style.display = 'none';

}

var newsArticle = null;


function newsDisclaimer(anchor){
	if(anchor.href){
		window.newsArticle = anchor.href;
	}
	showOverlayer();
	
	return false;
}

function newsDisclaimerGo(){
	hideOverlayer();
	if(newsArticle){
		window.location = newsArticle;
	}
	
	return false;
}


// contact us dropdown

function selectTab(tabNumber) {
	if (document.getElementById) {	
		for (i = 1; i <= 26; i++) {
			if ('tab' + tabNumber == 'tab' + i) {
				document.getElementById('tab' + i + 'nav').style.display = 'block';
			}
			else {
				document.getElementById('tab' + i + 'nav').style.display = 'none';
			}
		}
	}
}
function showContent3(tabID) {
	if (document.getElementById) {
		for (i = 1; i <= 3; i++) {
			if ('main-tab-' + tabID == 'main-tab-' + i) {
				document.getElementById('main-tab-' + i).style.borderBottom = '1px solid #ffffff';
				document.getElementById('main-tab-p-' + i).style.borderTop = '4px solid #e44c16';
				document.getElementById('main-tab-a-' + i).style.color = '#000000';
				document.getElementById('tab-info-' + i).style.display = 'block';
			}
			else {
				document.getElementById('main-tab-' + i).style.borderBottom = '1px solid #e4e2cf';
				document.getElementById('main-tab-p-' + i).style.borderTop = '4px solid #c1b5aa';
				document.getElementById('main-tab-a-' + i).style.color = '#a28f7f';	
				document.getElementById('tab-info-' + i).style.display = 'none';
			}
		}
	}
}


function showContent4(tabID) {
	if (document.getElementById) {
		for (i = 1; i <= 4; i++) {
			if ('main-tab-' + tabID == 'main-tab-' + i) {
				document.getElementById('main-tab-' + i).style.borderBottom = '1px solid #ffffff';
				document.getElementById('main-tab-p-' + i).style.borderTop = '4px solid #e44c16';
				document.getElementById('main-tab-a-' + i).style.color = '#000000';
				document.getElementById('tab-info-' + i).style.display = 'block';
			}
			else {
				document.getElementById('main-tab-' + i).style.borderBottom = '1px solid #e4e2cf';
				document.getElementById('main-tab-p-' + i).style.borderTop = '4px solid #c1b5aa';
				document.getElementById('main-tab-a-' + i).style.color = '#a28f7f';	
				document.getElementById('tab-info-' + i).style.display = 'none';
			}
		}
	}
}

function showContent6(tabID) {
	if (document.getElementById) {
		for (i = 1; i <= 6; i++) {
			if ('main-tab-' + tabID == 'main-tab-' + i) {
				document.getElementById('main-tab-' + i).style.borderBottom = '1px solid #ffffff';
				document.getElementById('main-tab-p-' + i).style.borderTop = '4px solid #e44c16';
				document.getElementById('main-tab-a-' + i).style.color = '#000000';
				document.getElementById('tab-info-' + i).style.display = 'block';
			}
			else {
				document.getElementById('main-tab-' + i).style.borderBottom = '1px solid #e4e2cf';
				document.getElementById('main-tab-p-' + i).style.borderTop = '4px solid #c1b5aa';
				document.getElementById('main-tab-a-' + i).style.color = '#a28f7f';	
				document.getElementById('tab-info-' + i).style.display = 'none';
			}
		}
	}
}

function linkURL(URL) {
	if (URL.options[URL.selectedIndex].value != "") top.location.href = URL.options[URL.selectedIndex].value;
	return true;
}
