﻿/*
* @projectDescription 	JuvedermUltraEUMini.Branded project js library
*                       project specific class (def|namespace)
* @author	Tom Newton tnewton@rosettamarketing.com
* @version	0.1
*
* REQUIRES rosetta application class (application.js)
*/
var showPostCallout;
var showPreCallout;

var juvedermUltra = juvedermUltra ? juvedermUltra : new Object(); // create the default namespace
juvedermUltra.application = new ROSETTA.application(); // instantiate application obj (REQUIRES application.js)
juvedermUltra.loaderBase = "/includes/js/libs/yui/";
// Pre-load global external API(s) from app AJAX API, then launch onload callback
juvedermUltra.application.loadLibrary("yuiloader"); //required for YUI
juvedermUltra.application.loadLibrary("validation"); //required for form validation
juvedermUltra.application.setOnLoadCallback(function(){
    var loader = new YAHOO.util.YUILoader(); //instantiate yui loader obj to our default namespace
    loader.base = juvedermUltra.loaderBase;
    loader.require(['animation','connection','container','element','cookie','button']);//CORE YUI Components
    loader.onSuccess = function() {
        juvedermUltra.init();
    }; 
    loader.insert();  
});
juvedermUltra.ptaf; 
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 * App Init
============================================ */
juvedermUltra.init = function() {
    //check for and load lite reg form modal
   juvedermUltra.rfmodal.init();
   //do any custom form styles
   fs = new juvedermUltra.styleForms();
   fs.init();
   //juvedermUltra.ppc = new juvedermUltra.prepost();
   //juvedermUltra.ppc.init();
   //tell a friend mofo
//   if (window.location.href.indexOf("taf.aspx") >= 0){
//        document.getElementById("taf").style.visibility = "hidden";
//   } else {
//        juvedermUltra.ptaf = new juvedermUltra.taf();
//        juvedermUltra.ptaf.init();
//   }
   //downloadable pdf lightbox
   juvedermUltra.mpdf = new juvedermUltra.pdf();
   juvedermUltra.mpdf.init();
   //callout cta clicks
	ctaClick = new juvedermUltra.ctaClick();
}
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*  Registration Modal Dialog Object/Methods
============================================ */
juvedermUltra.rfmodal = new Object();
juvedermUltra.rfmodal.targetDiv = "litereg_target";
juvedermUltra.rfmodal.targetURL = "/modeler/modeler.aspx";
juvedermUltra.rfmodal.xmlPath = "/Documents/xml/lite_reg.xml?uniq=" + Math.round(Math.random()*10000); //reg form html
juvedermUltra.rfmodal.dataPath = "/utilities/interstitial.aspx"; //path form data will post to
juvedermUltra.rfmodal.panelID = "yuidialog_liteReg"; //dom id to use for the panel object and refer back to
juvedermUltra.rfmodal.errorID = "errors";
juvedermUltra.rfmodal.closeTarget = "modalclose"; //dom id of target div to use for the close dialog listener
juvedermUltra.rfmodal.dialogHTML;
juvedermUltra.rfmodal.successHTML;
juvedermUltra.rfmodal.failureHTML
juvedermUltra.rfmodal.refObject; //empty container for the target div obj

juvedermUltra.rfmodal.init = function(){
    if(document.getElementById(juvedermUltra.rfmodal.targetDiv)){
        juvedermUltra.rfmodal.refObject = document.getElementById(juvedermUltra.rfmodal.targetDiv);
        var loader = new YAHOO.util.YUILoader(); //instantiate yui loader obj to our default namespace
        loader.base = juvedermUltra.loaderBase;
        loader.addModule({ 
            name: "litereg_css",
            type: "css",
            fullpath: "/Style%20Library/en-us/Juvederm/litereg.css",
            varName: "LITEREG_CSS"
        });
        loader.require(['litereg_css']);
	    loader.onSuccess = function() {
	        onYUIReady();
	    }; 
	    loader.insert(); 
    }
    
    function onYUIReady(){
        //set the default styles
        YAHOO.util.Dom.addClass(document.body, "yui-skin-sam"); 
        YAHOO.util.Dom.setStyle(juvedermUltra.rfmodal.targetDiv, 'cursor', 'pointer');
        
        //look for a valid profile cookie, if it doesn't exist, load the lite reg form listeners
        var profileExists = false;
        var profileCookie = YAHOO.util.Cookie.get("email");
        if (profileCookie && profileCookie.length > 5){
            profileExists = true;
        }
        if(!profileExists && location.href.indexOf("before_and_after") < 0){
            try {
                var tmpdiv = document.getElementById(juvedermUltra.rfmodal.targetDiv);
                tmpdiv.href = "javascript: juvedermUltra.rfmodal.loadForm();";
            } catch(g) { 
                YAHOO.util.Event.addListener(juvedermUltra.rfmodal.targetDiv, "click", juvedermUltra.rfmodal.loadForm); 
            }
        }
        
    }
}
juvedermUltra.rfmodal.pop = function(){
    juvedermUltra.rfmodal.dialogWidget.show();
}
juvedermUltra.rfmodal.hide = function(){
    juvedermUltra.rfmodal.dialogWidget.hide();
}


