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,_ffe){Disney.WDPRO.IBC.GuestServices.Plugins.Login._EXTRA_LOGIN_PARAMS.put(key,_ffe);},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(_1001){try{var _1002=new Figment.HashTable();_1002.put("action","logout");var _1003=new Figment.Net.Request();var _1004=function(_1005){window.clearTimeout(Disney.WDPRO.IBC.GuestServices.Plugins.Login._TIMEOUT_ID);var _1006=_1001;var _1007=Disney.WDPRO.IBC.GuestServices.Plugins.Login._getRequestXML(_1005);var _1008=Disney.WDPRO.IBC.GuestServices.Plugins.Login._sendEvent(_1007,"logout",_1006);Disney.WDPRO.IBC.GuestServices.dispatchEvent(_1008);return;};var _1009=function(){try{_1003.requestor.request.conn.abort();}catch(e){}_1004(null);};Disney.WDPRO.IBC.GuestServices.Plugins.Login._sendRequest(_1003,_1004,_1009,_1002);}catch(exception){Disney.WDPRO.IBC.GuestServices.Plugins.Login._handleException(exception);}},login:function(_100a,_100b,_100c){try{var _100d=new Figment.HashTable();_100d.putAll(Disney.WDPRO.IBC.GuestServices.Plugins.Login._EXTRA_LOGIN_PARAMS);_100d.put("memberName",_100a);_100d.put("password",_100b);_100d.put("action","login");var _100e=new Figment.Net.Request();var _100f=function(_1010){window.clearTimeout(Disney.WDPRO.IBC.GuestServices.Plugins.Login._TIMEOUT_ID);var _1011=_100c;var _1012=Disney.WDPRO.IBC.GuestServices.Plugins.Login._getRequestXML(_1010);Disney.WDPRO.IBC.GuestServices.Plugins.Login._handleErrors(_1012,"login");var _1013=Disney.WDPRO.IBC.GuestServices.Plugins.Login._sendEvent(_1012,"login",_1011);if(_1013.getResult()){Disney.WDPRO.IBC.GuestServices.close();}else{var _1014=document.getElementById(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.LOGIN_ACTION_BUTTON_ID);_1014.disabled=false;}Disney.WDPRO.IBC.GuestServices.Shared.logger.debug("Request failed");return;};var _1015=function(){alert("timeout reached");try{_100e.requestor.request.conn.abort();}catch(e){}_100f(null);};Disney.WDPRO.IBC.GuestServices.Plugins.Login._sendRequest(_100e,_100f,_1015,_100d);}catch(exception){Disney.WDPRO.IBC.GuestServices.Plugins.Login._handleException(exception);}},lookupAccount:function(_1016,_1017,_1018,_1019,_101a,_101b){try{var _101c=new Figment.HashTable();_101c.put("memberName",_1016);_101c.put("lastName",_1017);_101c.put("birthMonth",_1018);_101c.put("birthDay",_1019);_101c.put("birthYear",_101a);_101c.put("action","lookup");var _101d=Disney.WDPRO.IBC.GuestServices.Plugins.Login._validateDate(_1018,_1019,_101a);if(_101d.length>0){var xml=Disney.WDPRO.IBC.GuestServices.Plugins.Login._createXMLDocument(_101d);Disney.WDPRO.IBC.GuestServices.Plugins.Login._handleErrors(xml,"lookup");Disney.WDPRO.IBC.GuestServices.Plugins.Login._sendEvent(_101d,"lookup",_101b);}else{var _101f=new Figment.Net.Request();var _1020=function(_1021){window.clearTimeout(Disney.WDPRO.IBC.GuestServices.Plugins.Login._TIMEOUT_ID);var _1022=_101b;var _1023=Disney.WDPRO.IBC.GuestServices.Plugins.Login._getRequestXML(_1021);Disney.WDPRO.IBC.GuestServices.Plugins.Login._handleErrors(_1023,"lookup");Disney.WDPRO.IBC.GuestServices.Plugins.Login._changeMessage(_1023);Disney.WDPRO.IBC.GuestServices.Plugins.Login._sendEvent(_1023,"lookup",_101b);Disney.WDPRO.IBC.GuestServices.Shared.logger.debug("Request failed");return;};var _1024=function(){try{_101f.requestor.request.conn.abort();}catch(e){}_1020(null);};Disney.WDPRO.IBC.GuestServices.Plugins.Login._sendRequest(_101f,_1020,_1024,_101c);}}catch(exception){Disney.WDPRO.IBC.GuestServices.Plugins.Login._handleException(exception);}},_validateDate:function(_1025,_1026,_1027){var _1028=[];if(_1025===""||_1026===""||_1027===""){_1028.push(Disney.WDPRO.IBC.GuestServices.Plugins.Register.CONSTANTS.INVALID_DATE_ERROR_CODE);}return _1028;},_restoreMessage:function(){var _1029=document.getElementById(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.LOGIN_DESCRIPTION_ID);var _102a=Disney.WDPRO.IBC.GuestServices.Plugins.Login._PARAGRAPH_TEXT;if(_1029!==null&&_102a!==null){_1029.innerHTML=_102a;}},_changeMessage:function(xml){var _102c=xml.getElementsByTagName("Paragraph");if(_102c.length>0){var _102d=_102c[0].firstChild.nodeValue.trim();if(_102d!==null){var _102e=document.getElementById(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.LOGIN_DESCRIPTION_ID);if(_102e!==null){Disney.WDPRO.IBC.GuestServices.Plugins.Login._PARAGRAPH_TEXT=_102e.innerHTML;_102e.innerHTML=_102d;Disney.WDPRO.IBC.GuestServices.changeState("login",YAHOO.util.Dom.getElementsByClassName(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.PLUGIN_STATE_CLASS));}}}},_getRequestXML:function(_102f){var _1030=null;var _1031=null;if(_102f!==null){_1031=_102f.response.getResponseHeader["Content-Type"];if(_1031.indexOf("text/xml")>-1){_1030=_102f.getResponseXML();}}if(_1030===null){_1030=Disney.WDPRO.IBC.GuestServices.Plugins.Login._createXMLDocument([Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.SERVER_ERROR_CODE]);}return _1030;},_createXMLDocument:function(_1032){var doc;var xml="<?xml version=\"1.0\"?>\n";xml+="<Message>\n";xml+="<Errors id=\"ErrorList\">\n";for(var i=0;i<_1032.length;i++){var _1036=_1032[i];var _1037=Disney.WDPRO.IBC.GuestServices.getError(_1036);if(typeof _1037==="undefined"||_1037===null){_1037="Unknown error occurred";}xml+="<Error code=\""+_1036+"\">\n";xml+=_1037+"\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 _1038=new DOMParser();doc=_1038.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,_103a,_103b){var _103c=new Disney.WDPRO.IBC.GuestServices.Event();_103c.setEvent(_103a);_103c.setSource(_103b);var _103d=xml.getElementsByTagName("Error");for(var i=0;i<_103d.length;i++){var _103f=_103d[i];var code=_103f.getAttribute("code");_103c.addError(code);}var _1041=xml.getElementsByTagName("Result");if(_1041.length>0){var _1042=_1041[0].firstChild.nodeValue.trim();_103c.setResult(_1042==="true"?true:false);}var _1043=xml.getElementsByTagName("Child");if(_1043.length>0){var child=_1043[0].firstChild.nodeValue.trim();_103c.addData("child",child==="true"?true:false);}Disney.WDPRO.IBC.GuestServices.dispatchEvent(_103c);return _103c;},_loginEvent:function(e){var _1046=document.getElementById(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.LOGIN_ACTION_BUTTON_ID);_1046.disabled=true;var _1047={MEMBER_NAME_ID:"guest_services_login_member_name",PASSWORD_ID:"guest_services_login_password"};var _1048=null;var _1049=null;var _104a=document.getElementById(_1047.MEMBER_NAME_ID);if(_104a!==null){_1048=_104a.value;}var _104b=document.getElementById(_1047.PASSWORD_ID);if(_104b!==null){_1049=_104b.value;}var _104c=Figment.EventHandler.getEvent(e);var _104d=Disney.WDPRO.IBC.GuestServices.getHBXPNCode(_104c);var _104e=Disney.WDPRO.IBC.GuestServices.getHBXMLCCode(_104c);var _104f=Disney.WDPRO.IBC.GuestServices.getSCPNCode(_104c);var _1050=Disney.WDPRO.IBC.GuestServices.getSCHierCode(_104c);if(_104d!==null&&_104e!==null){Disney.WDPRO.IBC.GuestServices.EVENT_HBX_Event_PageView(_104d,_104e,_104f,_1050);}var _1051=Disney.WDPRO.IBC.GuestServices.getSourceName();Disney.WDPRO.IBC.GuestServices.Plugins.Login.login(_1048,_1049,_1051);},_logoutEvent:function(e){var _1053=Disney.WDPRO.IBC.GuestServices.getSourceName();Disney.WDPRO.IBC.GuestServices.Plugins.Login.logout(_1053);},_lookupAccountEvent:function(e){var _1055={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 _1056=null;var _1057=null;var _1058=0;var _1059=0;var _105a=0;var _105b=document.getElementById(_1055.MEMBER_NAME_ID);if(_105b!==null){_1056=_105b.value;}var _105c=document.getElementById(_1055.LAST_NAME_ID);if(_105c!==null){_1057=_105c.value;}var _105d=document.getElementById(_1055.BIRTH_MONTH_ID);if(_105d!==null){_1058=_105d.value;}var _105e=document.getElementById(_1055.BIRTH_DAY_ID);if(_105e!==null){_1059=_105e.value;}var _105f=document.getElementById(_1055.BIRTH_YEAR_ID);if(_105f!==null){_105a=_105f.value;}var _1060=Figment.EventHandler.getEvent(e);var _1061=Disney.WDPRO.IBC.GuestServices.getHBXPNCode(_1060);var _1062=Disney.WDPRO.IBC.GuestServices.getHBXMLCCode(_1060);var _1063=Disney.WDPRO.IBC.GuestServices.getSCPNCode(_1060);var _1064=Disney.WDPRO.IBC.GuestServices.getSCHierCode(_1060);if(_1061!==null&&_1062!==null){Disney.WDPRO.IBC.GuestServices.EVENT_HBX_Event_PageView(_1061,_1062,_1063,_1064);}var _1065=Disney.WDPRO.IBC.GuestServices.getSourceName();Disney.WDPRO.IBC.GuestServices.Plugins.Login.lookupAccount(_1056,_1057,_1058,_1059,_105a,_1065);},_changeStateEvent:function(e){var event=Figment.EventHandler.getEvent(e);var _1068=event.element;var _1069=_1068.getAttribute(Disney.WDPRO.IBC.GuestServices.CONSTANTS.STATE_ATTRIBUTE_NAME);var _106a=Figment.EventHandler.getEvent(e);var _106b=Disney.WDPRO.IBC.GuestServices.getHBXPNCode(_106a);var _106c=Disney.WDPRO.IBC.GuestServices.getHBXMLCCode(_106a);var _106d=Disney.WDPRO.IBC.GuestServices.getSCPNCode(_106a);var _106e=Disney.WDPRO.IBC.GuestServices.getSCHierCode(_106a);if(_106b!==null&&_106c!==null){Disney.WDPRO.IBC.GuestServices.EVENT_HBX_Event_PageView(_106b,_106c,_106d,_106e);}if(_1069!==null){Disney.WDPRO.IBC.GuestServices.changeState(_1069,YAHOO.util.Dom.getElementsByClassName(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.PLUGIN_STATE_CLASS));}},_handleException:function(_106f){Disney.WDPRO.IBC.GuestServices.Shared.logger.debug("Exception thrown: "+_106f.message);},_handleErrors:function(xml,state){var _1072={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 _1073=null;if(state==="login"){_1073=document.getElementById(_1072.ERROR_CODE_LIST_IN_LOGN_STATE_ID);}else{if(state==="lookup"){_1073=document.getElementById(_1072.ERROR_CODE_LIST_IN_LOOKUP_STATE_ID);}}if(_1073!==null){var _1074=_1073.getElementsByTagName("UL");var _1075=false;var _1076=null;if(_1074.length===0){_1076=document.createElement("UL");_1075=true;}else{_1076=_1074[0];while(_1076.hasChildNodes()){_1076.removeChild(_1076.firstChild);}}if(_1076!==null&&xml!==null){var _1077=xml.getElementsByTagName("Error");for(var i=0;i<_1077.length;i++){var _1079=_1077[i];var code=_1079.getAttribute("code");var _107b=Figment.DOM.getFirstChildElement(_1079).nodeValue.trim();if(code==="E1800004"){_107b="Last Name does not match our records";}Disney.WDPRO.IBC.GuestServices.Shared.logger.debug("Error: "+code+" ==> "+_107b);var error=document.createElement("LI");error.appendChild(document.createTextNode(_107b));_1076.appendChild(error);}if(_1075){_1073.appendChild(_1076);}}}},getPluginElement:function(){return document.getElementById(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.PLUGIN_ID);},_sendRequest:function(_107d,_107e,_107f,_1080){if(_107d!==null){Disney.WDPRO.IBC.GuestServices.Plugins.Login._TIMEOUT_ID=window.setTimeout(_107f,Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.SERVER_TIMEOUT);if(Disney.WDPRO.IBC.GuestServices.Shared.isNotEmptyOrNull(_1080)){var _1081=_1080.iterator();var field;while(_1081.hasNext()){field=_1081.next();_107d.addParameter(field.key,field.value);}}var _1083=Disney.WDPRO.IBC.GuestServices.Plugins.Login.getPluginElement();if(_1083!==null){_107d.addParameter("strModuleName",_1083.id);_107d.getOptions().setMethod("POST");if(Disney.WDPRO.IBC.GuestServices.Shared.isNotEmptyOrNull(_107e)){_107d.getOptions().setUseCallbacks(true);_107d.setCompleteCallBack(_107e);}_107d.send(Figment.getWebRoot()+Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.PROCESSOR);return _107d;}throw new Exception("Plugin not found");}return null;},_submitIfEnterPressed:function(e){var _1085="";if(window.event){_1085=e.keyCode;}else{_1085=e.which;}if(_1085===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(_1086){YAHOO.util.Dom.addClass(_1086,Disney.WDPRO.IBC.GuestServices.CONSTANTS.PREVENT_ASYNC_FROM_PLEASEWAIT);YAHOO.util.Event.addListener(_1086,"click",Disney.WDPRO.IBC.GuestServices.Plugins.Login._changeStateEvent);});var _1087=YAHOO.util.Dom.get(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.LOGIN_ACTION_BUTTON_ID);if(_1087!==null){YAHOO.util.Dom.addClass(_1087,Disney.WDPRO.IBC.GuestServices.CONSTANTS.PREVENT_ASYNC_FROM_PLEASEWAIT);YAHOO.util.Event.addListener(_1087,"click",Disney.WDPRO.IBC.GuestServices.Plugins.Login._loginEvent);}var _1088=YAHOO.util.Dom.get(Disney.WDPRO.IBC.GuestServices.Plugins.Login.CONSTANTS.LOOKUP_ACTION_BUTTON_ID);if(_1088!==null){YAHOO.util.Dom.addClass(_1088,Disney.WDPRO.IBC.GuestServices.CONSTANTS.PREVENT_ASYNC_FROM_PLEASEWAIT);YAHOO.util.Event.addListener(_1088,"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);