var url = window.location.href;
var pageName = url.substring(url.lastIndexOf('/') + 1).toLowerCase();
var $j = jQuery.noConflict();



$j(document).ready(function() {
    var windowHeight = $j(window).height();
    if ($j('div#OuterWrapper').height() < windowHeight) {
        $j('div.CurveContent').height(windowHeight - 140);
    }
    $j("#3").hide();
    $j("#2").hide();

    showAccordion();

    $j('#toggleFirst').bind("mouseenter", function(event) {
        $j('#toggleFirst').addClass('hoverstate');
    });

    $j('#toggleFirst').bind("mouseleave", function(event) {
        $j('#toggleFirst').removeClass('hoverstate');
    });

    $j('#threeToggle').bind("mouseenter", function(event) {
        $j('#threeToggle').addClass('hoverstate');
    });

    $j('#threeToggle').bind("mouseleave", function(event) {
        $j('#threeToggle').removeClass('hoverstate');
    });

    $j('#toggleSecondMain').bind("mouseenter", function(event) {
        $j('#toggleSecond').addClass('hoverstate');
    });

    $j('#toggleThirdMain').bind("mouseenter", function(event) {
        $j('#toggleThird').addClass('hoverstate');
    });

    $j('#toggleSecondMain').bind("mouseleave", function(event) {
        $j('#toggleSecond').removeClass('hoverstate');
    });

    $j('#toggleThirdMain').bind("mouseleave", function(event) {
        $j('#toggleThird').removeClass('hoverstate');
    });

    $j('#Col_left').bind("mouseleave", function(e) {
        showAccordion();
    });

    if (!(pageName.startsWith("index.aspx"))) {
        $j('.subcontent').hide();
        var imgCtl = document.getElementById('quickLinkArrow');
        $j('.quick_link').bind("mouseenter", function() {
            $j('.subcontent').slideDown('medium');
            imgCtl.src = "/images/hcp/quick-links_open.gif";
        });
        $j('.QuickLinksWrapper').bind("mouseleave", function() {
            $j('.subcontent').slideUp('medium');
            imgCtl.src = "/images/hcp/quick-links_close.gif";
        });
    }
    else {
        $j('.subcontent').show();
    }
})