juvedermUltra.rfmodal.loadForm = function(){
    //create a loading panel if it doesn't exist already
    if(!juvedermUltra.rfmodal.wait){
        juvedermUltra.rfmodal.wait = new YAHOO.widget.Panel("wait",  
            { width: "240px", 
              fixedcenter: true, 
              close: false, 
              draggable: false, 
              zindex:4,
              modal: true,
              visible: false
            } 
        );
            
        juvedermUltra.rfmodal.wait.setHeader("Loading, please wait...");
        juvedermUltra.rfmodal.wait.setBody("<img src=\"/Style%20Library/Images/rel_interstitial_loading.gif\"/>");
        juvedermUltra.rfmodal.wait.render(document.body);
    }

    //define the AJAX success handler
    var successHandler = function(o) {
        //get the root of the XML doc
        var xml = o.responseXML;
        var pages = xml.getElementsByTagName("page");
        var pageName = pages[0].getAttribute("name");
        juvedermUltra.rfmodal.dialogHTML = pages[0].childNodes[0].nodeValue;
        juvedermUltra.rfmodal.successHTML = pages[1].childNodes[0].nodeValue;
        juvedermUltra.rfmodal.wait.hide();
        juvedermUltra.rfmodal.initModule(juvedermUltra.rfmodal.dialogHTML);
        
    }
    //define the AJAX failure handler
    var failureHandler = function(o) {
        //alert the status code and error text
        juvedermUltra.rfmodal.wait.setBody(o.status + " : " + o.statusText);
    }
    
    //define the callback object
    var callback = {
        success:successHandler,
        failure:failureHandler
    };
    
    //show loading panel
    juvedermUltra.rfmodal.wait.show();
    
    //initiate the transaction
    var transaction = YAHOO.util.Connect.asyncRequest("GET", juvedermUltra.rfmodal.xmlPath, callback, null);
}

juvedermUltra.rfmodal.anchor = function (fx, fy) {
    var x = fx;
    var y = fy;
    this.setAnchor = function(nx, ny){
        x = nx;
        y = ny;
    }
    this.getPosition = function(rx, ry){
        var returnObj = new Object();
        returnObj.x = rx - x;
        returnObj.y = ry - y;
        return returnObj;
    }
}
juvedermUltra.rfmodal.initModule = function(content){
    
    if(!juvedermUltra.rfmodal.dialogWidget){
        var panelConfig = {visible:false, draggable:false, close:false, modal:true, underlay:"none", context:[juvedermUltra.rfmodal.targetDiv,"bl","br"], constraintoviewport:true, width:"614px", height:"552px", effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration: 0.25}};
        juvedermUltra.rfmodal.dialogWidget = new YAHOO.widget.Panel(juvedermUltra.rfmodal.panelID, panelConfig);
        juvedermUltra.rfmodal.dialogWidget.setBody(content);
        juvedermUltra.rfmodal.dialogWidget.render(document.body);
        YAHOO.util.Event.addListener(juvedermUltra.rfmodal.closeTarget, "click", juvedermUltra.rfmodal.hide);
        document.getElementById(juvedermUltra.rfmodal.panelID).className = "";
        juvedermUltra.rfmodal.form.init();
    }
    juvedermUltra.rfmodal.pop();//show the reg panel (among others);
    
}
juvedermUltra.rfmodal.form = new Object();
juvedermUltra.rfmodal.form.init = function(){
    var rfproperties = {
        lbl_email_id: "lr_lbl_email",
        frm_email_id: "lremail",
        dt_email: "enter your e-mail address",
        btn_submit_id: "litereg_submit"
    }
    juvedermUltra.rfmodal.form.properties = rfproperties;
    //local form field objects for manipulation and callback ref
    var emailField = document.getElementById(rfproperties.frm_email_id);
    //set form field help text
    emailField.value = rfproperties.dt_email;
    var fieldObjects = [emailField];
    //set form field focus handlers
    YAHOO.util.Event.addListener(emailField, "focus", function(){
        juvedermUltra.rfmodal.form.inputFocus(emailField);
    });
    //set form field blur handlers
    YAHOO.util.Event.addListener(emailField, "blur", function(){
        juvedermUltra.rfmodal.form.inputBlur(rfproperties.lbl_email_id, emailField);
    });
    //set submit button event handler
    YAHOO.util.Event.addListener(rfproperties.btn_submit_id, "click", juvedermUltra.rfmodal.form.submit);
}

