﻿/************************************************************************************/
isi_height = "1800px";
$(window).load(function() {
	$("#contentISI").css("height", "");
    $("div#fontResizer a.normalText").addClass("underlined");
    $("#WebPartWPQ5").css("margin-bottom", "60px");
    if ($.browser.msie) {
		if($.browser.version.substr(0,1)<8){
		$("#WebPartWPQ5").width("510px");
		}else{
		$("#WebPartWPQ5").width("480px");
		}
		}else{
    $("#WebPartWPQ5").width("485px");}
});

var fontTool = {
    increaseFont: function(triggerLink) {
        fontTool.increaseFontBy(triggerLink, 3);		
		$("#CmlTbl").addClass("fontresizeMarginfix");
		$("#footPara").addClass("margin115");
		$("#isiList").addClass("width550");
		$("#list1, #list2, #list3").addClass("width90");
		$("#leftColumnList").addClass("leftColListLarge");
        if ($.browser.msie) {
            if ($.browser.version == "6.0") {
                $('#isi_home  #contentISI #fist, #isi_home  #contentISI #fistrgt, #isi_home  #contentISI #scnd, #isi_home  #contentISI #scndrht, #isi_home #contentISI #thrd, #isi_home #contentISI #thrdrht, #isi_home  #contentISI #frth, #isi_home  #contentISI #frthrht').css({ "line-height": "22px" });
                $('.column.isi').css('line-height', '22px');
                $('span.top').css("margin-bottom", "-10px");
                if (window.location.pathname == "/consumer/ccyr.aspx") {
                    $('.bigochart').css({ "width": "500px" });
                }
            }			
			
            if (window.location.pathname == "/consumer/sprycel-important-safety-information.aspx") {
                $('.afterColumn').css({ "width": "505px" });
            }
            $(".td1").height("120px");
            $(".td2, .td3, .td4").height("90px");
        }
         /*$('.faqNextPageLink').css({ backgroundPosition: '105px 3px' });*/
		 $(".faqNextPageLink").addClass("bgPosition105");
        switch (window.location.pathname) {
            case "/consumer/cml-support.aspx":
                $("div#content p, div#content ul").css("margin-bottom", "14px");
                //$("div#content p, div#content ul").css("line-height", "1.25em");
                $("#content h1").css("margin-bottom", "23px");
                break;

            case "/consumer/sprycel-reimbursement.aspx":
                $("div#content p, div#content ul").css("margin-bottom", "14px");
                $("div#content p, div#content ul").css("margin-top", "-1px");
                $("div#content p, div#content ul").css("line-height", "1.25em");
                $("#content h1").css("margin-bottom", "24px");
                break;

            //			case "/hcp/nd/importantsafetyinformation.aspx":   
            //			    $("#bottom_safety_info").css("height", "2305px");   
            //			    break;   
            default:

                break;
        }

    },

    decreaseFont: function(triggerLink) {
        fontTool.increaseFontBy(triggerLink, -3);
		$(".faqNextPageLink").removeClass("bgPosition105");		
		$("#CmlTbl").removeClass("fontresizeMarginfix");
		$("#footPara").removeClass("margin115");
		$("#isiList").removeClass("width550");
		$("#list1, #list2, #list3").removeClass("width90");
		$("#leftColumnList").removeClass("leftColListLarge");

        if ($.browser.msie) {
            if ($.browser.version == "6.0") {
                $('#isi_home  #contentISI #fist, #isi_home  #contentISI #fistrgt, #isi_home  #contentISI #scnd, #isi_home  #contentISI #scndrht, #isi_home #contentISI #thrd, #isi_home #contentISI #thrdrht, #isi_home  #contentISI #frth, #isi_home  #contentISI #frthrht').css({ "line-height": "" });
                $('.column.isi').css('line-height', '');
                $('span.top').css("margin-bottom", "-10px");
                if (window.location.pathname == "/consumer/ccyr.aspx") {
                    $('.bigochart').css({ "width": "467px" });
                }

            }
            /*$('.faqNextPageLink').css({ backgroundPosition: '85px 3px' });*/
			
            if (window.location.pathname == "/consumer/sprycel-important-safety-information.aspx") {
                $('.afterColumn').css({ "width": "" });
            }
            $(".td1").height("");
            $(".td2, .td3, .td4").height("");
        }
        switch (window.location.pathname) {
            case "/consumer/cml-support.aspx":
                $("div#content p, div#content ul").css("margin-bottom", "11px");
                $("div#content p, div#content ul").css("line-height", "14px");
                $("#content h1").css("margin-bottom", "20px");
                break;

            case "/consumer/sprycel-reimbursement.aspx":
                $("div#content p, div#content ul").css("margin-bottom", "11px");
                $("div#content p, div#content ul").css("line-height", "14px");
                $("#content h1").css("margin-bottom", "20px");
                break;

            //			case "/hcp/nd/importantsafetyinformation.aspx":   
            //			    $("#bottom_safety_info").css("height", "2305px");   
            //			    break;   
            default:

                break;
        }
            if ($.browser.msie) {$("#WebPartWPQ5").width("510px");
            $(".purple_bullet").width("515px");            
            }else{
            $("#WebPartWPQ5").width("480px");}

    },

    increaseFontBy: function(triggerLink, incBy) {

        if (($(triggerLink).attr("class")) && ($(triggerLink).attr("class").indexOf("underlined") > -1)) return;

        fontTool.increaseAllFontsBy($('#content'), incBy);
        fontTool.increaseAllFontsBy($('#isi_home'), incBy);
        fontTool.increaseAllFontsBy($("#contentISI #isi_home").contents().find('#contentISI'), incBy);

        var beforeISIHeight = $("#contentISI #isi_home").height();

        $("#contentISI #isi_home").css("height", $("#contentISI #isi_home").contents().height() + 100 + "px");
        var afterISIHeight = $("#contentISI #isi_home").height();
        if (beforeISIHeight == afterISIHeight) {
            $("#contentISI #isi_home").css("height", $("#contentISI #isi_home").contents().height() + 100 + "px !important");
        }
        $(triggerLink).parent().children().removeClass("underlined");
        $(triggerLink).addClass("underlined");
    },

    increaseAllFontsBy: function(element, incBy) {
        if (($(element).attr("class")) && ($(element).attr("class").indexOf("no_resize") > -1)) return;
        if ($(element).children().size() > 0) {
            $(element).children().each(function() {
                fontTool.increaseAllFontsBy(this, incBy);
            });
        }
        if ($(element).css('font-size')) {
            var currentSize = parseFloat($(element).css('font-size').replace('px', ''), 10);
            if (currentSize > 100) return; //IE6 fix
            var incFont = currentSize + incBy;
            $(element).css('font-size', incFont);
        }
    }
};


