/**
 **********************************************************************************
 *  960 gridder overrides (used to verify layout adheres to site template)
 **********************************************************************************
 */
window.gOverride = {
	gColor: '#ff9999',
	gColumns: '16',
	gOpacity: 0.05,
	pEnabled: false,
	setupEnabled: false
}
call960gridder = function() {
	document.body.appendChild(document.createElement('script')).src='http://gridder.andreehansson.se/releases/latest/960.gridder.js';
}


/**
 **********************************************************************************
 *  initialize global variables
 **********************************************************************************
 */

var cobrandingActive = false;
var avenir = {src: '/ppdocs/us/cns/flash/avenir.swf'}; // activate sIFR font
sIFR.repaintOnResize = false;
sIFR.activate(avenir);

	/* browser detection */
	var IE6 = (navigator.appVersion.indexOf("MSIE 6.")==-1) ? false : true;
	var IE7 = (navigator.appVersion.indexOf("MSIE 7.")==-1) ? false : true;
	var IE8 = (navigator.appVersion.indexOf("MSIE 8.")==-1) ? false : true;


/**
 **********************************************************************************
 *  method called on DOM ready
 **********************************************************************************
 */

var MerckSource =
{
	init: function()
	{
		// build global page elements
		if (document.getElementById('topnav')) // BuildPageElements methods should only be fired if current page is using main site template
		{
			MerckSource.BuildPageElements.redirectCookie();
			MerckSource.BuildPageElements.header();
			MerckSource.BuildPageElements.alternate();
			MerckSource.BuildPageElements.firstLastElements();
			MerckSource.BuildPageElements.adjustCSS();
			MerckSource.BuildPageElements.sIFR();
		}

		// configure form submit buttons
		if ($('form a.submit').length > 0) {MerckSource.BuildPageElements.submitButtons();}

		// configure page tabs
		if (document.getElementById('tabs')) {MerckSource.Tabs.init();}

		// configure show/hide toggles and accordions
		if ($('*').hasClass("toggler") || document.getElementById('accordion')) {MerckSource.Toggles.init();}

		// configure home page carousel
		if (document.getElementById('carousel')) {MerckSource.Carousel.init();}

		// configure condition guide selection box
		if (document.getElementById('guide-select')) {MerckSource.ConditionGuides.attachEvents();}
		
		// configure page tooltips
		if ($('.tooltip-trigger').length > 0) {MerckSource.Tooltips.init();}

		// browser-specific bug fixes
		MerckSource.BugFixes.init();

		// run 960 gridder
//		call960gridder(); // this function call should only be executed for layout verification purposes
	}
};


/**
 **********************************************************************************
 *  MerckSource.BuildPageElements (build all global page elements)
 **********************************************************************************
 */

MerckSource.BuildPageElements =
{
// set page title and URL in redirect cookie
	redirectCookie: function()
	{
		var url = top.location.href;
		var restricted = false;

		var restrictedRedirectURL = new Array();
		restrictedRedirectURL.push("cns_sign_in.jsp")
		restrictedRedirectURL.push("cns_registration.jsp")
		restrictedRedirectURL.push("cns_registration_thankyou.jsp")
		restrictedRedirectURL.push("cns_my_info.jsp")
		restrictedRedirectURL.push("cns_update_my_info_thankyou.jsp");

		for(i=0;i<restrictedRedirectURL.length;i++)
		{
			if (url.indexOf(restrictedRedirectURL[i]) != -1)
			{
				restricted = true;
			}
		}
		
		if (restricted == false)
		{
			url = ( url.lastIndexOf("/") != -1	) ? url.substring(url.lastIndexOf("/")+1) : url ;
			url = ( url.indexOf(".") != -1		) ? url.substring(0,url.indexOf(".")+4)	  : url ;
			document.cookie = "RedirectURL" + "=" + escape(top.location.href + "~~" + document.title) + "; path=/";
		}
	},

// set layout and hover styles for header
	header: function()
	{
		$('#topnav li a').hover(
		  function () {
			$('#topnav').addClass('hovering');
		  }, 
		  function () {
			$('#topnav').removeClass('hovering');
		  }
		);

		// add "on" class to active section in top nav
		var section = $('body').attr('class').split(" ");
		if ($('body').hasClass(section[0])) {$('#topnav li#nav-' + section[0] + ' a').addClass('on');}
	},

// add onclick events to all button links for form submission
	submitButtons: function()
	{
		$('form a.submit').bind('click', function(event) {
			event.preventDefault();
			this.formID = $(this).closest('form').attr('id');
			$('#'+this.formID+' input[type=submit]').click();
		});
	},

// adds an "even" or "odd" class to alternating elements within any container that has an "alternate" class
// the :even and :odd selectors are zero-indexed, so :even actually matches odd results
// the :nth-child() selector restarts the index each time a new element is matched
	alternate: function ()
	{
		$('table.alternate tr:nth-child(even)').addClass('even');
		$('table.alternate tr:nth-child(odd)').addClass('odd');
		$('div.alternate ul:nth-child(even)').addClass('even');
		$('div.alternate ul:nth-child(odd)').addClass('odd');
		$('div.alternate .columns:nth-child(odd)').addClass('even');
		$('div.alternate .columns:nth-child(even)').addClass('odd');
		$('div.alternate .search-result:odd').addClass('even');
		$('div.alternate .search-result:even').addClass('odd');
		$('ul.alternate > li:nth-child(even)').addClass('even');
		$('ul.alternate > li:nth-child(odd)').addClass('odd');
	},

// add a CSS class to the first or last element in a container
	firstLastElements: function ()
	{
		$('ol > li:last-child').addClass('last');
		$('ul > li:last-child').addClass('last');
		$('div ol:last-child').addClass('last');
		$('div ul:last-child').addClass('last');
	},

// adjust CSS of elements based on global selectors
	adjustCSS: function ()
	{
		$("ol + p, ul + p").css("padding-top", "1em");
	},

// activate sIFR - text replacement called on page load and when hidden page elements are shown
	sIFR: function ()
	{
		sIFR.replace(avenir, {
			selector: '#content h1#page-title, #content #page-title h1',
			css: '.sIFR-root {color: #012d6b; leading: -10;}',
			fitExactly: true,
			forceSingleLine: true,
			wmode: 'transparent',
			tuneHeight: -4
		});
	}
};


/**
 **********************************************************************************
 *  MerckSource.Tabs (configure page tabs: http://flowplayer.org/tools/tabs.html#configuration)
 **********************************************************************************
 */

MerckSource.Tabs =
{
// build tab content and configure navigation
	init: function()
	{
		$('#tabnav').tabs('.panel',
		{
			current: 'on',
			onBeforeClick: function(event, tabIndex)
			{
				if(this.getIndex() != tabIndex)
				{
					this.getCurrentTab().removeClass('on');
				}
			},
			onClick: function(event, tabIndex)
			{
				if ($('#tabnav a.on').parent().hasClass('right'))
				{
					$('#tabnav').addClass('right-on');
				}
				else
				{
					$('#tabnav').removeClass('right-on');
				}
			}
		});
	}
};


/**
 **********************************************************************************
 *  MerckSource.Toggles (configure show/hide toggles: http://flowplayer.org/tools/tabs.html#api)
 **********************************************************************************
 */

