var show_continue_button = false;
$(document).ready(function(){

    //alert($("#asProduct option:contains('Rit')").val());

    //alert(getCookie("productCurr"));

    if (getCookie("productCurr") == 'f73257e77eb07210VgnVCM1000007dc9320aRCRD'){
    $("#asProduct option:contains('Rituxan')").val('f73257e77eb07210VgnVCM1000007dc9320aRCRD');
    }
    else if(getCookie("productCurr") == '22719b2510c07210VgnVCM1000007dc9320aRCRD'){
    $("#asProduct option:contains('Rituxan')").val('22719b2510c07210VgnVCM1000007dc9320aRCRD');
    }

    //alert(show_continue_button);
    //ensure FAQs are expanded when printing
    //verify the product is set then use it
    //initialize form selections
    if(getCookie("productCurr")!="")
    {
        $("#asProduct").val(getCookie("productCurr"));
    }
    if(getCookie("Audience")=="HCP")
    {
        $("#asHCP").attr("checked", "true");
    }
    else if(getCookie("Audience")=="Patient")
    {
        $("#asPatient").attr("checked", "true");
    }
    if(getCookie("productCurr")!="")
    {
        //alert(getCookie("productCurr"));
        //check for Rituxan issues
        if(getCookie("productCurr")=="f73257e77eb07210VgnVCM1000007dc9320aRCRD" || getCookie("productCurr")=="22719b2510c07210VgnVCM1000007dc9320aRCRD")
        {
            resetRituxan();
        }
    	  	
    }
    //use juery to modify footer links if the browser is IE
    if(isIE())
    {
    	 
        $("#footerWrapper").css("width", "1000px");
        $(".footNav").css("padding-left", "15px");
        $(".footNav").css("padding-right", "70px");
    	
    	
    }	  
    $(".tout.small .icon img").css("padding-left", "18px");
    $(".tout.small .icon img").css("padding-top", "9px");
    //initialize all interstial values
    if($("#asProduct").val()!="")
    {
        if($("#searchpopupForm #popupProduct").val($("#asProduct").val())!=undefined)
        {
            $("#searchpopupForm #popupProduct").val($("#asProduct").val()).attr("selected", "true");
        }
        if($("#toutpopupForm #popupProduct").val($("#asProduct").val())!=undefined)
        {
            $("#toutpopupForm #popupProduct").val($("#asProduct").val()).attr("selected", "true");
        }
    }
    //alert($("#asHCP:checked").val());
    if($("#asHCP:checked").val() != undefined)
    {
        $("#searchpopupForm #popupHCP").attr("checked", "true");
        $("#toutpopupForm input[name='popupHCP']").attr("checked", "true");
    //alert($("#toutpopupForm #popupHCP:checked").val());
    }
    else if($("#asPatient:checked").val() != undefined)
    {
        $("#searchpopupForm #popupPatient").attr("checked", "true");
        $("#toutpopupForm input[name='popupPatient']").attr("checked", "true");
    //alert($("#toutpopupForm #popupPatient:checked").val());
    }
    	  
    //This jquery removes any additional contruct on the glossary terms past the first and ignores terms in the ignore array
    i = 0;
    //ignore array
    var ignoreAr = new Array();
    //ignoreAr[0] = "Access";
    var firstAr = new Array();

    
    var linkset = new Array();
    linkset[0] = "gene.com";
    linkset[1] = "ACTEMRA.com";
    linkset[2] = "Rituxan.com";
    linkset[3] = "Avastin.com";
    linkset[4] = "BioOncology.com";
    linkset[5] = "Herceptin.com";
    linkset[6] = "Tarceva.com";
    linkset[7] = "LUCENTIS.com";
    linkset[8] = "Nutropin.com";
    linkset[9] = "XOLAIR.com";
    linkset[10] = "Pulmozyme.com";
    linkset[11] = "GenentechRheumatologyAccessSolutions.com";
    linkset[12] = "BioOncologyAccessSolutions.com";
    linkset[13] = "RituxanAccessSolutions.com";
    linkset[14] = "AvastinAccessSolutions.com";
    linkset[15] = "HerceptinAccessSolutions.com";
    linkset[16] = "TarcevaAccessSolutions.com";
    linkset[17] = "LUCENTISAccessSolutions.com";
    linkset[18] = "NutropinAccessSolutions.com";
    linkset[19] = "XOLAIRAccessSolutions.com";
    linkset[20] = "PulmozymeAccessSolutions.com";
    linkset[21] = "ACTEMRAcard.com";
    linkset[22] = "XELODA.com";
    linkset[23] = "PEGASYS.com";
    $('a[href^="http"]').each(function(index, value){
        var link = $(this).attr("href");
        //console.log(href);
        if (!(arrayContains(link, linkset))){
            //console.log(link);
            $(value).attr("href","#");
            //$(value).attr("onmousedown","leaveSite('" + link + "');return false;");
            $(value).click(function(){
                leaveSite(link);
                return false;
            });
        }
    });
   
    $('#productModalPage').css("background", "url('/deployedfiles/AS/images/product_interstitial_popup.png')");
    /*This detects the class based on a box warning, in the instance that we are already showing the indications, do not show again*/
    if($('#mainContent').attr('class')=="article boxwarning" || $('#mainContent').attr('class')=="article fullpage")
    {		
        $('#ISI').removeAttr("class");
        $('#ISI').removeAttr("style");
        $('#ISI').attr("style", "display:none");
        $('.footNav').attr("style", "padding:35px 0px 0px 0px");
    }  
    if($('#mainContent').attr('class')=="article  fullpage")
    {
        
        $('#rightToutWrapper').css('display', 'none');
        $('#mainContent').css('width', '902px');
    }
        
        
    //format ol li as they should be
    $('#mainContentWrapper').css('background', 'white');
    $("ol li").css("margin-bottom", "0px");
    $("ol li:not(ul li)").css("background", "url()");
    $("ol li:not(ul li)").css("display", "list-item");
    $("ol li:not(ul li)").css("list-style", "decimal");
    $("ol li:not(ul li)").css("font-weight", "normal");
    $("ol li:not(ul li)").css("font-face", "Arial, Helvetica, san-serif");
    $("ol li:not(ul li)").css("margin-left", "21px");
        
   
    $('#searchResultsFlash').css("right", "60px");
    $('#searchResultsFlash').css("top", "-1px");
    //modify all css for faqs
    $('.faqs').css("float", "left");
    $('.faqs').css("padding", "0 15px 0 0");
    $('.faqs').css("position", "relative");
    $('.faqs').css("width", "685px");
    $('.faqs').css("background", "url('/deployedfiles/AS/images/xolair/page_bg_with_rt.jpg') no-repeat scroll 0 0 transparent");
    $('#sb-player').css("overflow", "visible");
    //check nav button width and verify cuttoff
    $('#tNavHelp').css("width", "128px");
    $('#tNavHelp').css("align", "right");
        
    $('#tNavHelp').css("z-index", "3");
    $('#tNavISI').css("z-index", "2");
    $('#tNavSPI').css("z-index", "1");
    //manage print size
        
				
    if ($("#asProduct").val() == "f73257e77eb07210VgnVCM1000007dc9320aRCRD"){
        Shadowbox.init({
            overlayOpacity:.8
        });
    }
    else{
        Shadowbox.init({
            overlayOpacity:.8,
            onFinish:loadFormData
        });
    }

    $('.noJavascript').each( function(){
        var e = $(this);
        e.css("display", "block");
    });

        
    $("#searchTerms").autocomplete("/as-ext-templating/jsp/asAutocomplete.jsp");
    $('.sitemapList').css("margin-top", "10px");
    $("#asPopup").hover( function(){
        $("#asLoginPopup").css("display", "block");
    }, function(){
        $("#asLoginPopup").css("display", "none");
    });
    //fix all ok and cancel buttons
    $('.leaveSiteInner .cancel img').css("bottom", "30px");
    $('.leaveSiteInner .cancel img').css("left", "160px");
    $('.leaveSiteInner .cancel img').css("margin", "0 auto");
    $('.leaveSiteInner .cancel img').css("position", "absolute");
    $('.leaveSiteInner .cancel img').css("width", "55px");

    $('.leaveSiteInner .okay img').css("bottom", "30px");
    $('.leaveSiteInner .okay img').css("left", "230px");
    $('.leaveSiteInner .okay img').css("margin", "0 auto");
    $('.leaveSiteInner .okay img').css("position", "absolute");
    $('.leaveSiteInner .okay img').css("width", "55px");
      
				
    $('.resultsWrapper').css("height", "350px");
    
    //Change font size for just lucentis
    if ($("#asProduct").val() == "bf4a5465a5c07210VgnVCM1000007dc9320aRCRD" && $('input[name=Audience]:checked').val()=="Patient"){
            
        changeFontSize(16);
    }

    if ($("#asProduct").val() == "1fc2a88bc12d4210VgnVCM1000007dc9320aRCRD"){
        $("#breadCrumb a").hover( function(){
            if ($(this).text() == "Home / "){
                $(this).css('font-size', '14px');
            }
            $(this).css('color', '#D7C233');
        },
        function(){
            $(this).css('color', '#FFFFFF');
        });
    }
       
    changeFontSize(checkFontCookie());
   
});