function showAccordion() {
   if ((pageName.startsWith("monotherapy-study-design.aspx")) ||
        (pageName.startsWith("monotherapy-efficacy.aspx")) ||
        (pageName.startsWith("monotherapy-safety1.aspx")) ||
        (pageName.startsWith("monotherapy-safety2.aspx")) ||
        (pageName.startsWith("monotherapy-safety3.aspx"))) {
        $j("#2").slideDown('slow');
        //added - Perwez
        $j("#3").slideUp('slow');
        
        $j('#toggleSecond').addClass('accordion-toggle-active');
        $j('#toggleSecondLi1').addClass('activenew');
        clinicalAccord();
    }
    if ((pageName.startsWith("combination-therapy-study-design.aspx")) ||
        (pageName.startsWith("combinationtherapyefficacy1.aspx")) ||
        (pageName.startsWith("combinationtherapyefficacy2.aspx")) ||
        (pageName.startsWith("combination-subset-data1.aspx")) ||
        (pageName.startsWith("combination-subset-data2.aspx")) ||
        (pageName.startsWith("combination-therapy2.aspx")) ||
        (pageName.startsWith("combination-subset-data3.aspx")) ||
        (pageName.startsWith("combination-therapy1.aspx")) ||
        (pageName.startsWith("combination-therapy-safety.aspx"))) {
        $j("#2").slideDown('slow');

        //added - Perwez
        $j("#3").slideUp('slow');
        
        $j('#toggleSecond').addClass('accordion-toggle-active');
        $j('#toggleSecondLi2').addClass('active');
        
        clinicalAccord();
    }
    if (pageName.startsWith("dosing-and-administration.aspx")) {
        $j('#toggleThird').addClass('accordion-toggle-active');
        //added - Perwez
        dosingAccord();
        $j("#3").slideDown('slow');
        $j("#2").slideUp('slow');
    }
    if (pageName.startsWith("clinical_data.aspx")) {
        //added - Perwez
        clinicalAccord();
        $j("#3").slideUp('slow');
        $j("#2").slideDown('slow');
        
        $j('#toggleSecond').addClass('accordion-toggle-active');
    }
    if (pageName.startsWith("reimbursement.aspx") ||
        pageName.startsWith("references.aspx") ||
        pageName.startsWith("site-map.aspx") ||
        pageName.startsWith("important-safety-information.aspx") ||
        pageName.startsWith("unsubscribe.aspx") ||
        pageName.startsWith("unsubscribe-confirmation.aspx") ||
        pageName.startsWith("register-confirmation.aspx") ||
        pageName.startsWith("register.aspx")) {
        //added - Perwez
        $j("#3").slideUp('slow');
        $j("#2").slideUp('slow');

        if (pageName.startsWith("reimbursement.aspx")) {
            $j('#threeToggle').addClass('accordion-toggle-active');
        }

        $j('#toggleSecond').hoverIntent(function() {
            $j('#2').slideDown('slow');
            $j("#3").slideUp('slow');
        },
        function() {
            //mouseleave functionality
        });
        $j('#toggleThird').hoverIntent(function() {
            $j('#3').slideDown('slow');
            $j("#2").slideUp('slow');
        },
         function() {
            //mouseleave functionality
        });
        
        $j('#toggleFirst').mouseenter(function() {
            $j("#2").slideUp('slow');
            $j("#3").slideUp('slow');
        //}, function() {
            //moueleave functionality
        });
    }

    //added - Perwez

    if ((pageName.startsWith("dose-modification.aspx")) ||
	    (pageName.startsWith("how-supplied-materials-needed.aspx")) ||
	    (pageName.startsWith("handling-guidelines.aspx")) ||
	    (pageName.startsWith("constitution.aspx")) ||
	    (pageName.startsWith("dilution.aspx")) ||
	    (pageName.startsWith("iv-administration.aspx")) ||
	    (pageName.startsWith("faqs.aspx")) ||
	    (pageName.startsWith("additional-resources.aspx")) ||
	    (pageName.startsWith("test.htm")) ||
	    (pageName.startsWith("testfaq.html"))) {

        $j('#2').slideUp('slow');
        $j('#3').slideDown('slow');
        $j('#toggleThird').addClass('accordion-toggle-active');
        dosingAccord();
        if (pageName.startsWith("dose-modification.aspx")) {
            $j('#toggleThirdLi1').addClass('active');
        }
        if (pageName.startsWith("how-supplied-materials-needed.aspx")) {
            $j('#toggleThirdLi2').addClass('active');
        }
        if (pageName.startsWith("handling-guidelines.aspx")) {
            $j('#toggleThirdLi3').addClass('active');
        }
        if (pageName.startsWith("constitution.aspx")) {
            $j('#toggleThirdLi4').addClass('active');
        }
        if (pageName.startsWith("dilution.aspx")) {
            $j('#toggleThirdLi5').addClass('active');
        }
        if (pageName.startsWith("iv-administration.aspx")) {
            $j('#toggleThirdLi6').addClass('active');
        }
        if (pageName.startsWith("faqs.aspx")) {
            $j('#toggleThirdLi7').addClass('active');
        }
        if (pageName.startsWith("additional-resources.aspx")) {
            $j('#toggleThirdLi8').addClass('active');
        }
        
        if (pageName.startsWith("testfaq.html")) {
            $j('#toggleThirdLi1').addClass('active');
        }
    }
}

function clinicalAccord() {
    $j('#toggleThird').hoverIntent(function() {
        $j('#3').slideDown('slow');
    }, function() {
});

$j('#toggleFirst').mouseenter(function() {
    $j('#3').slideUp('slow');
});
$j('#toggleSecondMain').hoverIntent(function() {
    $j('#3').slideUp('slow');
}, function() {

})
}

function dosingAccord() {
    $j('#toggleSecond').hoverIntent(function() {
    $j('#2').slideDown('slow');
        }, function() {
    });
    $j('#toggleFirst').mouseenter(function() {
    $j('#2').slideUp('slow');
});
$j('#toggleThirdMain').hoverIntent(function() { 
    $j('#2').slideUp('slow');
},function(){
});
}

ddaccordion.init({
	headerclass: "popmenuheader", //Shared CSS class name of headers group
	contentclass: "popupbox", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["suffix", "Read More", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})

ddaccordion.init({
	headerclass: "faqsmenuheader", //Shared CSS class name of headers group
	contentclass: "faqsbox", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["on", "off"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["suffix", "<img src='/images/hcp/yellow_bullet_on.gif' class='statusicon' />", "<img src='/images/hcp/yellow_bullet_off.gif' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})

ddaccordion.init({
	headerclass: "mapheader", //Shared CSS class name of headers group
	contentclass: "mapbox", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["suffix", "<img src='/images/hcp/yellow_bullet_on.gif' class='statusicon' />", "<img src='/images/hcp/yellow_bullet_off.gif' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})