juvedermUltra.rfmodal.form.inputFocus = function(o){
    var cfg = juvedermUltra.rfmodal.form.properties;
    o.style.color = "black";
    if(o.value == cfg.dt_email || o.value == cfg.dt_confirmemail || o.value == cfg.dt_postal){
        o.value = "";
    }
}
juvedermUltra.rfmodal.form.inputBlur = function(id, o){
    var cfg = juvedermUltra.rfmodal.form.properties;
    var sVal = juvedermUltra.application.util.trimSpaces(o.value);
    if(sVal == ""){
        switch(id){
            case cfg.lbl_email_id:
                o.value = cfg.dt_email;
                break;
        }
    }
}

juvedermUltra.rfmodal.form.submit = function(){
    var cfg = juvedermUltra.rfmodal.form.properties;
    var tmpemail = document.getElementById(cfg.frm_email_id);
    var emaillabel = document.getElementById(cfg.lbl_email_id);
    var stremail = tmpemail.value;
    var tmpsubmit = document.getElementById(cfg.btn_submit_id); //submit btn obj for enable/disable
    
    // Validate the email address
    if(!validateEmail(stremail)){
        var tmperrordiv = document.getElementById(juvedermUltra.rfmodal.errorID);
        tmperrordiv.style.color = "red";
        tmperrordiv.style.fontWeight = "bold";
        tmperrordiv.style.fontStyle = "normal";
        tmperrordiv.innerHTML = "Please enter a valid e-mail address";
        
        emaillabel.style.color = "red";
        emaillabel.style.fontWeight = "bold";
        
        tmpemail.style.color = "red";
    } else {
        var tmperrordiv = document.getElementById(juvedermUltra.rfmodal.errorID);
        tmperrordiv.innerHTML = "";
        tmpsubmit.style.background = "url('/Style%20Library/Images/btn_loading.gif')";
        tmpsubmit.style.width = "77px";
        tmpsubmit.style.height = "21px";
        tmpsubmit.style.cursor = "normal";
        //compile the data path string with query values
        var rbinputs = document.getElementsByName("rfm_interests");
        var tmprbVal = "131";
        for(x=0;x<rbinputs.length;x++){
            if (rbinputs[x].checked == true){
                tmprbVal = rbinputs[x].value;
            }
        }
        var tmpDataPath = juvedermUltra.rfmodal.dataPath + "?email=" + stremail + "&interest=" + tmprbVal + "&uniq=" + Math.round(Math.random()*10000);
        //define the AJAX success handler
        var successHandler = function(o) {
            //Track complete registration event
            s.events = "event8";
            void(s.t());   
            s.events = "";
        
            //SUCCESS, lets see what the server returned and do the appropriate thing based on that response
            var r = o.responseText;
            var profileCookie = YAHOO.util.Cookie.get("email");
            if (!profileCookie){
                //alert(r.substr(r.indexOf("email")));
                juvedermUltra.rfmodal.targetURL += "?email=" + stremail;
            }
            //replace the email string with the users email addy
            var tmpHTML = juvedermUltra.rfmodal.successHTML.replace(/%%USEREMAIL%%/, stremail);
            //write out the success response html to the current panel
            document.getElementById("writeto").innerHTML = tmpHTML;
            //make close window link a yui button
            var oButton = new YAHOO.widget.Button (
                                "btn_closeWindow",
                                {
                                    type: "link",
                                    label: "Continue",
                                    href: juvedermUltra.rfmodal.targetURL
                                }
                            );
            //hide the stupid already registered link
            document.getElementById("rfm_ar").style.visibility = "hidden";      
            //create a hidden div via dom to output the server reponse page to for sc purposes
            var tmpDiv = document.createElement("div");
            tmpDiv.style.visibility = "hidden";
            var trackingImg = document.createElement("img");
            trackingImg.width = "1";
            trackingImg.height = "1";
            trackingImg.style.position = "absolute";
            trackingImg.style.left = "-10000";
            trackingImg.src = "https://switch.atdmt.com/action/umcall_080718registrationconfirmation_1";
            tmpDiv.appendChild(trackingImg);
            //tmpDiv.innerHTML += r;
            
            
            document.getElementById("writeto").appendChild(tmpDiv);
            //change close button listener to go to target url
            YAHOO.util.Event.addListener(juvedermUltra.rfmodal.closeTarget, "click", function(){
                window.location = juvedermUltra.rfmodal.targetURL;
            });
        }
        //define the AJAX failure handler
        var failureHandler = function(o) {
            //AJAX Failure, show failure message or do innerHTML statement on the open dialog
            alert("ajax failed " + tmpDataPath);
        }
        //define the callback object
        var callback = {
            success:successHandler,
            failure:failureHandler
        };
        //initiate the transaction
        var transaction = YAHOO.util.Connect.asyncRequest("GET", tmpDataPath, callback, null);
    }
    // RegEx validate email address
    function validateEmail(tmpEmailAddress) {
	    var validator = new ROSETTA.forms.validation();
	    return validator.validateEmail(tmpEmailAddress);
    }
}
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*  TAF Object/Methods
============================================ */
juvedermUltra.taf = function(){
    this.targetDiv = "taf";
    this.xmlPath = "/Documents/xml/taf.xml";
    this.panel_id = "yuidialog_tafpanel";
    //this.close_id = "taf_close"; //id of elem that close/hide form
    this.close_id = "btn_closeTAF"; //id of elem that close/hide form
    this.submit_id = "taf_submit"; //id of elem that submit form
    this.pageContent; //place holder for xml/html form content and success content below
    this.formStyles = {
        defaultInputColor: "#602E70",
        errorInputColor: "#FF0000",
        defaultLabelColor: "#707070",
        errorLabelColor: "#FF0000" 
    }
    this.contentSuccess;
    this.targetObj;
    this.inputConfig = []; //(f)orm (i)input config array
    this.formValidator = new ROSETTA.forms.validation();
    
    this.tafPanel = new YAHOO.widget.Panel(this.panel_id, {visible:false, draggable:false, close:false, modal:true, zIndex:20000, underlay:"none", iframe:true, monitorresize:true, width:"605px", height:"328px", context:[this.targetDiv,"tr","tr"],effect:[{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.5}, {effect:YAHOO.widget.ContainerEffect.SLIDE,duration:0.5}]});
    
};
juvedermUltra.taf.prototype.init = function(){
    if(document.getElementById(this.targetDiv)){
        var obj = this;
        this.targetObj = document.getElementById(obj.targetDiv);
        // send the user to the static page if on the ba modeler page
        if (window.location.href.indexOf("modeler") >= 0){
            YAHOO.util.Event.addListener(obj.targetDiv, "click", function(){
                window.location = "/utilities/taf.aspx";
            });
        } else {
            //load any required files, css for the taf in this case
            var loader = new YAHOO.util.YUILoader();
            loader.addModule({ 
                name: "taf_css",
                type: "css",
                fullpath: "/Style%20Library/en-us/Juvederm/taf.css",
                varName: "TAF_CSS"
            });
            loader.require(['taf_css']);
	        loader.onSuccess = function() {
                obj.loadContent();
	        }; 
	        loader.insert(); 
        }
    }
};
juvedermUltra.taf.prototype.loadContent = function(){
    //Load XML Content
    var obj = this; //internal obj re-reference
    var successHandler = function(o) {
        var xml = o.responseXML;
        var pages = xml.getElementsByTagName("page");
        var pageName = pages[0].getAttribute("name");
        obj.pageContent = pages[0].childNodes[0].nodeValue;
        obj.contentSuccess = pages[1].childNodes[0].nodeValue;
        obj.renderPanel();
    }
    //define the AJAX failure handler
    var failureHandler = function(o) {
        //alert the status code and error text
        alert(o.status + " : " + o.statusText);
    }
    //define the callback object
    var callback = {
        success:successHandler,
        failure:failureHandler
    };
    //initiate the transaction
    var transaction = YAHOO.util.Connect.asyncRequest("GET", obj.xmlPath, callback, null);
};