/**************************************************************************************
Function: printPage
Purpose:  Runs on the event that a print page icon is selected from the user interface
Function type: event handler
***************************************************************************************/
function printPage() { 
    $('div.slider').css('height', '100%');
    window.print();
}


/**************************************************************************************
Function: inArray
Parameters: needle (the search element to match on), haystack (the array to search)
Returns:  true if found, false if not
Purpose:  Utility function to test the existance of an element in an array
Function type: Utility
***************************************************************************************/
function inArray(needle, haystack) {
    var length = haystack.length;
    for(var i = 0; i < length; i++) {
        if(haystack[i] == needle) return true;
    }
    return false;
}

/**************************************************************************************
Function: arrayContains
Parameters: needle (the search element to match on), haystack (the array to search)
Returns:  true if found, false if not
Purpose:  Utility function to test the existance of an element in an array
Function type: Utility
***************************************************************************************/
function arrayContains(needle, haystack) {
    var length = haystack.length;
    var lneed = needle.toLowerCase();
    var test = "";
    for(var i = 0; i < length; i++) {
        test = haystack[i].toLowerCase();
        //alert(test + ":" + lneed);
        if(lneed.search(test) > -1){
            return true;
        }
    }
    return false;
}

/**************************************************************************************
Function: checkFontCookie
Parameters: none
Returns:  value of "fontCookie" if found, false if not
Purpose:  Utility function to test the current size of the articcle page fonts
Function type: Utility
***************************************************************************************/
function checkFontCookie(){
    return getCookie("fontCookie");
}

/**************************************************************************************
Function: 			changeFontSize
Parameters: 		value - the numeric value of the new font size selected, default is 12
Returns:  			none
Purpose:  			Utilizes the jquery library to change the font size on specific divs
Function type: 	Event handler
***************************************************************************************/
function changeFontSize(value){
	
    var ft_size = checkFontCookie();
    if(value=='' || value==null) {
        value = 12;
    }
    if(ft_size!=value){
        setCookie("fontCookie",value, "");
    }
	
    $('body').css("font-size", parseFloat(value)+"px");
    $('.headline h1').css("font-size", (parseFloat(value)+4)+"px");
    $('#toutAreaWrapper .toutHeader ').css("font-size", (parseFloat(value)+4)+"px");
    $('#toutAreaWrapper .toutHeader a').css("font-size", (parseFloat(value)+4)+"px");
    $('#rightToutWrapper .header').css("font-size", (parseFloat(value)+4)+"px");
    $('#rightToutWrapper .header a').css("font-size", (parseFloat(value)+4)+"px");
    $('#rightToutWrapper .item a').css("font-size", parseFloat(value)+"px");
    $('.isi').css("font-size", parseFloat(value)+"px");
    $('.sitemapList li a').css("font-size", parseFloat(value)+"px");
    $('#smHCP').css("font-size", parseFloat(value)+"px");
    $('#smPat').css("font-size", parseFloat(value)+"px");
    $('.faqItem .title').css("font-size", parseFloat(value)+"px");
    $('.footNav').css("font-size", (parseFloat(value))+"px");
    $('.forms .additionalWrapper .header').css("font-size", (parseFloat(value)+2)+"px");
	
}


function animateSlider( element, group ){
    var e = $(element);
    var s = e.find('.slider');
    s.show();
    s.attr("box_h", s.height());
    s.css("height", group+"px");
	
	
    /*if(s.attr("box_h") < group ){
		e.find('a.toggleLink').remove();
		return; 
	}*/
	
    var $action = $(e.target).find('slider_menu');

    e.find('a.toggleLink').click(function() {
        if($(this).hasClass('expanded')){
            s.parent().parent().parent().parent().find('.slider').animate({
                "height": group+"px"
            }, {
                duration: "slow"
            });
			
            var open_height = s.attr("box_h") + "px";

            s.animate({
                "height": group+"px"
            }, {
                duration: "slow"
            });
            $(this).removeClass("expanded");
			
        }
        else{
            s.parent().parent().parent().parent().find('.slider').animate({
                "height": group+"px"
            }, {
                duration: "slow"
            });
            s.parent().parent().parent().parent().find('a.toggleLink').removeClass("expanded");
			
            var open_height = s.attr("box_h") + "px";

            s.animate({
                "height": open_height
            }, {
                duration: "slow"
            });
            $(this).addClass("expanded");
        }
    })
}


function get_object(id) {
    var object = null;
    if (document.layers) {
        object = document.layers[id];
    } else if (document.all) {
        object = document.all[id];
    } else if (document.getElementById) {
        object = document.getElementById(id);
    }
    return object;
}



function imageOver( element ){
	
    /*var e = $(element).parent();
	//alert("x: " + e + " y: " + y);
	var pos = e.css('backgroundPosition').split(" ")
	var x = pos[0];
	var y = pos[1];
	
	
		e.attr("oldBP", x +" "+ y);
		e.css('backgroundPosition', x +" 100%");*/
		
    $(element).parent().css('backgroundPosition', '0 100%');
}

function imageOut( element ){
	
    /*var e = $(element).parent();
	
	var pos = e.attr("oldBP").split(" ")
	var x = pos[0];
	var y = pos[1];
	
	
		//e.css('backgroundPosition', x +" 0");*/
    $(element).parent().css('backgroundPosition', '0 0');
}

//Global Vars
var disabledElementList;   //var that will be stored with a list of elements to disable
//for each jsp to handle if necessary.
//because the default function disableElements() does not
//handle disabling certain elements (i.e. span elements)
//correctly

var vign_popwin = null; //var used by Popwin and verifyWinLoaded().  This global var is
//is needed because setTimeout() method only allows string
//parameters.

//Purpose: Detects if the browser type is Netscape
//Returns: a boolean value whether the browser type is netscape.
function isNetscape() {
    if(document.getElementById && !document.all)
        return true;
    return false;
}

//Purpose: Detects if the browser type is IE
//Returns: a boolean value whether the browser type is Internet Explorer
function isIE() {
    if (document.all)
        return true;
    return false;
}


//Purpose: to set features for a window used by function Popwin.
//Params: features- a string of window features
function fSet(features) {
    var features = "location=no,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=no";
    return features;
}


//Purpose: to form a URL to dispatch the session
//Params: srcContext - the source context of the session to dispatch
//	  url - the path
//	  key - the session key
//Returns: a url to dispatch the session
function dispatchURL(srcContext, url, key) {
    var context, path;

    // get target context and path
    var index = url.indexOf("/", 1);
    if ( index != -1 ) {
        context = url.substring(0, index);
        path = url.substring(index, url.length);
    } else {
        context = "/AppConsole";
        path = url;
    }


    var dispatchUrl = srcContext + "/secure/common/session/dispatch.jsp?VgnSessionKey=" + encodeURIComponent(key) + "&context=" + encodeURIComponent(context) + "&path=" + encodeURIComponent(path);
    return dispatchUrl;
}