MerckSource.Toggles =
{
// build different types of togglers based on element ID
	init: function()
	{
		if (document.getElementById('alphabet')){this.alphabetToggler();}
		if (document.getElementById('full-description-link')){this.fullDescriptionToggler();}
		if (document.getElementById('accordion')){this.accordion();}
	},

// check for "alphabet" toggler links
	alphabetToggler: function()
	{
		$('#alphabet a').bind('click', this.alphabet);
	},

// configure "alphabet" toggle
	alphabet: function(event)
	{
		event.preventDefault();
		if ($(this).parent().attr('id') == 'view-all')
		{
			$('#alphabetic .columns').show().removeClass('on');
		}
		else
		{
			var letter = $(this).attr('href').charAt(1);
			$('#alphabetic .columns').hide();
			$('#alphabetic #'+letter).show().addClass('on');
		}
		$('#alphabet a.on').removeClass('on');
		$(this).addClass('on');
	},

// check for "full description" toggler link
	fullDescriptionToggler: function()
	{
		$('#full-description-link').bind('click', this.fullDescription);
	},

// configure "full description" toggle
	fullDescription: function(event)
	{
		event.preventDefault();
		if ($('#full-description-link').hasClass('arrow-down'))
		{
			$('#full-description-link').text('Show Full Description');
			$('#full-description-link').removeClass('arrow-down');
		    $('#full-description').slideUp();
		}
		else
		{
			$('#full-description-link').text('Hide Full Description');
			$('#full-description-link').addClass('arrow-down');
		    $('#full-description').slideDown();
		}
	},

// configure section accordion on any element that has a class of "toggler"
	accordion: function()
	{
		if ($('#accordion').hasClass('toggler'))
		{
			$.tools.tabs.addEffect("disable", function(tabIndex, done) {
				done.call();
			});
			$('#accordion h4').wrapInner('<div><span class="arrow-right"></span></div>');
			$('#accordion').tabs('#accordion > .panel', {
				tabs: 'h4',
				current: '',
				effect: 'disable',
				onBeforeClick: function(event, tabIndex)
				{
					this.getTabs().eq(tabIndex).toggleClass('on');
					this.getPanes().eq(tabIndex).slideToggle('normal');
				}
			});
		}
		else
		{
			$('#accordion h4').wrapInner('<div></div>');
		}
	}
};


/**
 **********************************************************************************
 *  MerckSource.Carousel (configure home page carousel: http://jquery.malsup.com/cycle/)
 **********************************************************************************
 */

MerckSource.Carousel =
{
// configure carousel panels and navigation
	init: function()
	{
		$.fn.cycle.updateActivePagerLink = function(pager, currSlideIndex) { // redefine class name used for active panel nav
			$(pager).find('a').removeClass('on')
				.filter('a:eq('+currSlideIndex+')').addClass('on'); 
		}; 
		$('#carousel').cycle(
			{
				pause: 1,
				timeoutFn: this.setPanelTimeouts, // duration in seconds for each panel (panel-1, panel-2, panel-3)
				pager:  '#carouselnav',
				pagerAnchorBuilder: this.setCarouselNav,
				pagerClick: this.attachClickEvent
			}
		)
	},

// define navigation elements
	setCarouselNav: function(idx, slide) {
		return '#carouselnav li:eq(' + idx + ') a';
	},

// define navigation elements
	attachClickEvent: function(zeroBasedSlideIndex, slideElement) {
		$('#carousel').cycle('pause');
	},

// set panel-specific display durations
	setPanelTimeouts: function(currElement, nextElement, opts, isForward)
	{
		var sDuration;
		var duration = 7000; // set default slide duration to 7000 milliseconds in case duration is not defined
		if (opts.currSlide == 0)
		{
			sDuration = $('#panel-first .panel-inner').attr('data-duration');
		}
		else if (opts.currSlide == 1)
		{
			sDuration = $('#panel-second .panel-inner').attr('data-duration');
		}
		else if (opts.currSlide == 2)
		{
			sDuration = $('#panel-third .panel-inner').attr('data-duration');
		}
		if (!isNaN(parseInt(sDuration)))
		{
			duration = parseInt(sDuration)*1000; // convert seconds to milliseconds
		}
		return duration;
	}
};


/**
 **********************************************************************************
 *  MerckSource.ConditionGuides (configure condition guide selection box)
 **********************************************************************************
 */

MerckSource.ConditionGuides =
{
// add default events to condition guides box
	attachEvents: function()
	{
		$('#guide-select li a').bind('click', this.setActiveState).bind('dblclick', this.goToGuide).bind('keyup', this.goToGuide);
		$('#box-condition-guides a.button-blue-bg').bind('click', this.goToGuide);
		if($.browser.safari) // WebKit-based browsers (Safari and Chrome) do not support keydown events attached to DOM elements
		{
			$('input, textarea, select').bind('focus', function() { // disable scroll when form field is active
				$('#guide-select').addClass('disable-scroll');
			});
			$('input, textarea, select').bind('blur', function() { // enable scroll when form field is not active
				$('#guide-select').removeClass('disable-scroll');
			});
			$(document).keydown(this.scrollToLetter); // attach keydown event to entire page
		}
		else
		{
			$('#guide-select').keydown(this.scrollToLetter); // attach keydown event to Condition Guide box only
		}
	},

// set styles for currently selected guide
	setActiveState: function(event)
	{
		event.preventDefault(); // prevents default browser event
		$('#guide-select li a').removeClass('on');
		$(this).addClass('on');
	},
	
// scroll to first condition that starts with the letter pressed (documentation: http://plugins.jquery.com/project/ScrollTo)
	scrollToLetter: function(event)
	{
		if (!$('#guide-select').hasClass('disable-scroll'))
		{
			var scrollToDigit = 0;
			if (65 <= event.which && event.which <= 65 + 25) {
				scrollToDigit = event.which - 64;
			} else if (97 <= event.which && event.which <= 97 + 25) {
				scrollToDigit = event.which - 96;
			}
			var scrollToId = 'cg-'+scrollToDigit;
			if (document.getElementById(scrollToId))
			{
				$('#guide-select').scrollTo('#'+scrollToId, {duration: 500});
				$('#guide-select li a').removeClass('on');
				$('#guide-select #'+scrollToId+' a').addClass('on');
				$('#guide-select').focus();
			}
		}
	},

// navigate to selected guide
	goToGuide: function(event)
	{
		event.preventDefault(); // prevents default browser event
		var selectedGuide = $('#guide-select li a.on');
		var selectedGuideURL = selectedGuide.attr('href');
		
		// go to condition guide if "enter" key was pressed, if link was double-clicked, or if button was clicked
		if (((event.keyCode == 13 || event.type == 'dblclick') && selectedGuide != "") || ($(this).hasClass('button') && selectedGuide.length > 0))
		{
			window.location.href = selectedGuideURL;
		}
		else if (event.type == 'click')
		{
			alert("Please select a condition");
		}
	}
};


/**
 **********************************************************************************
 *  MerckSource.Tooltips (configure page tooltips: http://flowplayer.org/tools/tooltip.html#configuration)
 **********************************************************************************
 */
MerckSource.Tooltips =
{
// initialize standard tooltip configurations
	init: function()
	{
		$(".tooltip-trigger").tooltip({
			tip: '.tooltip',
			effect: 'slide'
		}).dynamic({
			bottom:
			{
				direction: 'down',
				bounce: true
			} 
		});
	}
};


/**
 **********************************************************************************
 *  MerckSource.BugFixes (browser-specific bug fixes)
 **********************************************************************************
 */