juvedermUltra.taf.prototype.renderPanel = function(){
    var obj = this; //internal obj re-reference
    obj.tafPanel.setBody(obj.pageContent);
    obj.tafPanel.render(document.body);
    //now that the form is rendered in the dom, we can intialize the form
    //and all the form listeners
    obj.initForm();
    YAHOO.util.Event.addListener(obj.close_id, "click", function(){
        obj.hidePanel()
    });
    document.getElementById(obj.panel_id).className = "";
    YAHOO.util.Event.addListener(obj.targetDiv, "click", function(){
        obj.showPanel();
    });
}

juvedermUltra.taf.prototype.showPanel = function(){
    this.tafPanel.show();
}
juvedermUltra.taf.prototype.hidePanel = function(rr){
    var obj = this;
    this.tafPanel.hide();
    if(rr){
        setTimeout("juvedermUltra.ptaf.closeEnd()",500);
    }
}
juvedermUltra.taf.prototype.closeEnd = function(){
    var obj = this; //internal obj re-reference
    obj.tafPanel.setBody(obj.pageContent);
    obj.initForm();
    YAHOO.util.Event.addListener(obj.close_id, "click", function(){
        obj.hidePanel()
    });
}
//
// TAF FORM Properties/Methods only below this line
//
juvedermUltra.taf.prototype.initForm = function(){
    var obj = this; //internal obj re-reference
    //form input configuration array[i]: ["labelid","inputid","input instructions","validation type"]
    obj.inputConfig.push(["taf_label1","taf_input1","enter your name","empty"],["taf_label2","taf_input2","enter your e-mail address","email"],["taf_label3","taf_input3","enter friend's name","empty"],["taf_label4","taf_input4","enter friend's email address","email"]);
    
    //loop through input config and put instructions and listeners
    for(a=0;a<obj.inputConfig.length;a++){
        var inputObj = document.getElementById(obj.inputConfig[a][1]);
        inputObj.value = obj.inputConfig[a][2];
        //set form field focus handlers
        YAHOO.util.Event.addListener(inputObj, "focus", function(){
            obj.inputFocus(this);
        });
        //set form field blur handlers
        YAHOO.util.Event.addListener(inputObj, "blur", function(){
            obj.inputBlur(this);
        });
    }
    //submit button listener
    YAHOO.util.Event.addListener(obj.submit_id, "click", function(){
        obj.submitForm();
    });
}
juvedermUltra.taf.prototype.inputFocus = function(o){
    o.style.color = this.formStyles.defaultInputColor;
    for(b=0;b<this.inputConfig.length;b++){
        if (o.value == this.inputConfig[b][2]){
            o.value = "";
            break;
        }
    }
}
juvedermUltra.taf.prototype.inputBlur = function(o){
    //if field loses focus and is blank, put the instructional text back
    var trimVal = juvedermUltra.application.util.trimSpaces(o.value);
    for(c=0;c<this.inputConfig.length;c++){
        if (o.id == this.inputConfig[c][1] && trimVal == ""){
            o.value = this.inputConfig[c][2];
            break;
        }
    }
}
juvedermUltra.taf.prototype.submitForm = function(){
    var obj = this;
    if(this.validateForm()){
        //Form is validated, disable the submit and change to loading
        YAHOO.util.Event.purgeElement(obj.submit_id, true);
        var tmpSubmit = document.getElementById(obj.submit_id);
        tmpSubmit.src = "/Style%20Library/Images/btn_loading.gif";
        tmpSubmit.style.cursor = "wait";
        //TAF function call here
        var senderName = document.getElementById(this.inputConfig[0][1]).value;
        var senderEmailAddress = document.getElementById(this.inputConfig[1][1]).value;
        var recipientName = document.getElementById(this.inputConfig[2][1]).value;
        var recipientEmailAddress = document.getElementById(this.inputConfig[3][1]).value;
        //alert(document.URL);
        TellAFriendSendMail(senderName, senderEmailAddress, recipientName, recipientEmailAddress, document.URL, juvedermUltra.ptaf.showResponse,juvedermUltra.ptaf.showFailure);
    }
}
juvedermUltra.taf.prototype.validateForm = function(){
    var formValid = true;
    for(d=0;d<this.inputConfig.length;d++){
        var formElem = document.getElementById(this.inputConfig[d][1]);
        var formLabel = document.getElementById(this.inputConfig[d][0]);
        var isValid = this.formValidator.validator(this.inputConfig[d][3],formElem.value);
        if(!isValid || formElem.value == this.inputConfig[d][2]){
            formElem.style.color = this.formStyles.errorInputColor;
            formLabel.style.color = this.formStyles.errorLabelColor;
            formValid = false;
            document.getElementById("taf_required").style.color = "#FF0000";
        } else {
            formElem.style.color = this.formStyles.defaultInputColor;
            formLabel.style.color = this.formStyles.defaultLabelColor;
        }
    }
    return formValid;
}