//Purpose: to open a pop up window.
//Params: context - context of url
//		  path - path of new window
//		  key - the active session key
//        target - name of the window
//        features - any features that a user wants to supply, if the user does not,
//                  calls function fSet to set default
//        width - width of window
//        height - height of window
//        modal - whether or not the resulting window is modal.  note, this is a boolean,
//               so the value false works, whereas "false" (in quotes) doesn't.
//        unique - whether or not a new browser window is opened when the same action is
//				performed multiple times.  if isUnique is true, a new browser is opened each time.
//				note, this is a boolean, so the value false works, whereas "false" (in quotes) doesn't.
//
//Returns: the window handle
function Popwin(context, path, key, target, features, width, height, modal, unique) {

    //	var url = context + path;
    //	return SimplePopwin(url, target, features, width, height, modal, unique);

    var ftrs;

    if (features == "") {
        ftrs = fSet(features);
    } else {
        ftrs = features;
    }

    var str = ftrs + ",height=" + height
    str += ",width=" + width

    if (window.screen) {
        var sh = screen.availHeight - 30;
        var sw = screen.availWidth - 10;

        var txc = (sw - width) / 2;
        var tyc = (sh - height) / 2;

        str += ",left=" + txc + ",screenX=" + txc;
        str += ",top=" + tyc + ",screenY=" + tyc;
    }

    if (unique) {
        target = target + new Date().getTime();
    }

    // if path is empty, that probably means they're doing a form submit on the window
    // default to the transfer.jsp with ContextUtils.TRANSFER_MAKE_ACTIVE flag set to true
    var transfer = false;
    if ( isEmpty(path) || isBlank(path) ) {
        path = "/secure/common/session/transfer.jsp?makeActive=true";
        transfer = true;
    }

    // get the source context
    var srcContext = window.location.pathname;
    if ( isEmpty(srcContext) || isBlank(srcContext) || (srcContext.length < 2) ) {
        // default to app console if we can't find the context
        srcContext = "/AppConsole";
    } else {
        // find the first '/' past the context
        var index = srcContext.indexOf("/", 1);
        if ( index != -1 ) {
            srcContext = srcContext.substring(0, index);
        }
    }

    // Create a url to the dispatch hopper which includes the session key, destination context and path
    // Note the parameter VgnSessionKey must match VgnSessionMgr.VGN_SESSION_KEY
    var popwinUrl = srcContext + "/secure/common/session/dispatch.jsp?VgnSessionKey=" + encodeURIComponent(key) + "&context=" + encodeURIComponent(context) + "&path=" + encodeURIComponent(path);


    // Add session key to target
    var targetKey = createBrowserSafeName(target + "_" + key);




    if(modal && supportsShowModal() ) {
        showModalDialog(popwinUrl,targetKey,str,width,height);
    } else {

        // By setting popwinUrl to win.location, we guarantee a repost even when a popup
        // window with the target name already exists.
        var win = window.open('',targetKey,str);
        win.location = popwinUrl;

        // if we're doing a transfer then we need to allow the transfer.jsp to fully
        // load. this is to allow session dispatching to work properly and avoid
        // concurrent dispatches. we manage this by looking for the form that transfer.jsp
        // will create to let us know its done. thx casey.

        //Detecting if IE.  This while loop does not work in netscape.
        //The fix in the else statement should work in IE as well, but do not
        //have time to test the netscape soln in IE for this release.
        //Should be used by both browsers in 7.1  Will enter vicket
        if (isIE()) {
            while ( transfer ) {
                if ( !win || win.closed || (win.document && win.document.forms[0]) ) {
                    transfer = false;
                }
            }
        } else {
            vign_popwin = win;
            verifyWinLoaded();
            vign_popwin = null;
        }
        return win;
    }
}

//Purpose:  If we're doing a transfer then we need to allow the transfer.jsp to fully
//          load. this is to allow session dispatching to work properly and avoid
//          concurrent dispatches. we manage this by looking for the form that transfer.jsp
//          will create to let us know its done.  Uses global var vign_popwin, since setTimeout
//          only allows passing strings as its parameter
//
//TODO:     Right now only being called in the Netscape case. We should use this approach
//          for IE as well in 7.1; See Popwin function.
//
//Returns:  Just returns out of the function once vign_popwin has been fully loaded.
function verifyWinLoaded() {
    //If the user closed the window at this point, just return
    if (!vign_popwin || vign_popwin.closed) {
        return;
    }
    //Because the dispatch.jsp sometimes will take a while to load to do its
    //session magic, must determine that window.document.forms[0] in transfer.jsp
    //has been loaded before performing any other actions
    if (vign_popwin && !vign_popwin.closed) {
        if (vign_popwin.document) {
            if (vign_popwin.document.forms[0]) {
                return;
            }
        }
    }

    setTimeout('verifyWinLoaded()', 100);
}

function SimplePopwin(theUrl, winName, features, width, height, isModal, isUnique) {
    // To get rid of XUL error (in mozilla and firefox) that infects all crossbrowser
    // codes when we try to set the focus() to a dynamic generated <input> field.
    var iX = document.createElement("INPUT");
    iX.setAttribute("autocomplete","OFF");
    var ftrs;
    if (features == "") {
        ftrs = fSet(features);
    } else {
        ftrs = features;
    }

    // escape the windowName in case it has any nonAlphaNumeric or non-underscore
    // characters
    winName = createBrowserSafeName(winName);

    var str = ftrs + ",height=" + height + ",innerHeight=" + height;
    str += ",width=" + width + ",innerWidth=" + width;

    if (window.screen) {
        var sh = screen.availHeight - 30;
        var sw = screen.availWidth - 10;

        var txc = (sw - width) / 2;
        var tyc = (sh - height) / 2;

        str += ",left=" + txc + ",screenX=" + txc;
        str += ",top=" + tyc + ",screenY=" + tyc;
    }

    if(isModal && supportsShowModal() ) {
        showModalDialog(theUrl,winName,str,width,height);
    } else {
        if (isUnique) {
            winName = winName + new Date().getTime();
        }

        return window.open(theUrl, winName, str);
    }
}

function supportsShowModal() {

    var name = navigator.appName;
    var version = navigator.appVersion.substring(0,navigator.appVersion.indexOf("."));
    if( name == "Microsoft Internet Explorer" && parseInt(version) >= 4 ) {
        return true;

    } else {
        return false;
    }
}

//Purpose: Returns a string that wraps the form with the appropriate html and body
//         tags.
//Params: form - A string that is a well-structured html form
//Returns: a well structured string representation of an html document
function getHtmlDoc (form) {
    return "<html><body>" + form + "</body></html>";
}