MerckSource.BugFixes =
{
// browser detection and bug fixes
	init: function()
	{
		// detection and bug fixes for <=IE6
		var m = document.uniqueID // IE
		&& document.compatMode // >=IE6
		&& document.execCommand ;
		try
		{
			if(!!m)
			{
				m("BackgroundImageCache", false, true)// fix IE background image flicker
				$(document).pngFix(); // fix IE6 alpha transparency on PNGs
				
				// td alignment for 3rd-party content
				$('.vendor #body td[align=center]').css('text-align', 'center');
				$('.vendor #body td[align=middle]').css('text-align', 'center');
				$('.vendor #body td[align=right]').css('text-align', 'right');

				// IE bug that requires a delay after DOM ready before setting form field focus (used for sign in form)
				if ($('input#userName').length > 0)
				{
					setTimeout(function() {
						$('input#userName').focus();
					}, 500);
				}
			}
		}
		catch(err) {}
	}
};










/**
 *********************************************************************************
 **                                                                             **
 **          functions used on site prior to Release 48 Reskin project          **
 **                                                                             **
 *********************************************************************************
 */
var date = new Date();
var d  = date.getDate();
var day = (d < 10) ? '0' + d : d;
var m = date.getMonth() + 1;
var month = (m < 10) ? '0' + m : m;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;

function formNavSubmit() {
	theForm=document.forms['navseek'];
	if (theForm.qt.value != "")
	theForm.submit();
	else
	alert("Please enter a term or phrase to search.");
	return false;
}

function formMedSubmit() {
	if ($('#medseek #qt').val() == "")
	{
		alert("Please enter a term or phrase to search.");
		return false;
	}
}

function gotoSiteDownPage(){
	var url = '/ppdocs/us/cns/cns_registration_down.html';
	window.location.href = url;
}

function openWindow() {
	winStats='toolbar=no,location=no,directories=no,menubar=no,'
	winStats+='scrollbars=no'
	if (navigator.appName.indexOf("Microsoft")>=0)
	{
		winStats+=',left=30,top=50,width=760,height=599'
	}
	else
	{
		winStats+=',screenX=20,screenY=70,width=760,height=599'
	}
	freak = window.open("/ppdocs/us/cns/content/adam/visualbody/index.html","",winStats)
	freak.focus()
}

function MM_callJS(jsStr) { //v2.0
	return eval(jsStr)
}

function setTitle(){
	var title = window.document.title;
	document.forms['titleform'].condition_title.value = title;
}


/**
 ********************************************************
 **          copied from merck_source.js               **
 **          FOR global MerckSource functions          **
 ********************************************************
 */

//show tool tip for non-IE browser (title tag truncates, alt tag does not render)
function mozTooltip(evt,elementID){
	if(document.getElementById && navigator.userAgent.indexOf('MSIE')<=-1){
		var displayStyle = document.getElementById(elementID).style.display;

		if(displayStyle == "none"){
			var posx = 0;
			var posy = 0;

			if (evt.pageX || evt.pageY)
			{
				posx = evt.pageX;
				posy = evt.pageY;
			}
			else if (evt.clientX || evt.clientY)
			{
				posx = evt.clientX;
				posy = evt.clientY;
			}

			posy -= 65; // resize by vertical offset of left nav (see merck_source.css #leftNav top: value.)

			document.getElementById(elementID).style.display = "block";
			document.getElementById(elementID).style.left = posx+"px";
			document.getElementById(elementID).style.top = posy+"px";
		}
		else if (displayStyle == "block"){
			document.getElementById(elementID).style.display = "none";
		}
	}
}

function resizeArticle(fSize){
// This function should resize the text of the article displayed below
	var emSize;
	switch(fSize)
	{
		case 1: emSize = '.909em'; break;
		case 2: emSize = '1em'; break;
		case 3: emSize = '1.273em'; break;
		case 4: emSize = '1.455em'; break;
		case 5: emSize = '1.636em'; break;
	}
	$('#article-copy').css('font-size', emSize);
}

function Toggle(node)
{
	// Unfold the branch if it isn't visible
	if (node.nextSibling.style.display == 'none')
	{
		// Change the image (if there is an image)
		if (node.childNodes.length > 0)
		{
			if (node.childNodes.item(0).nodeName == "IMG")
			{
				node.childNodes.item(0).src = "/ppdocs/us/cns/images/minus.gif";
			}
		}

		node.nextSibling.style.display = 'block';
	}
	// Collapse the branch if it IS visible
	else
	{
		// Change the image (if there is an image)
		if (node.childNodes.length > 0)
		{
			if (node.childNodes.item(0).nodeName == "IMG")
			{
				node.childNodes.item(0).src = "/ppdocs/us/cns/images/plus.gif";
			}
		}

		node.nextSibling.style.display = 'none';
	}

}

function healthCentersTabShowHide(divToShow,divToHide){
	if(document.getElementById){
		var showThis = document.getElementById(divToShow);
		var hideThis = document.getElementById(divToHide);
		var showTab = divToShow + "Tab";
		var hideTab = divToHide + "Tab";
		var onTab = document.getElementById(showTab);
		var offTab = document.getElementById(hideTab);

		onTab.className = "on";
		offTab.className = "";
		showThis.style.display = "block";
		hideThis.style.display = "none";

		return false;
	}
	else {
		return false;
	}

}

function validateForm(theform){
	//moc-sso changes - remove username/password validation
	return true;
	var checkObjects = new Array();
	//minimums changed from 6 to 4 for Single Signon - WRF - 5/31/08
   	checkObjects[0] = defineObject( "login", "Username", document.MerckSourceSignIn.username.value, 4, 20);
	checkObjects[1] = defineObject( "login", "Password", document.MerckSourceSignIn.password.value, 4, 16);

	return validate( checkObjects ) ;
		if (document.all||document.getElementById)
			{
				for (i=0;i<theform.length;i++)
				{
					var tempobj=theform.elements[i];
					if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
					tempobj.disabled=true;
				}
			}
			else
			{
				return false;
			}
}

function detectHeader(){
	var strId=document.getElementById("headerSEO").className;
	if (strId=="Introduction to Cancer")
	{
		//strId="Cancer";
		document.getElementById("headerSEO").className="hidden";
		document.getElementById("headerSEOCancer").className="headerTEXT";
		document.getElementById("headerSEO2").className="hidden";
		document.getElementById("headerSEOCancer2").className="headerTEXT";
	}
	else
	{
		document.getElementById("headerSEO").className="headerTEXT";
		document.getElementById("headerSEO2").className="headerTEXT";
	}
}

function detectSubHeader(){
	var strId=document.getElementById("subHeaderSEO").className;
	//if (strId==" " || strId==""){
	//alert("This is string ID " + strId);
	if (strId=="Introduction to Cancer"){
		document.getElementById("subHeaderSEO").className="hidden";
		document.getElementById("subHeaderLearnAboutCancer").className="headerTEXT";

		document.getElementById("subHeaderSEO2").className="hidden";
		document.getElementById("subHeaderManageCancer").className="headerTEXT";
	}
}

function submitonce(theform)
{
	alert('test');
	if (document.all||document.getElementById)
	{
		for (i=0;i<theform.length;i++)
		{
			var tempobj=theform.elements[i];
			if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
			tempobj.disabled=true;
		}
	}
	else
	{
		return false;
	}
}


/**
 *********************************************
 **          copied from popup.js           **
 **          FOR popup definitions          **
 *********************************************
 */

function popUpNewWindow(URL) {

var hobo = window.open(URL, "Popup", "location=no,scrollbars=yes,menubars=yes,toolbar=yes,resizable=yes");
hobo.focus();
}

function popUpMedium(URL) {

var hobo = window.open(URL, "Popup", "height=210,width=205,location=no,scrollbars=no,menubars=no,toolbar=no,resizable=no");
hobo.focus();
}

