/*******************************************************************************
____________________________ API DOCUMENTATION BEGIN ___________________________
````````````````````````````````````````````````````````````````````````````````
Variables and functions used throughout website.

````````````````````````````````````````````````````````````````````````````````
_____________________________ API DOCUMENTATION END ____________________________
*******************************************************************************/

//------------------------------------------------------------------------------
// VARIABLES BEGIN
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// VARIABLES END
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// AUTO INVOKE FUNCTIONALITY BEGIN
//------------------------------------------------------------------------------

if(top.location.href != self.location.href) top.location.href = self.location.href; //prevent unauthorized framing

//------------------------------------------------------------------------------
// AUTO INVOKE FUNCTIONALITY END
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// NEW BROWSER WINDOW FUNCTIONS BEGIN
//------------------------------------------------------------------------------

//FUNCTION-- creates a mini popup browser window for glossary
function glossaryWin(url) {
 glossaryWin1= window.open(url,"cml_glossary",'directories=no,location=no,menubar=1,resizable=yes,scrollbars=yes,status=no,titlebar=yes,width=690,height=275,toolbar=0');
 if(glossaryWin1 != null) glossaryWin1.focus();
}

//------------------------------------------------------------------------------
// NEW BROWSER WINDOW FUNCTIONS END
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// DIALOGS BEGIN
//------------------------------------------------------------------------------

function interstitial1Dialog() {
 return confirm("This link will take you to a Web site not controlled or endorsed by MyCMLCare.com or its sponsor, Bristol-Myers Squibb. Bristol-Myers Squibb is not responsible for its content. Click OK to continue or CANCEL to return.");
}

function interstitial2Dialog() {
 return confirm("This link will take you to a Web site with information about reimbursement assistance for Bristol-Myers Squibb oncology products. Click OK to continue or CANCEL to return.");
}

function interstitial3Dialog() {
 return confirm("You are now leaving MyCMLCare.com. This link will take you to a Web site with information about a treatment for CML. Click OK to continue or CANCEL to return.");
}

function interstitialHcpDialog() {
 return confirm("The contents of this site are intended for US Healthcare Professionals.\n\nClick OK if you are a Healthcare Professional in the United States.");
}

//------------------------------------------------------------------------------
// DIALOGS END
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// CSS FUNCTIONS BEGIN
//------------------------------------------------------------------------------

//FUNCTION-- sets CSS class
function setCssClass(argID, argClass) {
 document.getElementById(argID).className = argClass;
}

//------------------------------------------------------------------------------
// CSS FUNCTIONS END
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// MENU BEGIN
//------------------------------------------------------------------------------

menus = new Array(); 

//CLASS CONSTRUCTOR-- creates menu object with foundation properties
function menu(argID, argPage, argParentMenu, argSubMenu, argMenuOnClass) {
 this.id = argID;
 this.page = argPage;
 this.parentMenu = argParentMenu;   
 this.subMenu = argSubMenu; 
 this.menuOnClass = argMenuOnClass;

 menus.push(this);
}

//------------------------------------------------------------------------------

function setMenu() {
 var pageId = document.getElementById("leftColumnDiv").className; //set target class

 for(var j=0;j<menus.length;j++)
 {
  if(pageId == menus[j].page)
  {
   setCssClass(menus[j].id, menus[j].menuOnClass); //set selected state of menu for page

   //if menu has a subMenu then expand it
   if(menus[j].subMenu)
   {
    document.getElementById(menus[j].subMenu).style.display = "inline";
   }

   var parentMenu = menus[j].parentMenu;

   while(parentMenu)
   {
	  document.getElementById(parentMenu.subMenu).style.display = "inline"; //expand parent menu
	  setCssClass(parentMenu.id, parentMenu.menuOnClass); //set selected state of parent menu
	  parentMenu = parentMenu.parentMenu; //set flag for next parentMenu check
   }
   break;
  }
 } 
}

//------------------------------------------------------------------------------
// MENU END
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// FONT SIZE BEGIN
//------------------------------------------------------------------------------

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 getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

window.onload = function(e) {
 var cookie = getCookie("cmlfs");
 var title = cookie ? cookie : getPreferredStyleSheet();
 setActiveStyleSheet(title);
}

window.onunload = function(e) {
 var title = getActiveStyleSheet();
 setCookie("cmlfs", title, 365);
}

var cookie = getCookie("cmlfs");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

//FUNCTION-- sets a cookie - jsv 1.0
function setCookie(cookieName, cookieValue, expireDate) { 
 if(expireDate != null)
 {
  //set expiration date for cookie
	var expires = new Date( );                                   
	expires.setTime(expires.getTime( ) + (1000 * 60 * 60 * 24 * expireDate)); //days ahead
 }
 document.cookie = cookieName + "=" + escape(cookieValue) + "; path=/" + ((expireDate == null) ? ";" : "; expires=" + expires.toGMTString());
}

//FUNCTION-- retrieves a cookie - jsv 1.0
function getCookie(cookieName) {
 var cookieNameStr = cookieName + "=";               
 var dc = document.cookie;
	            
 if(dc.length > 0)
 {              
  var beginStr = dc.indexOf(cookieNameStr);       
  if(beginStr != -1) 
  {           
   beginStr += cookieNameStr.length;       
   var endStr = dc.indexOf(";", beginStr);
   if(endStr == -1) {endStr = dc.length;}
   return unescape(dc.substring(beginStr, endStr));
  } 
 }
 return null;
}

//FUNCTION-- deletes a cookie - jsv 1.0
function deleteCookie(cookieName) {
 document.cookie = cookieName + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" + "; path=/";
}

//------------------------------------------------------------------------------
// FONT SIZE END
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// MISCELLANEOUS BEGIN
//------------------------------------------------------------------------------

function displayNone(argId) {
 document.getElementById(argId).style.display = "none";
}

function displayBlock(argId) {
 document.getElementById(argId).style.display = "block";
}

//------------------------------------------------------------------------------
// MISCELLANEOUS END
//------------------------------------------------------------------------------