var Filmstrip=function(a){var b=this;b.eOriginal=a.eOriginal;if(!a.sThumbnail_tag_name){a.sThumbnail_tag_name='a'}var c=a.eThumbnails.getElementsByTagName(a.sThumbnail_tag_name);if(a.sThumbnail_tag_name.toLowerCase()!='a'){for(var i=0;i<c.length;i++){var d=c[i].getElementsByTagName('a');if(d.length){if(Common.Class.match(d[0],'selected')){b.eSelected=d[0]}b.create_thumbnail(d[0])}}}else{for(var i=0;i<c.length;i++){if(Common.Class.match(c[i],'selected')){b.eSelected=c[i]}b.create_thumbnail(c[i])}}};Filmstrip.prototype={create_thumbnail:function(c){var d=this;Common.Event.add(c,'click',function(a){if(d.eSelected){Common.Class.remove(d.eSelected,'selected')}d.eSelected=c;Common.Class.add(d.eSelected,'selected');var b='<img src="'+c.href+'" alt="'+c.title+'"';b+=' width="'+c.className.match(new RegExp('w_(\\w+)'))[1]+'" height="'+c.className.match(new RegExp('h_(\\w+)'))[1]+'"';if(c.href.match(new RegExp('.png'))){b+=' class="png"'}b+=' />';if(c.className.match(new RegExp('shadow'))){b+='<br /><img src="/f/1/global/shadow.gif" alt="" width="'+c.className.match(new RegExp('w_(\\w+)'))[1]+'" height="15" class="shadow" />'}d.eOriginal.innerHTML=b;Common.Event.cancel(a);if(c.blur){c.blur()}})}};function UserlistLink(b,c){this.container=$(b);this.successMsgBox=this.container.find(".success_msg_box");this.link=this.container.find(".link a");this.timeoutId=null;var d=this.link.attr("href").split("?");this.url=d[0];this.data=d[1];var e=this;this.link.click(function(a){if(IS_LOGGED_IN){e.send()}else if(oLoginForm){oLoginForm.show(a,true,c)}a.preventDefault();a.stopPropagation()});this.successMsgBox.hover(function(){clearTimeout(e.timeoutId)},function(){e.timeoutId=setTimeout(function(){e.hideSuccessMsgBox()},5000)})}UserlistLink.prototype={send:function(){var a=this;$.post(this.url,this.data,function(){a.showSuccessMsgBox()})},showSuccessMsgBox:function(){var a=this;$(".success_msg_box").hide();clearTimeout(a.timeoutId);this.successMsgBox.fadeIn("fast");this.timeoutId=setTimeout(function(){a.hideSuccessMsgBox()},5000)},hideSuccessMsgBox:function(){this.successMsgBox.fadeOut("slow")}};function CompareManager(b){this.bInit=null;var c=this;this.iProductId=b;this.oLink=document.getElementById('compare_link');this.sLink=this.oLink.getAttribute('href');this.disableLink();this.oLoadingContainer=document.getElementById('compare_loading');this.oAddLinkContainer=document.getElementById('compare_add_link');this.oRemoveLinkContainer=document.getElementById('compare_remove_link');if(this.oAddLinkContainer){var d=this.oAddLinkContainer.getElementsByTagName('a')[0];if(d){Common.Event.add(d,'click',function(a){c.addProduct();Common.Event.cancel(a)})}}if(this.oRemoveLinkContainer){var e=this.oRemoveLinkContainer.getElementsByTagName('a')[0];if(e){Common.Event.add(e,'click',function(a){c.removeProduct();Common.Event.cancel(a)})}}this.oAjax=new AJAXRequestClass('/compare/ajax/','POST');var f=function(a){c.handleResponse(a.responseXML)};this.oAjax.SetCallback(f);this.sendRequest()}CompareManager.prototype.sendRequest=function(a){Common.Class.add(this.oAddLinkContainer,'hidden');Common.Class.add(this.oRemoveLinkContainer,'hidden');Common.Class.remove(this.oLoadingContainer,'hidden');var b={productId:this.iProductId};if(a){b.action=a}this.oAjax.SetParams(b);this.oAjax.Load()};CompareManager.prototype.addProduct=function(){this.sendRequest('add')};CompareManager.prototype.removeProduct=function(){this.sendRequest('remove')};CompareManager.prototype.handleResponse=function(a){var b=a.getElementsByTagName('Product');var c=false;for(var i=0,iLength=b.length;i<iLength;i++){if(this.iProductId==b[i].getAttribute('id')){c=true;break}}if(c){this.enableRemove()}else{this.enableAdd()}if(b.length>0){this.enableLink()}else{this.disableLink()}};CompareManager.prototype.enableLink=function(){this.oLink.setAttribute("href",this.sLink);Common.Class.remove(this.oLink,'disabled')};CompareManager.prototype.disableLink=function(){this.oLink.removeAttribute("href");Common.Class.add(this.oLink,'disabled')};CompareManager.prototype.enableAdd=function(){Common.Class.add(this.oLoadingContainer,'hidden');Common.Class.add(this.oRemoveLinkContainer,'hidden');Common.Class.remove(this.oAddLinkContainer,'hidden')};CompareManager.prototype.enableRemove=function(){Common.Class.add(this.oLoadingContainer,'hidden');Common.Class.add(this.oAddLinkContainer,'hidden');Common.Class.remove(this.oRemoveLinkContainer,'hidden')};function OperatorController(){var b=this;this.bLoaded=false;this.oOperatorsContainer=document.getElementById('operators');this.oOperatorsContainerInner=document.getElementById('operators_inner');var c=document.getElementById('fader');c.parentNode.insertBefore(this.oOperatorsContainer,c.nextSibling);this.oSelectButton=document.getElementById('select_contract_button');OperatorController.baseConstructor.call(this,this.oOperatorsContainer,this.oSelectButton,c);this.oForm=document.getElementById('product_card_order_form');this.oClose=document.getElementById('operators_close');if(this.oClose){Common.Event.add(this.oClose,'click',function(a){b.hide(a);return Common.Event.cancel(a)})}this.oAjax=new AJAXRequestClass('/contracts/','POST');var d=function(a){b.showResponse(a.responseText)};this.oAjax.SetCallback(d)}OperatorController.inheritFrom(PopupBlock,{show:function(a){OperatorController.superClass.show.call(this,a);if(!this.bLoaded){Common.Class.add(this.oOperatorsContainer,'loading');var b=this.oForm.getElementsByTagName('input');var c={};for(var i=0,iLength=b.length,oInput;i<iLength;i++){oInput=b[i];if(oInput.name&&oInput.type!='checkbox'&&oInput.type!='radio'){c[oInput.name]=oInput.value}}this.oAjax.SetParams(c);this.oAjax.Load()}},showResponse:function(a){this.bLoaded=true;Common.Class.replace(this.oOperatorsContainer,'loading','invisible loaded');this.oOperatorsContainerInner.innerHTML=a;this.initOperators();Common.Class.remove(this.oOperatorsContainer,'invisible')},initOperators:function(){var c=document.getElementById('operator_logos');var d=document.getElementById('operator_contracts');this.oContractData=document.getElementById('contract_data');this.oProductPrice=document.getElementById('product_price');this.iProductPrice=parseFloat(this.oProductPrice.innerHTML);this.oProductDiscountContainer=document.getElementById('product_discount_container');this.oProductDiscount=document.getElementById('product_discount');this.oContractName=document.getElementById('contract_name');this.oContractPrice=document.getElementById('contract_price');this.oContractDiscountContainer=document.getElementById('contract_discount_container');this.oContractDiscount=document.getElementById('contract_discount');this.oGrandTotal=document.getElementById('grand_total');this.oContractForm=document.getElementById('contract_add_to_cart');this.aOperators=[];this.oActiveOperator=null;var e=this;if(c&&d){var f=Common.Dom.getElementsByClassName(c,'logo','div');if(f.length>0){for(var i=0,iLength=f.length;i<iLength;i++){var g=f[i];var h=g.className.match(new RegExp('for_(\\w+)'))[1];var j=Common.Dom.getElementsByClassName(d,h,'div')[0];if(j){var k=new Operator(g,j);this.aOperators[this.aOperators.length]=k;k.attachObserver(Operator.EVENT_TYPE_OPERATOR_ACTIVATED,function(a,b){e.activateOperator(b);e.updateContractData()});k.attachObserver(Operator.EVENT_TYPE_CONTRACT_ACTIVATED,function(a,b){e.updateContractData()})}}}}if(this.aOperators.length>0){this.aOperators[0].activate()}},activateOperator:function(a){if(this.oActiveOperator){this.oActiveOperator.deactivate()}this.oActiveOperator=a},updateContractData:function(){if(this.oActiveOperator){var a=this.oActiveOperator.getActiveContract();if(this.oActiveOperator&&a){var b=a.getDiscountProduct();var c=this.iProductPrice-b;this.oProductPrice.innerHTML=c.nice()+'&nbsp;'+CURRENCY_SIGN;this.oProductDiscount.innerHTML=b.nice()+'&nbsp;'+CURRENCY_SIGN;if(b>0){Common.Class.remove(this.oProductDiscountContainer,'hidden')}else{Common.Class.add(this.oProductDiscountContainer,'hidden')}this.oContractName.innerHTML=this.oActiveOperator.getName()+'&nbsp;&mdash; '+a.getName();var d=a.getDiscountItself();var e=a.getPrice()-d;this.oContractPrice.innerHTML=e.nice()+'&nbsp;'+CURRENCY_SIGN;this.oContractDiscount.innerHTML=d.nice()+'&nbsp;'+CURRENCY_SIGN;if(d>0){Common.Class.remove(this.oContractDiscountContainer,'hidden')}else{Common.Class.add(this.oContractDiscountContainer,'hidden')}var f=c+e;this.oGrandTotal.innerHTML=f.nice()+'&nbsp;'+CURRENCY_SIGN;this.oContractForm.aid.value=a.getId();this.enableContractData()}else{this.disableContractData()}}},enableContractData:function(){Common.Class.add(this.oContractData,'enabled')},disableContractData:function(){Common.Class.remove(this.oContractData,'enabled')}});function Operator(c,d){Operator.baseConstructor.call(this);this.bActive=false;this.oLogo=c;this.oContractsContainer=d;this.sName=Common.Dom.getElementsByClassName(this.oContractsContainer,'operator_name','h3')[0].innerHTML;this.oContractDescription=Common.Dom.getElementsByClassName(this.oContractsContainer,'contract_desc_inner','div')[0];this.aContracts=[];this.oActiveContract=null;var e=this;Common.Event.add(this.oLogo,'click',function(){e.activate()});var f=Common.Dom.getElementsByClassName(this.oContractsContainer,'data','table')[0];if(f){var g=f.getElementsByTagName('tr');if(g.length>0){for(var i=0,iLength=g.length;i<iLength;i++){var h=new Contract(g[i]);this.aContracts[this.aContracts.length]=h;h.attachObserver(Contract.EVENT_TYPE_CONTRACT_ACTIVATED,function(a,b){e.activateContract(b)})}}}if(this.aContracts.length>0){this.aContracts[0].activate()}}Operator.EVENT_TYPE_OPERATOR_ACTIVATED='OPERATOR_ACTIVATED';Operator.EVENT_TYPE_CONTRACT_ACTIVATED='CONTRACT_ACTIVATED';Operator.inheritFrom(Observable,{activate:function(){if(!this.bActive){Common.Class.add(this.oLogo,'selected');Common.Class.add(this.oContractsContainer,'selected');this.bActive=true;this.notify(Operator.EVENT_TYPE_OPERATOR_ACTIVATED)}},deactivate:function(){Common.Class.remove(this.oLogo,'selected');Common.Class.remove(this.oContractsContainer,'selected');this.bActive=false},activateContract:function(a){if(this.oActiveContract){this.oActiveContract.deactivate()}this.oActiveContract=a;this.oContractDescription.innerHTML=a.getDescription();this.notify(Operator.EVENT_TYPE_CONTRACT_ACTIVATED)},getName:function(){return this.sName},getActiveContract:function(){return this.oActiveContract}});function Contract(a){Contract.baseConstructor.call(this);this.bActive=false;this.oPtr=a;this.sName=Common.Dom.getElementsByClassName(this.oPtr,'name','td')[0].innerHTML;var b=Common.Dom.getElementsByClassName(this.oPtr,'price','td')[0];this.iPrice=parseFloat(b.innerHTML);if(isNaN(this.iPrice)){this.iPrice=0}b.innerHTML='<div class="cell_content">'+this.iPrice.nice()+'&nbsp;'+CURRENCY_SIGN+'</div>';var c=Common.Dom.getElementsByClassName(this.oPtr,'price_total','td')[0];var d=parseFloat(c.innerHTML);if(isNaN(d)){d=0}c.innerHTML='<div class="cell_content">'+d.nice()+'&nbsp;'+CURRENCY_SIGN+'</div>';this.sDescription=Common.Dom.getElementsByClassName(this.oPtr,'desc','td')[0].innerHTML;this.sId=Common.Dom.getElementsByClassName(this.oPtr,'id','td')[0].innerHTML;var e=Common.Dom.getElementsByClassName(this.oPtr,'discount_itself','td')[0];if(e){this.iDiscountItself=parseFloat(e.innerHTML)}if(isNaN(this.iDiscountItself)){this.iDiscountItself=0}var f=Common.Dom.getElementsByClassName(this.oPtr,'discount_product','td')[0];if(f){this.iDiscountProduct=parseFloat(f.innerHTML)}if(isNaN(this.iDiscountProduct)){this.iDiscountProduct=0}var g=this;Common.Event.add(this.oPtr,'mouseover',function(){Common.Class.add(g.oPtr,'hover')});Common.Event.add(this.oPtr,'mouseout',function(){Common.Class.remove(g.oPtr,'hover')});Common.Event.add(this.oPtr,'click',function(){g.activate()})}Contract.EVENT_TYPE_CONTRACT_ACTIVATED='CONTRACT_ACTIVATED';Contract.inheritFrom(Observable,{activate:function(){if(!this.bActive){Common.Class.add(this.oPtr,'selected');this.bActive=true;this.notify(Contract.EVENT_TYPE_CONTRACT_ACTIVATED)}},deactivate:function(){Common.Class.remove(this.oPtr,'selected');this.bActive=false},getName:function(){return this.sName},getPrice:function(){return this.iPrice},getDescription:function(){return this.sDescription},getId:function(){return this.sId},getDiscountItself:function(){return this.iDiscountItself},getDiscountProduct:function(){return this.iDiscountProduct}});var Modifications={init:function(a){if(!this.isInit){$('#modifications').load('/product_modifications/?productId='+a);this.isInit=true}}};