/*******************************************************************************
____________________________ API DOCUMENTATION BEGIN ___________________________
````````````````````````````````````````````````````````````````````````````````
Variables and functions used throughout website.

````````````````````````````````````````````````````````````````````````````````
_____________________________ API DOCUMENTATION 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(argID) {
 var pageId = document.getElementById(argID).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
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// CSS FUNCTIONS BEGIN
//------------------------------------------------------------------------------

//FUNCTION-- sets CSS class
function setCssClass(argID, argClass) {
 document.getElementById(argID).className = argClass;
}

//------------------------------------------------------------------------------
// CSS FUNCTIONS END
//------------------------------------------------------------------------------

//FUNCTION-- process flash requests
function flashExternalInterfaceReceiver(argValue) {
 switch(parseInt(argValue))
 {
  case 1:
    window.location.href = "/rizatriptan_benzoate/maxalt/consumer/migraine-diary/maxalt-coupon.jsp?WT.svl=5"; //flash banner 1
    break;
  case 2:
    window.location.href = "/rizatriptan_benzoate/maxalt/consumer/migraine-pain/maxalt-mlt-tablets.jsp?WT.svl=5"; //flash banner 2
    break;
  case 3:
    window.location.href = "/rizatriptan_benzoate/maxalt/consumer/migraine-pain/migraine-pain.jsp?WT.svl=5"; //flash banner 3
    break;
  default:
    alert("flashExternalInterfaceReceiver: NO MATCHES FOUND");
 }
}

//FUNCTION-- fixes png transparency in unsupported browsers
function setPng(argId, argClearEl, argClearBg, argImagePath, argSizingMethod) {
 if(document.all)
 {
  var targetEl = document.getElementById(argId);
  if(argClearEl) targetEl.innerHTML = "";
  if(argClearBg) targetEl.style.backgroundImage = "none";
  targetEl.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+argImagePath+"', sizingMethod='"+argSizingMethod+"')";
 }
}

function openMerckExternalWin(product, url) {
	if(! confirm("Thank you for visiting " + product + ".com.\n\nThe site you are going to is an unbranded, health education site brought to you by Merck, and is not related to " + product + ".com.\n\nDo you wish to continue?"))
    	return;

    var externalWin = window.open(url,null,"toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=600,height=500");
    if (externalWin.opener == null)
    	externalWin.opener=window;
        externalWin.opener.name="opener";
}