function popUpSmall(URL) {

var hobo = window.open(URL, "Popup", "height=140,width=205,location=no,scrollbars=no,menubars=no,toolbar=no,resizable=no");
hobo.focus();
}

function popUpMediumLarge(URL) {

var hobo = window.open(URL, "Popup", "height=310,width=405,location=no,scrollbars=no,menubars=no,toolbar=no,resizable=no");
hobo.focus();
}

function popUpMediumLargeScroll(URL) {
escape(URL);
var hobo = window.open(URL, "Popup", "height=310,width=425,location=no,scrollbars=yes,menubars=no,toolbar=no,resizable=no");
hobo.focus();
}

function popUpFull(URL) {

var hobo = window.open(URL, "Popup", "height=600,width=700,location=no,scrollbars=yes,menubars=no,toolbar=no,resizable=yes");
hobo.focus();
}

function popUpLarge(URL) {

var hobo = window.open(URL, "Popup", "height=600,width=620,location=no,scrollbars=yes,menubars=no,toolbar=no,resizable=yes");
hobo.focus();
}

function popUpSiteTour(URL) {

var hobo = window.open(URL, "Popup", "height=400,width=520,location=no,scrollbars=yes,menubars=no,toolbar=no,resizable=yes");
hobo.focus();
}

function popUpMM(URL) {

var hobo = window.open("/pp/us/hcp/framemm.jspzQzpgzEz"+URL, "Popup", "height=600,width=700,location=no,scrollbars=yes,menubars=no,toolbar=yes,resizable=yes");
hobo.focus();
}

function popUpFullBrowser(URL) {

var hobo = window.open(URL, "Popup");
hobo.focus();
}

function openAddWindow(urlcontrolname, titlecontrolname) {

	var url = window.location;
	var title = window.document.title;

//	title = title.replace(/\s/gi, "+");

	newWindow = window.open("/pp/us/cns/myfolders/bookmarksaddurl.jspzQz" + urlcontrolname + "zEz" + escape(url) + "zAz" +  titlecontrolname + "=" + escape(title) + "", "Popup", "dependent=true,height=500,width=600,location=true,menubar=false,resizable=yes,status=false,toolbar=false,scrollbars=yes");
	//return false;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function openNewsLetterArchive(URL) {

	var url = window.location;
	//var title = "Merck Source - The Source Report";
	//title = window.document.title;
	//alert(title);

	var hobo = window.open(URL, "Popup", "height=600,width=690,location=no,scrollbars=yes,escape(title),menubar=false,toolbar=no,resizable=no");
	hobo.focus();
	
}

function openCNSAddWindow(urlcontrolname, titlecontrolname) {
	var url;
	var title = "";

	// If the bookmarked page exist in frames, get the parent's
	// frameset location and pass the content frame's PG parameter.
	if (parent.frames[0]){
		var strPg = "pg=";
		var strPgEnc = "pgzEz";
		var strParentURL = parent.document.location.toString();
		var strContentURL = window.location.toString();
		var intIndex;

		if(strContentURL.indexOf(strPgEnc, 0) < 0)
			intIndex = strContentURL.indexOf(strPg, 0);
		else
			intIndex = strContentURL.indexOf(strPgEnc, 0);

		strContentURL = strContentURL.substring(intIndex, strContentURL.length);	// Get content frame's PG parameter.

		if(strParentURL.indexOf(strPgEnc, 0) < 0){
			intIndex = strParentURL.indexOf(strPg, 0);
			intIndex = strParentURL.indexOf(strPg, intIndex + 1);
		}
		else{
			intIndex = strParentURL.indexOf(strPgEnc, 0);
			intIndex = strParentURL.indexOf(strPgEnc, intIndex + 1);
		}

		strParentURL = strParentURL.substring(0, intIndex);		// Remove the default PG parameter from the parent URL.

		url = strParentURL + strContentURL;		// Append the content frame's PG parameter to the parent URL.

		// If parent frame is PDR Health Maps add JS code to pop-up window.
		if(strParentURL.indexOf("cns_pdr_frameset.jsp") > -1)
			url = 'javascript:popUpFullBrowser(&#034;' + url + '&#034;)';
	}
	// Else, get the current window's location and title
	else
		url = window.location;

	var ind = title.indexOf("and how those diseases can affect you");
	if (ind != -1)
		title = title.substring(0, title.length-38);

	var ind = title.indexOf("and how they can affect you");
	if (ind != -1)
		title = title.substring(0, title.length-28);

	var ind = title.indexOf("and how it can affect you");
	if (ind != -1)
		title = title.substring(0, title.length-26);

	var ind = title.indexOf("MerckSource provides important information about");
	if (ind != -1)
		title = title.substring(0, ind) + title.substring(ind + 49, title.length);

	title = window.document.title;

	newWindow = window.open("/pp/us/cns/myfolders/bookmarksaddurl.jspzQz" + urlcontrolname + "zEz" + escape(url) + "zAz" +  titlecontrolname + "zEz" + escape(title) + "", "Popup", "dependent=true,height=500,width=600,location=true,menubar=false,resizable=yes,status=false,toolbar=false,scrollbars=yes");
}

function openCNSAddHLWindow(urlcontrolname, url, titlecontrolname, title) {
	newWindow = window.open("/pp/us/cns/myfolders/bookmarksaddurl.jspzQz" + urlcontrolname + "zEz" + escape(url) + "zAz" +  titlecontrolname + "zEz" + escape(title) + "", "Popup", "dependent=true,height=500,width=600,location=true,menubar=false,resizable=yes,status=false,toolbar=false,scrollbars=yes");
	//return false;
}
function navHandler(list) {
        window.location.href = list.options[list.selectedIndex].value;
}

function openInfoWindow (infoPage) {

// openInfoWindow opens the passed html page parameter in a remote window.
// You can create more remote windows by naming the new window object a
// different name.

var browser=navigator.appName + " " + navigator.appVersion;

   if (browser.substring(0, 8) == "Netscape" ){
      var newWind=window.open(infoPage,'info','toolbar=no,location=no,status=no,menubar=no,scrollbars=1,top=20,width=450,height=450,resizable=yes');
      if (newWind.closed){
        if (newWind.opener == null){
          newWind.opener = window;
        }
        else {
          if (browser.substring(0, 12) == "Netscape 3.0" )
            newWind.focus();
          if (browser.substring(0, 12) == "Netscape 2.0" )
            newWind.document.forms[0].display.focus();
        }
      }
      else {
        newWind.focus()
      }
   }
   else {
     var newWind=window.open(infoPage,'info','toolbar=no,location=no,status=no,menubar=no,scrollbars=1,top=20,width=450,height=450,resizable=yes');
   }
}

function popUpEXTERNAL(URL, NAME)
{
	var newWin = window.open('/pp/us/cns/cns_exit.jspzQzurlzEz'+URL+'zAznamezEz'+NAME);
	newWind.focus()
}
function virtbodysys(){
	var newpage = window.open("/ppdocs/us/cns/content/adam/animationplayer_merck/detector_qt.htm", "Popup", "height=620,width=640,location=no,scrollbars=no,menubars=no,toolbar=no,resizable=no");
	newpage.focus();
}
function popUpInteractiveBody(){
	var newWin = window.open("/ppdocs/us/cns/content/adam/visualbody/index.html", "Popup", "width=760,height=599,toolbar=no,location=no,directories=no,menubar=no,scrollbars=no");
	newWin.focus();
}

