﻿function goSelectedValue(ddlSelectBox)
{
	if (ddlSelectBox.value.length > 0)
    {	
        //alert(ddlSelectBox.value);	
        window.open(ddlSelectBox.value, '_self');
    }
}



//GLOSSARY
var offsetfrommouse=[20,-10]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always.
var currentimageheight = 0;	// maximum image size.

if (document.getElementById || document.all){
	document.write('<div id="trailimageid">');
	document.write('</div>');
}

function gettrailobj()
{
	if (document.getElementById)
		return document.getElementById("trailimageid").style
	else if (document.all)
		return document.all.trailimageid.style
}

function gettrailobjnostyle()
{
	if (document.getElementById)
		return document.getElementById("trailimageid")
	else if (document.all)
		return document.all.trailimageid
}


function truebody(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showGlossPop(id)
{
	document.onmousemove=followmouse;
	//document.onclick=followmouse;
	
	gettrailobjnostyle().innerHTML = document.getElementById(id).innerHTML;
	gettrailobj().display = "block";
}
function hideGlossPop(){
	gettrailobj().display = "none";
	document.onmousemove = "";
	gettrailobj().left = "-500px";

}
function followmouse(e){
    /*
    if (gettrailobj().display == "block") {
	    document.onclick="";
	}
	*/
	
	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	/*
	if (document.all){
		gettrailobjnostyle().innerHTML = 'A = ' + truebody().scrollHeight + '<br>B = ' + truebody().clientHeight;
	} else {
		gettrailobjnostyle().innerHTML = 'C = ' + document.body.offsetHeight + '<br>D = ' + window.innerHeight;
	}
	*/

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < 380){
			xcoord = e.pageX - xcoord - 300; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + 110)){
			ycoord += e.pageY - Math.max(0,(110 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < 400){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 380; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight + 110)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(110 + currentimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
		if(ycoord < 0) { ycoord = ycoord*-1; }
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"

}
//END GLOSSARY



//SLIDE NAV
/*****************************************************
 * ypSlideOutMenu
 * 3/04/2001
 * 
 * a nice little script to create exclusive, slide-out
 * menus for ns4, ns6, mozilla, opera, ie4, ie5 on 
 * mac and win32. I've got no linux or unix to test on but 
 * it should(?) work... 
 *
 * --youngpup--
 *****************************************************/

ypSlideOutMenu.Registry = []
ypSlideOutMenu.aniLen = 650
ypSlideOutMenu.hideDelay = 1
ypSlideOutMenu.minCPUResolution = 10

//Image Toggler Needed With SlideOut Component
function toggleImage(imgId, imgPath)
{
	var img = document.getElementById(imgId);
	img.src = imgPath;
}

// constructor
function ypSlideOutMenu(id, dir, left, top, width, height)
{
	this.ie  = document.all ? 1 : 0
	this.ns4 = document.layers ? 1 : 0
	this.dom = document.getElementById ? 1 : 0

	if (this.ie || this.ns4 || this.dom) {
		this.id			 = id
		this.dir		 = dir
		this.orientation = dir == "left" || dir == "right" ? "h" : "v"
		this.dirType	 = dir == "right" || dir == "down" ? "-" : "+"
		this.dim		 = this.orientation == "h" ? width : height
		this.hideTimer	 = false
		this.aniTimer	 = false
		this.open		 = false
		this.over		 = false
		this.startTime	 = 0

		// global reference to this object
		this.gRef = "ypSlideOutMenu_"+id
		eval(this.gRef+"=this")

		// add this menu object to an internal list of all menus
		ypSlideOutMenu.Registry[id] = this

		var d = document
		d.write('<style type="text/css">')
		d.write('#' + this.id + 'Container { visibility: hidden; ')
		d.write('left: ' + left + 'px; ')
		d.write('top: ' + top + 'px; ')
		d.write('overflow: hidden; }')
		d.write('#' + this.id + 'Container, #' + this.id + 'Content { position: absolute; ')
		d.write('width: ' + width + 'px; ')
		d.write('height: ' + height + 'px; ')
		d.write('clip:rect(0 ' + width + ' ' + height + ' 0); ')
		d.write('}')
		d.write('</style>')

		this.load()
	}
}

ypSlideOutMenu.prototype.load = function() {
	var d = document
	var lyrId1 = this.id + "Container"
	var lyrId2 = this.id + "Content"
	var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1]
	if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
	var temp

	if (!obj1 || !obj2) window.setTimeout(this.gRef + ".load()", 100)
	else {

		this.container	= obj1
		this.menu		= obj2
		this.style		= this.ns4 ? this.menu : this.menu.style
		this.homePos	= eval("0" + this.dirType + this.dim)
		this.outPos		= 0
		this.accelConst	= (this.outPos - this.homePos) / ypSlideOutMenu.aniLen / ypSlideOutMenu.aniLen 

		// set event handlers.
		if (this.ns4) this.menu.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
//		this.menu.onmouseover = new Function("ypSlideOutMenu.showMenu('" + this.id + "')")
//		this.menu.onmouseout = new Function("ypSlideOutMenu.hideMenu('" + this.id + "')")

		//set initial state
		this.endSlide()
		
	}

}

	
ypSlideOutMenu.showMenu = function(id)
{
	var reg = ypSlideOutMenu.Registry
	var obj = ypSlideOutMenu.Registry[id]
	
	if (obj.container) {
		obj.over = true

		// if this menu is scheduled to close, cancel it.
		if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) }

		// if this menu is closed, open it.
		if (!obj.open && !obj.aniTimer) reg[id].startSlide(true)
	}
}