juvedermUltra.taf.prototype.showResponse = function(){
    //alert("reponse accepted!");
    //change the panel bkg and remove content
    var tmpBkg = document.getElementById("taf_background");
    tmpBkg.style.background="url('/Style%20Library/Images/bkg_taf_response.png') no-repeat";
    var tmpWriteDiv = document.getElementById("taf_writeto");
    tmpWriteDiv.innerHTML = juvedermUltra.ptaf.contentSuccess;
    //change the stupid close button to YUI button and default href to close the taf panel
    tmpBtmClose = document.getElementById("btn_closeTAF");
    tmpBtmClose.href = "javascript:juvedermUltra.ptaf.hidePanel(true);";
    var oButton = new YAHOO.widget.Button ("btn_closeTAF",{type: "push", label: "Stäng fönstret"});
    
    YAHOO.util.Event.addListener(juvedermUltra.ptaf.close_id, "click", function(){
        juvedermUltra.ptaf.hidePanel(true)
    });
}
juvedermUltra.taf.prototype.showFailure = function(){
    alert("A failure has occured.  Please close your window and try again.");
}

/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 * Custom form element styles baby YEAH!!
============================================ */
juvedermUltra.styleForms = function(){};
juvedermUltra.styleForms.prototype.init = function(){
    //load the library
    var loader = new YAHOO.util.YUILoader(); 
    loader.base = juvedermUltra.loaderBase;
    loader.addModule({ 
        name: "forms_style",
        type: "js",
        fullpath: "/includes/js/classes/forms-style.js",
        varName: "FORMS_STYLE"
    });
    loader.require(['forms_style']);
    loader.onSuccess = function() {
        createRadioButtons();
    }; 
    loader.insert();
    
    function createRadioButtons(){
        //replace radio buttons on level0 with default style
        var rb1 = new ROSETTA.forms.radioButtons("searchtype");
        rb1.show();
        //replace radio buttons on level1 with custom attributes
		var rb2 = new ROSETTA.forms.radioButtons("searchtype",{imgsrc: "/Style%20Library/Images/radio_right_callout.gif",
                   replaceClass: "lvl1_rbcallout",
                   height: 15,
                   width: 15
		});
		/*
		var rb2 = new ROSETTA.forms.radioButtons("ctl00$ctl16$g_dc5e527f_b5a8_4342_b3ef_8b4e062c1455$ctl00$searchtype",{imgsrc: "/Style%20Library/Images/radio_right_callout.gif",
            replaceClass: "lvl1_rbcallout",
            height: 15,
            width: 15
        });
		*/
        rb2.show();
        //signup form radio buttons
        var rb3 = new ROSETTA.forms.radioButtons("interest",{imgsrc: "/Style%20Library/Images/radio_right_callout.gif",
            replaceClass: "lvl1_rbcallout",
            height: 15,
            width: 15
        });
        rb3.show();
        //signup form radio buttons
        var rb4 = new ROSETTA.forms.radioButtons("ctl00$PlaceHolderMain$Interestlist",{imgsrc: "/Style%20Library/Images/radio_right_callout.gif",
            replaceClass: "",
            height: 15,
            width: 15
        });
        rb4.show();
    }
};