// This script is used only for Blausen Interactive Human Atlas
siteURL = "/ppdocs/us/cns/content/blausen/flash_content/BMCfile/";
//modify for clients
basefolder = "human";
//BASEurl = siteURL + "BMCfile/" + basefolder + "/atlasvar.js";
popupURL = siteURL + "popupNF.js";
//document.write(' <script language=\"JavaScript\" src=\"'+BASEurl+'"><\/script>');
document.write(' <script language=\"JavaScript\" src=\"'+popupURL+'"><\/script>');
document.write(' <link rel=\"stylesheet\" type=\"text/css\" href=\"'+ siteURL +'propertiesfordivs.css">');
// This script is used only for Blausen Interactive Human Atlas


function popUpBlausen2(URL,id,topicSelection,subtopicSelection)
	{
	topicMyDoc=topicSelection;
	subtopicMyDoc=subtopicSelection;

	if (id == "videoWindow")
		{
/*
		w	= "770";
		h	= (basefolder == "SLH")?465:535;
		if	(	basefolder == "human"
			&&	typeof(cobrandingActive) == "boolean"
			&&	cobrandingActive == true
			)
			{
			h += 24;
			URL += "?cb=1";
			}
		scrol	= "0";
		L	= "185";
		T	= "10";
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars='+scrol+',location=0,status=1,menubar=0,resizable=0,width='+w+',height='+h+',screenX='+L+',screenY='+T+',left = '+L+',top = '+T+' ');pagevideoWindow.focus();");
*/
		selectedVideo = subtopicSelection;
		var tag = document.getElementById("blausenLaunchLink");
		fireEvent(tag,'click');
		}
	else if (id == "clientWindow")
		{
		w	= "340";
		h	= "450";
		scrol	= "1";
		L	= "10";
		T	= "10";
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars='+scrol+',location=0,status=1,menubar=0,resizable=0,width='+w+',height='+h+',screenX='+L+',screenY='+T+',left = '+L+',top = '+T+' ');pageclientWindow.focus();");
		}
	else
		{
		w	= "330";
		h	= (basefolder == "SLH")?465:440;
		scrol	= "0";
		L	= "360";
		T	= "10";
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars='+scrol+',location=0,status=1,menubar=0,resizable=0,width='+w+',height='+h+',screenX='+L+',screenY='+T+',left = '+L+',top = '+T+' ');pageBMCWindow.focus();");
		}
	}

// Popup used for Care Guides
function popUpHealthTool(targetTool,desc)
		{
				window.open("/pp/us/cns/cns_healthtools_frame.jsp?targetTool="+targetTool + "&desc="+desc ,"winHealthtool"," width=900, height=550, status=yes, resizeable=yes");
				window.focus;
		}

// Popup used for RESTRICTED Health Tools
function popUpRestricted(targetTool,vendor,desc,lockState){
	if (!(targetTool==null || vendor == null || desc == null || lockState == null)){
		if(lockState == "listRestricted"){

			var referer = top.location.href;
			// check whether the URL contains question mark or not
			referer = (referer.indexOf("zQz") != -1 || referer.indexOf("?") != -1) ? referer + "&" : referer + "?";
			document.cookie = "RedirectURL" + "=" + escape(referer + "targetTool=" + targetTool + "&vendor=" + vendor + "&desc=" + desc  + "~~" + parent.document.title) + "; path=/";
			window.location = "https://"+location.hostname+"/pp/us/cns/cns_sign_in.jsp";
		}
		else{
			var healthToolsWin = window.open("/pp/us/cns/cns_healthtools_redirector.jsp?targetTool="+targetTool + "&vendor="+vendor + "&desc="+desc ,"winHealthtool","width=800,height=550,location=no,scrollbars=yes,menubar=yes,toolbar=yes,status=yes,resizable=yes");
			healthToolsWin.focus();
		}
	}
}

function MozKeyCap(e){
	if (navigator.appName == 'Netscape') {
		if (e.which == 13)
			viewCondGuide ();
	}
}

function IEKeyCap(){
	if (navigator.appName != 'Netscape') {
		if (window.event.keyCode == 13)
			viewCondGuide ();
	}
}

function popUp(URL) {
var hobo = window.open(URL, "Popup", "height=540,width=556,location=no,scrollbars=yes,menubars=no,toolbar=no,resizable=yes");
hobo.focus();
}


/**
 ****************************************************
 **          copied from frames                    **
 **          FOR co-branding links                 **
 ****************************************************
 */
function checkOpener(url)
{
	var openerExists = "";
	openerExists = window.top.checkIfExist(); 
	if (openerExists == "No")
	{
		var mywindow = window.open(url,"_blank","toolbar=yes, location=yes,  menubar=yes, scrollbars=yes, resizable=yes, copyhistory=yes")
		mywindow.moveTo(0,0);	
		mywindow.focus();
	}
}

function checkIfExist()
{
	//alert("in checkIfExist");
	if (window.opener && !window.opener.closed)
	{
		popupOpenerExist= "Yes";
		//alert("parent window still open"); 
	}
	else
	{
		popupOpenerExist= "No";
		//alert("parent window NOT open"); 
	}
	return popupOpenerExist;
}


/**
 **************************************************
 **          copied from validation.js           **
 **          FOR form validation                 **
 **************************************************
 */

hasalert = true;
function onExitPage() {
if (!hasalert)
{
	message = "Please click Register button to complete your registration.";
	if (window.location.href.indexOf("/pp/us/cns/cns_registration.jsp") == -1)
	{
		message = "Please click Submit button to save your changes.";
	}
	alert(message);
	window.location.href="javascript:void(0)";
	hasalert = true;
}
}

// Used to create objects for validation
   function defineObject( type, htmlname, val, min, max) {

     object = new Object();
     object.type = type;
     object.htmlname = htmlname;
     object.value = val;
     object.min = min;
     object.max = max;
     object.len = val.length;

     return object;
   }

// Used to create compare to object for validation.
// Used to compare password and password confirm values
   function defineCompareObject( type, htmlname, val, min, max, compareVal , compareHtmlName ) {

     object = defineObject ( type, htmlname, val, min, max );
     object.compareTo = compareVal;
     object.compareToName = compareHtmlName;

     return object;
   }

// Returns True if special characters are contained in input
     function hasSpecialCharacters ( input )	{

      var forbidden = false;
      var i;
      var exclude = " ,\"$;&}{][)(^><~?%#*|_\`/!\'-.@+:=\\/";

      for ( i = 0; i < input.length; i ++ )	{

         var c = input.charAt(i);

         if ( exclude.indexOf(c) != -1 )  	// on exclude list

             forbidden = true;

         if ( forbidden == true ) break;
       }

      return forbidden;

   }//:

// Used to check a string for special characters
// Any characters contained in the include string are ignored
    function hasSpecialCharactersExcept ( input, include )	{

      var forbidden = false;
      var i;
      var exclude = " ,\"$;&}{][)(^><~?%#*|_\`!\'-.@+=:\\/";

      for ( i = 0; i < input.length; i ++ )	{

         var c = input.charAt(i);

         if ( include.indexOf(c) != -1 ) //character on include list

           {} //do nothing

         else {

           if ( exclude.indexOf(c) != -1 )  	// on exclude list
             forbidden = true;

         }

         if ( forbidden == true ) break;
      }

      return forbidden;
   }//:

// Return true if all characters fit within 7 bits
   function check7BitClean(input) {
     for ( var i = 0; i < input.length; i ++ )
       if (! (input.charCodeAt(i) < 128)) // check 7-bit clean
         return false;

     return true;
   }

