var activeDialog=null;
var defaultImage=null;
var activeStyleSheet=null;
var activeFaqTab=null;
var closedialog;
var additionalDDGFlashVars=new Array();
var tabs = { "#about-arthritis": "#faqTab1", "#about-celebrex": "#faqTab2", "#treatment-options": "#faqTab3", "#living-with-arthritis": "#faqTab4", "#taking-celebrex": "#faqTab5" }
function getParameterByName( name ) 
{ 
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 
  var regexS = "[\\?&]"+name+"=([^&#]*)"; 
  var regex = new RegExp( regexS ); 
  var results = regex.exec( window.location.href ); 
  if( results == null ) 
    return null; 
  else 
    return results[1]; 
}
function levelToNum(strPainLevel) {
    if (strPainLevel == "mild")
        return 1;
    else if (strPainLevel == "moderate")
        return 2;
    else if (strPainLevel == "severe")
        return 3;
    else if (strPainLevel == "extreme")
        return 4;
    return 1;
}
$(document).ready(function() {
    $("div.leftNav_Callout").click(function(e) {
        var value = $("a", this).attr("name");
        value = value.replace("&lid=", "");        
        sendTracking(e, value);
        window.location = $("a", this).attr("href");
    });
    $(".DownloadCouponPDF").click(function() {
        var tcSuccess = false;
        $.ajax({
            url: '/Controller.aspx',
            type: "post",
            data: "hdnOrchID=TrailCard15Offer",
            async: false,
            success: function(data) {

                if ($(data).find("result").attr("status") == "success") {
                    tcSuccess = true;
                } else {
                    tcSuccess = false;
                }
            }
        });
        if (!tcSuccess) {
            window.location = 'offers-unavailable.aspx';
        }
        return tcSuccess;
    });
    try {
        hiLiteMenu();
        //call onwindow.load safari improper ht calc.  setGradientHeight();

        activeFaqTab = $("#faqTab1");
        //add nofollow tags to these links
        $("#ctl00_FooterLinks_hlkNodeBottom0,#ctl00_FooterLinks_hlkNodeBottom1,#utilityLinkPrint").each(function(e) {
            $(this).attr("rel", "nofollow");
        });
        //hide footerLogoAdobeLink if has flash. commented out. display always. people r confused
        /*if(parseInt(swfobject.getFlashPlayerVersion().major) <=parseInt("0")	){
        $("#footerLogoAdobeLink").css("display","block");
        }*/
        //spotlight tags fire
        $(".spotLightPI").click(function(e) {
            doSpotLightLinkTag("cbx16", $(this).attr('href'));
        });
        $(".spotLightMG").click(function(e) {
            doSpotLightLinkTag("cbx17", $(this).attr('href'));
        });

        //position the right arrow for safari
        if ($.browser.safari) {
            $("div#leftColumn img.arrow").css("vertical-align", "text-top");

        }
        $("#utilityLinkEmail,#utilityLinkTextResizer,#utilityLinkPrint,#utilityLinkFAQs").click(function(event) {
            //do tracking for site Tools- Email/print/faq/text resizer
            siteToolTrack($(this).attr("title"), $(this));
        });
        $("#ctl00_FooterLinks_hlkNodeBottom0,#ctl00_FooterLinks_hlkNodeBottom1,#ctl00_FooterLinks_hlkNodeBottom4, #ctl00_FooterLinks_hlkNodeBottom5").click(function(event) {
            //do tracking for Click to footer and top hcp
            //alert('PartnerLinkClicked'+$("#"+this.id).attr("title"));
            PartnerLinkClicked($(this).attr("title"), $(this));
        });

        //blue call out
        $(".calloutClickable").click(function(e) {
            if ($(this).find("a").size() < 1) return;
            $(this).find("a").eq(0).click();
        });

        $("ul.secNav a").each(function(e) {
            var secLink = $(this);
            secLink.mouseover(function(e) {
                var menuParentChilds = $(this).parents('.menuparent').children().children().filter(".menuparentLink");
                menuParentChilds.each(function() {
                    var t = $(this);
                    if (t.hasClass("menuparentLink")) {
                        t.addClass("highlightMenuParentLink");
                        return false;
                    }
                });
            }); //secLink mouse over

            secLink.mouseout(function(e) {
                var menuParentChilds = $(this).parents('.menuparent').children().children().filter(".menuparentLink");
                menuParentChilds.each(function() {
                    var t = $(this);
                    if (t.hasClass("menuparentLink")) {
                        t.removeClass("highlightMenuParentLink");
                        return false;
                    }
                });
            }); //secLink mouse out
        });

        // rollover onmouse over and mouseout change link images 
        $("a.rollover").each(function(e) {
            var secLink = $(this);
            $(this).attr('imgoff', $(this).find('img').attr('src'));
            secLink.hover(function(e) {
                onStateEventHandler($(this));

            }, function() {
                offStateEventHandler($(this));

            }); //hover
        }); //each

        $("a.clicked").each(function(e) {
            var secLink = $(this);
            $(this).attr('imgoff', $(this).find('img').attr('src'));
            secLink.click(function(e) {
                $(this).unbind('mouseenter').unbind('mouseleave');
                $(this).removeClass("rollover");
                $(this).css({ 'z-index': '10' }); /*Add a higher z-index value so this image stays on top*/
                var aimg = $(this).find('img');
                //alert( $(this).find('img').attr('src'));
                swapImage(aimg, "-on");
            }
            ); //clicked 
        }); //each

        $("input.clicked").each(function(e) {
            var secLink = $(this);
            $(this).attr('imgoff', $(this).attr('src'));
            secLink.click(function(e) {
                $(this).unbind('mouseenter').unbind('mouseleave');
                $(this).removeClass("rollover");
                $(this).css({ 'z-index': '10' }); /*Add a higher z-index value so this image stays on top*/
                swapImage($(this), "-click");
            }
            ); //clicked 
        }); //each

        // rollover onmouse over and mouseout change link images 
        $("input.rollover").each(function(e) {
            var secLink = $(this);
            $(this).attr('imgoff', $(this).attr('src'));
            secLink.hover(function(e) {

                // do for off images ..dont do for inactive images
                if ($(this).attr('imgoff').toLowerCase().indexOf("off") > -1) {
                    swapImage($(this), "-on");
                    // $(this).attr('src',imgBaseName+"-on."+imgExt);
                }

            }, function() {
                $(this).attr('src', $(this).attr('imgoff'));
            }); //hover
        }); //each
        // FAQ TAB click and hover
        $("ul.faqMenuList li").each(function(e) {
            $(this).attr('imgoff', $(this).find('img').attr('src'));
            var secLink = $(this);
            secLink.click(function(e) {
                activeFaqTab = $(this);
                faqTabSwap($(this), "active", "inactive", "showit", "hideit", true);
                //fire tracking
                sendPageTracking($(this).attr("name"));
            }); //click
            secLink.hover(function(e) {
                $(this).attr('imgoff', $(this).find('img').attr('src'));
                faqTabSwap($(this), "active", "inactive", "showit", "hideit", false);
                //fire tracking
                //s.prop38 = s.pageName; s.tl(e, 'o', $(this).attr("name")); 
            },
	                 function() {
	                     faqTabSwap(activeFaqTab, "active", "inactive", "showit", "hideit", false);
	                 }

	             ); //hover
        }); // faq each


        //SIFR
        // initialize WOMAC dialog wmcDialog
        $.fx.speeds._default = 500;


        // emailPageLink on page header / OARA View to show dialog		
        $('a.emailPageLink, a.RALayerBtn, a.OALayerBtn, a.MOALayerBtn').click(function(e) {
            try {
                $('#' + $(this).attr("dlgname")).dialog("destroy");
                doDialogPreOpen($(this).attr("dlgname"), 0);

                //setHeadline and Main Image
                if ($(this).hasClass("emailPageLink")) {
                    initEmailDialog();
                } else if ($(this).hasClass("RALayerBtn")) {
                    //fire 
                    s.prop38 = s.pageName; s.prop39 = $(this).attr("name"); s.prop40 = s.prop38 + '|' + $(this).attr("name"); s.t();
                    initOARADialog();
                    $("#OARAMOAWrapper .overlayHeadline").text("Rheumatoid arthritis illustration");
                    $("#OARAMOAWrapper img#oaraMainPic").attr("src", "/images/other/img_large_kneegraphic_ra.jpg");
                    $("#OARAMOAWrapper #oaraImgCopy").text("In this example of a knee with rheumatoid arthritis, there is swelling and thickening of the synovial membrane, the connective tissue that lines the joint cavity and produces fluid to lubricate the joint. There is also loss of the cartilage and bone.  All of this can result in pain.");
                } else if ($(this).hasClass("OALayerBtn")) {
                    //fire tracking
                    s.prop38 = s.pageName; s.prop39 = $(this).attr("name"); s.prop40 = s.prop38 + '|' + $(this).attr("name"); s.t();
                    initOARADialog();

                    $("#OARAMOAWrapper .overlayHeadline").text("Osteoarthritis illustration");
                    $("#OARAMOAWrapper img#oaraMainPic").attr("src", "/images/other/img_large_kneegraphic_oa.jpg");
                    $("#OARAMOAWrapper #oaraImgCopy").text("Normally, the ends of the bones in a joint are cushioned by cartilage.  In this example of a knee with osteoarthritis, a joint commonly affected by OA, the cartilage thins out, and the ends of the bones become exposed to each other and rub together.  This can damage the bones, with pain and decreased range of motion in the knee. Bone spurs, or bony projections, can also develop along the joint, which can also cause pain when extending or bending the knee.");
                } else if ($(this).hasClass("MOALayerBtn")) {
                    s.prop38 = s.pageName; s.prop39 = $(this).attr("name"); s.prop40 = s.prop38 + '|' + $(this).attr("name"); s.t();
                    initOARADialog();
                    $("#OARAMOAWrapper .overlayHeadline").text("Illustration of how CELEBREX works");
                    $("#OARAMOAWrapper img#oaraMainPic").attr("src", "/images/other/img_large_moa.jpg");
                    $("#OARAMOAWrapper #oaraImgCopy").text("");
                }

                return false;
            } catch (e) { alert(e.message); }
        });
        //ON  EMAIL/OARA DIALOG-->CLOSE
        /* $('.emailCloseBtn, #emailFinished, a.oaramoaCloseBtn').click(function() {
        $('#'+$(this).attr("dlgname")).dialog('close');
        $('sIFR-replaced').css("display","block");
        return false;
        });*/


        // DDG QUIZ BUTTON
        $('.ddgQuizBtn').click(function(e) {
            launchFlashDDDQuiz(e);

        });

        //ARTHRITIS QUIZ BUTTON
        $('.arthritisQuizBtn').click(function(e) {
            launchArthritisQuiz(e);
        });
        //
        $('.TVLayerBtn').click(function(e) {
            s.tl(e, 'o', $(this).attr("name"));
            launchTVAd(e);

        });
        
        //Unsubscribe Button 
        $(".unsubscribe #imgSubmit").mouseover(function() {
             $(this).attr("src","/images/btns/Unsubscribe-btn-on.gif");
        });   
        
        $(".unsubscribe #imgSubmit").mouseout(function() {
             $(this).attr("src","/images/btns/Unsubscribe-btn-green.gif");
        });  


        //Dialog overlay CLOSE BUTTON
        $('.overlayCloseBtn').click(function(e) {
            if ($(this).hasClass("hasFlash")) {
                var flashMovie = getFlashMovieObject("tvAdFlashContent");
                if (flashMovie != null) {
                    swfobject.removeSWF("tvAdFlashContent");
                }
            }
            $("#" + activeDialog).dialog('close');
            $('.sIFR-replaced').css("display", "block"); //h1.pageTitle

        });

        //Open Layer
        var bOpenLayer = false;
        var paramIntialValueA = "";
        var paramIntialValueB = ",";
        var paramIntialValueC = ",";
        for (var i = 1; i <= 14; i++) {

            if (getParameterByName("q1a" + i)) {
                bOpenLayer = true;
                paramIntialValueA = "q1a" + i;
                break;
            }
        }

        for (var i = 1; i <= 4; i++) {

            if (getParameterByName("q1b" + i)) {
                paramIntialValueB += levelToNum(getParameterByName("q1b" + i).toLowerCase());
                break;
            }
        }
        for (var i = 1; i <= 2; i++) {

            if (getParameterByName("q1c" + i)) {
                paramIntialValueC += getParameterByName("q1c" + i);
                paramIntialValueC = paramIntialValueC.toLowerCase();
                paramIntialValueC = paramIntialValueC.replace("y", "Y");
                paramIntialValueC = paramIntialValueC.replace("n", "N");
                break;
            }
        }
        if (bOpenLayer) {
            additionalDDGFlashVars["initialValue"] = paramIntialValueA + paramIntialValueB + paramIntialValueC;
            launchFlashDDDQuiz(null);
        }

    } catch (ee) { alert(ee.message); }
});           //doc ready 
$(window).load(function() {
   setGradientHeight();
}); //window loads
function setGradientHeight()
{
 $("#leftBorder,#rightBorder").css("height", $("#mainDiv").height());
}
function onStateEventHandler(targetObj)
{
 try{
     $(targetObj).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/ 
    var aimg=$(targetObj).find('img');   
	           
    aimg.addClass("hover").stop(); /* Add class of "hover", then stop animation queue buildup*/
		        
	// if lnav image then on hover  replace with -ro image else replace with -on image
	 if($(targetObj).hasClass("lnav")){
	    swapImage(aimg,"-ro");
      }else{          
         swapImage(aimg,"-on");
      }
  } catch(ee){alert(ee.message);}
}