/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*  Testimonials Object
============================================ */
juvedermUltra.testimonials = {
    show: function(id,a){
        var closeText = "Stäng [X]";
        var curText = escape(document.getElementById(a).innerHTML);
        document.getElementById(id).style.display = "block";
        document.getElementById(a).href="javascript: juvedermUltra.testimonials.hide('"+id+"','"+a+"','"+escape(curText)+"');";
        document.getElementById(a).innerHTML = closeText;
    },
    hide: function(id,a,oText){
        document.getElementById(id).style.display = "none";
        document.getElementById(a).innerHTML = unescape(oText);
        document.getElementById(a).href="javascript: juvedermUltra.testimonials.show('"+id+"','"+a+"');";
    }
}
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*  This is a dummy function for the video player so it stops throwing JS errors
============================================ */
function blink_next(){}
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 * Prepost Callout
============================================ */
juvedermUltra.prepost = function(){
    this.callout;
};
juvedermUltra.prepost.prototype.init = function(){
    var obj = this;
    //load the library
    var loader = new YAHOO.util.YUILoader(); 
    loader.base = juvedermUltra.loaderBase;
    loader.addModule({ 
        name: "prepost",
        type: "js",
        fullpath: "/includes/js/classes/prepost.js",
        varName: "PREPOST"
    });
    loader.addModule({ 
        name: "prepost_css",
        type: "css",
        fullpath: "/Style%20Library/en-us/Juvederm/survey_style.css",
        varName: "PREPOST_CSS"
    });
    loader.require(['prepost','prepost_css']);
    loader.onSuccess = function() {
        obj.callout = new ROSETTA.prepost();
        obj.callout.showPostCallout = showPostCallout;
        obj.callout.showPreCallout = showPreCallout;
        obj.callout.popCallout();
        
    }; 
    loader.insert();
}
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 * Video Player - Modal Dialog, used for TV ad and Testimonial videos.
============================================ */
juvedermUltra.videoCallout = function(){
    this.panel_id = "";
    this.videoModal = {};
}
juvedermUltra.videoCallout.prototype.build = function(panelID){
    this.panel_id = panelID;
    var panelObj  = new YAHOO.widget.Panel(this.panel_id, {visible:false, draggable:false, close:false, modal:true, zIndex:20001, underlay:"none", fixedcenter:true });
    panelObj.render(document.body);
    this.videoModal = panelObj;
    document.getElementById(this.panel_id).className = "";
}
// below methods are specific to the tv ad video callout
// we can reuse this for the testimonial videos callout and the testimonial videos
juvedermUltra.showTVad = function(xmlFileName){

    juvedermUltra.videoPlayer = new juvedermUltra.videoCallout();
    juvedermUltra.videoPlayer.build("video_modal");
    var so2 = new SWFObject("/Documents/fla/videoplayer_callout.swf", "videoplayer_callout", 630, 353, "9.0.0.0", "#ffffff");
    so2.addParam("allowScriptAccess", "sameDomain");
    so2.addParam("allowFullScreen", "false");
    if(xmlFileName){
        so2.addParam("flashVars", "xmlPathName=/Documents/xml&xmlFileName="+xmlFileName);
    } else {
        so2.addParam("flashVars", "xmlPathName=/Documents/xml&xmlFileName=tv_ad.xml");
    }
    //key listener for modal close event
    juvedermUltra.modalKeyClose = new YAHOO.util.KeyListener(document, { keys:27 }, juvedermUltra.videoModalKeyClose, "keyup" );
    
    so2.addParam("wmode", "transparent");
    so2.write(juvedermUltra.videoPlayer.panel_id);
	// added if statement to look for the ID of the litereg dialog to 
	// make sure it exists before setting the style of the element
	// tnewton 5/05/2009
	if(document.getElementById("literegDialog")){
		document.getElementById("literegDialog").style.display = "none";
	}
    juvedermUltra.videoPlayer.videoModal.show();
    juvedermUltra.modalKeyClose.enable();
}