/**
 * Returns TRUE if value passes as a valid email address
 *
 * Examines each character in a string to determine
 * if the string represents a valid email address
 *
 * Definition :  Valid email address
 *  1) A string no less than 5 characters
 *  2) Does not begin with a special character
 *  3) Mailbox name contains only letters, numbers, underscores,
 *      dashes and periods
 *  4) Contains an "@" symbol
 *  5) The "@" symbol is not followed by a special character
 *  5) Contains a "." after the "@" symbol
 *  6) Suffix does not contain any special characters
 *
 *
 * Example :
 *
 *    Correct :  scott_tiger@merck.com  scott.tiger@merck.com   scott-tiger@merck.com.edu
 *  Incorrect :  $$scott_tiger@merck.co(  scot#tiger@merck.com    scott@.com.
 *
 *
*/
   function checkValidEmail (  emailAddress ) 	{

      var invalid = true;
      var state = "initial";
      var ampersand = "@";
      var exclude = ", \"$;&}{][)(^><~?%#*|_\`!\'-.@=+:\\/";
      var stateOneExclude = " ,\"$;&}{][)(^><~?%#*|\`!\'@=+:\\/";
      var stateThreeExclude = " ,\"$;&}{][)(^><~?%#*|\`!\'.@=+:\\/";


      if ( emailAddress.length < 5 )

         state = "invalid";

      else {

          for ( var i = 0; i < emailAddress.length; i ++ ) 	{

             var textChar = emailAddress.charAt(i);

             switch ( state ) 	{

                case "initial":  // must begin with letter or number

                   if ( exclude.indexOf(textChar) != -1 )
                      state = "invalid";

                   else
                      state = "one";

                break;

                case "one":

                   if ( textChar == "@" )
                      state = "two";
                   else {

                      if ( stateOneExclude.indexOf(textChar) != -1 )
                         state = "invalid";
                      }
               break;


               case "two":

                  if ( exclude.indexOf( textChar) != -1)
                     state = "invalid";
                  else
                     state = "three";
                  break;


               case "three":

                  if ( textChar == "." )
                     state = "four";
                  else  {

                     if ( stateThreeExclude.indexOf( textChar ) != -1)
                       state = "invalid";
                  }

               break;


               case "four":

                  if ( exclude.indexOf( textChar ) != -1 )
                     state = "invalid";

                  else
                     state = "five";
               break;

              case "five":

                 if ( textChar == "." )
                    state = "four";
                 else {

                 if ( exclude.indexOf( textChar ) != -1)
                    state = "invalid";
                 }
                 break;

              default:
              break;

            }//switch

	  }//for

        } //else

     return ( state == "five" );

   }//:

// Verifies that a text string contains only digits.
   function isANumber( txtNumber ) 	{

     var allNums = "0123456789";

     var validNum = true;

     for ( var i = 0; i < txtNumber.length; i ++ ) 	{

         var n = txtNumber.charAt(i);

         if ( allNums.indexOf(n) == -1 ) {

            validNum = false;

            break;

         }

    }

    return validNum;

}//:

/*
 * Generic method used to validate forms.
 *
 *  Overview:  Define a javascript object with properties from html form elements
 *             The method queries attributes of the generated object for validation purposes
 *             And builds an error message to display
 *
 */
   function validate ( objects )	{
     var language		= new Array();
     language["header"]	= "The following error(s) occured:"
     language["start"]	= "->";
     language["field"]	= " Field ";
     language["require"]	= " is required";
     language["min"]		= " and must consist of at least ";
     language["max"]		= " and must not contain more than ";
     language["minmax"]	= " and no more than ";
     language["chars"]	= " characters";
     language["num"]		= " and must contain a number";
     language["exact"]		= " and must equal the value of ";
     language["email"]	= " must contain a valid e-mail address ";
     language["specialchars"] = " and must consist of only letters, underscores, and hypens ";
     language["nospecialchars"] = " and must contain only letters and numbers ";
     language["valid"] = " and must contain a valid value";

     var returnVal = true;
     var i;
     var errorString = "";

     for ( i =0; i < objects.length; i ++ ) 	{

        switch ( objects[i].type )	{

           case 'login':

              if ( objects[i].len == 0 ) {
                 errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"]+"\n";
              }
              else if ((!check7BitClean(objects[i].value)) || hasSpecialCharactersExcept(objects[i].value, "-_" ) ) {
                 errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"] + language["specialchars"] + "\n";

              } else if ( objects[i].len < objects[i].min || objects[i].len > objects[i].max ) {
                 errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"] + language["min"] + objects[i].min + language["chars"] + language["minmax"] + objects[i].max + language["chars"] + "\n";

              } else {}

           break;

           case 'firstname':

              if ( objects[i].len == 0 ) {
                 errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"]+"\n";
              }
              else if ((!check7BitClean(objects[i].value)) || hasSpecialCharactersExcept(objects[i].value, "-_" ) ) {
                 errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"] + language["specialchars"] + "\n";

              } else if ( objects[i].len < objects[i].min || objects[i].len > objects[i].max ) {
                 errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"] + language["min"] + objects[i].min + language["chars"] + language["minmax"] + objects[i].max + language["chars"] + "\n";

              } else {}

           break;

           case 'lastname':

              if ( objects[i].len == 0 ) {
                 errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"]+"\n";
              }
              else if ((!check7BitClean(objects[i].value)) || hasSpecialCharactersExcept(objects[i].value, "-_" ) ) {
                 errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"] + language["specialchars"] + "\n";

              } else if ( objects[i].len < objects[i].min || objects[i].len > objects[i].max ) {
                 errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"] + language["min"] + objects[i].min + language["chars"] + language["minmax"] + objects[i].max + language["chars"] + "\n";

              } else {}

           break;

           case 'password':

              if ( objects[i].len == 0 ) {
                 errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"]+"\n";
              }
              else if ((!check7BitClean(objects[i].value)) || hasSpecialCharactersExcept(objects[i].value, "-_" ) ) {
                 errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"] + language["specialchars"] + "\n";
              } else if ( objects[i].len < objects[i].min || objects[i].len > objects[i].max ) {
                  errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"] + language["min"] + objects[i].min + language["chars"] + language["minmax"] + objects[i].max + language["chars"] + "\n";

              } else if ( objects[i].value != objects[i].compareTo ) {
						errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"] + language["exact"] + language["field"] + objects[i].compareToName + "\n";
              } else {}

           break;

           case 'string':

              if ( objects[i].len == 0 ) {
                 errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"]+"\n";
              }
              else {

                 if ( objects[i].len < objects[i].min || objects[i].len > objects[i].max ) {
                    errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"] + language["min"] + objects[i].min + language["chars"] + language["minmax"] + objects[i].max + language["chars"] + "\n";

                 }
              }

          break;

          case 'num':
              if ( objects[i].len == 0 ) {
                 errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"]+"\n";
              } else {

                 if ( ! isANumber ( objects[i].value ) ) {
                    errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"] + language["num"]+ "\n";
                 }
              }
          break;

         case 'email':

            if ((!check7BitClean(objects[i].value)) || !checkValidEmail ( objects[i].value ) ) {

               errorString += language["start"] + language["field"] + objects[i].htmlname + language["email"] + "\n";
            }

          break;


           case 'numlength':

			if ( objects[i].len == 0 ) {
					 errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"]+"\n";
				}

			else if ( ! isANumber ( objects[i].value ) ) {
						errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"] + language["num"]+ "\n";
			 }
			else if ( objects[i].len < objects[i].min ) {
						errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"]+ language["valid"] +  "\n";
				  }

            else if( (objects[i].htmlname == "Zip") &&  ( ( objects[i].value == "00000") || ( objects[i].value == "99999")) )
			 	 {
			            errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"]+ language["valid"] +  "\n";
       		 }

		      break;



        case 'hint':

              if ( objects[i].len == 0 ) {
                 errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"]+"\n";
              }
              else if ( hasSpecialCharactersExcept(objects[i].value, " '?.-_" ) ) {
                 errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"] + language["nospecialchars"] + "\n";
              } else if ( objects[i].len < objects[i].min || objects[i].len > objects[i].max ) {
                  errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"] + language["min"] + objects[i].min + language["chars"] + language["minmax"] + objects[i].max + language["chars"] + "\n";

              } else {}

           break;

        case 'nospecialcharacters':

           if ( objects[i].len != 0 && hasSpecialCharactersExcept(objects[i].value, "-_" ) ) {
                 errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"] + language["nospecialchars"] + "\n";
           }
        break;

        case 'htmlselect':

           if ( objects[i].value < 1 ) {
              errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"]+"\n";
           }
        break;
        default:

           if ( objects[i].len == 0 ) {
              errorString += language["start"] + language["field"] + objects[i].htmlname + language["require"]+"\n";
           }
        break;

       }//switch

     }//for

     if ( errorString ) 	{

         alert(language["header"].concat("\n" + errorString) );
         errors = "";
         returnVal = false;

     } else {

	 hasalert = true;
         returnVal = true;

     }//if


     return returnVal;

  }//:


