Figment.Import("Disney.WDPRO.IBC.GuestServices",Figment.getJSRoot()+"modules/");Figment.Import("Figment.EventHandler",Figment.getJSRoot()+"_framework/");Figment.Import("Figment.DOM",Figment.getJSRoot()+"_framework/");Figment.Import("Figment.Net.Request",Figment.getJSRoot()+"_framework/");Figment.Import("Figment.Cookies",Figment.getJSRoot()+"_framework/");Figment.Namespace("Disney.WDPRO.IBC.GuestServices.Plugins.Login");Disney.WDPRO.IBC.GuestServices.Plugins.Login={CONSTANTS:{PROCESSOR:"en_US/_framework/components/ajaxProcessor",PLUGIN_ID:"GuestServices_Login_PlugIn",CHANGE_STATE_BUTTON_CLASS:"guest_services_login_plugin_change_state_button",PLUGIN_STATE_CLASS:"guest_services_login_plugin_state",LOGIN_ACTION_BUTTON_ID:"guest_services_login_action_button",LOOKUP_ACTION_BUTTON_ID:"guest_services_lookup_action_button",LOGIN_DESCRIPTION_ID:"guest_services_login_intro_description",MEMBER_NAME_INPUT_ID:"guest_services_login_member_name",PASSWORD_INPUT_ID:"guest_services_login_password",DEFAULT_STATE:"login",SERVER_ERROR_CODE:"E1800018",SERVER_TIMEOUT:20000},_TIMEOUT_ID:null,_PARAGRAPH_TEXT:null,_EXTRA_LOGIN_PARAMS:new Figment.HashTable(),addLoginParams:function(key,value){Disney.WDPRO.IBC.GuestServices.Plugins.Login._EXTRA_LOGIN_PARAMS.put(key,value);},removeLoginParam:function(key){Disney.WDPRO.IBC.GuestServices.Plugins.Login._EXTRA_LOGIN_PARAMS.remove(key);},getClassName:function(){return "Disney.WDPRO.IBC.GuestServices.Plugins.Login";},setToDefaultState:function(){Disney.WDPRO.IBC.GuestServices.Plugins.Login.setToState(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.DEFAULT_STATE);},setToState:function(state){Disney.WDPRO.IBC.GuestServices.Plugins.Login._restoreMessage();Disney.WDPRO.IBC.GuestServices.changeState(state,YAHOO.util.Dom.getElementsByClassName(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.PLUGIN_STATE_CLASS));},isLoggedIn:function(){return (Figment.Cookies.readCookie("BLUE")!==null)?true:false;},logout:function(_1043){try{var _1044=new Figment.HashTable();_1044.put("action","logout");var _1045=new Figment.Net.Request();var _1046=function(_1047){window.clearTimeout(Disney.WDPRO.IBC.GuestServices.Plugins.Login._TIMEOUT_ID);var _1048=_1043;var _1049=Disney.WDPRO.IBC.GuestServices.Plugins.Login._getRequestXML(_1047);var _104a=Disney.WDPRO.IBC.GuestServices.Plugins.Login._sendEvent(_1049,"logout",_1048);Disney.WDPRO.IBC.GuestServices.dispatchEvent(_104a);return;};var _104b=function(){try{_1045.requestor.request.conn.abort();}catch(e){}_1046(null);};Disney.WDPRO.IBC.GuestServices.Plugins.Login._sendRequest(_1045,_1046,_104b,_1044);}catch(exception){Disney.WDPRO.IBC.GuestServices.Plugins.Login._handleException(exception);}},login:function(_104c,_104d,_104e){try{var _104f=new Figment.HashTable();_104f.putAll(Disney.WDPRO.IBC.GuestServices.Plugins.Login._EXTRA_LOGIN_PARAMS);_104f.put("memberName",_104c);_104f.put("password",_104d);_104f.put("action","login");var _1050=new Figment.Net.Request();var _1051=function(_1052){window.clearTimeout(Disney.WDPRO.IBC.GuestServices.Plugins.Login._TIMEOUT_ID);var _1053=_104e;var _1054=Disney.WDPRO.IBC.GuestServices.Plugins.Login._getRequestXML(_1052);Disney.WDPRO.IBC.GuestServices.Plugins.Login._handleErrors(_1054,"login");var _1055=Disney.WDPRO.IBC.GuestServices.Plugins.Login._sendEvent(_1054,"login",_1053);if(_1055.getResult()){Disney.WDPRO.IBC.GuestServices.close();}else{var _1056=document.getElementById(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.LOGIN_ACTION_BUTTON_ID);_1056.disabled=false;}Disney.WDPRO.IBC.GuestServices.Shared.logger.debug("Request failed");return;};var _1057=function(){alert("timeout reached");try{_1050.requestor.request.conn.abort();}catch(e){}_1051(null);};Disney.WDPRO.IBC.GuestServices.Plugins.Login._sendRequest(_1050,_1051,_1057,_104f);}catch(exception){Disney.WDPRO.IBC.GuestServices.Plugins.Login._handleException(exception);}},lookupAccount:function(_1058,_1059,_105a,_105b,_105c,_105d){try{var _105e=new Figment.HashTable();_105e.put("memberName",_1058);_105e.put("lastName",_1059);_105e.put("birthMonth",_105a);_105e.put("birthDay",_105b);_105e.put("birthYear",_105c);_105e.put("action","lookup");var _105f=Disney.WDPRO.IBC.GuestServices.Plugins.Login._validateDate(_105a,_105b,_105c);if(_105f.length>0){var xml=Disney.WDPRO.IBC.GuestServices.Plugins.Login._createXMLDocument(_105f);Disney.WDPRO.IBC.GuestServices.Plugins.Login._handleErrors(xml,"lookup");Disney.WDPRO.IBC.GuestServices.Plugins.Login._sendEvent(_105f,"lookup",_105d);}else{var _1061=new Figment.Net.Request();var _1062=function(_1063){window.clearTimeout(Disney.WDPRO.IBC.GuestServices.Plugins.Login._TIMEOUT_ID);var _1064=_105d;var _1065=Disney.WDPRO.IBC.GuestServices.Plugins.Login._getRequestXML(_1063);Disney.WDPRO.IBC.GuestServices.Plugins.Login._handleErrors(_1065,"lookup");Disney.WDPRO.IBC.GuestServices.Plugins.Login._changeMessage(_1065);Disney.WDPRO.IBC.GuestServices.Plugins.Login._sendEvent(_1065,"lookup",_105d);Disney.WDPRO.IBC.GuestServices.Shared.logger.debug("Request failed");return;};var _1066=function(){try{_1061.requestor.request.conn.abort();}catch(e){}_1062(null);};Disney.WDPRO.IBC.GuestServices.Plugins.Login._sendRequest(_1061,_1062,_1066,_105e);}}catch(exception){Disney.WDPRO.IBC.GuestServices.Plugins.Login._handleException(exception);}},_validateDate:function(_1067,_1068,_1069){var _106a=[];if(_1067===""||_1068===""||_1069===""){_106a.push(Disney.WDPRO.IBC.GuestServices.Plugins.Register.CONSTANTS.INVALID_DATE_ERROR_CODE);}return _106a;},_restoreMessage:function(){var _106b=document.getElementById(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.LOGIN_DESCRIPTION_ID);var _106c=Disney.WDPRO.IBC.GuestServices.Plugins.Login._PARAGRAPH_TEXT;if(_106b!==null&&_106c!==null){_106b.innerHTML=_106c;}},_changeMessage:function(xml){var _106e=xml.getElementsByTagName("Paragraph");if(_106e.length>0){var _106f=_106e[0].firstChild.nodeValue.trim();if(_106f!==null){var _1070=document.getElementById(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.LOGIN_DESCRIPTION_ID);if(_1070!==null){Disney.WDPRO.IBC.GuestServices.Plugins.Login._PARAGRAPH_TEXT=_1070.innerHTML;_1070.innerHTML=_106f;Disney.WDPRO.IBC.GuestServices.changeState("login",YAHOO.util.Dom.getElementsByClassName(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.PLUGIN_STATE_CLASS));}}}},_getRequestXML:function(_1071){var _1072=null;var _1073=null;if(_1071!==null){_1073=_1071.response.getResponseHeader["Content-Type"];if(_1073.indexOf("text/xml")>-1){_1072=_1071.getResponseXML();}}if(_1072===null){_1072=Disney.WDPRO.IBC.GuestServices.Plugins.Login._createXMLDocument([Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.SERVER_ERROR_CODE]);}return _1072;},_createXMLDocument:function(_1074){var doc;var xml="<?xml version=\"1.0\"?>\n";xml+="<Message>\n";xml+="<Errors id=\"ErrorList\">\n";for(var i=0;i<_1074.length;i++){var _1078=_1074[i];var _1079=Disney.WDPRO.IBC.GuestServices.getError(_1078);if(typeof _1079==="undefined"||_1079===null){_1079="Unknown error occurred";}xml+="<Error code=\""+_1078+"\">\n";xml+=_1079+"\n";xml+="</Error>\n";}xml+="</Errors>\n";xml+="<Response>\n";xml+="<Result id=\"result\">\n";xml+="false\n";xml+="</Result>\n";xml+="</Response>\n";xml+="</Message>\n";if(document.implementation.createDocument){Disney.WDPRO.IBC.GuestServices.Shared.logger.debug("Creating XML document in W3C-compliant browser");var _107a=new DOMParser();doc=_107a.parseFromString(xml,"text/xml");}else{if(window.ActiveXObject){Disney.WDPRO.IBC.GuestServices.Shared.logger.debug("Creating XML document in IE browser");doc=new ActiveXObject("Microsoft.XMLDOM");doc.async="false";doc.loadXML(xml);}}return doc;},_sendEvent:function(xml,_107c,_107d){var _107e=new Disney.WDPRO.IBC.GuestServices.Event();_107e.setEvent(_107c);_107e.setSource(_107d);var _107f=xml.getElementsByTagName("Error");for(var i=0;i<_107f.length;i++){var _1081=_107f[i];var code=_1081.getAttribute("code");_107e.addError(code);}var _1083=xml.getElementsByTagName("Result");if(_1083.length>0){var _1084=_1083[0].firstChild.nodeValue.trim();_107e.setResult(_1084==="true"?true:false);}var _1085=xml.getElementsByTagName("Child");if(_1085.length>0){var child=_1085[0].firstChild.nodeValue.trim();_107e.addData("child",child==="true"?true:false);}Disney.WDPRO.IBC.GuestServices.dispatchEvent(_107e);return _107e;},_loginEvent:function(e){var _1088=document.getElementById(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.LOGIN_ACTION_BUTTON_ID);_1088.disabled=true;var _1089={MEMBER_NAME_ID:"guest_services_login_member_name",PASSWORD_ID:"guest_services_login_password"};var _108a=null;var _108b=null;var _108c=document.getElementById(_1089.MEMBER_NAME_ID);if(_108c!==null){_108a=_108c.value;}var _108d=document.getElementById(_1089.PASSWORD_ID);if(_108d!==null){_108b=_108d.value;}var _108e=Figment.EventHandler.getEvent(e);var _108f=Disney.WDPRO.IBC.GuestServices.getHBXPNCode(_108e);var _1090=Disney.WDPRO.IBC.GuestServices.getHBXMLCCode(_108e);var _1091=Disney.WDPRO.IBC.GuestServices.getSCPNCode(_108e);var _1092=Disney.WDPRO.IBC.GuestServices.getSCHierCode(_108e);if(_108f!==null&&_1090!==null){Disney.WDPRO.IBC.GuestServices.EVENT_HBX_Event_PageView(_108f,_1090,_1091,_1092);}var _1093=Disney.WDPRO.IBC.GuestServices.getSourceName();Disney.WDPRO.IBC.GuestServices.Plugins.Login.login(_108a,_108b,_1093);},_logoutEvent:function(e){var _1095=Disney.WDPRO.IBC.GuestServices.getSourceName();Disney.WDPRO.IBC.GuestServices.Plugins.Login.logout(_1095);},_lookupAccountEvent:function(e){var _1097={MEMBER_NAME_ID:"guest_services_lookup_member_name",LAST_NAME_ID:"guest_services_lookup_last_name",BIRTH_MONTH_ID:"guest_services_lookup_birth_month",BIRTH_DAY_ID:"guest_services_lookup_birth_day",BIRTH_YEAR_ID:"guest_services_lookup_birth_year"};var _1098=null;var _1099=null;var _109a=0;var _109b=0;var _109c=0;var _109d=document.getElementById(_1097.MEMBER_NAME_ID);if(_109d!==null){_1098=_109d.value;}var _109e=document.getElementById(_1097.LAST_NAME_ID);if(_109e!==null){_1099=_109e.value;}var _109f=document.getElementById(_1097.BIRTH_MONTH_ID);if(_109f!==null){_109a=_109f.value;}var _10a0=document.getElementById(_1097.BIRTH_DAY_ID);if(_10a0!==null){_109b=_10a0.value;}var _10a1=document.getElementById(_1097.BIRTH_YEAR_ID);if(_10a1!==null){_109c=_10a1.value;}var _10a2=Figment.EventHandler.getEvent(e);var _10a3=Disney.WDPRO.IBC.GuestServices.getHBXPNCode(_10a2);var _10a4=Disney.WDPRO.IBC.GuestServices.getHBXMLCCode(_10a2);var _10a5=Disney.WDPRO.IBC.GuestServices.getSCPNCode(_10a2);var _10a6=Disney.WDPRO.IBC.GuestServices.getSCHierCode(_10a2);if(_10a3!==null&&_10a4!==null){Disney.WDPRO.IBC.GuestServices.EVENT_HBX_Event_PageView(_10a3,_10a4,_10a5,_10a6);}var _10a7=Disney.WDPRO.IBC.GuestServices.getSourceName();Disney.WDPRO.IBC.GuestServices.Plugins.Login.lookupAccount(_1098,_1099,_109a,_109b,_109c,_10a7);},_changeStateEvent:function(e){var event=Figment.EventHandler.getEvent(e);var _10aa=event.element;var _10ab=_10aa.getAttribute(Disney.WDPRO.IBC.GuestServices.CONSTANTS.STATE_ATTRIBUTE_NAME);var _10ac=Figment.EventHandler.getEvent(e);var _10ad=Disney.WDPRO.IBC.GuestServices.getHBXPNCode(_10ac);var _10ae=Disney.WDPRO.IBC.GuestServices.getHBXMLCCode(_10ac);var _10af=Disney.WDPRO.IBC.GuestServices.getSCPNCode(_10ac);var _10b0=Disney.WDPRO.IBC.GuestServices.getSCHierCode(_10ac);if(_10ad!==null&&_10ae!==null){Disney.WDPRO.IBC.GuestServices.EVENT_HBX_Event_PageView(_10ad,_10ae,_10af,_10b0);}if(_10ab!==null){Disney.WDPRO.IBC.GuestServices.changeState(_10ab,YAHOO.util.Dom.getElementsByClassName(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.PLUGIN_STATE_CLASS));}},_handleException:function(_10b1){Disney.WDPRO.IBC.GuestServices.Shared.logger.debug("Exception thrown: "+_10b1.message);},_handleErrors:function(xml,state){var _10b4={ERROR_CODE_LIST_IN_LOGN_STATE_ID:"guest_services_login_error_list",ERROR_CODE_LIST_IN_LOOKUP_STATE_ID:"guest_services_lookup_error_list"};var _10b5=null;if(state==="login"){_10b5=document.getElementById(_10b4.ERROR_CODE_LIST_IN_LOGN_STATE_ID);}else{if(state==="lookup"){_10b5=document.getElementById(_10b4.ERROR_CODE_LIST_IN_LOOKUP_STATE_ID);}}if(_10b5!==null){var _10b6=_10b5.getElementsByTagName("UL");var _10b7=false;var _10b8=null;if(_10b6.length===0){_10b8=document.createElement("UL");_10b7=true;}else{_10b8=_10b6[0];while(_10b8.hasChildNodes()){_10b8.removeChild(_10b8.firstChild);}}if(_10b8!==null&&xml!==null){var _10b9=xml.getElementsByTagName("Error");for(var i=0;i<_10b9.length;i++){var _10bb=_10b9[i];var code=_10bb.getAttribute("code");var _10bd=Figment.DOM.getFirstChildElement(_10bb).nodeValue.trim();if(code==="E1800004"){_10bd="Last Name does not match our records";}Disney.WDPRO.IBC.GuestServices.Shared.logger.debug("Error: "+code+" ==> "+_10bd);var error=document.createElement("LI");error.appendChild(document.createTextNode(_10bd));_10b8.appendChild(error);}if(_10b7){_10b5.appendChild(_10b8);}}}},getPluginElement:function(){return document.getElementById(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.PLUGIN_ID);},_sendRequest:function(_10bf,_10c0,_10c1,_10c2){if(_10bf!==null){Disney.WDPRO.IBC.GuestServices.Plugins.Login._TIMEOUT_ID=window.setTimeout(_10c1,Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.SERVER_TIMEOUT);if(Disney.WDPRO.IBC.GuestServices.Shared.isNotEmptyOrNull(_10c2)){var _10c3=_10c2.iterator();var field;while(_10c3.hasNext()){field=_10c3.next();_10bf.addParameter(field.key,field.value);}}var _10c5=Disney.WDPRO.IBC.GuestServices.Plugins.Login.getPluginElement();if(_10c5!==null){_10bf.addParameter("strModuleName",_10c5.id);_10bf.getOptions().setMethod("POST");if(Disney.WDPRO.IBC.GuestServices.Shared.isNotEmptyOrNull(_10c0)){_10bf.getOptions().setUseCallbacks(true);_10bf.setCompleteCallBack(_10c0);}_10bf.send(Figment.getWebRoot()+Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.PROCESSOR);return _10bf;}throw new Exception("Plugin not found");}return null;},_submitIfEnterPressed:function(e){var _10c7="";if(window.event){_10c7=e.keyCode;}else{_10c7=e.which;}if(_10c7===13){document.getElementById(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.LOGIN_ACTION_BUTTON_ID).click();}},main:function(){Disney.WDPRO.IBC.GuestServices.registerPlugin(Disney.WDPRO.IBC.GuestServices.Plugins.Login);YAHOO.util.Dom.getElementsByClassName(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.CHANGE_STATE_BUTTON_CLASS,null,null,function(_10c8){YAHOO.util.Dom.addClass(_10c8,Disney.WDPRO.IBC.GuestServices.CONSTANTS.PREVENT_ASYNC_FROM_PLEASEWAIT);YAHOO.util.Event.addListener(_10c8,"click",Disney.WDPRO.IBC.GuestServices.Plugins.Login._changeStateEvent);});var _10c9=YAHOO.util.Dom.get(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.LOGIN_ACTION_BUTTON_ID);if(_10c9!==null){YAHOO.util.Dom.addClass(_10c9,Disney.WDPRO.IBC.GuestServices.CONSTANTS.PREVENT_ASYNC_FROM_PLEASEWAIT);YAHOO.util.Event.addListener(_10c9,"click",Disney.WDPRO.IBC.GuestServices.Plugins.Login._loginEvent);}var _10ca=YAHOO.util.Dom.get(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.LOOKUP_ACTION_BUTTON_ID);if(_10ca!==null){YAHOO.util.Dom.addClass(_10ca,Disney.WDPRO.IBC.GuestServices.CONSTANTS.PREVENT_ASYNC_FROM_PLEASEWAIT);YAHOO.util.Event.addListener(_10ca,"click",Disney.WDPRO.IBC.GuestServices.Plugins.Login._lookupAccountEvent);}YAHOO.util.Event.addListener(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.MEMBER_NAME_INPUT_ID,"keyup",Disney.WDPRO.IBC.GuestServices.Plugins.Login._submitIfEnterPressed);YAHOO.util.Event.addListener(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.PASSWORD_INPUT_ID,"keyup",Disney.WDPRO.IBC.GuestServices.Plugins.Login._submitIfEnterPressed);}};Figment.EntryPoint.add(Disney.WDPRO.IBC.GuestServices.Plugins.Login);
