var AdvSelectBox=Class.create();Object.extend(AdvSelectBox.prototype,{bindedCloseSelectbox:null,classNameSuffix:"",initialize:function(){},init:function(D,B,A){this.classNameSuffix=A;this.hideOptions();var C=this.createComboDOM(D,B);var E=$(D).ancestors()[0];E.replaceChild(C,document.getElementById(D));this.registerObserveOption()},createComboDOM:function(B,A){var M=$(B).options[$(B).selectedIndex].text;var H=$(B).options[$(B).selectedIndex].value;var N=document.createElement("div");N.setAttribute("id","adv-select-"+B);N.className="adv-select"+this.classNameSuffix+" hidden_selectbox";var G=document.createElement("a");G.setAttribute("id","button-selectbox-"+B);G.setAttribute("href","#");var O=this;G.onclick=function(){return O.open(this)};G.className="adv-opener"+this.classNameSuffix;N.appendChild(G);var I=document.createTextNode(M);G.appendChild(I);var L=document.createElement("div");L.setAttribute("id","adv-dropdown-"+B);L.style.display="none";L.className="adv-dropdown"+this.classNameSuffix;var Q=$(B).childElements();var K;var E,D;var J,C,F;for(E=0;E<Q.length;E++){if(Q[E].tagName.toUpperCase()==="OPTGROUP"){J=document.createElement("div");J.className="adv-dropdown-group";C=document.createElement("span");C.appendChild(document.createTextNode(Q[E].getAttribute("label")));J.appendChild(C);F=Q[E].firstChild;while(F){K=document.createElement("a");K.setAttribute("value",F.getAttribute("value"));K.appendChild(document.createTextNode(F.text));J.appendChild(K);K.selectBox=L;F=F.nextSibling}L.appendChild(J)}else{K=document.createElement("a");K.setAttribute("value",Q[E].getAttribute("value"));K.appendChild(document.createTextNode(Q[E].text));L.appendChild(K);K.selectBox=L}}if(Q.length){K.className="last"}N.appendChild(L);var P=document.createElement("input");P.setAttribute("id",A);P.setAttribute("name",A);P.setAttribute("value",H);P.setAttribute("type","hidden");N.appendChild(P);return N},hideOptions:function(){var A=document.getElementsByClassName("adv-select"+this.classNameSuffix);for(var B=0;B<A.length;B++){_temp=A[B];Element.addClassName(_temp,"hidden_selectbox");var C=_temp.getElementsByTagName("DIV")[0];C.style.display="none"}},open:function(C){var A=C.parentNode;var B=A.getElementsByTagName("DIV")[0];if(Element.hasClassName(A,"hidden_selectbox")){this.hideOptions();A.removeClassName("hidden_selectbox");B.style.display="block";if(!this.bindedCloseSelectbox){this.bindedCloseSelectbox=this.closeSelectBox.bindAsEventListener(this)}Event.observe(document,"click",this.bindedCloseSelectbox)}else{A.addClassName("hidden_selectbox");B.style.display="none";Event.stopObserving(document,"click",this.bindedCloseSelectbox)}return false},selectOption:function(C){var G=C.getAttribute("value");var I=C.firstChild.nodeValue;var A=C.selectBox.parentNode;var B=A.firstChild.getAttribute("id");var D=A.getElementsByTagName("input");var H=document.getElementById(B);var F=D[0];var E=A.getElementsByTagName("a")[1];if(H){H.update(I)}if(F){F.value=G}},observeOption:function(C){var B=Event.element(C);var A=B.selectBox;this.selectOption(B);A.style.display="none";Element.addClassName(A.parentNode,"hidden_selectbox");Event.stop(C);Event.stopObserving(document,"click",this.bindedCloseSelectbox)},optionMouseOn:function(B){var A=Event.element(B);Element.addClassName(A,"hover")},optionMouseOut:function(B){var A=Event.element(B);Element.removeClassName(A,"hover")},closeSelectBox:function(E){var D=$(Event.element(E));if(D.tagName=="A"&&D.hasClassName("adv-opener"+this.classNameSuffix)){return false}var F=document.getElementsByClassName("adv-select"+this.classNameSuffix);for(var C=0;C<F.length;C++){var A=F[C];A.addClassName("hidden_selectbox");var B=A.getElementsByTagName("DIV")[0];B.hide();Event.stopObserving(document,"click",this.bindedCloseSelectbox)}},registerObserveOption:function(){var F=document.getElementsByClassName("adv-dropdown"+this.classNameSuffix);for(var D=0;D<F.length;D++){var B=F[D];var A=B.getElementsByTagName("A");for(var C=0;C<A.length;C++){var E=A[C];Event.observe(E,"click",(this.observeOption.bind(this)));Event.observe(E,"mouseover",(this.optionMouseOn.bind(this)));Event.observe(E,"mouseout",(this.optionMouseOut.bind(this)))}}}});var portal;var Portal=Class.create();Object.extend(Portal.prototype,AppCore.prototype);Object.extend(Portal.prototype,{limitDigits:function(B){if(B.charCode==0){return }var A=typeof B.charCode!=="undefined"?B.charCode:B.keyCode;if((A<48||A>57)){B.stop();return false}},addDigitFilter:function(A){Event.observe($(A),"keypress",this.limitDigits.bindAsEventListener(this))}});portal=new Portal();var Payments=Class.create();var payments={};Object.extend(Payments.prototype,AppCore.prototype);Object.extend(Payments.prototype,{toggleInvoiceForm:function(){if($("invoice").checked){$("invoice_data").show()}else{$("invoice_data").hide()}redrawCorners(true)},switchCustomerType:function(B,C){var A=C==="company";$("div_nip").style.display=A?"block":"none";$("div_pesel").style.display=A?"none":"block";$("div_company_name").style.display=A?"block":"none"},initialize:function(){this.toggleInvoiceForm();this.switchCustomerType(null,$("invoice_payor").value);var A=this;var B=$("invoice_payor");B.observe("change",function(C){A.switchCustomerType(A,B.getValue())})}});Event.onDOMReady(function(){payments=new Payments()});var eshop;var Eshop=Class.create();Object.extend(Eshop.prototype,AppCore.prototype);Object.extend(Eshop.prototype,{oldMNPOperators:null,isNewMNP:false,imgBackToMergeSrc:null,imgContinueOrderSrc:null,STATUS_OK:null,STATUS_ERROR:null,STATUS_MERGE_CONFIRM:null,STATUS_CANCEL_NOT_POSSIBLE:null,STATUS_CONFIRM_OPERATOR:null,smsConfirmed:null,operatorChoosen:null,toggleInvoice:function(){var B=$("want_invoice").checked;$("div_invoice").style.display=B?"block":"none";var A=$("invoice_copy_address");if(!B){A.checked=false}A.disabled=!B;redrawCorners(true);return true},toggleAdditional:function(){var A=$("additional").checked;$("div_additional").style.display=(A)?"block":"none";redrawCorners(true);return true},toggleLabelAdditional:function(){var A=$("additional").checked;if(A){$("additional").checked=false}else{$("additional").checked=true}this.toggleAdditional()},switchCustomerType:function(B,C){var A=C==="company";$("div_nip").style.display=A?"block":"none";$("div_pesel").style.display=A?"none":"block";$("div_company_name").style.display=A?"block":"none"},initCustomerTypeSwitch:function(B){var A=this;$(B).observe("change",function(C){A.switchCustomerType(C,this.options[this.selectedIndex].value)});this.switchCustomerType(null,$("invoice_customer_type").value);this.toggleInvoice()},copyDeliveryAddress:function(){var C={"delivery_first_name":"invoice_first_name","delivery_last_name":"invoice_last_name","delivery_zipcode":"invoice_zipcode","delivery_zipcode_ex":"invoice_zipcode_ex","delivery_city":"invoice_city","delivery_street":"invoice_street","delivery_house_no":"invoice_house_no","delivery_house_no_ex":"invoice_house_no_ex"},B;if($("invoice_copy_address").checked){for(var A in C){B=C[A];$(B).value=$(A).value}}},doubleInputSwitch:function(D,A){var C=document.getElementById(D).value;var B=document.getElementById(D+"_ex");if(C&&B&&C.length==A){B.focus();B.select()}},limitDigits:function(B){if(B.keyCode!=8){if(B.charCode==0){return }var A=typeof B.charCode!=="undefined"?B.charCode:B.keyCode;if((A<48||A>57)){B.stop();return false}}},addDigitFilter:function(A){Event.observe($(A),"keypress",this.limitDigits.bindAsEventListener(this))},switchNotificationType:function(A,C){var B=C!=="E-MAIL";$("div_notification_phone").style.display=B?"block":"none";$("div_notification_email").style.display=!B?"block":"none";if(C===""){$("div_notification_phone").style.display="none";$("div_notification_email").style.display="none"}else{$("div_notification_empty").style.display="none"}},switchMoveType:function(B,C){var A=(C==="DAY")||(C==="");$("div_move_day").style.display=A?"block":"none";$("div_notif_day").style.display=A?"block":"none"},initExtraMnpDataForm:function(D){if(D){var F="notificationType",C,B=this;var E=$$("#div_notification_types input.radio");var A=$("moveType");E.each(function(G){$(G).observe("click",function(){B.switchNotificationType(B,G.getAttribute("value"))})});A.observe("change",function(G){B.switchMoveType(G,this.options[this.selectedIndex].value)});this.switchMoveType(null,A.options[A.selectedIndex].value)}else{var E=$$("#div_notification_types input.radio");var A=$("moveType");B=this;E.each(function(G){$(G).observe("click",B.switchNotificationType.bindAsEventListener(B,G.getAttribute("value")))})}},addOldMNPOperator:function(A){if(this.oldMNPOperators===null){this.oldMNPOperators=new Array(A)}else{this.oldMNPOperators.push(A)}},supportsNewMNP:function(A){var B;var C=A.split("_",2);A=C[0];for(B=0;B<this.oldMNPOperators.length;B++){if(this.oldMNPOperators[B]==A){return false}}return true},enableOperatorListener:function(){var A=$$("ul.operators-list li input");for(var B=0;B<A.length;B++){A[B].observe("click",this.changeMNPOperator.bind(this))}},changeMNPOperator:function(C){var B=Event.element(C);var A=B.getAttribute("value");if(this.supportsNewMNP(A)){$("op_not_ready_err").hide()}else{$("op_not_ready_err").show()}},submitRecommendationForm:function(){var A=$("configuration").action;new Ajax.Request(A,{method:"post",parameters:{form_type:"recommendation",rcm_msisdn:$("rcm_msisdn").value},onSuccess:function(E){var B=E.responseText.evalJSON();var C="";var D='<a href="#" onclick="eshop.recommendationFormSwitch(false); return false;">'+Eshop_lang.try_again+"</a>";this.recommendationFormSwitch(true);switch(B.status){case this.STATUS_ERROR:C='<span class="error wide">'+B.message+" "+D+"</span>";break;case this.STATUS_OK:C='<span class="success wide">'+B.message+"</span>";break;default:C='<span class="error wide">'+Eshop_lang.communications_error+"</span>"}$("recommendationFields").insert(C)}.bind(this),onFailure:function(B){alert(Eshop_lang.communications_error)}})},submitConfirmSmsForm:function(){var A=$("configuration").action;new Ajax.Request(A,{method:"post",parameters:{form_type:"confirm_sms",code:$("code").value},onSuccess:function(E){var B=E.responseText.evalJSON();var C="";var D='<a href="#" onclick="eshop.confirmSmsFormSwitch(false); return false;">'+Eshop_lang.try_again+"</a>";this.confirmSmsFormSwitch(true);switch(B.status){case this.STATUS_ERROR:C='<span class="error wide">'+B.message+" "+D+"</span>";break;case this.STATUS_OK:this.smsConfirmed=true;C='<span class="success wide">'+B.message+"</span>";break;default:C='<span class="error wide">'+Eshop_lang.communications_error+"</span>"}$("confirmSmsFields").insert(C)}.bind(this),onFailure:function(B){alert(Eshop_lang.communications_error)}})},recommendationFormSwitch:function(A){if(A){$$("#recommendationFields div").invoke("hide");$$("#recommendationFields span.error").invoke("remove")}else{$$("#recommendationFields div").invoke("show");$$("#recommendationFields span.error").invoke("remove")}},mergeFormSwitch:function(A){if(A){$("mergeResponse").update("");$$("#mergeFields div").invoke("hide");$("mergeResponse").show()}else{$("mergeResponse").update("");$$("#mergeFields div").invoke("show");$("mergeResponse").hide()}},confirmSmsFormSwitch:function(A){if(A){$$("#confirmSmsFields div").invoke("hide");$$("#confirmSmsFields span.error").invoke("remove")}else{$$("#confirmSmsFields div").invoke("show");$$("#confirmSmsFields span.error").invoke("remove")}},submitMergeForm:function(B){var A=$("configuration").action;if(B=="merge"){params={form_type:"merge",gg_uin:$("gg_uin").value,gg_pass:$("gg_pass").value}}else{params={form_type:"merge_confirm"}}new Ajax.Request(A,{method:"post",parameters:params,onSuccess:function(G){var C=G.responseText.evalJSON();var D="";var E='<a href="#" onclick="eshop.mergeFormSwitch(false); return false;" />'+Eshop_lang.try_again+"</a>";var F='<img src="'+this.imgBackToMergeSrc+'" onclick="eshop.mergeFormSwitch(false); return false;" />';this.mergeFormSwitch(true);switch(C.status){case this.STATUS_ERROR:D='<span class="error wide">'+C.message+" "+E+"</span>";break;case this.STATUS_OK:D='<span class="success wide">'+C.message+"</span>";break;case this.STATUS_CANCEL_NOT_POSSIBLE:D=C.message;D+=F;break;case this.STATUS_MERGE_CONFIRM:D=C.message+"";D+='<img src="'+this.imgBackToMergeSrc+'" onclick="eshop.mergeFormSwitch(false); return false;" /> ';D+='<img src="'+this.imgContinueOrderSrc+'" onclick="eshop.submitMergeForm(\'merge_confirm\'); return false;" />';break;default:D='<span class="error wide">'+Eshop_lang.communications_error+"</span>"}$("mergeResponse").insert(D)}.bind(this),onFailure:function(C){alert(Eshop_lang.communications_error)}})},canSendOperatorForm:function(){if(!this.smsConfirmed){alert(Eshop_lang.confirm_sms);return false}if(!this.operatorChoosen){alert(Eshop_lang.choose_current_operator);return false}return true},switchMNPCustomerType:function(A){switch(A){case"person":$("form_person").show();$("form_company").hide();$("form_person_id_type_fields").show();$("form_foreigner_id_type_fields").hide();$("form_person_first_name_field").show();$("form_person_last_name_field").show();$("form_person_data_consistency").show();$("form_company_name_field").hide();$("form_company_documents").hide();$("form_company_representative_field").hide();break;case"company":$("form_person").hide();$("form_company").show();$("form_person_id_type_fields").hide();$("form_foreigner_id_type_fields").hide();$("form_person_first_name_field").hide();$("form_person_last_name_field").hide();$("form_person_data_consistency").hide();$("form_company_name_field").show();$("form_company_documents").show();$("form_company_representative_field").show();break;case"foreigner":$("form_person").show();$("form_company").hide();$("form_person_id_type_fields").hide();$("form_foreigner_id_type_fields").show();$("form_person_first_name_field").show();$("form_person_last_name_field").show();$("form_person_data_consistency").show();$("form_company_name_field").hide();$("form_company_documents").hide();$("form_company_representative_field").hide();break}redrawCorners(true)},prepareBirthDate:function(E){var D=/^\d{11}$/;var G="-";if(E.match(D)){var C="19"+E.substr(0,2);var F=E.substr(2,2);var A=E.substr(4,2);var B=new Date(C,F,A);if(B.getFullYear()==C&&B.getMonth()==F&&B.getDate()==A){$("birthDate").value=C+G+F+G+A}}}});eshop=new Eshop()