/**
 ***************************************************************
 **          copied from forgotpassword.js                    **
 **          FOR Forgot Password Validation                   **
 ***************************************************************
 */
function toForm(formfieldnm) 
{
	formfieldnm.focus();
}

function checkUserNameIsEntered(message) 
{
	userName = document.Username.elements["Username"].value;
	if (userName.length < 1) 
	{
		alert (message);
		return false;
	}
	else
	{
		return true;
	}
}

function checkPw(redurl) 
{
	pw1 = document.passwordchange.elements["password"].value;
	pw2 = document.passwordchange.elements["retypedpassword"].value;
	if ((pw1.length < 6) || (pw1 != pw2)) 
	{
		window.location = redurl;		
		return false;
	}
	else
	{
		return true;
	}
}

function checkPersonalAnwerIsNotBlank(message) 
{
	answer = document.Question.elements["Answer"].value;
	if (answer.length < 1) 
	{
		alert (message);
		return false;
	}
	else
	{
		return true;
	}
}

function isEntered(theField,message) 
{
	var value = theField.value;
	if (value.length < 1)
	{
		alert (message);
		return false;
	}
	else
	{
		return true;
	}
}


/**
 ******************************************************
 **          copied from renderredirect.js           **
 **          FOR back to adam Link                   **
 ******************************************************
 */
function search(tmpObject)
{
	isFound = false;
	if (typeof(tmpObject) == "string")
	{
		for(i=0;i<this.length;i++)
		{
			if (this[i] == tmpObject)
			{
				isFound = true;
				break;
			}
		}
	}
	return isFound;
}
Array.prototype.contains=search;

//function to get the parameter for URL
function getParam(paramName,url)
{
	exp = new Array("zQz","zAz", "zEz", "zPz", "zCz", "zSz", "zTz", "zUz");
	val = new Array( "?"  ,"&"  , "="  , "."  , ":"  , "/"  , "+"  , "%");
	for (i =0 ; i < exp.length; url=url.replace(new RegExp(exp[i],"g"),val[i]), i++);

	startPos = url.indexOf(paramName+"=");
	return (startPos == -1) ? null : url.substring( (startPos + paramName.length + 1) , ( url.indexOf("&",startPos) == -1 ) ? url.length : url.indexOf("&",startPos) );
}


/**
 ***********************************************************************
 **          revised/rewritten from faq_flyouts.js                    **
 **          FOR You and Your Doctor FAQs                             **
 ***********************************************************************
 */

// toggle visibility for topic and question
function loadTopic(tID, qID)
{
	if(tID == undefined || tID == null) {return;} // escape from function if parameters have not been defined

	$('#topic').attr("value",tID); // set dropdown value
	$('.topic').hide(); // hide all topics
	$('#topic-'+tID).show(); // show selected topic
	if(qID != undefined && qID != null) // expand question
	{
		toggleAnswer(qID);
	}

	// loop through all questions within the topic and run ajax call for answer include files
	var aID;
	$('#topic-'+tID+' .answer').each(function()
	{
		aID = $(this).attr('data-answer-id');
		$('#answer-'+aID).load('/ppdocs/us/cns/content/savard/qa_0731/sav_a_'+aID+'.html');
	});
}

// toggle visibility and style for questions and answers
function toggleAnswer(qID)
{
	$('#answer-'+qID).toggle();
	$('#qa-'+qID).toggleClass('on');
}

// toggle visibility for all answers within a given topic
function toggleAll(state, tID)
{
	if (state == "show")
	{
		$('#topic-'+tID+' .answer').show();
		$('#topic-'+tID+' .qa').addClass('on');
	}
	else
	{
		$('#topic-'+tID+' .answer').hide();
		$('#topic-'+tID+' .qa').removeClass('on');
	}
}


/**
 ********************************************************************
 **          copied from blausen.js                                **
 **          FOR Blausen Interactive Human Atlas                   **
 ********************************************************************
 */
//window.setTimeout("popUpBlausen2('','videoWindow','','0000');", 1000);
//------------------------
function popupAtlas(topic)
//------------------------
	{
	//-------------------------------------------------------------------------------------------
	//hack to transform the carousel's animation request from a specitic request to a generic one
	//-------------------------------------------------------------------------------------------
	if (topic == "0090" && document.location.pathname.indexOf("cns_home.jsp") != -1)
		topic = "0000";
	//---------------------------------
	//record the SDC tagging page event
	//---------------------------------
	if (typeof sdcCollector == "object")
		{
		var title = videoTitles[topic];
		if (topic == "0000") title = "none";
		if (!title) title = "unknown";
		var eventName = title + " (" + topic + ")";
		sdcCollector.recordPageEvent
			(	"blausenVideoPlayer",
				eventName,
				"WT.cg_n",	"Interactive learning",
				"WT.cg_s",	"3D Medical Animations - Blausen"
			);
		}
	//-----------------------------------
	//make the screen wider, if necessary
	//-----------------------------------
//	changeScreenWidth(880);
	//----------------
	//launch the video
	//----------------
	var videoWidth	= 450;
	var videoRatio	= 'widescreen';
	var vars	= [];
	if (topic != "0000")
		vars[vars.length] = ["selected_topic",topic];
	loadAtlas(videoWidth,videoRatio,vars);
	document.getElementById("myshell").style.display = "block";
	document.getElementById("atlasHolder").style.display = "block";
	}
//-------------------------------------
function changeScreenWidth(widthNeeded)
//-------------------------------------
	{
	var screenResolution	= getScreenResolution();
	var windowSize		= getWindowResolution();
	if	(	screenResolution	!= null
		&&	windowSize		!= null
		&&	screenResolution.width	> widthNeeded
		&&	windowSize.width	< widthNeeded
		)
		window.resizeBy(widthNeeded - windowSize.width, 0);
	}
//----------------------------
function getScreenResolution()
//----------------------------
	{
	if (typeof(screen)=="object")
		{
		var obj = new Object;
		obj.width = screen.width;
		obj.height = screen.height;
		return (obj);
		}
	return null;
	}