juvedermUltra.closeTVad = function(){
    document.getElementById(juvedermUltra.videoPlayer.panel_id).innerHTML = "";
    juvedermUltra.videoPlayer.videoModal.hide();
	// added if statement to look for the ID of the litereg dialog to 
	// make sure it exists before setting the style of the element
	// tnewton 5/05/2009
	if(document.getElementById("literegDialog")){
		document.getElementById("literegDialog").style.display = "block";
	}
    juvedermUltra.modalKeyClose.disable();
}
juvedermUltra.videoModalKeyClose = function (){
    var tmpMovie = document.getElementById("videoplayer_callout");
    tmpMovie.doVideoClose();
}

var scPdfTracking = function(){ 
       
     s = s_gi(s_account);
     
    /*Set the event*/
    s.events = 'event8'; /*Whichever event you have assigned to this tracking*/   
    /*Make the async SC call*/
    void(s.t());
}

/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 * PDF Download Lightbox
============================================ */
/* Programmers NOTE: Due to time constraints, similar functions shared by all
    modal dialog objects were not shared, and instead copied.  This is not ideal
    but there is no time left in the day to do this right, so, here is the hack
    @tnewton */
juvedermUltra.pdf = function(){
    this.targetDiv = "download_pdf";
    this.xmlPath = "/Documents/xml/pdf_modal.xml";
    this.panel_id = "yuidialog_pdfpanel";
    this.close_id = "pdf_modalclose"; //id of elem that close/hide form
    this.pageContent; //place holder for xml/html content
    this.targetObj;
    
    this.pdfPanel = new YAHOO.widget.Panel(this.panel_id, {visible:false, draggable:false, close:false, modal:true, zIndex:20000, underlay:"none", monitorresize:true, width:"596px", height:"417px", context:[this.targetDiv,"br","tl"], effect:[{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.5}]});
    
};
juvedermUltra.pdf.prototype.init = function(){
    if(document.getElementById(this.targetDiv)){
        var obj = this;
        this.targetObj = document.getElementById(obj.targetDiv);
        //load any required files, css for the pdf modal in this case
        var loader = new YAHOO.util.YUILoader();
        loader.addModule({ 
            name: "pdf_css",
            type: "css",
            fullpath: "/Style%20Library/en-us/Juvederm/pdf_modal.css",
            varName: "PDF_CSS"
        });
        loader.require(['pdf_css']);
        loader.onSuccess = function() {
            obj.loadContent();
        }; 
        loader.insert(); 
    }
};
juvedermUltra.pdf.prototype.loadContent = function(){
    //Load XML Content
    var obj = this; //internal obj re-reference
    var successHandler = function(o) {
        var xml = o.responseXML;
        var pages = xml.getElementsByTagName("page");
        var pageName = pages[0].getAttribute("name");
        obj.pageContent = pages[0].childNodes[0].nodeValue;
        obj.renderPanel();
    }
    //define the AJAX failure handler
    var failureHandler = function(o) {
        //alert the status code and error text
        alert(o.status + " : " + o.statusText);
    }
    //define the callback object
    var callback = {
        success:successHandler,
        failure:failureHandler
    };
    //initiate the transaction
    var transaction = YAHOO.util.Connect.asyncRequest("GET", obj.xmlPath, callback, null);
};