ypSlideOutMenu.hideMenu = function(id)
{
	// schedules the menu to close after <hideDelay> ms, which
	// gives the user time to cancel the action if they accidentally moused out
	var obj = ypSlideOutMenu.Registry[id]
	   if (obj.container) {
		   if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
		   obj.hideTimer = window.setTimeout("ypSlideOutMenu.hide('" + id + "')", ypSlideOutMenu.hideDelay);
	   }
}

ypSlideOutMenu.hide = function(id)
{
	var obj = ypSlideOutMenu.Registry[id]
	obj.over = false

	if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
	
	// flag that this scheduled event has occured.
	obj.hideTimer = 0

	// if this menu is open, close it.
	if (obj.open && !obj.aniTimer) obj.startSlide(false)
}

ypSlideOutMenu.prototype.startSlide = function(open) {
	this[open ? "onactivate" : "ondeactivate"]()
	this.open = open
	if (open) this.setVisibility(true)
	this.startTime = (new Date()).getTime()	
	this.aniTimer = window.setInterval(this.gRef + ".slide()", ypSlideOutMenu.minCPUResolution)
}

ypSlideOutMenu.prototype.slide = function() {
	var elapsed = (new Date()).getTime() - this.startTime
	if (elapsed > ypSlideOutMenu.aniLen) this.endSlide()
	else {
		var d = Math.round(Math.pow(ypSlideOutMenu.aniLen-elapsed, 2) * this.accelConst)
		if (this.open && this.dirType == "-")		d = -d
		else if (this.open && this.dirType == "+")	d = -d
		else if (!this.open && this.dirType == "-")	d = -this.dim + d
		else										d = this.dim + d

		this.moveTo(d)
	}
}

ypSlideOutMenu.prototype.endSlide = function() {

	this.aniTimer = window.clearTimeout(this.aniTimer)
	this.moveTo(this.open ? this.outPos : this.homePos)
	if (!this.open) this.setVisibility(false)
	if ((this.open && !this.over) || (!this.open && this.over)) {
		this.startSlide(this.over)
	}

}

ypSlideOutMenu.prototype.setVisibility = function(bShow) { 
	var s = this.ns4 ? this.container : this.container.style
	s.visibility = bShow ? "visible" : "hidden"
}
ypSlideOutMenu.prototype.moveTo = function(p) { 
	this.style[this.orientation == "h" ? "left" : "top"] = this.ns4 ? p : (p) + "px"
}
ypSlideOutMenu.prototype.getPos = function(c) {
	return parseInt(this.style[c])
}

// events
ypSlideOutMenu.prototype.onactivate		= function() { }
ypSlideOutMenu.prototype.ondeactivate	= function() { }
//END SLIDE NAV

//Get the URL of current page and append ?type=print to it. Open the new page.
function printPage() {
	var append = document.URL;
	if(append!=''){
		var finalURL = append + "?print=true";
	window.open(finalURL);
	}
}
/**
 * @class this is the Rollover class
 * @desacription specialized rollover class for the callouts
 */