function offStateEventHandler(targetObj)
{
try{
    $(targetObj).css({'z-index' : '0'}); /* Set z-index back to 0 */
    var aimg=null;
    aimg = $(targetObj).find('img');
    var aimg=$(targetObj).find('img');              
    aimg.removeClass("hover").stop();  /* Remove the "hover" class , then stop animation queue buildup*/
     swapImage(aimg,"-off");
      } catch(ee){alert(ee.message);}
}
function faqTabSwap(elm, onState, offState, onClass, offClass, contentFlag){
      //activate clicked LI. rest remove active class
	   /*         $("ul.faqMenuList li").filter("[id!="+elm.attr("id")+"]").removeClass(onState); //"active"
	            $("ul.faqMenuList li").filter("[id!="+elm.attr("id")+"]").addClass(offState); //"inactive"
	             
	            $("ul.faqMenuList li").filter("[id="+elm.attr("id")+"]").removeClass(offState);
	            $("ul.faqMenuList li").filter("[id="+elm.attr("id")+"]").addClass(onState);
	            //do the same for li>div also
	            $("ul.faqMenuList li").filter("[id!="+elm.attr("id")+"]").find("div").removeClass(onState);
	            $("ul.faqMenuList li").filter("[id!="+elm.attr("id")+"]").find("div").addClass(offState);
	             
	            $("ul.faqMenuList li").filter("[id="+elm.attr("id")+"]").find("div").removeClass(offState);
	            $("ul.faqMenuList li").filter("[id="+elm.attr("id")+"]").find("div").addClass(onState);
	     */
                if (contentFlag)
                    window.location.hash=($(elm).attr("tab"));
	           $("ul.faqMenuList li").filter("[id!="+elm.attr("id")+"]").each(function(e) { 
	                offStateEventHandler($(this));   
	           });
	           $("ul.faqMenuList li").filter("[id="+elm.attr("id")+"]").each(function(e) { 
	                onStateEventHandler($(this));   
	           });
	            // show/hide Content
	            if(contentFlag){
	                $("div.faqTabs div.faqTabContent").filter("[id="+elm.attr("id")+"Content]").addClass(onClass);
	                $("div.faqTabs div.faqTabContent").filter("[id!="+elm.attr("id")+"Content]").removeClass(onClass);
	                $("div.faqTabs div.faqTabContent").filter("[id!="+elm.attr("id")+"Content]").addClass(offClass);
	                $("div.faqTabs div.faqTabContent").filter("[id="+elm.attr("id")+"Content]").fadeIn();
	                setGradientHeight();
	            }
	            return false;

}
function initOARADialog(){
        $("#OARAMOAWrapper").css("display","block");  
           //OARAMOA DIALOG
        $('#oaramoaDialog').dialog({
			            autoOpen: false,
			            minHeight:590,
			            height:'auto',
			            width:929,
			            modal:true,
			            resizable:false,
			            position:'center',  
			            open:function(event, ui) {
                                        moveActiveDialog(null,100);
                                        closedialog = 1;$(document).bind('click', overlayclickclose);
                        },
                        focus: function(){closedialog = 0;},
	                    close: function(){$(document).unbind('click');}
                                      
		         });
		        
		  $('#oaramoaDialog').dialog('open');
		  closedialog = 0;
}

