var Dialog = new Object();
    Dialog = {
       additionData:null,
       curAction:null,
       productID:null,
       Val:new Validate("widgetLoginResponseMessage"),
       init:function()
       {
           
       },
       keyListener:function()
       {
            switch(Dialog.curAction)
            {
                case "products":
                    Dialog.Val.CharCountdown('userComment',500,'characterLimit');
                break;
                case "submit_question":
                    Dialog.Val.CharCountdown('userComment',500,'characterLimit');
                break;
                case "add_comment":
                    Dialog.Val.CharCountdown('userComment',500,'characterLimit');
                break;
                case "add_comment_screentime":
                    Dialog.Val.CharCountdown('userComment',500,'characterLimit');
                break;
                case "ages_stages":
                    Dialog.Val.CharCountdown('userComment',500,'characterLimit');
                break;
                case "homepage_ticker":
                    Dialog.Val.CharCountdown('userComment',500,'characterLimit');
                break;
                case "add_comment_julie":
                    Dialog.Val.CharCountdown('userComment',500,'characterLimit');
                break;
                
                default:
                break;
            }
       },
       showPanel:function(command,productID,AgeRange,Theme,YearMonth)
       {
            if(!$("widgetContainer"))
            {
                return alert("widgets not installed on this page");
            }
            this.curAction = command;
            this.Reset();
            // Set up Omniture tracking object
            ctoWidget=new CTO();
            ctoWidget.account="babyeinstein";
            ctoWidget.category="dshop";
            ctoWidget.site="bbe";
            ctoWidget.contentType="regular";
            ctoWidget.leadType="";
            ctoWidget.property="";
            
            switch(command)
            {
                case "products":
                    Utility.turnOnAbsolute("widgetContainer",100,100);
                    $("userComment").onkeyup = this.keyListener;
                    $("characterLimit").innerHTML = "500";
                    $("widgetHeaderText").innerHTML = "Have you purchased this product or received it as a gift? Share your experience with other moms in the Baby Einstein community by telling us how you and your child interact with this product.";
                    $("widgetHeaderImage").src = "/en/images/widget/header/widgetProductHeader.gif";
                    $("filter").value = "productID=" + productID;
                    
                    ctoWidget.pageName="product_ugc";
                    ctoWidget.siteSection="widget";
                break;
                case "submit_question":
                    Utility.turnOnAbsolute("widgetContainer",390,600);
                    $("userComment").onkeyup = this.keyListener;
                    $("characterLimit").innerHTML = "500";
                    $("widgetHeaderText").innerHTML = "Share your opinion with other parents in the Baby Einstein community! Submit a comment on this month's topic, or ask a question on next month&rsquo;s topic.";
                    $("widgetHeaderImage").src = "/en/images/widget/header/widgetExpertHeader.gif";
                    
                    ctoWidget.pageName="ask_expert_question_ugc";
                    ctoWidget.siteSection="widget";
                break;
                case "add_comment":
                    Utility.turnOnAbsolute("widgetContainer",390,380);
                    $("userComment").onkeyup = this.keyListener;
                    $("characterLimit").innerHTML = "500";
                    $("widgetHeaderText").innerHTML = "Share your opinion with other parents in the Baby Einstein community! Submit a comment on this month's topic, or ask a question on next month&rsquo;s topic.";
                    $("widgetHeaderImage").src = "/en/images/widget/header/widgetExpertHeader.gif";
                    $("filter").value = "YearMonth=" + YearMonth;
                    
                    ctoWidget.pageName="ask_expert_conversation_ugc";
                    ctoWidget.siteSection="widget";
                break;
                case "add_comment_screentime":
                    Utility.turnOnAbsolute("widgetContainer",390,380);
                    $("userComment").onkeyup = this.keyListener;
                    $("characterLimit").innerHTML = "500";
                    $("widgetHeaderText").innerHTML = "Share your opinion with other parents in the Baby Einstein community! Submit a comment on this month's topic, or ask a question on next month&rsquo;s topic.";
                    $("widgetHeaderImage").src = "/en/images/widget/header/widgetExpertHeader.gif";
                    $("filter").value = "YearMonth=" + YearMonth;
                    
                    ctoWidget.pageName="ask_expert_conversation_ugc";
                    ctoWidget.siteSection="widget";
                break;
                case "add_comment_julie":
                    Utility.turnOnAbsolute("widgetContainer",390,750);
                    $("userComment").onkeyup = this.keyListener;
                    $("characterLimit").innerHTML = "500";
                    $("widgetHeaderText").innerHTML = "Share your own ideas with other moms and dads on ways to spend more quality time with your baby. Your suggestion might be shown here.";
                    $("widgetHeaderImage").src = "/en/images/widget/header/widgetJulieHeader.gif";
                    
                    ctoWidget.pageName="julies_corner_ugc";
                    ctoWidget.siteSection="widget";
                break;
                case "homepage_ticker":
                    Utility.turnOnAbsolute("widgetContainer",215,100);
                    $("userComment").onkeyup = this.keyListener;
                    $("characterLimit").innerHTML = "500";
                    $("widgetHeaderText").innerHTML = "Every moment of discovery you share with your little one is worth celebrating. So share it with the Baby Einstein community. Submit your baby's special moment below and you might see it on our homepage news widget!";
                    $("widgetHeaderImage").src = "/en/images/widget/header/widgetNewsHeader.gif";
                    
                    ctoWidget.pageName="news_ticker";
                    ctoWidget.siteSection="widget";
                break;
                case "ages_stages":
                    Utility.turnOnAbsolute("widgetContainer",228,165);
                    $("userComment").onkeyup = this.keyListener;
                    $("characterLimit").innerHTML = "500";
                    $("widgetHeaderText").innerHTML = "Share your experiences with other parents in the Baby Einstein community. Submit a tip for this age and theme, or comment on the one you're reading now.";
                    $("widgetHeaderImage").src = "/en/images/widget/header/widgetAgeHeader.gif";
                    $("filter").value = "AgeRange=" + AgeRange + ":Theme=" + Theme;
                    
                    ctoWidget.pageName="ages&stages_ugc";
                    ctoWidget.siteSection="widget";
                break;
                default:
                    return;
                break;
            }
            
            ctoWidget.track();//Required. Do not remove.
            
            if(LoginStatus.isLoggedIn)
            {
              if($("loginOptions"))
              {
                Utility.turnOn("commentForm");
                $("loginOptions").className = "hidden";
              }
              if($("widgetInputContainer"))
              {
                Utility.swap("widgetInputContainer","widgetSubmitComment");
              }
            }
       },
	   Reset:function()
       {
            // reset panel
            if($("widgetSubmitComment")) $("widgetSubmitComment").style.display = "none";
            if($("widgetInputContainer")) $("widgetInputContainer").style.display = "block";
            // reset fields
            if($("userComment")) $("userComment").value = "";
            if($("commentValidationError")) $("commentValidationError").innerHTML = "ENTER TEXT BELOW";
            
			// turn off main window
			Utility.turnOff("widgetContainer");
			// panels
			Utility.turnOff("screen2");
			Utility.turnOff("forgotPasswordField");
			Utility.turnOff("submitOptions");
			Utility.turnOff("finalScreen");
			
			// reset errors
			var val = new Validate("widgetLoginResponseMessage");
			var spans = new Array("widgetLoginIDErrorSpan",
			                      "widgetPasswordErrorSpan",
//			                      "commentValidationError",
			                      "widgetLoginIDErrorSpan",
			                      "widgetPasswordErrorSpan",
			                      "passRequestValidationErrorSpan",
//			                      "preFirstnameValidationError",
//			                      "preLastnameValidationError",
			                      "birthdateSpanError",
			                      "firstNameValidationSpan",
			                      "lastNameValidationSpan",
			                      "birthdateValidationSpan",
			                      "emailValidationSpan",
			                      "passwordValidationSpan",
			                      "confirmPassordValidationSpan",
			                      "zipCodeValidationSpan",
			                      "parentEmailValidationSpan");
            val.resetFields(spans);
			// reset report fields
			$("widgetSummaryText").innerHTML = "";
			$("passwordStatusMessage").innerHTML = "";
			$("registrationValidationMessage").innerHTML = "";
			$("registrationStep1Summary").innerHTML = "";

			$("register_button").disabled = false;
			
			// turn on default panels
			Utility.turnOn("screen1");
			Utility.turnOff("commentForm");
			Utility.turnOn("loginOptions");
			Utility.turnOn("widgetRegistrationOptions");
			Utility.turnOn("registrationForm");
			Utility.turnOff("thanksscreen");
			
			// reset form data
			$("aspnetForm").reset();
       }
    };