var CalloutRollovers = Class.create();
CalloutRollovers.prototype = {
	initialize:function(rollers) 
	{
		this.rollers = $$('.'+rollers);
		for (i=0, len=this.rollers.length; i < len; ++i) {
			Event.observe(this.rollers[i], 'mouseover', this.rollover.bind(this), false);
			Event.observe(this.rollers[i], 'mouseout', this.rollout.bind(this), false);
		}//for...
	},

	rollover:function(event) 
	{
		this.ele = Event.element(event);
		this.ele.style.backgroundImage = 'url(images/'+this.ele.id+'-on.jpg)';
	
	},
	/**
	 * used in the mouseout state
	 * @param {Event} event
	 */
	rollout:function(event) 
	{
		this.ele = Event.element(event);
		this.ele.style.backgroundImage = 'url(images/'+this.ele.id+'.jpg)';
		
	}
};

Event.observe (window, 'load', function() {
	if ($$('.calloutRollover')[0] != null) {
		new CalloutRollovers('calloutRollover');
	}
	if ($('send_to_friend') != null) {
		Event.observe($('send_to_friend'), 'click', function(e){
			var send = $('send_area');
			
			$('register_area').style.display = 'none';
			send.style.display = 'block';
			send.up().style.backgroundImage = 'url(images/calloutB-send_to_friend.jpg)';
		}, false);
	}	
	if ($('register_for_updates') != null) { 
		Event.observe ($('register_for_updates'), 'click', function(e) {
			var reg = $('register_area');
			
			$('send_area').style.display = 'none';
			reg.style.display = 'block';
			reg.up().style.backgroundImage = 'url(images/calloutB-register_for_updates.jpg)';
		}, false);
	}

}, false);

function printerFriendly() {
		setActiveStyleSheet('printer');
		window.print();
}

function setActiveStyleSheet(title) {

   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}

function popSearch()
{
    //alert(document.getElementById("txtSearchBox").value);
    var srchTerm = document.getElementById("txtSearchBox").value;
    
    /* if(srchTerm != "")
    { */
        //var strURL = "/030-search-results.aspx?searchID=" + srchTerm;
        var strURL = "030-search-results.aspx?searchID=" + srchTerm;
        //alert(strURL);
        window.open(strURL, "_self");
    // }
    
    return true;
}

function trackAndPrintWindow(link)
{
    s.linkTrackVars = 'events';
    s.linkTrackEvents = 'event10';
    s.events = 'event10:' + sessionID;
    s.tl(link, 'o', 'PrintQuestions');
    
    window.print();
}

/*=======================================
-- Write Session Cookies
=========================================*/

function testSessionCookie () {
	document.cookie ="testSessionCookie=Enabled";
	if (readCookie("testSessionCookie")=="Enabled")
		return true;
	else
		return false;
}

function writeSessionCookie (cookieName, cookieValue) {
	if (testSessionCookie()) {
		document.cookie = escape(cookieName) + "=" + escape(cookieValue) + "; path=/";
		return true;
	}
	else return false;
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

/*=======================================
-- Check first visit
=========================================*/

function checkFirstVisit()
{
	var curURL = window.location.href;
	curURL = curURL.toLowerCase();
	if( curURL.indexOf('default.aspx') > 0 || 
	    curURL == 'http://www.mytreatmentdecision.com' ||
	    curURL == 'http://www.mytreatmentdecision.com/' ||
	    curURL == 'http://mytreatmentdecision.com' ||
	    curURL == 'http://mytreatmentdecision.com/'
	     )
	{
		//alert('on the homepage.');
		var chkVisit = readCookie('firstVisit');
		//alert('chkVisit cookie is: ' + chkVisit);
	
		if( chkVisit == null || chkVisit == '' )
		{
			writeSessionCookie('firstVisit', 'true');
			return true;
		}
		else return false;
	}
	else return false;
}				

var blnFirst = checkFirstVisit();
//alert('First Visit value is: ' + blnFirst);

function trackandPop(objTarg)
{
    s.linkTrackVars = "events"; 
    s.linkTrackEvents = "event15";
    s.events = "event15";
    s.tl(objTarg,'o','Home_Treatment_Coach_Tout');
    window.open('https://www.breastcancertreatmentcoach.com','Breast_Cancer_Treatment_Coach','width=666,height=546');
}