function initEmailDialog(){
     $('#emailDialog').dialog("destroy");
     $('#emailDialog').dialog({
         autoOpen: false,
         minHeight: 555,
         minWidth: 715,
         width: 715,
         modal: true,
         resizable: false,
         open: function(event, ui) {
             moveActiveDialog(null,100);
             closedialog = 1; $(document).bind('click', overlayclickclose);            
             $(".ui-dialog").css("top", "80px");
         },
         focus: function() { closedialog = 0; },
         close: function() { $(document).unbind('click'); $("#emailFrame").attr("src", $("#iframesrc").val() + "?paramurl=" + window.location.href + "&" + Math.random()); }
     });
	        $("#emailFrame").attr("height", "650");
	        
	        $("#emailFrame").attr("src", $("#iframesrc").val() + "?paramurl=" + window.location.href + "&" + Math.random());
      
      $('#emailDialog').dialog('open'); 
      //closedialog=0;
      /*$('.overlayHeadline').html("Email this Page");
      $('#emailConfirmWrapper').fadeOut('slow'); 
      $('#emailFormWrapper').fadeIn('slow'); 
      clearErrorMessages('EmailPageForm');
      $('#EmailPageForm [name=txtToEmail]').val('');*/
        
}

function cleariframe()
{
    alert("hola");
}