//----------------------------
function getWindowResolution()
//----------------------------
	{
	if (parseInt(navigator.appVersion) > 3)
		{
		if ((navigator.appName=="Microsoft Internet Explorer") && document.body)
			{
			var obj = new Object;
			obj.width = document.body.offsetWidth;
			obj.height = document.body.offsetHeight;
			return (obj);
			}
		if (navigator.appName=="Netscape")
			{
			var obj = new Object;
			obj.width = window.innerWidth;
			obj.height = window.innerHeight;
			return (obj);
			}
		}
	return null;
	}
//-------------------------
function showInstructions()
//-------------------------
	{
	document.getElementById("BD_downArrow").style.display = "block";
	document.getElementById("BD_sideArrow").style.display = "none";
	document.getElementById("BP_InstructionsWindow").style.display = "block";
	changeStyle("atlasHolder","top",119,250);
	changeStyle("blausenDisclaimer","height",433,564);
	}
//-------------------------
function hideInstructions()
//-------------------------
	{
	document.getElementById("BD_downArrow").style.display = "none";
	document.getElementById("BD_sideArrow").style.display = "block";
	document.getElementById("BP_InstructionsWindow").style.display = "none";
	changeStyle("atlasHolder","top",250,119);
	changeStyle("blausenDisclaimer","height",564,433);
	}
//-------------------------
function fireEvent(obj,evt)
//-------------------------
	{
	var fireOnThis = obj;
	if( document.createEvent)
		{
		var evObj = document.createEvent('MouseEvents');
		evObj.initEvent( evt, true, false );
		fireOnThis.dispatchEvent(evObj);
		}
	else if(document.createEventObject)
		{
		fireOnThis.fireEvent('on'+evt);
		}
	}
//-------------------------
var itemsToChange = [];
var selectedVideo = "0090";
//-----------------------------------
function changeStyle(id,attr,from,to)
//-----------------------------------
	{
	var details	= new Object;
	details.from	= from;
	details.now	= from;
	details.to	= to;
	details.attr	= attr;
	if (id != "window")details.tag = document.getElementById(id);
	itemsToChange[itemsToChange.length] = details;
	window.setTimeout("alterDisplayAttributes();", 1);
	}
//-------------------------------
function alterDisplayAttributes()
//-------------------------------
	{
	var newItems = [];
	for (var x = 0; x < itemsToChange.length; x++)
		{
		var item = itemsToChange[x];
		if (item.now != item.to)
			{
			var increment = 0;
			if (item.to > item.from)
				{
				increment = 1;
				if (item.to > item.now + 5) increment *= 5;
				}
			else
				{
				increment = -1;
				if (item.to < item.now - 5) increment *= 5;
				}
			item.now += increment;
			if (item.attr == "top")		item.tag.style.top = item.now + "px";
			if (item.attr == "height")	item.tag.style.height = item.now + "px";
			newItems[newItems.length] = item;
			}
		}
	itemsToChange = newItems;
	if (itemsToChange.length > 0)
		window.setTimeout("alterDisplayAttributes();", 1);
	}
//-----------------------
function BD_closePlayer()
//-----------------------
	{
	//---------------------------------------------
	//the following 2 statements are needed for IE6
	//---------------------------------------------
	document.getElementById("myshell").style.display = "none";
	document.getElementById("atlasHolder").style.display = "none";
//	$("#blausenPlayer").html = "";
//	if sound stops when closing blausen in IE6, the line above can be removed
	//---------------------------------------------
	tb_remove();
	}


/**
 ********************************************************************
 **          copied from atlasLoader.js                            **
 **          FOR Blausen Interactive Human Atlas                   **
 ********************************************************************
 */
function loadAtlas(videoWidth,videoRatio,variableArray){
	// to overright one of the variables below... add the following line to the SWFOBJECT script
	// =================================================
	// /////////////////////////////////////////////////
	/*
		atlasLoader.addVariable("VariableName","Value");
	*/
	// /////////////////////////////////////////////////
	// =================================================
	// loadPath :		The main path for loading all atlas components
	// ----------------------------------------------------------------------------------------
	// atlasType :		is used to pull both the main image skin and to pull the 
	//				current topics from the XML file							
	// ----------------------------------------------------------------------------------------
	// atlasLanguage	selects the correct folder to pull your assets from. it also 
	//				lets the text section know whether it needs to handle 
	//				characters in a special way (ie. arabic text)
	// ----------------------------------------------------------------------------------------
	// assetPath		sets the path for 'video','model','slides','text'
	// ----------------------------------------------------------------------------------------
	// autoLoadClip		designates which section should run automatically when a topic
	//				is selected
	// ----------------------------------------------------------------------------------------
	// selected_topic	if selected topic is set to a topic id that exists in the xml
	//				that is loaded, the topic will begin playing automatically
	//				when the atlas launches. this is most useful when clicking 
	//				an html link for a specific topic, which will then send
	//				the correct JS variable upon launching the atlas
	// ----------------------------------------------------------------------------------------
	// videoFolder		selects the folder from which to load the video files
	// ----------------------------------------------------------------------------------------
	// videoBufferTime	designates the number (in seconds) for how long you want a
	//				video to buffer before playing
	// ----------------------------------------------------------------------------------------
	// videoLoadPercent	designates the number (in seconds) for how long you want a
	//				video to buffer before playing
	// ----------------------------------------------------------------------------------------
	// videoType		designates whether the video is an flv or swf format
	// ----------------------------------------------------------------------------------------
	// videoAR		designates whether a video is 16x9 ('wide') or 4x3 ('standard')
	// ----------------------------------------------------------------------------------------
	// modelType		designates whether the qtvr model rorates on one axis or more
	//				if set to standar, the model only rotates on the x axis
	// ----------------------------------------------------------------------------------------
	// modelAspectRatio	designates whether the qtvr is 4x3 or 16x9
	// ----------------------------------------------------------------------------------------
	// skinColor		designates the folder to pull the background skins from
	//				also used to add external movie clips that are named with the
	//				'_skinColor' suffix
	// ----------------------------------------------------------------------------------------
	// skinBuild		designates the folder from which to pull all skins from
	//				default is 'skin/builds/' but there is a also a
	//				'skin/custom/' folder
	// ----------------------------------------------------------------------------------------
	// screenImage		designates the path for the main image loaded to screenLoader
	//				default is the name of the atlas being loaded
	// ----------------------------------------------------------------------------------------
	// XMLPath		designates the path for the xml file being loaded
	// ----------------------------------------------------------------------------------------	
	
	// set sizing
	if(videoRatio == 'widescreen')	var videoHeight = Math.round(videoWidth/1.78);
	else				var videoHeight = Math.round(videoWidth/1.33);
	videoWidth += 358;
	videoHeight += 109;	
	flashVars =
		{
		loadPath: "/ppdocs/us/cns/content/blausen/dvd/atlas/",
		skinBuild: "/ppdocs/us/cns/content/blausen/dvd/atlas/skins/builds/black/"
		};
	var params =
		{
		wmode: 'transparent',
		allowFullScreen: 'true'
		};
	var attributes =
		{
		};
	// for each variable that was added to the array, run the for loop to add a "flashvar" to the atlasLoader
	for(var i=0; i<variableArray.length; i++)
		flashVars[variableArray[i][0]] = variableArray[i][1];

	swfobject.embedSWF("/ppdocs/us/cns/flash/blausen.swf", "blausenPlayer", videoWidth, videoHeight, "9.0.0","/ppdocs/us/cns/flash/expressInstall.swf", flashVars, params, attributes);
}


/**
 **********************************************************************************
 *  methods to run on DOM ready
 **********************************************************************************
 */

$(document).ready(function() {
	MerckSource.init();
});