//Purpose:  Returns a string that is an html form used to submit data to the hierarchy browser.
//Params:   contextPath - required; the portion of the request's uri that denotes the context of the request.
//          service- required; the name of the service provider
//          title- the title of the hierarchy browser
//          rootPath- the beginning of the tree in the hierarchy browser
//          logicalPath- path beyond the root path
//          multiselect- whether the browser has multiple selections
//          formBeanId- id of the form bean in the session to populate.
//          formBeanClass- class of the form bean in the session.
//          formBeanProperty- name of the form bean's property to populate with the selected id(s)
//          formAction- an alternate action that the hierarchybrowser will submit to.
//                      If the not specified, when a user selects OK, the hierarchybrowser
//                      will post to hierarchyBrowserClose.jsp
//          formObj - required if you want your form to retain dirty parameters. (If a user
//                    has changed any elements in the form, then need to add
//                    as parameters to the request.)
//          requestParamName - attribute name of the request parameter object optionally set in the list view.
//          refreshCmd - cmd to pass to the the window.opener.submitCmd(cmd) javascript method, if null will do
//                       normal window.opener.location.reload()
//          linkAssets - whether the leaf assets should be links.
//          displayAssets- whether leaf assets should be displayed
//          enableContainerSelectors- whether to allow the user to select container assets
//          enableAssetSelectors- whether to allow the user to select leaf assets.
//          displayPath- whether the list selectable drop-down path should be displayed at the top
//                       of the list view
//          listTitle- a sting representation of the list title for this instance of the tag
//
//Notes: -If the contextPath and service params are not provided, the function will
//        alert the user, and return back to the caller.
//
function getHierarchyBrowserForm (formName, hbFormAction, contextPath, sessionKey, service, title, rootPath, logicalPath, multiselect, formBeanId, formBeanClass, formBeanProperty, formAction, formObj, requestParamName, refreshCmd, linkAssets, displayAssets, enableContainerSelectors, enableAssetSelectors, displayPath, listTitle) {

    if (isEmpty(contextPath) || isBlank(contextPath)) {
        alert("Please provide a context path.");
        return;
    }

    if (isEmpty(service) || isBlank(service)) {
        alert("Please provide a service provider.");
        return;
    }

    var form = "<form name='"+formName+"' method='post' action='"+contextPath+hbFormAction+"'>";
    var begField = "<input type='hidden' name='";
    var valueField = "' value='";
    var endField = "' >";

    form = form + begField + "spfSPId" + valueField + service + endField;

    if (!isEmpty(title) && !isBlank(title)) {
        form = form + begField + "hb_title" + valueField + title + endField;
    }

    //Determine if have a root path
    //so will be placed on the url correctly.
    if (!isEmpty(rootPath) && !isBlank(rootPath)) {
        form = form + begField + "spfRP" + valueField + rootPath + endField;
    }

    //Determine if have a logical path
    //so will be placed on the url correctly.
    if (!isEmpty(logicalPath) && !isBlank(logicalPath)) {
        form = form + begField + "spfLP" + valueField + logicalPath + endField;
    }

    if (!isEmpty(multiselect) && !isBlank(multiselect)) {
        form = form + begField + "multiselect" + valueField + multiselect + endField;
    }

    if (!isEmpty(formBeanId) && !isBlank(formBeanId)) {
        form = form + begField + "hb_formBeanId" + valueField + formBeanId + endField;
    }

    if (!isEmpty(formBeanClass) && !isBlank(formBeanClass)) {
        form = form + begField + "hb_formBeanClass" + valueField + formBeanClass + endField;
    }

    if (!isEmpty(formBeanProperty) && !isBlank(formBeanProperty)) {
        form = form + begField + "hb_formBeanProperty" + valueField + formBeanProperty + endField;
    }

    if (!isEmpty(formAction) && !isBlank(formAction)) {
        form = form + begField + "hb_formAction" + valueField + formAction + endField;
    }

    if (!isEmpty(requestParamName) && !isBlank(requestParamName)) {
        form = form + begField + "hb_requestParamName" + valueField + requestParamName + endField;
    }

    if (!isEmpty(refreshCmd) && !isBlank(refreshCmd)) {
        form = form + begField + "hb_refreshCmd" + valueField + refreshCmd + endField;
    }

    if (!isEmpty(linkAssets) && !isBlank(linkAssets)) {
        form = form + begField + "hb_linkAssets" + valueField + linkAssets + endField;
    }

    if (!isEmpty(displayAssets) && !isBlank(displayAssets)) {
        form = form + begField + "hb_displayAssets" + valueField + displayAssets + endField;
    }

    if (!isEmpty(enableContainerSelectors) && !isBlank(enableContainerSelectors)) {
        form = form + begField + "hb_enableContainerSelectors" + valueField + enableContainerSelectors + endField;
    }

    if (!isEmpty(enableAssetSelectors) && !isBlank(enableAssetSelectors)) {
        form = form + begField + "hb_enableAssetSelectors" + valueField + enableAssetSelectors + endField;
    }

    if (!isEmpty(displayPath) && !isBlank(displayPath)) {
        form = form + begField + "hb_displayPath" + valueField + displayPath + endField;
    }

    if (!isEmpty(listTitle) && !isBlank(listTitle)) {
        form = form + begField + "hb_listTitle" + valueField + listTitle + endField;
    }

    if (!isEmpty(sessionKey) && !isBlank(sessionKey)) {
        form = form + begField + "VgnSessionKey" + valueField + sessionKey + endField;
    }

    // finally add context path
    form = form + begField + "hb_contextPath" + valueField + contextPath + endField;

    //Determine if user has passed a formObj
    if (formObj != null) {
        var elementList = formObj.elements;
        if (elementList.length != null && elementList.length > 0) {
            var hasChanged = false;

            for (i=0;i<elementList.length;i++) {
                //If disabled dont remember dirty value.
                if (elementList.disabled == false) {
                    hasChanged = isFrmElementDirty(elementList[i]);
                    if (hasChanged && elementList[i].name != 'undefined' && !isEmpty(elementList[i].name) && !isBlank(elementList[i].name)) {
                        form = form + begField + "hb_dirtyParam_" + elementList[i].name + valueField + elementList[i].value + endField;
                    }
                }
            }  //end of for loop
        } //end of if
    } // end of if
    form = form + "</form>";

    return form;

}

//Purpose:  Opens the search hierarchy browser and sets certain params on the request that
//          the browser may need.
//Params:   contextPath - required; the portion of the request's uri that denotes the context of the request.
//			sessionKey - required; the active session key.
//          service- required; the name of the service provider
//          title- the title of the hierarchy browser
//          rootPath- the beginning of the tree in the hierarchy browser
//          logicalPath- path beyond the root path
//          multiselect- whether the browser has multiple selections
//          formBeanId- id of the form bean in the session to populate.
//          formBeanClass- class of the form bean in the session.
//          formBeanProperty- name of the form bean's property to populate with the selected id(s)
//          formAction- an alternate action that the hierarchybrowser will submit to.
//                      If the not specified, when a user selects OK, the hierarchybrowser
//                      will post to hierarchyBrowserClose.jsp
//          formObj - required if you want your form to retain dirty parameters. (If a user
//                    has changed any elements in the form, then need to add
//                    as parameters to the request.)
//          requestParamName - attribute name of the request parameter object optionally set in the list view.
//          refreshCmd - cmd to pass to the the window.opener.submitCmd(cmd) javascript method, if null will do
//                       normal window.opener.location.reload()
//          linkAssets - whether the leaf assets should be links.
//          displayAssets- whether leaf assets should be displayed
//          enableContainerSelectors- whether to allow the user to select container assets
//          enableAssetSelectors- whether to allow the user to select leaf assets.
//          displayPath- whether the list selectable drop-down path should be displayed at the top
//                       of the list view
//          listTitle- a sting representation of the list title for this instance of the tag
//
//Notes: -If the contextPath and service params are not provided, the function will
//        alert the user, and return back to the caller.
//
function openSearchBrowser(contextPath, sessionKey, service, title, rootPath, logicalPath, multiselect, formBeanId, formBeanClass, formBeanProperty, formAction, formObj, requestParamName, refreshCmd, linkAssets, displayAssets, enableContainerSelectors, enableAssetSelectors, displayPath, listTitle) {

    var form = getHierarchyBrowserForm("searchBrowserForm", "/secure/common/searchBrowser.jsp", contextPath, sessionKey, service, title, rootPath, logicalPath, multiselect, formBeanId, formBeanClass, formBeanProperty, formAction, formObj, null, refreshCmd, linkAssets, displayAssets, enableContainerSelectors, enableAssetSelectors, displayPath, listTitle);
    var win = Popwin(contextPath, '', sessionKey, 'searchBrowser', '', '700', '500');

    win.document.write(getHtmlDoc(form));
    win.document.forms[0].submit();

}