//function openDDGCAPTCHA()
//{
//    alert("Entre");
//    window.open('captcha-page.aspx');
//}
    
function launchHPFlash(){
    if(parseInt(swfobject.getFlashPlayerVersion().major) >parseInt("0")	)
	{
	    $("#homeFlash").css("display","block");
	    $("#homeNoFlash").css("display","none");
	   /* $("#homeFlash").css("display","none");
	    $("#homeNoFlash").css("display","block");*/
	    var c = document.getElementById("homeFlashReplace");
	    if (!c) {
		    var d = document.createElement("div");
		    d.setAttribute("id", "homeFlashReplace");
		    document.getElementById("homeFlash").appendChild(d);
		}				
	    var flashvars = {};
	    flashvars.account = s_account;
	    flashvars.ctaURL="/about-celebrex.aspx";
	    flashvars.omnitureAccount = s_account;
	    flashvars.rolloverCTAURL = "/offers.aspx";	    
	    flashvars.learnMoreURL = "/celebrex2012";
	    flashvars.newYearURL = "/celebrex2012";
    	
	    var params = {};
	    params.play = "true";
	    params.loop = "false";
	    params.quality = "best";
	    params.allowscriptaccess = "sameDomain";
	    params.allowFullScreen = "true";
	    params.wmode = "transparent";
    	
	    var attributes = {};
	    attributes.scale = "noScale";
	    swfobject.embedSWF("/flash/HomePageAnimation.swf", "homeFlashReplace", "1030", "310", "9.0.0", "/flash/media/ei/expressInstall.swf", flashvars, params, attributes);	
	    
	}

}       
 function swapImage(tgt, newImageHint){
        var aimg=tgt; 
	    var imgPath=aimg.attr('src').substring(0,aimg.attr('src').lastIndexOf("/"));
	    var imgExt=aimg.attr('src').substring(aimg.attr('src').lastIndexOf(".")+1);
	    var imgBaseName=aimg.attr('src').substring(0, aimg.attr('src').lastIndexOf("-"));
	    //alert('new image'+imgBaseName+newImageHint+"."+imgExt);
	    $(tgt).attr('src',imgBaseName+newImageHint+"."+imgExt);
 }
 function hiLiteMenu(){
  try{
        // set selected Section's menuparentLink image as light blue for Non default.aspx
        if($(location).attr('pathname')=="/" ||$(location).attr('pathname').toLowerCase().indexOf("default.aspx")>0){
        }else{
            var sectionName= $("div#mainDiv").attr("class").split(" ")[1];
            var hilitedMenu=$("a.menuparentLink[id='"+sectionName+"']").find('img');
            var imgExt=hilitedMenu.attr('src').substring(hilitedMenu.attr('src').lastIndexOf(".")+1);
            hilitedMenu.attr('src',hilitedMenu.attr('src').substring(0, hilitedMenu.attr('src').lastIndexOf("-"))+"-on."+imgExt);
        }
  }  catch(e){}
 }
 function launchFlashDDDQuiz(e){
  try{
     $('#ddgQuizDialog').dialog( "destroy" );
    //DDG Dialog
    doDialogPreOpen('ddgQuizDialog',20);
    $('#ddgQuizDialog').dialog({
			    autoOpen: false,
			    minHeight:628,
			    minWidth:791,
			    width:791,
			    height:628,
			    modal:true,
			    resizable:false,
			    position : 'center',
			    open:function(event, ui) {
                                moveActiveDialog(null,100);
                                }
                                
		 });
    
    var params = {
		quality: "high",
		scale: "noscale",
		wmode: "opaque",
		allowscriptaccess: "always",
		allowfullscreen: "true",
		bgcolor: "#FFFFFF"
	};
	var flashvars = {
		//do not modify  - base path is appended to these
		questionConfig: "xml/questionConfig.xml",
		viewConfig: "xml/viewConfig.xml",
		cssStyles: "css/ddg_flash_styles.css",
		//
		emailPath :  "/ddg-email-result.aspx?",
		pdfPath: "/ddg-print-results.aspx",
		//base path is appended to all assets and xml 
		basePath: "/flash/",
		omnitureAccount: s_account
	};
	for(key in additionalDDGFlashVars){
	    flashvars[key]=additionalDDGFlashVars[key];
	}
	//additionalDDGFlashVars
	var attributes = {
		id: "ddgQuizVideoContent",
		name: "ddgQuizVideoContent"
	};
    if(parseInt(swfobject.getFlashPlayerVersion().major) >parseInt("0")	)
	{
	    $('#ddgQuizDialog').dialog('option','width',791);  
	    $('#ddgQuizDialog').dialog('option','height',628);     
	    $('#ddgQuizDialog').dialog('open');
	    
	    $("#ddgQuizVideo").css("display","block");
	    $("#ddgQuizHtml").css("display","none");
	  
	    var c = document.getElementById("ddgQuizVideoContent");
	    if (!c) {
		    var d = document.createElement("div");
		    d.setAttribute("id", "ddgQuizVideoContent");
		    document.getElementById("ddgQuizVideo").appendChild(d);
	    }
	    swfobject.embedSWF("/flash/media/swf/application/doc-discussion-guide.swf", "ddgQuizVideoContent", "791", "628", "9.0.0", "/flash/media/ei/expressInstall.swf", flashvars, params, attributes);	
	   
	    
	}else {
	    //$('#ddgQuizDialog').dialog('option','width',658');    
	    $('#ddgQuizDialog').dialog('open');
	    $("#ddgQuizVideo").css("display","none");
	    $("#ddgQuizHtml").css("display","block");
	    $('#noFlashBit').text("discussion guide");
	   
	}
    return false;	
	}catch(ee){alert(ee.message);}     
 }       
 
 function launchArthritisQuiz(){
    $('#arthritisQuizDialog').dialog( "destroy" );
    doDialogPreOpen("arthritisQuizDialog",0);
     //ARTHRITIS QUIZ 
       //h 502 w658
         $('#arthritisQuizDialog').dialog({
			    autoOpen: false,
			    minHeight:502,
			    height:502,
			    width:658,
			    modal:true,
			    resizable:false,
			    position:'center',
			    open:function(event, ui) {
                                moveActiveDialog(null,100);
                                }

		 });

    var flashvars = {};
	flashvars.configFile = "/flash/xml/config.xml";
	flashvars.learnMoreAboutArthritisLink = "/treatment-options.aspx";
	flashvars.learnAboutCelebrexLink = "/about-celebrex.aspx";
	flashvars.omnitureAccount = s_account;
	
	var params = {};
	params.play = "true";
	params.loop = "false";
	params.quality = "best";
	params.allowscriptaccess = "sameDomain";
	params.allowFullScreen = "true";
	
	var attributes = {};
	attributes.scale = "noScale";
	if(parseInt(swfobject.getFlashPlayerVersion().major) >parseInt("0")	)
	{
	    $('#arthritisQuizDialog').dialog('option','width',658);    
	    $('#arthritisQuizDialog').dialog('open');
	    $("#arthritisQuiz").css("display","block");
	    $("#arthritisQuizHtml").css("display","none");
	    var c = document.getElementById("arthritisQuizContent");
	    if (!c) {
		    var d = document.createElement("div");
		    d.setAttribute("id", "arthritisQuizContent");
		    document.getElementById("arthritisQuiz").appendChild(d);
	    }
	    swfobject.embedSWF("/flash/arthritis_quiz.swf", "arthritisQuizContent", "658", "502", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
	    
	}else {
	    $('#arthritisQuizDialog').dialog('option','width',715);    
	    $('#arthritisQuizDialog').dialog('open');
	    $("#arthritisQuiz").css("display","none");
	    $("#arthritisQuizHtml").css("display","block");
	    $("#noFlashBit").text("quiz");
	    
	  
	}
 }
 function launchTVAd(){
    $('#tvAdDialog').dialog( "destroy" );
    doDialogPreOpen("tvAdDialog",0);
         $('#tvAdDialog').dialog({
			    autoOpen: false,
			    minHeight:800,
			    height:'auto',
			    width:733,
			    modal:true,
			    resizable:false,
			    position:'center',
			    open:function(event, ui) {
                                moveActiveDialog(null,100);
                                }

		 });

    var flashvars = {};
	flashvars.xmlPath = "/flash/xml/tv-app_config.xml";
	flashvars.account = s_account;
	
	var params = {};
	params.play = "true";
	params.loop = "false";
	params.quality = "best";
	params.allowscriptaccess = "sameDomain";
	params.allowFullScreen = "true";
	
	var attributes = {};
	attributes.scale = "noScale";
	$('#tvAdDialog').dialog('open');
	if(parseInt(swfobject.getFlashPlayerVersion().major) >parseInt("0")	)
	{
	    $("#tvAdFlash").css("display","block");
	    $("#tvAdHtml").css("display","none");
	    var c = document.getElementById("tvAdFlashContent");
	    if (!c) {
		    var d = document.createElement("div");
		    d.setAttribute("id", "tvAdFlashContent");
		    document.getElementById("tvAdFlash").appendChild(d);
	    }
	    swfobject.embedSWF("/flash/CelebrexVideoPlayer.swf", "tvAdFlashContent",  "632", "382", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
	    
	}else {
	    $("#tvAdFlash").css("display","none");
	    $("#tvAdHtml").css("display","block");
	    
	}
	
 }
 function doDialogPreOpen(dialogName, winTop){
    activeDialog =dialogName;
    window.scrollTo(0,winTop);
    $('.sIFR-replaced').css("display","none");
   // $(".ui-dialog-titlebar").css("display","none");
	//$('.ui-dialog').css({'border' : '0px', 'padding' : '0px'});
    //$('.ui-dialog-content').css({'border' : '0px', 'padding' : '0px'});
 }
 function moveActiveDialog(dx,dy)
 {
	    $('#'+activeDialog).dialog('option','position',[dx,dy]);  
 }
 function overlayclickclose() 
 {
	   if (closedialog) {
                $('#'+activeDialog).dialog('close');
       }
            //set to one because click on dialog box sets to zero
       closedialog = 1;
 }
 
 function closeFlashWindow(movieName){
 try{
        var flashMovie = getFlashMovieObject(movieName);
        
        if(flashMovie != null){
            swfobject.removeSWF(movieName);			
        }	
        if(movieName.indexOf('arthritis')>-1)
          $('#arthritisQuizDialog').dialog('close');
        if(movieName.indexOf('ddg')>-1)
          $('#ddgQuizDialog').dialog('close'); 
        //unhide the sifr flash title
        $('.sIFR-replaced').css("display","block");  
        
        if(arguments.length>1){
        location.href=arguments[1];
        }
    }catch(ee){alert(ee.message);}
 }
function getFlashMovieObject(movieName){
   
    if (window.document[movieName]) {
          return window.document[movieName];
      }
      if (navigator.appName.indexOf("Microsoft Internet")==-1){
        if (document.embeds && document.embeds[movieName]){
          return document.embeds[movieName];
          } 
      }
      else {
        return document.getElementById(movieName);
      } 	
}
       
 
function getParameterValue(url, parameter)
	 {
        keys = new Array(); 
        values = new Array(); 

        var query = url.substring(url.indexOf("?")+1);
        var pairs = query.split("&"); 
        for (var i=0;i<pairs.length;i++) 
        { 
            var pos = pairs[i].indexOf('='); 
            if (pos >= 0) 
            { 
                var argname = pairs[i].substring(0,pos); 
                var value = pairs[i].substring(pos+1); 
                
                if ( argname == parameter)
                {
                    return value;
                }
            }    
        } 
        return null;
      }

function scrollToElement(theElement){

  var selectedPosX = 0;
  var selectedPosY = 0;
          
  while(theElement != null){
    selectedPosX += theElement.offsetLeft;
    selectedPosY += theElement.offsetTop;
    theElement = theElement.offsetParent;
  }              		      
 window.scrollTo(selectedPosX,selectedPosY);
 }

function clearNonSysFields(formId){
try{
    var allfields= $("#"+formId +" :input");
    
    $(allfields).each( function(i){
                    if( !($(this).hasClass("sysField"))){
					        $(this).val("");
					        if($(this).is(':checked')){
					            $(this).attr('checked', false);
					        }
					    }
				});
				
} catch(ee){
alert(ee.message);
}
}


function SetUnsubContent(){}
var spTagPassed= function(aurl) {
    try{
	    top.location.href=aurl;
	}catch(ee){alert(ee.message);}
}

function doSpotLightLinkTag(catNo, aurl){
/*
Start of DoubleClick Floodlight Tag: Please do not remove
Activity name of this tag: Prescribing Information PDF Link_Standard
URL of the webpage where the tag is expected to be placed: Button linking to http://pfizer.com/files/products/uspi_celebrex.pdf
This tag must be placed between the <body> and </body> tags, as close as possible to the opening tag.
Creation Date: 08/16/2010
*/
var axel = Math.random() + "";
	var a = axel * 1000000000000000000;
	var spotpix = new Image();
	spotpix.src = 'http://ad.doubleclick.net/activity;src=123456789;type=celbrx;cat='+catNo+';ord=' + a + '?';
	var f='spTagPassed('+aurl+')';
	spotpix.onload = function() {f};
	return false;

/*End of DoubleClick Floodlight Tag: Please do not remove */
}
function sendPageTracking(pageName) {
    s = s_gi(s_account);    
    s.pageName = pageName;    
    s.channel = "CELEBREX";
    s.prop1 = "FAQs"    
    s.tl();
}

function layerTracking (pageName) {


    s = s_gi(s_account);
    s.setupLinkTrack("", "SC_LINK");
   
    if (!s.pageName) {
        s.pageName = 'celebrex' + window.location.pathname;
    }
   
    if (typeof pageName != "undefined") {
       // originalPName = s.pageName;  
        s.pageName = pageName; 
    }   
   
    if (typeof events != 'undefined')
        s.events = events;
    if (typeof channel != "undefined") {
        s.channel = channel;
        s.prop1 = pageName;
        s.prop2= pageName;
    }
    
    if (typeof prop1 != "undefined") {
        s.prop1 = prop1;
    }
       
    s.prop38 = '';
    s.prop39 = '';
    s.prop40 = '';
    s.t();    //////  create site catalyst tracking beacon   

} // layertracking

function sendTracking(e, prop39, pageName, events) {
    s = s_gi(s_account);
    s.trackExternalLinks = false;
    s.trackDownloadLinks = false;
    s.setupLinkTrack("", "SC_LINK");

    

    if (typeof prop39 == "undefined")
        var itemsName = $(this).attr('name')
    else
        var itemsName = prop39;

    if (!s.pageName) {
        s.pageName = 'celebrex' + window.location.pathname;
    }
    if (typeof pageName != "undefined" && pageName != ""  )
        s.pageName = pageName;
        
        
    if (typeof events != 'undefined')
        s.events = events;
    s.prop38 = s.pageName;
    s.prop39 = itemsName;
    s.prop40 = s.prop38 + '|' + itemsName;

    s.t();    //////  create site catalyst tracking beacon
}