juvedermUltra.pdf.prototype.renderPanel = function(){
    var obj = this; //internal obj re-reference
    obj.pdfPanel.setBody(obj.pageContent);
    obj.pdfPanel.render(document.body);
    //now that the form is rendered in the dom, we can intialize the form
    //and all the form listeners
    YAHOO.util.Event.addListener(obj.close_id, "click", function(){
        obj.hidePanel();
        return false;
    });
    document.getElementById(obj.panel_id).className = "";
    YAHOO.util.Event.addListener(obj.targetDiv, "click", function(){
        obj.showPanel();
        return false;
    });
}

juvedermUltra.pdf.prototype.showPanel = function(){
    this.pdfPanel.show();
    return false;
}
juvedermUltra.pdf.prototype.hidePanel = function(rr){
    var obj = this;
    this.pdfPanel.hide();
    return false;
}
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*  Makes an area clickable based on target
============================================ */
juvedermUltra.ctaClick = function(c) {
	this.config = c || {
		links: [["locator-cta", "/ClinicLocator/Pages/ClinicLocator.aspx"], ["ba-cta", "/Experience/Pages/before_and_after.aspx"]]
	};
	this.init(this);
};
juvedermUltra.ctaClick.prototype.init = function(o) {
	for(a=0;a<o.config.links.length;a++){
		if (document.getElementById(o.config.links[a][0])) {
			YAHOO.util.Dom.setStyle(o.config.links[a][0], 'cursor', 'pointer');
			YAHOO.util.Event.addListener(o.config.links[a][0], "click", o.clickHandler, o);
		}
	}
};
juvedermUltra.ctaClick.prototype.clickHandler = function(e,o) {
	for(a=0;a<o.config.links.length;a++){
		if (this.id == o.config.links[a][0]) {
			window.location = o.config.links[a][1];
			break;
		}
	}

};
/* --------------------------------------------------------------------------------------- */
juvedermUltra.noReturn = function() {};

function scAjaxEvent(evt, sVar, sEvalue){ //can take more than these 3 arguments
        s.events = evt;
        s.eVar1 = "JuvedermSE";
        
        if(typeof sVar!== 'undefined' && sVar!== null && sVar!== ''){ //track evar if passed in
        	s[sVar] = sEvalue;
        	if(arguments.length > 3){ //loop through remaining variables, passed in as key-value pairs
        		for(var i = 3, arg_len = arguments.length; i < arg_len; i++){
        			if(i%2 != 0){ //only set if i is an odd #, as evens store values
	        			var tmpCntr = i;
		        		s[arguments[i]] = arguments[tmpCntr+1];
	        		}
	        	}
        	}
        }
        void(s.t());
        //Clear variables
        s.events = "";  
        s[sVar] = "";
        if(arguments.length > 3){
        	for(var i = 3, arg_len = arguments.length; i < arg_len; i++){
    			if(i%2 != 0){ //only set if i is an odd #, as evens store values
	        		s[arguments[i]] = "";
        		}
        	}
        }
    }
    
var scAjaxVariable = function(variable, value){
s[variable] = value;
void(s.t());
};