//Purpose:  Opens the hierarchy browser and sets certain params on the request that
//          the browser may need.
//Params:   contextPath - required; the portion of the request's uri that denotes the context of the request.
//			sessionKey - required; the active session key.
//          service- required; the name of the service provider
//          title- the title of the hierarchy browser
//          rootPath- the beginning of the tree in the hierarchy browser
//          logicalPath- path beyond the root path
//          multiselect- whether the browser has multiple selections
//          formBeanId- id of the form bean in the session to populate.
//          formBeanClass- class of the form bean in the session.
//          formBeanProperty- name of the form bean's property to populate with the selected id(s)
//          formAction- an alternate action that the hierarchybrowser will submit to.
//                      If the not specified, when a user selects OK, the hierarchybrowser
//                      will post to hierarchyBrowserClose.jsp
//          formObj - required if you want your form to retain dirty parameters. (If a user
//                    has changed any elements in the form, then need to add
//                    as parameters to the request.)
//          requestParamName - attribute name of the request parameter object optionally set in the list view.
//          refreshCmd - cmd to pass to the the window.opener.submitCmd(cmd) javascript method, if null will do
//                       normal window.opener.location.reload()
//          linkAssets - whether the leaf assets should be links.
//          displayAssets- whether leaf assets should be displayed
//          enableContainerSelectors- whether to allow the user to select container assets
//          enableAssetSelectors- whether to allow the user to select leaf assets.
//          displayPath- whether the list selectable drop-down path should be displayed at the top
//                       of the list view
//          listTitle- a sting representation of the list title for this instance of the tag
//
//Notes: -If the contextPath and service params are not provided, the function will
//        alert the user, and return back to the caller.
//
//See: hierarchyBrowser.jsp, hierarchyBrowserClose.jsp for further information.
function openHierarchyBrowser(contextPath, sessionKey, service, title, rootPath, logicalPath, multiselect, formBeanId, formBeanClass, formBeanProperty, formAction, formObj, requestParamName, refreshCmd, linkAssets, displayAssets, enableContainerSelectors, enableAssetSelectors, displayPath, listTitle) {

    var form = getHierarchyBrowserForm("hb_form", "/secure/common/hierarchyBrowser.jsp", contextPath, sessionKey, service, title, rootPath, logicalPath, multiselect, formBeanId, formBeanClass, formBeanProperty, formAction, formObj, requestParamName, refreshCmd, linkAssets, displayAssets, enableContainerSelectors, enableAssetSelectors, displayPath, listTitle);
    var win = Popwin(contextPath, '', sessionKey, 'hBrowser', '', '600', '600');

    win.document.write(getHtmlDoc(form));
    win.document.forms[0].submit();
}

//Purpose:  Opens the hierarchy browser and sets certain params on the request that
//          the browser may need. This is a simplified veneer over the openHierarchyBrowser function.
//			Defaults are provided for most of the parameters such that the displayed hiearchy browser
//			behaves as a simple asset picker.
//Params:   contextPath - required; the portion of the request's uri that denotes the context of the request.
//			sessionKey - required; the active session key.
//          service- required; the name of the service provider
//          title- the title of the hierarchy browser
//          rootPath- the beginning of the tree in the hierarchy browser
//          formBeanId- id of the form bean in the session to populate.
//          requestParamName - attribute name of the request parameter object optionally set in the list view.
//
//Notes: -If the contextPath and service params are not provided, the function will
//        alert the user, and return back to the caller.
//
//See: hierarchyBrowser.jsp, hierarchyBrowserClose.jsp for further information.
function showHierarchyBrowser(contextPath, sessionKey, service, title, rootPath, formBeanId, requestParamName) {
    openHierarchyBrowser(contextPath, sessionKey, service, title, rootPath, "/", 'false', formBeanId, "com.vignette.as.ui.common.widgets.HierarchyBrowserResult", "singleSelectValue", null, self.document.forms[0], requestParamName, "refresh", 'false', 'true', 'false', 'true', 'true', "");
}

//Purpose: To open the property pages for a content item.  If the user supplies
//         an empty contentID, the function will return false.
//Params: sessionKey - the unique session identifier
//        contentID - the content management id
//        checkDirtyOnParent - boolean value indicating whether to check
//          if any changes were made to the invoking window before it is refreshed.
//          (ie , if the subform peforms an OK or APPLY)
function openCMAViewer(sessionKey, contentID, checkDirtyOnParent) {
    if (isEmpty(contentID) && isBlank(contentID))
        return false;

    var cmaViewerURI =  '/secure/cmaViewer.do?spfAId='+contentID+'&propertiesClose=true';
    //Do we want the subform to check if parent window's fields are dirty upon submit.
    if (checkDirtyOnParent)
        cmaViewerURI = cmaViewerURI + '&checkDirtyOnParent='+checkDirtyOnParent;

    var win = Popwin('/AppConsole', cmaViewerURI, sessionKey, 'cmaBrowser', '', '700', '500');

    return true;
}

// Purpose: disables form elements
// Params: theForm- the form object (i.e. document.forms[0])
//         elementList - javascript Array object that consists of the names or indices of the elements to disable.
//
// Notes: If the element does not exist in the form, nothing is done.
function disableElements(theForm, elementList) {
    if (elementList == null || elementList == 'undefined' || theForm == null || theForm == 'undefined')
        return;
    for (i=0; i < elementList.length; i++) {
        var elementToDisable = theForm.elements[elementList[i]];
        if (elementToDisable != null && elementToDisable != 'undefined')
            elementToDisable.disabled = true;
    }
    disabledElementList = elementList;
}

// Purpose: enables form elements
// Params: theForm- the form object (i.e. document.forms[0])
//         elementList - javascript Array object that consists of the names or indices of the elements to enable.
//
// Notes: If the element does not exist in the form, nothing is done.
function enableElements(theForm, elementList) {
    if (elementList == null || elementList == 'undefined' || theForm == null || theForm == 'undefined')
        return;
    for (i=0; i < elementList.length; i++) {
        var elementToEnable = theForm.elements[elementList[i]];
        if (elementToEnable != null && elementToEnable != 'undefined')
            elementToEnable.disabled = false;
    }
}

// Purpose: determines if the string is empty. A blank string is anything containing only whitespaces, newlines, tabs, form feeds, and/or line feeds.
// Params: s- the string to test
//
// Notes: If the element does not exist in the form, nothing is done.
// Returns: a boolean value whether the string is blank or not.
function isBlank(s) {
    //set up the regular expression to test if the string contains whitespaces, newlines, tabs, form feeds or line feeds.
    var re = /^\s+$/;
    if (re.test(s))
        return true;
    return false;
}

//Determines if a string is null or empty.
function isEmpty(s) {
    return ((s == null) || (s == ""));
}

//Purpose: returns a string that has escaped forward slashes (to %2F);
//Param: s- the string to escape
//ReturnS: a string where all forward slashes are replaced with %2f
function escapeForwardSlash(s) {
    var re = /\/+/g;
    if (s != null) {
        s = s.replace(re, "%2F");
    }
    return s;
}

