var PriceCalendarProduct=function(A){this.init(A)};PriceCalendarProduct.prototype={_name:"",_months:null,init:function(A){this._name=A;this._months=[]},getName:function(){return this._name},addMonth:function(A){if(!this.hasMonth(A)){this._months[this._months.length]=A}},hasMonth:function(B){for(var A=0;A<this._months.length;A++){if(this._months[A]==B){return true}}return false},getMonths:function(){return this._months}};var PriceCalendarProductList=function(){this.init()};PriceCalendarProductList.prototype={_products:null,init:function(){this._products=[]},add:function(C){var D=this.indexOf(C.getName());if(D!=-1){var A=C.getMonths();for(var B=0;B<A;B++){this._products[D].addMonth(A[B])}}else{this._products[this._products.length]=C}},addMonth:function(A,C){var D=this.indexOf(A);if(D!=-1){this._products[D].addMonth(C)}else{var B=new PriceCalendarProduct(A);B.addMonth(C);this.add(B)}},indexOf:function(A){for(var B=0;B<this._products.length;B++){if(this._products[B].getName().toLowerCase()==A.toLowerCase()){return B}}return -1},getProducts:function(){return this._products},getProduct:function(A){var B=this.indexOf(A);if(B==-1){return null}return this._products[B]},getMonths:function(A){var B=this.indexOf(A);if(B==-1){return[]}return this._products[B].getMonths()},search:function(C){var D=[];if(typeof (C)=="object"&&C.constructor.toString().indexOf("Array")!=-1){for(var B=0;B<this._products.length;B++){for(var A=0;A<C.length;A++){if(this._products[B].getName().toLowerCase().indexOf(C[A].toLowerCase())!=-1){D[D.length]=this._products[B]}}}}else{if(typeof (C)=="string"){for(var B=0;B<this._products.length;B++){if(this._products[B].getName().indexOf(C)!=-1){D[D.length]=this._products[B]}}}}return D}};var PriceCalendar=function(B,A){this.init(B)};PriceCalendar.prototype={_animations:null,_productList:null,init:function(E){var E=YAHOO.util.Dom.get(E);YAHOO.util.Dom.setStyle(E,"display","none");this._animations=[];this._productList=new PriceCalendarProductList();var B=document.createElement("p");YAHOO.util.Dom.insertBefore(B,E);YAHOO.util.Dom.setStyle(B,"display","none");var D=[],K=0,N;var O,M;for(var H=0;H<E.rows.length;H+=2){for(var G=0;G<E.rows[H].cells.length;G++){O=YAHOO.lang.trim(E.rows[H].cells[G].innerHTML);D[K]=O;N=E.rows[H+1].cells[G].getElementsByTagName("li");for(var F=0;F<N.length;F++){M=this.cleanProductString(N[F].innerHTML);this._productList.addMonth(M,O)}K++}}this.getMonths=function(){return D};var J=document.createElement("div");YAHOO.util.Dom.addClass(J,"price_calendar_js");YAHOO.util.Dom.insertAfter(J,E);this.getEl=function(){return E};this.getJsEl=function(){return J};this.initSearch();var C=document.createElement("p");YAHOO.util.Dom.addClass(C,"or");C.innerHTML=lang.priceCalendar.orTxt;J.appendChild(C);var A=document.createElement("div");YAHOO.util.Dom.addClass(A,"products_text");J.appendChild(A);var C=document.createElement("p");YAHOO.util.Dom.setStyle(C,"float","right");A.appendChild(C);var I=document.createElement("a");I.href="javascript:void(0);";YAHOO.util.Event.on(I,"click",function(P){YAHOO.util.Dom.setStyle(E,"display","block");YAHOO.util.Dom.setStyle(B,"display","block");YAHOO.util.Dom.setStyle(J,"display","none")});I.innerHTML=lang.priceCalendar.listTxt;C.appendChild(I);var C=document.createElement("p");C.innerHTML=lang.priceCalendar.selectTxt;A.appendChild(C);var L=document.createElement("a");L.href="javascript:void(0);";YAHOO.util.Event.on(L,"click",function(P){YAHOO.util.Dom.setStyle(E,"display","none");YAHOO.util.Dom.setStyle(B,"display","none");YAHOO.util.Dom.setStyle(J,"display","block")});L.innerHTML=lang.priceCalendar.searchTxt;B.appendChild(L);this.initProductsList();this.initCalendar()},cleanProductString:function(A){A=A.replace("<br>","");A=A.replace("<BR>","");A=A.replace("&nbsp;","");A=YAHOO.lang.trim(A);return A},initSearch:function(){var E=document.createElement("table");YAHOO.util.Dom.addClass(E,"search");this.getJsEl().appendChild(E);var C=document.createElement("tbody");E.appendChild(C);var F=document.createElement("tr");C.appendChild(F);var G=document.createElement("td");YAHOO.util.Dom.addClass(G,"input");F.appendChild(G);var B=document.createElement("input");B.id="price_calendar_query";B.name="price_calendar_query";B.type="text";YAHOO.util.Dom.addClass(B,"text");G.appendChild(B);var G=document.createElement("td");YAHOO.util.Dom.addClass(G,"button");F.appendChild(G);var A=document.createElement("img");A.src=lang.searchButtonImg;A.alt=lang.searchButtonAlt;G.appendChild(A);this.getQueryEl=function(){return B};var D=this;YAHOO.util.Event.on(this.getQueryEl(),"keyup",function(H){D.search()});YAHOO.util.Event.on(A,"click",function(H){D.search()})},initProductsList:function(){var E=document.createElement("select");E.id="price_calendar_products";E.name="price_calendar_products";E.size=21;YAHOO.util.Dom.addClass(E,"products");this.getJsEl().appendChild(E);var B=new Option("","");E.options[E.options.length]=B;E.remove(0);this.getProductsEl=function(){return E};var D=this._productList.getProducts();for(var A=0;A<D.length;A++){this.addToProductsEl(D[A].getName())}E.selectedIndex=-1;var C=this;YAHOO.util.Event.on(this.getProductsEl(),"change",function(F){C.updateCalendar()})},initCalendar:function(){var E,B,F,G,A,D;E=document.createElement("table");YAHOO.util.Dom.addClass(E,"calendar");this.getJsEl().appendChild(E);B=document.createElement("tbody");E.appendChild(B);for(var C=0;C<this.getMonths().length;C++){F=document.createElement("tr");if(C%2==0){YAHOO.util.Dom.addClass(F,"alternate");D="/images/project/check-greybg.gif"}else{D="/images/project/check-whitebg.gif"}B.appendChild(F);G=document.createElement("td");YAHOO.util.Dom.addClass(G,"month");G.innerHTML=this.getMonths()[C];F.appendChild(G);G=document.createElement("td");YAHOO.util.Dom.addClass(G,"check");F.appendChild(G);A=document.createElement("img");YAHOO.util.Dom.setStyle(A,"opacity",0);A.src=D;A.width=18;A.height=17;A.alt="Check";G.appendChild(A)}this.getCheckImg=function(){return A};this.getCalendarEl=function(){return E}},search:function(){this.resetProductsEl();this.resetCalendar();var A=this.getQueryEl().value.toLowerCase().split(" ");var C=this._productList.search(A);this.resetProductsEl();for(var B=0;B<C.length;B++){this.addToProductsEl(C[B].getName())}},resetCalendar:function(){var C,A;for(var B=0;B<this._animations.length;B++){C=this._animations[B];if(C.isAnimated()){C.stop()}}for(var B=0;B<this.getCalendarEl().rows.length;B++){A=this.getCalendarEl().rows[B].cells[1].getElementsByTagName("img")[0];if(YAHOO.util.Dom.getStyle(A,"opacity")>0){YAHOO.util.Dom.setStyle(A,"opacity",0)}}},updateCalendar:function(){var D=this.getProductsEl().options[this.getProductsEl().selectedIndex];var H=D.innerHTML;var G=this._productList.getMonths(H);var A=this.getMonths();var I=[];for(var E=0;E<G.length;E++){for(var C=0;C<A.length;C++){if(G[E]==A[C]){I[I.length]=C}}}this.resetCalendar();for(var E=0;E<I.length;E++){var F=this.getCalendarEl().rows[I[E]].cells[1].getElementsByTagName("img")[0];var B=new YAHOO.util.Anim(F,{opacity:{to:1}});this._animations[this._animations.length]=B;B.animate()}},resetProductsEl:function(){this.getProductsEl().innerHTML=""},addToProductsEl:function(A){var D=document.createElement("option");D.value=A;D.innerHTML=A;var C=false;for(var B=0;B<this.getProductsEl().options.length&&!C;B++){if(A<this.getProductsEl().options[B].innerHTML){YAHOO.util.Dom.insertBefore(D,this.getProductsEl().options[B]);C=true}}if(!C){this.getProductsEl().appendChild(D)}}};var calendars=YAHOO.util.Dom.getElementsByClassName("price_calendar");if(calendars.length>0){Loader.insertYUIScript("animation/animation-min.js");for(var i=0;i<calendars.length;i++){new PriceCalendar(calendars[i])}};
