﻿//Drug hiding in nav
//hide the other drugs when you're on a drug page
  function hideDrugPages() { 
    var currentUrl = document.location.href;    
    var urlArray = currentUrl.split('/');
    for(var i=3; i<urlArray.length; i++) 
    {
        // If the current page we're on is in the [productname] directory, hide the others...
        if (urlArray[i] == 'erbitux')
        {
            document.getElementById('headitem6').style.display = 'none';
            document.getElementById('headitem7').style.display = 'none';
            //show the 'See more drugs' item
            document.getElementById('seeMoreDrugs').style.display = 'block';
        }
        else if (urlArray[i] == 'ixempra')
        {
            document.getElementById('headitem5').style.display = 'none';
            document.getElementById('headitem7').style.display = 'none';
            
            //show the 'See more drugs' item
            document.getElementById('seeMoreDrugs').style.display = 'block';
        }
        else if (urlArray[i] == 'sprycel')
        {
            document.getElementById('headitem5').style.display = 'none';
            document.getElementById('headitem6').style.display = 'none';
            document.getElementById('thirdlevel').style.display = 'block';
            
            //show the 'See more drugs' item
            document.getElementById('seeMoreDrugs').style.display = 'block';
        }
        else //Otherwise... don't filter the products
        {

        }
    }
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

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;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


//For Patient Assessment page
/* display = boolean: true if you want it to show  */
/* which = string: which item you're hovering over */
function showDiv(display, which)
{
   if(display) { 
        document.getElementById(which).style.display = 'block'; 
        //changeClass(which, 'rolloverLinkHover');
   }
   else { 
        document.getElementById(which).style.display = 'none'; 
        //changeClass(which, 'rolloverLink');
   } 
}

/* Change class name of an element with an ID */
function changeClass(itemID, itemClass) {
	document.getElementById(itemID).className = itemClass; 
}


function imgSwap(img, src1, src2, rolloverString) {
  if (document.images) {
    if (img.src.indexOf(rolloverString) == -1) {
      img.src = img.src.replace(src1, src2);
    }
    else {
      img.src = img.src.replace(src2, src1);
    }
  }
}

// Leave site (external links - from Destination Access to outside site)
function leaveBrandSite(url) {
	msg = 'You are about to leave the the Bristol-Myers Squibb www.destinationaccess.com site. The site you are linking to is not controlled or endorsed by Bristol-Myers Squibb Company and we are not responsible for the content provided on that site. Your linking to any off-site pages or other sites is at your own risk.'
  if (confirm(msg)) {
       window.open(url);
	};
}

function toBMS(url) {
	msg = 'You are about to leave the Bristol-Myers Squibb Company, Inc. DestinationAccess.com site. You are being redirected to a site maintained by Bristol-Myers Squibb, Company, Inc.'
  if (confirm(msg)) {
       window.open(url);
	};
}


function d(fieldName){
    var x;
    return (x = document.getElementById(fieldName)) ? x : alert(fieldName + " not found");
}


function validateUpdatesForm()
{
    var eMsg = document.getElementById('error_messages');
    eMsg.style.display = 'none';
    var eMsgLastName = document.getElementById('error_message_lastname');
    eMsgLastName.style.display = 'none';

    var eMsgEmail = document.getElementById('error_messagesEmail');
    eMsgEmail.style.display = 'none';
    var eMsgAddress1 = document.getElementById('error_messagesAddress1');
    eMsgAddress1.style.display = 'none';
    var eMsgAddress2 = document.getElementById('error_messagesAddress2');
    eMsgAddress2.style.display = 'none';
    var eMsgCity = document.getElementById('error_messagesCity');
    eMsgCity.style.display = 'none';
    var eMsgState = document.getElementById('error_messagesState');
    eMsgState.style.display = 'none'
    var eMsgZip = document.getElementById('error_messagesZip');
    eMsgZip.style.display = 'none'

    var bRegistration = myValidator.validateRegistration()
    
    if(bRegistration)
    {
        //window.location = "/updates-confirm.aspx";
        return true;
    } 
    else
    {
        if (eMsg.innerText != '')
        { eMsg.style.display = 'block'; }
        if (eMsgLastName.innerText != '')
        { eMsgLastName.style.display = 'block'; }
        if (eMsgEmail.innerText != '')
        { eMsgEmail.style.display = 'block'; }
        if (eMsgAddress1.innerText != '')
        { eMsgAddress1.style.display = 'block'; }
        if (eMsgAddress2.innerText != '')
        { eMsgAddress2.style.display = 'block'; }
        if (eMsgCity.innerText != '')
        { eMsgCity.style.display = 'block'; }
        if (eMsgState.innerText != '')
        { eMsgState.style.display = 'block'; }
        if (eMsgZip.innerText != '')
        { eMsgZip.style.display = 'block'; }
        return false;
        
    } 
}


function validateShareForm() {

    var eMsgName = document.getElementById('YourNameError');
    eMsgName.style.display = 'none';
    var eMsgemail = document.getElementById('YourEmailError');
    eMsgemail.style.display = 'none';
    var eMsgFrndName = document.getElementById('FriendNameError');
    eMsgFrndName.style.display = 'none';
    var eMsgFrndEmail = document.getElementById('FriendEmailError');
    eMsgFrndEmail.style.display = 'none';
    var bRegistration = myValidator.validateShare()
    
    if(bRegistration)
    {
        //window.location = "/email-page-thanks.aspx";
        return true;
    } 
    else
    {
        eMsgName.style.display = 'block';
        eMsgemail.style.display = 'block';
        eMsgFrndName.style.display = 'block';
        eMsgFrndEmail.style.display = 'block';
        return false;
    }      
}

function validateUnsubscribeForm()
{
    var eMsg = document.getElementById('error_messages');
    eMsg.style.display = 'none';

    var eMsgLastName = document.getElementById('error_message_lastname');
    eMsgLastName.style.display = 'none';

    var eMsgEmail = document.getElementById('error_messagesEmail');
    eMsgEmail.style.display = 'none';
    var eMsgAddress1 = document.getElementById('error_messagesAddress1');
    eMsgAddress1.style.display = 'none';
  //var eMsgAddress2 = document.getElementById('error_messagesAddress2');
    //eMsgAddress2.style.display = 'none';
    var eMsgCity = document.getElementById('error_messagesCity');
    eMsgCity.style.display = 'none';
    var eMsgState = document.getElementById('error_messagesState');
    eMsgState.style.display = 'none'
    var eMsgZip = document.getElementById('error_messagesZip');
    eMsgZip.style.display = 'none'
    
    var bRegistration = myValidator.validateUnsubscribe()
    
    if(bRegistration)
    {
        //window.location = "/unsubscribe-confirm.aspx";
        return true;
    } 
    else {

        if (eMsg.innerText != '')
        { eMsg.style.display = 'block'; }
        if (eMsgLastName.innerText != '')
        { eMsgLastName.style.display = 'block'; }
        if (eMsgEmail.innerText != '')
        { eMsgEmail.style.display = 'block'; }
        if (eMsgAddress1.innerText != '')
        { eMsgAddress1.style.display = 'block'; }
        //if (eMsgAddress2.innerText != '')
        //{ eMsgAddress2.style.display = 'block'; }
        if (eMsgCity.innerText != '')
        { eMsgCity.style.display = 'block'; }
        if (eMsgState.innerText != '')
        { eMsgState.style.display = 'block'; }
        if (eMsgZip.innerText != '')
        { eMsgZip.style.display = 'block'; }
        return false;    
    }      
}

function urchinTracker()
{
    //this is a temp fix so the flash doesnt cause a JS error
    //once the flash is fixed this function should be deleted;
    return;
}