//Purpose: trims a string
//Param: s- the string to trim
//ReturnS: the trimmed string
function trimString (str) {
    str = this != window? this : str;
    return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

//Purpose: To check if an html radio or checkbox form element
//         is dirty.
//Params: select - an html select form element.
//Returns: a boolean value whether a checkbox or radio form element is dirty.
function checkRadioOrCheckbox( radio )
{
    return (radio.checked!=radio.defaultChecked)
}

//Purpose: To check if an html select form element
//         is dirty
//Params: select - an html select form element.
//Returns: a boolean value whether a select form element is dirty.
function checkSelect( select )
{
    var children=select.options
    for(var i=0;i!=children.length;i++)
    {
        if(children[i].selected != children[i].defaultSelected)
        {
            return true;
        }
    }
    return false;
}

//Purpose: To check if form element is dirty.
//Params: element- a form element that can have a "defaultValue" property
//Returns: a boolean value whether a form element is dirty.
function checkDefaultValue( element )
{
    return (element.defaultValue!=element.value)
}

//Purpose: To determine if a form element is dirty.  This method handles
//         text, password, textarea, file, reset, hidden, select (select-one or select-multiple),
//         checkbox, and radio form elements.  If the form element is passed in that
//         is not of one of the types listed above, returns false.
//Params:  element- a form element
//Returns: a boolean value whether a form element is dirty.
function isFrmElementDirty( element) {

    switch( element.type )
    {
        case "text":
        case "password":
        case "textarea":
        case "file":
        case "reset":
        case "hidden":
            return checkDefaultValue( element )
            break;

        case "select-one":
        case "select-multiple":
            return checkSelect( element )
            break;

        case "submit":
        case "button":
            break

        case "checkbox":
        case "radio":
            return checkRadioOrCheckbox( element )
            break;

        default:
            return false;
    }
}


function PopHelp(helpUrl) {
    if (helpUrl == "") {
        helpUrl = "/help";
    }
    SimplePopwin(helpUrl, 'newHelpWindow', 'location=no,menubar=yes,resizable=yes,scrollbars=yes,status=no,toolbar=yes', '700', '500');
    return false;
}

// removes all non-alphanumeric characters
// except underscore from the input value
function createBrowserSafeName(inputVal) {

    newString = "";

    for (i = 0; i < inputVal.length; i++) {
        ch = inputVal.substring(i, i+1);

        if ((ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z") ||
            (ch >= "0" && ch <= "9") || ch == "_")  {
            newString += ch;
        }
    }

    // if the name is empty at this point, we may be dealing with a localized
    // set of characters in which case we default the name to something generic and single-byte
    if (newString == "") {
        newString = "defaultVCMWindow";
    }

    return newString;
}

// get actual browser window position
function getLeft(oObject) {
    return (oObject.x) ? oObject.x : getPosition(oObject,"Left");
}

function getTop(oObject) {
    return (oObject.y) ? oObject.y : getPosition(oObject,"Top");
}

function getPosition(oObject,xyString) {
    inc = 0;
    var embeddedFlag = oObject.embedded;
    while (oObject != null) {
        if (isIE()) {
            if ((oObject.currentStyle.position == "absolute") &&  embeddedFlag) {
                return inc;
            }
        }
        if (isNetscape()) {
            if (document.defaultView.getComputedStyle(oObject, null).getPropertyValue("position") == "absolute") {
                return inc;
            }
        }
        inc = inc + oObject["offset" + xyString];
        oObject = oObject.offsetParent;
    }
    return inc;
}
function cacheRefresh( param, message) {

    var selection = confirm(message);
    //after confirmation pass the request parameters to cacheRefresh.jsp..
    if( selection == true){
        var href = '/vgn-ext-templating-cma/secure/cache/clearCache.jsp';
        href += '?';
        href += param
        SimplePopwin(href, 'cache clear', '', '600', '400');
    }
}


//Confirmation for CacheClear
function confirmClearCache(message , href ){
    var name=confirm(message );
    if (name==true)
    {
        SimplePopwin(href, 'cache clear', '', '800', '600');
    }
}

//Confirmation for Remove CC
function confirmComponentRemove(message , href, isCOEMode ){
    var name=confirm(message );
    if (name==true)
    {
        var url = href;
        if(isCOEMode == true) {
            parent.opener.setDirty(true);
            url = url + '&VgnSessionKey=' + parent.VgnSessionKey;
            url = url + '&returnURL=' + encodeURIComponent(parent.returnURL);
        } else {
            url = url + '&returnURL=' + encodeURIComponent(document.location.href);
        }
        document.location.href=url;
        if(isCOEMode == true) {
            parent.opener.submitCMD('refresh', true);
        }
    }
}


//AS_Forms - Indication Tabs
function ManageTabPanelDisplay() {
    //
    // Between the parenthesis, list the id's of the div's that
    //     will be affected when tabs are clicked. List in any
    //     order. Put the id's in single quotes (apostrophes)
    //     and separate them with a comma -- all one line.
    //
    var idlist = new Array('tab1focus','tab2focus','tab3focus','tab1ready','tab2ready','tab3ready','content1','content2','content3');

    // No other customizations are necessary.
    if(arguments.length < 1) {
        return;
    }
    for(var i = 0; i < idlist.length; i++) {
        var block = false;
        for(var ii = 0; ii < arguments.length; ii++) {
            if(idlist[i] == arguments[ii]) {
                block = true;
                break;
            }
        }
        if(block) {
            document.getElementById(idlist[i]).style.display = "block";
        }
        else {
            document.getElementById(idlist[i]).style.display = "none";
        }
    }
}


function getRequestParameter(paramerterName) {
    var queryString = unescape(window.top.location.search.substring(1));
    var parameterName = paramerterName + "=";
    var parameterValue = "";
    if (queryString.length > 0) {
        // Find the beginning of the string
        var begin = queryString.indexOf(parameterName);
        // If the parameter name is not found, skip it, otherwise return the value
        if ( begin != -1 ) {
            // Add the length (integer) to the beginning
            begin += parameterName.length;
            // Multiple parameters are separated by the "&" sign
            var end = queryString.indexOf ( "&" , begin );
            if (end == -1 ) {
                end = queryString.length;
            }
            parameterValue = queryString.substring (begin, end);
        }
        return parameterValue;
    }
}

function getCookie(c_name) {
    if (document.cookie.length>0) {
        c_start=document.cookie.indexOf(c_name + "=");
        if (c_start!=-1) {
            c_start=c_start + c_name.length+1;
            c_end=document.cookie.indexOf(";",c_start);
            if (c_end==-1) {
                c_end=document.cookie.length;
            }
            return unescape(document.cookie.substring(c_start,c_end));
        }
    }
    return "";
}

function setCookie(c_name,value,expiredays) {
    //alert('set ' + c_name + ' to ' + value);
    var exdate=new Date();
    if (expiredays = "") {
        expiredays = null;
    } else {
        exdate.setDate(exdate.getDate()+expiredays);
    }
    document.cookie=c_name+ "=" +escape(value)+ ((expiredays == null || expiredays == "") ? "" : ";expires="+exdate.toGMTString()) + "; path=/";
//document.cookie=c_name+ "=" +escape(value)+ "; path=/";
}

/* form data */
function oc(a)
{
    var o = {};
    for(var i=0;i<a.length;i++)
    {
        o[a[i]]='';
    }
    return o;
}
	
function loadFormData( ele ){
	  
    
    if ($("#asProduct").val() != "f73257e77eb07210VgnVCM1000007dc9320aRCRD" && $("#asProduct").val() !="22719b2510c07210VgnVCM1000007dc9320aRCRD"){
        var forms = ["as_search_form", "popupForm"];
        //load all forms based on selected values
        //alert($("#asProduct").val());
				
        if($("#asProduct").val()!="")
        {
            $("#searchpopupForm #popupProduct").val($("#asProduct").val()).attr("selected", "true");
            $("#toutpopupForm #popupProduct").val($("#asProduct").val()).attr("selected", "true");
        }
        if($("#asHCP:checked").val() != undefined)
        {
            $("#searchpopupForm #popupHCP").attr("checked", "true");
            $("#toutpopupForm #popupHCP").attr("checked", "true");
        }
        if($("#asPatient:checked").val() != undefined)
        {
            $("#searchpopupForm #popupPatient").attr("checked", "true");
            $("#toutpopupForm #popupPatient").attr("checked", "true");
        }
    //$("#toutpopupForm #popupProduct").val(getCookie("productCurr"));
    //$('#searchpopupForm #popupProduct').val(getCookie('productCurr')).attr("selected", "selected");
    //$("#toutpopupForm input[name='Audience']:checked").val($("#ASsearchForm input[name='Audience']:checked").val());
    //$("#searchpopupForm input[name='Audience']:checked").val($("#ASsearchForm input[name='Audience']:checked").val());
        
    }
    
}
var rituxanSet = '';
function setProduct(){

    //alert($("input[name='product_choice']:checked").val());
    
    if ($("input[name='product_choice']:checked").val() == "Rituxan for NHL"){
        $("#ritSelect").attr('value', "Rituxan for NHL");
        $("#asProduct option:[value='22719b2510c07210VgnVCM1000007dc9320aRCRD']").attr('value','f73257e77eb07210VgnVCM1000007dc9320aRCRD');
        $("#asProduct option:[value='f73257e77eb07210VgnVCM1000007dc9320aRCRD']").attr('selected','selected');
        setCookie('productCurr', 'f73257e77eb07210VgnVCM1000007dc9320aRCRD');
    }
    else if($("input[name='product_choice']:checked").val() == "Rituxan for RA"){
        $("#ritSelect").attr('value', "Rituxan for RA");
        $("#asProduct option:[value='f73257e77eb07210VgnVCM1000007dc9320aRCRD']").attr('selected','selected');
        $("#asProduct option:[value='f73257e77eb07210VgnVCM1000007dc9320aRCRD']").attr('value','22719b2510c07210VgnVCM1000007dc9320aRCRD');
        setCookie('productCurr', '22719b2510c07210VgnVCM1000007dc9320aRCRD');
        
    }

}

//alert(getCookie("productCurr"));
    

if (getCookie("productCurr") == 'f73257e77eb07210VgnVCM1000007dc9320aRCRD'){
//$("#asProduct option:contains('Rituxan')").val('f73257e77eb07210VgnVCM1000007dc9320aRCRD');
}
else if(getCookie("productCurr") == '22719b2510c07210VgnVCM1000007dc9320aRCRD'){
//$("#asProduct option:contains('Rituxan')").val('22719b2510c07210VgnVCM1000007dc9320aRCRD');
}

function resetRituxan()
{
    if (getCookie("productCurr") == 'f73257e77eb07210VgnVCM1000007dc9320aRCRD'){
        $("#ritSelect").attr('value', "Rituxan for NHL");
        $("#asProduct option:[value='f73257e77eb07210VgnVCM1000007dc9320aRCRD']").attr('selected','selected');
        //$("#asProduct option:[value='22719b2510c07210VgnVCM1000007dc9320aRCRD']").attr('value','f73257e77eb07210VgnVCM1000007dc9320aRCRD');
        //$("#asProduct option:contains('Rituxan')").val('f73257e77eb07210VgnVCM1000007dc9320aRCRD');
        setCookie('productCurr', 'f73257e77eb07210VgnVCM1000007dc9320aRCRD');

    }
    else if(getCookie("productCurr") == '22719b2510c07210VgnVCM1000007dc9320aRCRD'){
        $("#ritSelect").attr('value', "Rituxan for RA");
        $("#asProduct option:[value='f73257e77eb07210VgnVCM1000007dc9320aRCRD']").attr('selected','selected');
        $("#asProduct option:[value='f73257e77eb07210VgnVCM1000007dc9320aRCRD']").attr('value','22719b2510c07210VgnVCM1000007dc9320aRCRD');
        //$("#asProduct option:contains('Rituxan')").val('22719b2510c07210VgnVCM1000007dc9320aRCRD');
        setCookie('productCurr', '22719b2510c07210VgnVCM1000007dc9320aRCRD');
        
    }
	
	
}
		
function holdFormData(ele, value, searchbar){

    //alert(ele + " : " + value);

    //alert($(ele).attr("id"));

    //alert ($("#asProduct").val());

    //console.log( getCookie('productCurr'));
    //added logic to make continue button disappear when needed - CI
    if (searchbar == true){
        $(".iDontKnowInner").children().eq(2).children().eq(0).hide();
    }
    else{
        $(".iDontKnowInner").children().eq(2).children().eq(0).show();
    }
    
    switch(ele){
			
        
        case "Patient":
           
            setCookie("Audience","Patient");
            $("#searchpopupForm #popupPatient").attr("checked", "true");
            $("#toutpopupForm #popupPatient").attr("checked", "true");
            $("#asPatient").attr("checked", value);
            break;
				
        case "HCP":
            $("#searchpopupForm #popupHCP").attr("checked", "true");
            $("#toutpopupForm #popupHCP").attr("checked", "true");
            $("#asHCP").attr("checked", value);
            setCookie("Audience","HCP");
            //document.getElementById("asHCP").checked = value;
            break;
				
        case "Product":
            var popSelected = value;
            if(value == "idontknow"){
                //alert(show_continue_button);
                //alert($("#asProduct").val());
                if (show_continue_button == true && $("#asProduct").val() != "idontknow"){
                    $("#continue_dk").show();
                }
                else{
                    $("#continue_dk").hide();
                }
                //            		$("#asProduct").val('idontknow').attr('selected', 'selected');
                //            		$("#searchpopupForm #popupProduct").val('idontknow').attr("selected", "selected");
                //					      $("#toutpopupForm #popupProduct").val('idontknow').attr("selected", "selected");
                Shadowbox.close();
                setTimeout(function(){
                    revealModal('iDontKnow', "Shadowbox.close();");
                //$(".iDontKnowInner").show();
                }, 500);

                return false;
                
            }
            $("#searchpopupForm #popupProduct").val(value).attr("selected", "selected");
            $("#toutpopupForm #popupProduct").val(value).attr("selected", "selected");
            $("#asProduct").val(value).attr("selected", "selected");
            setCookie('lastProduct', getCookie('productCurr'), ""); //storing last product id - DB
            setCookie('productCurr', $("#asProduct").val(), "");  //storing last product id - DB
            break;
    }
    $("#ritSelect").attr('value', "");	
    if(value=="f73257e77eb07210VgnVCM1000007dc9320aRCRD" || value=="22719b2510c07210VgnVCM1000007dc9320aRCRD")
    {
        Shadowbox.close();
        setTimeout(function(){
            revealProductModal('productModalPage', "Shadowbox.close();");
        //$(".iDontKnowInner").show();
        }, 500);

        return false;
    //revealProductModal('productModalPage', "Shadowbox.close();");
    //$("#CloseModal").show();
    }

}

function submitSearchForm(){

    //alert($("#asProduct").val());
    //console.log($("input[name='product_choice']:checked").val());
    //console.log($("#asProduct option:[value='f73257e77eb07210VgnVCM1000007dc9320aRCRD']").text());

    if(document.as_search_form.Product.value==""){
    		
        revealModal('modalPage', "Shadowbox.close();");
    }
    else if(document.as_search_form.searchTerms.value==""){
        alert("Please Enter Keywords to Search");
        document.as_search_form.searchTerms.focus();
    }else{
        if((document.getElementById("asHCP").checked == true) && (getCookie("seenHCP") != "true")){
            $("#searchTerms").blur();
            //alert("HCP modal should pop");
            //alert("error");
				
            try{
            //document.getElementById("HCPCloseSubmit").onclick = "Shadowbox.close();";
            //document.getElementById("HCPCloseModal").onclick = "Shadowbox.close();";
            //document.getElementById("HCPContinueModal").onclick = "checkGoHCP('ok');";
            //document.getElementById("HCPCancelSubmit").onclick = "checkGoHCP('cancel');";
            }
            catch(error){
                alert(error);
            }
            $('#englishPDF').hide();
            Shadowbox.open({
                content: 	'#goHCP',
                player: 	"inline",
                width:      600,
                height:     500,
                handleOversize: "none"

            });
	
	
            //revealModal('goHCP', "Shadowbox.close();")
            return false;
        }
        else{// Setting cookie b4 submitting the form.
            if((document.getElementById("asHCP").checked == true))
            {
                setCookie("Audience","HCP");
            }else{
                setCookie("Audience","Patient");
            }
            //setCookie("Product", $("#asProduct").val());
            document.as_search_form.submit();
            return true;
        }
			
    }
    return false;
}

function removeText(formField){
    if(document.as_search_form.Product.value=="" || (document.as_search_form.Audience[0].checked==false && document.as_search_form.Audience[1].checked==false)){
        $("#searchTerms").blur();
        revealModal('modalPage', "Shadowbox.close();");
    }
    if(formField.value=="Type in what you're looking for."){
        formField.value="";
    }
}

function clearSearchText() {
    document.as_search_form.searchTerms.value="";
    if(document.as_search_form.Product.value=="idontknow"){
        document.getElementById("asProduct").options[0].selected = true;
        //document.getElementById("continue").style.display = "none";
        revealModal('iDontKnow', "Shadowbox.close();");
    }

}
 	
function hideModal(divID) {
//
}


function checkLeave(btn){
    if(btn == "ok"){
        Shadowbox.close();
        //window.location.href=LeavingSiteURL;
        url =window.open(LeavingSiteURL, "_blank");
        LeavingSiteURL = null;
    }
    else{
        Shadowbox.close();
    }
}

var LeavingSiteURL = null;

function leaveSite(url) {
    LeavingSiteURL = url;
	
    //    Shadowbox.open({
    //        content: 	'#leaveSite',
    //        player: 	"inline",
    //        width:      500,
    //        height:     400
    //
    //    });
    $(".leaveSiteInner").css('display',"block");
    revealModal('leaveSite', "Shadowbox.close();");
}

function revealModal(divID, closer) {
	
    try{
    //        document.getElementById("CloseSubmit").onclick = closer;
    //        document.getElementById("CloseModal").onclick = closer;
    //        document.getElementById("ContinueModal").onclick = closer;
    //        document.getElementById("CancelModal").onclick = closer;
    }
    catch(error){
    //console.log (error)
    }
    $('#englishPDF').hide();
    Shadowbox.open({
        content: 	'#'+divID,
        player: 	"inline",
        width:      500,
        height:     400

    });
	
}

function revealProductModal(divID, closer) {
	
    $('#englishPDF').hide();
    try{
        document.getElementById("CloseSubmit").onclick = closer;
        document.getElementById("CloseModal").onclick = closer;
        document.getElementById("ContinueModal").onclick = closer;
        document.getElementById("CancelModal").onclick = closer;
    }
    catch(error){}
	
    Shadowbox.open({
        content: 	'#'+divID,
        player: 	"inline",
        width:      605,
        height:     233 
    });
	
}


function checkAudience(url){
    if(document.as_search_form.Product.value=="" || (document.as_search_form.Audience[0].checked==false && document.as_search_form.Audience[1].checked==false)){
        revealModal('modalPage', "Shadowbox.close();");
    }else{
        window.location.href=url;
    }
}

//function toutLookup( tag ){
//    //$(".iDontKnowInner").children().eq(2).children().eq(0).attr("style","display:block");
//    var tProduct = String(document.as_search_form.Product.value);
//    var tAudience = (document.as_search_form.Audience[1].checked) ? String(document.as_search_form.Audience[1].value) : String(document.as_search_form.Audience[0].value);
//    var finalURL = "";
//
//    if(document.as_search_form.Product.value=="" || (document.as_search_form.Audience[0].checked==false && document.as_search_form.Audience[1].checked==false)){
//        revealModal('modalPage', "toutLookup('"+tag+"');");
//        return;
//    }
//
//    Shadowbox.close();
//
//    var toutTags = getToutData();
//
//    if (toutTags[tag] != undefined) {
//        if (toutTags[tag][tProduct] != undefined) {
//            if (toutTags[tag][tProduct][tAudience] != undefined) {
//                finalURL = toutTags[tag][tProduct][tAudience];
//            } else if (toutTags[tag]['default'] != undefined) {
//                if (toutTags[tag]['default']['default'] != undefined) {
//                    finalURL = toutTags[tag]['default']['default'];
//                }
//            }
//        } else if (toutTags[tag]['default'] != undefined) {
//            if (toutTags[tag]['default']['default'] != undefined) {
//                finalURL = toutTags[tag]['default']['default'];
//            }
//        }
//    }
//
//    alert("Go to this url: " + finalURL);
////window.location.href = finalURL;
//
//
//
////ACTEMRA     = d57a49efb10f4210VgnVCM1000007dc9320aRCRD
////Avastin     = 5ce2a88bc12d4210VgnVCM1000007dc9320aRCRD
////Herceptin   = 354a49efb10f4210VgnVCM1000007dc9320aRCRD
////LUCENTIS    = 179a49efb10f4210VgnVCM1000007dc9320aRCRD
////Nutropin    = 5f9a49efb10f4210VgnVCM1000007dc9320aRCRD
////Pulmozyme   = c7aa49efb10f4210VgnVCM1000007dc9320aRCRD
////Rituxan (NHL) = ad4a49efb10f4210VgnVCM1000007dc9320aRCRD
////Rituxan (RA)  = 1e7a49efb10f4210VgnVCM1000007dc9320aRCRD
////Tarceva     = 465a49efb10f4210VgnVCM1000007dc9320aRCRD
////XOLAIR      = 1fc2a88bc12d4210VgnVCM1000007dc9320aRCRD
//
//
//}
  
		
function toutSubmit(){
		
}
function checkGoHCP(btn, url){
    if(btn == "ok"){
        setCookie("seenHCP","true", "");
        Shadowbox.close();
        document.as_search_form.submit();
    }
    else{
        $('#englishPDF').show();
        Shadowbox.close();
    }
    if (url){
    
}
}

function checkGoModalHCP(btn, url){
    if(btn == "ok"){
        setCookie("seenHCP","true", "");
        Shadowbox.close();
        hitLookup(url);
        
    //document.as_search_form.submit();
    }
    else{
        Shadowbox.close();
    }
    if (url){
    
}
}


function goToHCP(toShowHCPPopup, url){
    if(toShowHCPPopup=='true'){
        $('#englishPDF').hide();
        if(getCookie("seenHCP") != "true"){
            $("#HCPContinueModal2").attr('onmousedown',"Shadowbox.close();");
            revealModal('goModalHCP', "Shadowbox.close();");
            setCookie("seenHCP","true", "");
        }
    }
    if(url.indexOf("#") != -1 )
    {
        window.location.href=url;
    }
}


function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        do {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
        } while (obj = obj.offsetParent);
        return [curleft,curtop];
    }
}