var closeTimer = null;
var subMenuUL = null;
var parentLI = null;
function closeMenu()
{  
    if (subMenuUL) subMenuUL.css('display', 'none');
    if (parentLI) parentLI.removeClass("selected");
}
//Close menu immediately if user clicks off menu
document.onclick = closeMenu;


		var timeout         = 500;
		var closetimer		= 0;
		var ddmenuitem      = 0;

		function dropdown_open()
		{	dropdown_canceltimer();
			dropdown_close();
			ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}

		function dropdown_close()
		{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

		function dropdown_timer()
		{	closetimer = window.setTimeout(dropdown_close, timeout);}

		function dropdown_canceltimer()
		{	if(closetimer)
			{	window.clearTimeout(closetimer);
				closetimer = null;}}

		$(document).ready(function()
		{	$('#dropdown > li').bind('mouseover', dropdown_open);
			$('#dropdown > li').bind('mouseout',  dropdown_timer);});

		document.onclick = dropdown_close;


		$(document).ready(function() {

		    //Tooltip support for IE6 (which doesn't have :hover support)
		    $("a.define").hover(
        function() {
            $(this).addClass("hover");

            //Calculate tooltip height and position it above link
            var height = $(this).find("span.tooltip").height();
            var offset = height + 10;
            $("a.hover span.tooltip").css("top", "-" + offset + "px");
        },
        function() {
            $(this).removeClass("hover");
        }
    );

		    $("div.faq-container").click(function() {
		        $("html").animate({ scrollTop: 0 }, "fast");

		    });
		    //Set up dropdown menu
		    $('ul#mainNav > li').mouseenter(function() {
		        //Reset timer
		        if (closeTimer) {
		            window.clearTimeout(closeTimer);
		            closeTimer = null;
		        }
		        closeMenu();
		        subMenuUL = $(this).find('ul').css('display', 'block'); //Show menu
		        parentLI = subMenuUL.parent("li").addClass("selected"); //Add selected class
		    });
		    $('ul#mainNav > li').mouseleave(function() {
		        closeTimer = window.setTimeout(closeMenu, 300); //Start timer to hide menu after 300ms delay
		    });
		    isi_height = $('.isi_iframe').css('height');
		    $('div#fontResizer a.normalText').click(function() {
		        $("div#fontResizer a.normalText").addClass("selected");
		        $("div#fontResizer a.largeText").removeClass("selected");
		        if ($("div#fontResizer a.normalText").attr("class") != "underlined") {
		            fontTool.decreaseFont(this);
		            $("div#fontResizer a.largeText").removeClass("underlined");
		        }
		    });

		    $('div#fontResizer a.largeText').click(function() {
		        $("div#fontResizer a.largeText").addClass("selected");
		        $("div#fontResizer a.normalText").removeClass("selected");
		        if ($("div#fontResizer a.largeText").attr("class") != "underlined") {
		            fontTool.increaseFont(this);
		            $("div#fontResizer a.normalText").removeClass("underlined");
		        }
		    });

		    //Save questions button
		    $("a#saveQuestions").click(function() {
		        //set "Ask Your Doctor" cookie
		        if ($("ul.auto_print_questions").length > 0) {
		            $.cookies.set("AskWhat", true);
		        }
		        //Get question text
		        var questionText = $("#questionInput").get(0).value;
		        questionText = jQuery.trim(questionText);
		        if (!questionText) {
		            questionText = " ";
		        }
		        //Save to cookie
		        $.cookies.set("savedQuestions", questionText);
		        return false;
		    });

		    //Print questions button
		    $("a#printQuestions").click(function() {

		        //Three questions need to be printed only when the user is printing from /consumer/treating-cmt-sprycel.aspx
		        var autoQuestions = "";

		        //Programatically save contents of textarea
		        $("a#saveQuestions").click();

		        //if "Ask Your Doctor" cookie is a present
		        var askFlag = $.cookies.get("AskWhat");
		        if (askFlag) {
		            autoQuestions = "What did my last test results mean?" + "<br style='margin-bottom:20px;' />\n";
		            autoQuestions += "When I'm experiencing a side effect, how do I know if it is a side effect of treatment or a symptom of CML?" + "<br style='margin-bottom:20px;' />\n"
		            autoQuestions += "What are the possible next steps, depending on upcoming test results?" + "<br style='margin-bottom:30px;' />\n"
		        }




		        //Retrieve question cookies
		        var questions = $.cookies.get("savedQuestions");
		        //alert(questions.toString().length);
		        var questionHTML;
		        if (questions) {

		            questionHTML = questions.toString().replace(/\n/g, '<br style="margin-bottom:12px;" />\n');
		            //alert(questionHTML.toString().length);
		            //alert(questionHTML);
		        }

		        if (questionHTML || autoQuestions.length > 0) {
		            if (!questionHTML) {
		                questionHTML = "";
		            }
		            //Create popup window, load questions into it, and print it
		            var printWindow = window.open("", "printWindow", "toolbar=0,location=0,width=600,height=600,scrollbars=yes");
		            var html = "<html><head><title>Questions for your doctor or nurse | SPRYCEL&reg; (dasatinib)</title></head>" +
                        "<body style='padding:10px 20px 30px 20px; font-family:arial,verdana,sans-serif;'><div id='myQuestions' style=' display:inline-block; width:500px; word-wrap: break-word; overflow: hidden;'>" +
                        "<h3 style='text-decoration:underline;margin-bottom:20px;'>Questions for your doctor or nurse?</h3>" +
                        "<a>What did my last test results mean?</a> <br /><br /><a>When I'm experiencing a side effect, how do I know if it is a side effect of treatment or a symptom of CML?</a> <br /><br /> <a>What are the possible next steps, depending on upcoming test results?</a> <br /><br />" +
                        $("<div />").append(autoQuestions + questionHTML).html() +
                        "</div></body></html>";
		            printWindow.document.open();
		            printWindow.document.write(html);
		            printWindow.document.close();
		            printWindow.window.print();
		        }
		        return false;
		    });


		    // Hide second tab and wire up tab buttons
		    $("#effectivenessTab2").hide();
		    $("#effectivenessTab1 div.tabButton").click(function() {
		        $("#effectivenessTab1").hide();
		        $("#effectivenessTab2").show();
		        return false;
		    });
		    $("#effectivenessTab2 div.tabButton").click(function() {
		        $("#effectivenessTab2").hide();
		        $("#effectivenessTab1").show();
		        return false;
		    });

		    //If the question list is on this page, try to load its contents from the cookie, if it exists
		    if ($("#myQuestions").length) {

		        //Show My Questions list if cookies are supported
		        if ($.cookies.test()) {
		            $("#myQuestions").show();

		            function updateCharCount() {
		                //Only allow cetain amt of characters
		                var maxChar = 4000;
		                var thatContent = $("#questionInput").val()
		                thatContent = thatContent.substring(0, maxChar);
		                var originalScrollTopPosition = thatContent.scrollTop;
		                //container.val(thatContent.substring(0, maxChar));
		                thatContent.scrollTop = originalScrollTopPosition;
		                var numChars = thatContent.length;
		                $("span#numChars").html(maxChar - numChars);
		            }

		            //Populate textarea if there is data in the cookie
		            var questions = $.cookies.get("savedQuestions");
		            if (questions) {
		                if (questions.toString().length > 0) {
		                    questions = jQuery.trim(questions);
		                    $("#questionInput").get(0).value = questions;

		                    updateCharCount();
		                }
		            }

		            //Update remaining character count on every keypress
		            $("#questionInput").bind('keyup', function(event) { updateCharCount(); })
								.bind('paste', function(event) { updateCharCount(); })
								.bind('mouseover', function(event) { updateCharCount(); });
		        }
		    }

		});

function leavesite(url)
{
   // var external_link = confirm('You are now leaving the SPRYCEL.com website.\n\nThe link you clicked on will take you to a site maintained by a third party, which is solely responsible for its content. Bristol-Myers Squibb Company does not control, influence, or endorse this site, and the opinions, claims or comments expressed on this site should not be attributed to Bristol-Myers Squibb Company. Bristol-Myers Squibb Company is not responsible for the privacy policy of any third-party websites. We encourage you to read the privacy policy of every website you visit.');
  
  var external_link = confirm('You are about to leave the Bristol-Myers Squibb SPRYCEL.com site. The site you are linking to is not controlled or endorsed by Bristol-Myers Squibb, and Bristol-Myers Squibb is not responsible for the content provided on that site.');
  if (external_link == true)
    {
        window.open(url);
    }
}

function otherBMS(url)
{
    var external_link = confirm('You are about to leave SPRYCEL.com, a Bristol-Myers Squibb site. You are being redirected to another Bristol-Myers Squibb site.');
    if (external_link == true)
    {
        window.open(url);
    }
}

// Leave site (external links - from Sprycel to Otsuka corp site)
function toOtsuka(url) {
	msg = 'You are about to leave the Bristol-Myers Squibb Company and Otsuka America Pharmaceutical, Inc. SPRYCEL.com site.  You are being redirected to the Otsuka America Pharmaceutical, Inc. corporate Web site.  Your linking to any other off-site pages or other sites is at your own risk.'
  if (confirm(msg)) {
		window.open(url);
	};
}

function newWindow(page, height, width, scrolls) 
{   

	var features =
        'width='	+ 350 +
        ',height='	+ 350 +
		',scrollbars='	+ scrolls +
        ',resizable= 1'	
	popupWindow = window.open(page, 'popupWindow', features);
	popupWindow.focus();
}

function toggle(element){
	if ($(element).is(':visible')) {
		$(element).hide(200);
	} else {
		$(element).show(200);
	}
}

function gotoISI(){
	$(document).scrollTop($('iframe.isi_iframe').offset().top);
}