function getMouseX(e)
{

    // this doesn't work on IE6!! (works on FF,Moz,Opera7)
    if (e.pageX || e.pageY)
        return e.pageX;

    // works on IE6,FF,Moz,Opera7
    if (e.clientX || e.clientY)
        return e.clientX + document.body.scrollLeft;  //document.body.scrollLeft

}
function getMouseY(e)
{

    // this doesn't work on IE6!! (works on FF,Moz,Opera7)
    if (e.pageX || e.pageY)
        return e.pageY;

    // works on IE6,FF,Moz,Opera7
    if (e.clientX || e.clientY)
        return e.clientY + document.body.scrollTop;  //document.body.scrollTop

}
   
  
function getThePosition(e) {
    e = e || window.event;
    var cursor = {
        x:0,
        y:0
    };
    if (e.clientX || e.clientY) {
        cursor.x = e.clientX;
        cursor.y = e.clientY;
    }
    else {
        cursor.x = e.clientX +
        (document.documentElement.scrollLeft ||
            document.body.scrollLeft) -
        document.documentElement.clientLeft;
        cursor.y = e.clientY +
        (document.documentElement.scrollTop ||
            document.body.scrollTop) -
        document.documentElement.clientTop;
    }
    return cursor;
}
function getElementTopLeft(id) {
		
    var ele = document.getElementById(id);
    var top = 0;
    var left = 0;
		   
    // while(ele.tagName != "BODY") {
    top  = ele.offsetTop;
    left = ele.offsetLeft;
    //  ele = ele.offsetParent;
    //}
		   
    return {
        top: top,
        left: left
    };
		   
}

		
function repositionIt(ele){
    objBlock = document.getElementById('calloutBlock');
    gloBlock = document.getElementById('Glossary_Text');
    // get width and height of calloutBlock
    var cBlk_W = objBlock.offsetWidth;
    var cBlk_H = objBlock.offsetHeight;
    var gBlk_W = gloBlock.offsetWidth;
    var gBlk_H = gloBlock.offsetHeight;
    var scwidth = 1440 - document.documentElement.clientWidth;
		
    var currentId = $(ele).attr('id');
    var position = $(ele).offset();
    //console.log("top"+position.top);
    //console.log("left"+position.left);
    //console.log("Callblock W:"+cBlk_W);
    //console.log("Glossary W:"+gBlk_W);
    //console.log("Width:"+width);
    objBlock.style.top =  (position.top - cBlk_H) + 'px';
    objBlock.style.left = (position.left - gBlk_W + (scwidth/2)) + 'px';
}

// Get Dynamic text for Glossary PopUp : Position PopUp via cursor location...
var currentGlossaryElement = null;
function popGlossary(ele, e, idRef) {
		
    currentGlossaryElement = ele;
		
    objBlock = document.getElementById('calloutBlock');
		 
    // set the content
    document.getElementById('Glossary_Text').innerHTML = unescape(idRef);
		
    // shoe escape of text
    //alert(unescape(idRef));
		
		
		
		
		
    // position the block
		
    //var elePos = findPos(ele);
    //alert(elePos);

    repositionIt(ele);
		
    // set the visibility
    objBlock.style.visibility = "visible";
		
//ele.onmousemove = repositionIt;
//glossaryInterval = setInterval ( repositionIt, 100 );

}
	
function hideGlossary() {
    currentGlossaryElement.onmousemove = null;
    currentGlossaryElement = null;
    //clearInterval  ( glossaryInterval );
    document.getElementById('calloutBlock').style.visibility = "hidden";
    document.getElementById('Glossary_Text').innerHTML = '';
}
	
//  End -->


