function info(a){}Function.prototype.createDelegate=function(c,b,a){var d=this;return function(){var f=b||arguments;if(a===true){f=Array.prototype.slice.call(arguments,0);f=f.concat(b)}else{if(typeof a=="number"){f=Array.prototype.slice.call(arguments,0);var e=[a,0].concat(b);Array.prototype.splice.apply(f,e)}}return d.apply(c||window,f)}};var C={};C.apply=function(d,e,b){if(b){C.apply(d,b)}if(d&&e&&typeof e=="object"){for(var a in e){d[a]=e[a]}}return d};C.extend=function(){var b=function(d){for(var c in d){this[c]=d[c]}};var a=Object.prototype.constructor;return function(h,e,g){if(typeof e=="object"){g=e;e=h;h=g.constructor!=a?g.constructor:function(){e.apply(this,arguments)}}var d=function(){},f,c=e.prototype;d.prototype=c;f=h.prototype=new d();f.constructor=h;h.superclass=c;if(c.constructor==a){c.constructor=e}h.override=function(i){C.override(h,i)};f.override=b;C.override(h,g);h.extend=function(i){C.extend(h,i)};return h}}();C.override=function(a,c){if(c){var b=a.prototype;for(var d in c){b[d]=c[d]}}};C.UA=new function(){var a=navigator.userAgent.toLowerCase();this.isOpera=a.indexOf("opera")>-1,this.isSafari=(/webkit|khtml/).test(a);this.isSafari3=this.isSafari&&a.indexOf("webkit/5")!=-1;this.isIE=!this.isOpera&&a.indexOf("msie")>-1;this.isIE7=!this.isOpera&&a.indexOf("msie 7")>-1;this.isGecko=!this.isSafari&&a.indexOf("gecko")>-1}();C.dom={round:function(a){if(a!=0){return Math.round(a*100)/100}return 0},roundAsString:function(a,b){a=(Math.round((a-0)*100))/100;a=(a==Math.floor(a))?a+".00":((a*10==Math.floor(a*10))?a+"0":a);a=String(a);var f=a.split(".");var e=f[0];var c=f[1]?"."+f[1]:".00";var d=/(\d+)(\d{3})/;while(d.test(e)){e=e.replace(d,"$1,$2")}a=e+(!b?c:"");return a},formatUsMoney:function(a){a=C.dom.roundAsString(a);if(a.charAt(0)=="-"){return"-$ "+a.substr(1)}return"$ "+a},createDom:function(g,b){var f;if(g instanceof Array){f=document.createDocumentFragment();for(var e=0,c=g.length;e<c;e++){this.createDom(g[e],f)}}else{if(typeof g=="string"){f=document.createTextNode(g)}else{f=document.createElement(g&&g.tag?g.tag:"div");var d=!!f.setAttribute;for(var a in g){if(a=="tag"||a=="children"||a=="cn"||a=="html"||a=="style"||typeof g[a]=="function"){continue}if(a=="cls"){f.className=g.cls}else{if(d){f.setAttribute(a,g[a])}else{f[a]=g[a]}}}var h=g?(g.children?g.children:g.cn?g.cn:null):null;if(h){this.createDom(h,f)}else{if(g&&g.html){f.innerHTML=g.html}}}}if(b){b.appendChild(f)}return f},selectGenerateOptions:function(a,d,c){var e="";if(!a){return e}if(a instanceof Array){if(!d||!c||a.length<1){return e}if(d&&c){for(var b=0;b<a.length;b++){var f=a[b];e+='<option value="'+a[b][d]+'" '+(a[b][d]=="0"?'class="title"':"")+">"+a[b][c]+"</option>"}}}else{for(var b in a){e+='<option value="'+b+'">'+a[b]+"</option>"}}return e},selectReloadOptions:function(g,j,a,f){if(!g){return false}var b;while(g.childNodes.length){if(g.firstChild.tagName=="OPTGROUP"){while(g.firstChild.childNodes.length){g.firstChild.removeChild(g.firstChild.firstChild)}}g.removeChild(g.firstChild)}if(!a||!f||!j){return false}var d,c,h;for(b=0;b<j.length;b++){if(j[b]["is_group"]){c=document.createElement("optgroup");c.label=j[b][f];g.appendChild(c)}else{d=document.createElement("option");h=j[b][f];d.text=h;d.value=j[b][a];if(c){c.appendChild(d);d.innerHTML=h}else{try{g.add(d,null)}catch(e){g.add(d)}}}}return true},readFieldValue:function(c,d){if(!c){return null}var b=c.tagName=="SELECT"?c.options[c.selectedIndex].value:c.value;switch(d){case"number":var a=parseInt(b,10);return !a?0:a;break;case"float":var a=parseFloat(b,10);return !a?0:a;break;default:return b;break}},removeAllChilds:function(a){while(a.firstChild){a.removeChild(a.firstChild)}},setFieldValue:function(c,d,e){if(!c){return false}if(c.tagName=="SELECT"){var a=c.selectedIndex;for(var b=0;b<c.options.length;b++){if(c.options[b].value==d){a=b;break}}if(a==c.selectedIndex){return true}c.selectedIndex=a}else{if(c.value==d){return true}c.value=d}if(!e){c.onchange()}return true},processTemplate:function(b,c){if(!b||typeof b!="string"||!c||typeof c!="object"){return b}for(var a in c){if(typeof a!="string"){info("not string "+a);continue}b=b.replace("{$"+a+"}",c[a])}return b}};C.Store=function(a,b){if(a){for(var c in a){this[c]=a[c]}}this.loadData(b)};C.Store.prototype={fields:null,key_field:"id",records:[],maps:{},readRecord:function(d){if(!d){return null}var c={};if(d instanceof Array){var b=0;for(var a in this.fields){c[a]=d[b]?d[b]:null;b++}}else{for(var a in this.fields){c[a]=d[a]?d[a]:null}}return c},getMap:function(b,a){if(!b||!this.fields[b]){return{}}if(this.maps[b]&&!a){return this.maps[b]}this.maps[b]=this._buildMap(b);return this.maps[b]},_buildMap:function(a){var e={};for(var b=0;b<this.records.length;b++){var d=this.records[b][a];if(!e[d]){e[d]=[b]}else{e[d].push(b)}}return e},loadData:function(c){this.records=[];this.maps={};if(!c||!this.fields){return false}if(c instanceof Array){var a=null;for(var b=0;b<c.length;b++){a=this.readRecord(c[b]);if(a){this.records.push(a)}}}},getById:function(a){return this.getWhere(this.key_field,a).pop()},getWhere:function(d,e){var b=[];if(!d||!this.fields[d]){return b}var a=this.getMap(d);if(e=="*"){for(var c in a){b.concat(a[c])}}else{if(e){if(typeof e=="string"||typeof e=="number"){if(a[e]){b=a[e]}}else{if(e instanceof Array){for(var c=0;c<e.length;c++){if(a[e[c]]){b=b.concat(a[e[c]])}}}}}}return this.getIndexes(b)},getIndexes:function(a){var c=[];for(var b=0;b<a.length;b++){if(this.records[a[b]]){c.push(this.records[a[b]])}}return c},getAll:function(){return this.records},select:function(e){if(!e){return this.records}for(var c in e){if(!this.fields[c]){delete (e[c])}}var a=[];for(var b=0;b<this.records.length;b++){var d=true;for(var c in e){if(this.records[b][c]!=e[c]){d=false;continue}}if(d){a.push(this.records[b])}}return a}};C.EventObject=function(a){if(a){this.setEvent(a)}};C.EventObject.prototype={safariKeys:{63234:37,63235:39,63232:38,63233:40,63276:33,63277:34,63272:46,63273:36,63275:35},getBtnMap:function(){return C.UA.isIE?{1:0,4:1,2:2}:(C.UAisSafari?{1:0,2:1,3:2}:{0:0,1:1,2:2})},browserEvent:null,button:-1,shiftKey:false,ctrlKey:false,altKey:false,BACKSPACE:8,TAB:9,RETURN:13,ENTER:13,SHIFT:16,CONTROL:17,ESC:27,SPACE:32,PAGEUP:33,PAGEDOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46,F5:116,setEvent:function(a){if(a==this||(a&&a.browserEvent)){return a}this.browserEvent=a;if(a){this.button=a.button?this.getBtnMap[a.button]:(a.which?a.which-1:-1);if(a.type=="click"&&this.button==-1){this.button=0}this.type=a.type;this.shiftKey=a.shiftKey;this.ctrlKey=a.ctrlKey||a.metaKey;this.altKey=a.altKey;this.keyCode=a.keyCode;this.charCode=a.charCode;this.target=a.target?a.target:a.srcElement}else{this.button=-1;this.shiftKey=false;this.ctrlKey=false;this.altKey=false;this.keyCode=0;this.charCode=0;this.target=null}return this},stopEvent:function(){if(this.browserEvent){if(this.browserEvent.stopPropagation){this.browserEvent.stopPropagation()}else{this.browserEvent.cancelBubble=true}}},isNavKeyPress:function(){var a=this.keyCode;a=C.UA.isSafari?(this.safariKeys[a]||a):a;return(a>=33&&a<=40)||a==this.RETURN||a==this.TAB||a==this.ESC},isSpecialKey:function(){var a=this.keyCode;return(this.type=="keypress"&&this.ctrlKey)||a==9||a==13||a==40||a==27||(a==16)||(a==17)||(a>=18&&a<=20)||(a>=33&&a<=35)||(a>=36&&a<=39)||(a>=44&&a<=45)},getCharCode:function(){return this.charCode||this.keyCode},getKey:function(){var a=this.keyCode||this.charCode;return C.UA.isSafari?(this.safariKeys[a]||a):a},hasModifier:function(){return((this.ctrlKey||this.altKey)||this.shiftKey)?true:false}};C.Dialog=function(a){C.apply(this,a);this.id=this.generateId()};C.Dialog.prototype={id:0,currentIdIndex:0,el_ids:{main_container:"cdialog_main_container",dccontainer:"cdialog_ccontainer",body_container:"body_container",close_button:"close_btn"},dialogTemplate:'<div class="hd" style="display: none;"></div><div class="dheader-left"><div class="dheader-right"><div class="dheader-center"></div></div></div><div class="dcontent-left"><div class="dcontent-right"><div class="dcontent-center"><div class="dccontainer" id="{$dccontainer}"><a id="{$close_button}" class="close_button">Close Window</a><form method="POST"><div id="{$body_container}"></div></form></div></div></div></div><div class="dfooter-left"><div class="dfooter-right"><div class="dfooter-center"></div></div></div>',dialog:null,dialog_config:{width:600,close:false,modal:true,fixedcenter:true,underlay:"none"},buttons:{},show:function(){if(!this.check()){return false}this.dialog.show();return true},hide:function(){if(!this.check()){return false}this.dialog.cancel();return true},onClose:function(){return this.hide()},setBody:function(a){if(!this.check()){return false}var b=this.getControl("body_container");if(!b){return false}b.innerHTML=a?a:"";return true},check:function(){if(this.dialog){return true}if(this.createDialogTemplate()){var a={};this.dialog=new YAHOO.widget.Dialog(this.getControlId("main_container"),C.apply({},a,this.dialog_config));this.dialog.render();this.dialog.hide();this.getControl("main_container").style.display="";var b=this.getControl("close_button");if(b){b.onclick=this.onClose.createDelegate(this)}return true}else{return false}},createDialogTemplate:function(){if(this.dialog){return true}var a=this.getControl("main_container");if(!a){a=document.createElement("div");a.id=this.getControlId("main_container");a.style.display="none";document.body.appendChild(a)}var b=this.prepeareParamsForTemplate();a.innerHTML=C.dom.processTemplate(this.dialogTemplate,b);return true},prepeareParamsForTemplate:function(){var b,a={};for(b in this.el_ids){a[b]=this.getControlId(b)}return a},getControlId:function(a){if(!this.el_ids[a]){info('getControl: unknown control name "'+a+'"');return null}return this.el_ids[a]+this.id},getControl:function(b){var a=this.getControlId(b);if(a){return document.getElementById(a)}return null},generateId:function(){C.Dialog.prototype.currentIdIndex++;return C.Dialog.prototype.currentIdIndex},setButtonState:function(c,f,e){if(!this.buttons[c]){return false}var a=this.buttons[c];a.style.display=f?"":"none";if(f){var d=e?true:false;if(d!=a.disabled){a.disabled=d;if(a.className!=""){if(d){a.className+=" disabled"}else{a.className=a.className.replace(" disabled","")}}}}}};C.HelpWindow=function(a,b){C.HelpWindow.superclass.constructor.call(this,a);this.initSores(b)};C.extend(C.HelpWindow,C.Dialog,{el_ids:{main_container:"cdialog_main_container",dccontainer:"cdialog_ccontainer",body_container:"body_container",close_button:"close_btn",questions_container:"questions_container",button_select:"hw_button_select"},buttons:{select:null},dialog_config:{width:640,close:false,modal:true,fixedcenter:true,underlay:"none"},bodyTemplate:'<div class="info"><b>Fixture Identification:</b><br/>The following questions have been developed to help you identify your current fixture type.<br/>To begin - simply select the type of lamp currently in the fixture you wish to replace.<br/>Follow up questions (1 or 2) will appear as you answer.</div><div id="{$questions_container}"></div><div style="text-align: right;"><button id="{$button_select}"  name="b3" class="button select_fixture_button"></button></div>',QStore:null,AStore:null,ResultsStore:null,result_data:null,onSelectCallback:null,currentRowIndex:null,startSelectFixture:function(a){if(!this.check()){return false}if(a<1){info("startSelectFixture: rowIndex < 1");return false}this.currentRowIndex=a;this.current_step_index=0;this.prev_step_data=[];if(this.addNextQuestion(1)&&this.refresh()){C.HelpWindow.superclass.show.call(this);return true}return false},current_step_index:0,prev_step_data:[],generateQuestionNode:function(n,j){if(!j){info("generateQuestionNode: params error");return null}var p=C.dom.createDom({tag:"div",cn:[{tag:"div",cls:"question"},{tag:"div",cls:"answers"}]});var l=j.question_info;var b=j.answers_list;var m=j.value;p.firstChild.innerHTML="Question "+(n+1)+":&nbsp;&nbsp;&nbsp;"+l.text;var e='<div class="question_row">';var g,d,a=b.length;var o=Math.round(a/2-0.4)+a%2;for(var h=0;h<a;h++){if(h==o){e+='</div><div class="question_row">'}if(m&&b[h]["id"]==m){g=true;d=true}else{d=false}e+='<div style="float: left; padding-right: 10px;"><input style="height: 21px;" type="radio" name="answer_'+n+'" value="'+b[h]["id"]+'"'+(d?" checked":"")+'/></div><div style="float: left; line-height: 21px; width: 190px;">'+b[h]["text"]+'</div><div class="clear"></div>'}p.lastChild.innerHTML=e+'</div><div class="clear"></div>';var f=p.lastChild.getElementsByTagName("input");if(f&&f.length>0){var c=this.onChangeValue.createDelegate(this,[n]);var k;for(var h=0;h<f.length;h++){k=f[h];if(k.type&&k.type=="radio"){k.onclick=c}}}return p},onChangeValue:function(c){if(c-1>this.current_step_index){info("onChangeValue: question_num more");return false}while(c+1<this.prev_step_data.length){this.prev_step_data.pop()}this.current_step_index=this.prev_step_data.length;var e=this.dialog.getData();var b=e["answer_"+c]>0?e["answer_"+c]:0;if(b>0){var d=this.AStore.getById(b);if(!d){info("onChangeValue: wrong answer_id");return false}var a=d.action;if(this.prev_step_data[this.current_step_index-1]){this.prev_step_data[this.current_step_index-1]["value"]=b}else{info("onChangeValue: data not set "+(this.current_step_index-1));return false}if(a.action=="next_question"){if(this.addNextQuestion(a.id)){return this.refresh()}}else{return this.showSuggestedFixture(this.ResultsStore.getById(a.id))}}else{info("onChangeValue: bad value");return false}},addNextQuestion:function(a){if(a<1){info("addNextQuestion: bad question_id");return false}var b=this.QStore.getById(a);if(!b){info("display: question not founded - "+a);return false}var c=this.AStore.getWhere("id",b.variants);if(!c||c.length<2){info("display: number of answers is less than 2");return false}this.prev_step_data.push({question_info:b,answers_list:c,value:0});this.current_step_index=this.prev_step_data.length;return true},showSuggestedFixture:function(b){if(!b){info("showSuggestedFixture: data is empty");return false}var a=this.getControl("questions_container");if(!a){info("showSuggestedFixture: questions_container not found");return false}if(!this.refresh()){return false}this.result_data=b;var d=C.dom.createDom({tag:"div",cls:"title",html:"Suggested Fixture Type: "+b.name},a);this.setButtonState("select",true);return true},refresh:function(){var b=this.getControl("questions_container");if(!b){info("refresh: questions_container not found");return false}if(this.prev_step_data.length>0){while(b.firstChild){b.removeChild(b.firstChild)}var a;for(var c=0;c<this.prev_step_data.length;c++){a=this.generateQuestionNode(c,this.prev_step_data[c]);if(a){b.appendChild(a)}else{info("refresh: new_row is empty");return false}}this.setButtonState("select",false);return true}else{info("refresh: list of questions is empty");return false}},onSelectFixture:function(){if(!this.result_data){return false}if(this.onSelectCallback){if(this.onSelectCallback.scope&&typeof this.onSelectCallback.fn=="function"){this.onSelectCallback.fn.apply(this.onSelectCallback.scope,[this.result_data.id,this.currentRowIndex]);this.hide();return true}}info("onSelectFixture: callback error");return false},onClose:function(){if(!this.onSelectFixture()){return this.hide()}return true},initSores:function(a){if(!a){info("initSores: list is empty");return false}var b=false;if(a.questions){this.QStore=new C.Store({fields:{id:true,text:true,variants:true}},a.questions)}else{info("initSores: QUESTIONS list is unassigned");b=true}if(a.answers){this.AStore=new C.Store({fields:{id:true,text:true,action:true}},a.answers)}else{info("initSores: ANSWERS list is unassigned");b=true}if(a.res_list){this.ResultsStore=new C.Store({fields:{id:true,name:true}},a.res_list)}else{info("initSores: RES_LIST list is unassigned");b=true}return !b},createDialogTemplate:function(){if(C.HelpWindow.superclass.createDialogTemplate.call(this)){var c=this.getControl("main_container");if(!c){return false}c.style.width=this.dialog_config.width+"px";var b=this.getControl("body_container");if(!b){return false}b.style.height="355px";var d=this.prepeareParamsForTemplate();b.innerHTML=C.dom.processTemplate(this.bodyTemplate,d);var a=this.getControl("button_select");if(!a){info("createDialogTemplate: button_select not found");return false}this.buttons.select=a;a.onclick=this.onSelectFixture.createDelegate(this);return true}return false}});C.RateWindow=function(a){this.dialog_config.width=450;C.RateWindow.superclass.constructor.call(this,a)};C.extend(C.RateWindow,C.Dialog,{el_ids:{main_container:"cdialog_main_container",dccontainer:"cdialog_ccontainer",body_container:"body_container",close_button:"close_btn",button_ok:"rw_button_ok",input_watts:"rw_input_watts",input_cost:"rw_input_cost",rate_result_box:"rw_result_box"},buttons:{ok:null},inputs:{watts:null,cost:null},last_result:0,bodyTemplate:'<div class="rate_window_container"><span class="title">Estimate Your Cost Per Kilowatt Hour</span><br />Please enter the following information from your monthly bill:<table><tr><td><b>Total number of kilowatt hours: </b></td><td>&nbsp;</td><td><input type="text" class="dialog_number" id="{$input_watts}" value="" name="watts" maxLength="10" /></td></tr><tr><td><b>Total amount of bill:</b></td><td>&nbsp;$&nbsp;</td><td><input type="text" class="dialog_number" id="{$input_cost}" value="" name="cost" maxLength="9" /></td></tr></table><br /><b>Estimated cost per kilowatt hour:&nbsp;&nbsp;<span id="{$rate_result_box}">0.0</span>&nbsp;&cent;/kWh</b></div><div style="text-align: center;"><button id="{$button_ok}" class="button apply_button"></button></div>',onSelectCallback:null,recalculate:function(){var c,d,a=0;if(this.inputs.watts){c=parseInt(this.inputs.watts.value.replace(",",""))}else{info("recalculate: input watts not set");return false}if(this.inputs.cost){d=parseFloat(this.inputs.cost.value.replace(",",""))}else{info("recalculate: input cost not set");return false}if(c>0&&d>0){a=Math.round(d*1000/c)/10}if(this.last_result!=a){this.last_result=a;if(a>0&&a<100){this.setButtonState("ok",true,false)}else{this.setButtonState("ok",true,true)}var b=this.getControl("rate_result_box");if(!b){info("recalculate: rate_result_box not found");return false}b.innerHTML=a}return true},onApply:function(){if(this.onSelectCallback){if(this.onSelectCallback.scope&&typeof this.onSelectCallback.fn=="function"){this.onSelectCallback.fn.apply(this.onSelectCallback.scope,[this.last_result]);this.onClose();return true}}info("onApply: callback error");return false},maskFilter:function(c,a){if(!a){return true}var d=new C.EventObject(c);if(d.target.tagName!="INPUT"||d.target.type!="text"){return true}var b=d.getKey();if(!C.UA.isIE&&(d.isNavKeyPress()||b==d.BACKSPACE||(b==d.DELETE&&d.button==-1))){return true}var g=String.fromCharCode(d.getCharCode());if(C.UA.isIE&&(d.isSpecialKey()||!g)){return true}var f=d.target.value.replace(",","")+g;if(!a.test(f)){return false}return true},createDialogTemplate:function(){if(C.RateWindow.superclass.createDialogTemplate.call(this)){var g=this.getControl("body_container");if(!g){return false}var h=this.prepeareParamsForTemplate();g.innerHTML=C.dom.processTemplate(this.bodyTemplate,h);var f=this.recalculate.createDelegate(this);var c=function(l,k){var j=l.value;var i=v=j.replace(",","").replace(",","");var p=v.split(".");var o=String(p[0]-0);if(o=="0"&&i.charAt(0)!="0"){o=""}var m=p[1]?"."+p[1]:"";var n=/(\d+)(\d{3})/;while(n.test(o)){o=o.replace(n,"$1,$2")}v=o+(!k?(m?m:(i.charAt(i.length-1)=="."?".":"")):"");l.value=v};var b=this;var a=this.getControl("input_watts");if(!a){info("createDialogTemplate: input_watts not found");return false}this.inputs.watts=a;a.onchange=f;a.formatterDelegate=c.createDelegate(window,[a,true]);a.onkeypress=function(j){if(!j){j=event}if(b.maskFilter(j,/^\d*$/)){var i=j.target?j.target:j.srcElement;clearTimeout(i.tOut);i.tOut=setTimeout(i.onchange,300);clearTimeout(i.ffTout);setTimeout(i.formatterDelegate,100);return true}else{return false}};var e=this.getControl("input_cost");if(!e){info("createDialogTemplate: input_cost not found");return false}this.inputs.cost=e;e.onchange=f;e.formatterDelegate=c.createDelegate(window,[e,false]);e.onkeypress=function(j){if(!j){j=event}if(b.maskFilter(j,/^\d{0,5}(\.\d{0,2})?$/)){var i=j.target?j.target:j.srcElement;clearTimeout(i.tOut);i.tOut=setTimeout(i.onchange,300);clearTimeout(i.ffTout);setTimeout(i.formatterDelegate,100);return true}else{return false}};var d=this.getControl("button_ok");if(!d){info("createDialogTemplate: btn_ok not found");return false}this.buttons.ok=d;d.onclick=this.onApply.createDelegate(this);this.setButtonState("ok",true,true);return true}return false}});C.Calculator=function(a,b){C.apply(this,a);this.initContolListeners();b=C.apply({},b,{lights:[],alternatives:[],sections:[]});this.initSores(b);if(b.helpWindow){b.helpWindow.res_list=b.lights;this.initHelpWindow(b.helpWindow)}else{this.initHelpWindow({})}};C.Calculator.prototype={autoRecalculate:false,el_ids_prefix:"",el_ids:{results_container:"results_container",results_per_f_container:"results_per_fixture_container",main_table:"table_fixtures",main_table_flag:"table_fixtures_flag_row",t_results_table:"table_total_results",t_results_table_note:"table_total_results_note_box",f_results_table:"table_fixtures_results",cost_input:"input_cost_per_hour",add_row_button:"add_row_button",recalculate_button:"recalculate_button",mode_switcher:"change_calculate_mode_checkbox",print_btn:"print_button",print_container:"print_container",print_source:"print_source",find_my_rate:"find_my_rate_link"},defaultValues:{ct:0,cn:"",oh:"",rt:0,rn:""},data:{},inputs:{},main_table:null,costDefaultValue:0,cIndex:1,LStore:null,AStore:null,SStore:null,controls:{},helpWindow:null,rateWindow:null,messageWindow:null,addRow:function(){if(!this.main_table){this.main_table=document.getElementById(this.el_ids.main_table);if(!this.main_table){return false}}var g;var a={};for(g in this.defaultValues){a[g]=this.defaultValues[g]}delete (g);var t=this.LStore.getAll();var o=this._optionsProcessSections(this.AStore.getWhere("id",t[0]["alternatives"]));var d='<select id="'+this.getInputId("ct",this.cIndex)+'" style="width: 296px;">'+C.dom.selectGenerateOptions(t,"id","name")+"</select>";var k='<input id="'+this.getInputId("cn",this.cIndex)+'" type="text" value="'+a.cn+'" maxLength="5" class="text"/>';var p='<input id="'+this.getInputId("oh",this.cIndex)+'" type="text" value="'+a.oh+'" maxLength="3" class="text"/>';var j='<select id="'+this.getInputId("rt",this.cIndex)+'" style="width: 425px;">'+C.dom.selectGenerateOptions(o,"id","name")+"</select>";var m='<input id="'+this.getInputId("rn",this.cIndex)+'" type="text" value="'+a.rn+'" maxLength="5" class="text"/>';var l=1;for(var s in this.data){l++}var e={tag:"tr",id:"ltable_row_"+this.cIndex,cls:"box-middle "+(l%2==0?"even":"odd"),cn:[{tag:"td",cls:"left"},{tag:"td",cls:"center left-gap",html:'<h5 class="fixture" id="'+this.getInputId("f_label",this.cIndex)+'">Fixture '+l+"</h5>"+d+'<a class="ico-question pointer" id="'+this.getInputId("help_btn",this.cIndex)+'" title="What is my current fixture type?"></a><div class="clear" style="height: 10px;"></div><label style="width: 185px;">Number of Fixtures:</label>'+k+'<div class="clear" style="height: 10px;"></div><label style="width: 185px;">Weekly Hours of Operation:</label>'+p},{tag:"td",cls:"center right-gap",html:'<h5 class="fixture">&nbsp;</h5>'+j+'<div class="clear" style="height: 10px;"></div><label style="width: 255px;">Number of Retrofit/Replacement Fixtures:</label>'+m+'<div class="icons"><a id="'+this.getInputId("ref_btn",this.cIndex)+'" class="ico-refresh pointer" title="Clear Entries"></a>'+(this.cIndex>1?'<a id="'+this.getInputId("del_btn",this.cIndex)+'" class="ico-delete pointer" title="Delete Row"></a>':"")+"</div>"},{tag:"td",cls:"right"},]};this.main_table.insertBefore(C.dom.createDom(e),document.getElementById(this.el_ids.main_table_flag));this.data[this.cIndex]=a;var c=["cn","oh","rn","ct","rt"];var q=this;this.recalculateDelegate=this.recalculate.createDelegate(this);for(var s=0;s<c.length;s++){var n=c[s];var b=this.getInput(n,this.cIndex);if(b){if(b.tagName!="SELECT"&&b.type=="text"){b.onkeypress=function(u){if(!u){u=event}if(q.maskFilter(u,/^\d*$/)){var i=u.target?u.target:u.srcElement;clearTimeout(i.tOut);i.tOut=setTimeout(i.oncange_delegate,300);return true}else{return false}}}b.onchange=this.onChange.createDelegate(this,[c[s],this.cIndex,b]);b.oncange_delegate=b.onchange.createDelegate(b)}}var h=this.getDom(this.getInputId("ref_btn",this.cIndex));if(h){h.onclick=this.resetRow.createDelegate(this,[this.cIndex])}if(this.cIndex>1){var r=this.getDom(this.getInputId("del_btn",this.cIndex));if(r){r.onclick=this.deleteRow.createDelegate(this,[this.cIndex])}}var f=this.getDom(this.getInputId("help_btn",this.cIndex));if(f){f.onclick=this.showHelpWindow.createDelegate(this,[this.cIndex])}this.cIndex++;return this.resetRow(this.cIndex-1)},resetRow:function(a){if(a<1||!this.data[a]){return false}var c,b;for(c in this.defaultValues){b=this.defaultValues[c];if(C.dom.setFieldValue(this.getInput(c,a),b,c!="ct"?true:false)){this.data[a][c]=b}}return this.recalculate()},deleteRow:function(d){if(d<=1){return false}var f=function(g){return document.getElementById("ltable_row_"+g)};var a=f(d);if(!a){return false}a.parentNode.removeChild(a);delete (this.data[d]);delete (this.inputs[d]);var b=1;var c;for(var e in this.data){c=this.getInput("f_label",e);if(c){c.innerHTML="Fixture "+b}b++}var b=0;for(var e in this.data){b++;if(e<d){continue}a=f(e);if(!a){continue}a.className="box-middle "+(b%2==0?"even":"odd")}this.recalculate();return true},showHelpWindow:function(a){if(this.helpWindow){return this.helpWindow.startSelectFixture(a)}else{info("showHelpWindow: window not created");return false}},onChange:function(c,e,a){if(!c||e<1||!a){return}var j=C.dom.readFieldValue(a,"number");var i=this.data[e]&&this.data[e][c]?this.data[e][c]:null;if(i!=j){this.data[e][c]=j;switch(c){case"ct":var h=this.getInput("rt",e);if(h){var b=this.LStore.getById(j);var d;if(b){d=this._optionsProcessSections(this.AStore.getWhere("id",b.alternatives));if(d.length>0){d=[{id:"0",name:"Please select your replacement fixture type"}].concat(d)}}C.dom.selectReloadOptions(h,d,"id","name")}break;case"cn":if(j<1){return C.dom.setFieldValue(a,this.defaultValues.cn)}var g=this.getInput("rn",e);if(g&&g.value!=j){return C.dom.setFieldValue(g,j)}break;case"oh":if(j<1||j>168){this.data[e][c]=0;this.displayMessage("Please enter any number between 1 and 168.")}break;case"rt":if(j=="0"){a.selectedIndex++;j=a[a.selectedIndex].value;this.data[e][c]=j}break;case"rn":if(j<1){return C.dom.setFieldValue(a,this.defaultValues.rn)}break}this.recalculate()}},recalculate:function(x){if(!x&&!this.autoRecalculate){return}if(!this.autoRecalculate){this.autoRecalculate=true}var a=C.dom.readFieldValue(this.getControl("cost_input"),"float");if(a>0){a=a/100}var u=0;var p=0;var h=0;var q=[];var e,c,m,r,k,d;var n=0;for(var t in this.data){n++;e=this.data[t];c=this.LStore.getById(e.ct);m=this.AStore.getById(e.rt);if(!c||!m){info("recalculate: cur_node & rep_node error, row:"+t);continue}r=c.watts*e.cn*e.oh*0.052;k=m.watts*e.rn*e.oh*0.052;d=(r-k)*1.119;q.push({cur_dataIndex:n,cur_name:c.name,cur_number:e.cn,rep_name:m.name,rep_is_not_highest:m.section>1?true:false,rep_number:e.rn,e_save:r-k,co_save:d,money_save:(r-k)*a});u+=r;p+=k;h+=d}var f=this.getControl("results_per_f_container");if(!f){info("recalculate: results per fixture container not found");return}f.style.display="none";var o=this.getControl("results_container");if(!o){info("recalculate: results container not found");return}o.style.display="";var j=this.getControl("t_results_table");var w=this.getControl("f_results_table");if(!j||!w){return}var b={tag:"tr",cn:[{tag:"td",html:C.dom.formatUsMoney(u*a)},{tag:"td",html:C.dom.formatUsMoney(p*a)},{tag:"td",html:C.dom.roundAsString(u-p,true)},{tag:"td",cls:"green_text",html:C.dom.roundAsString(h,true)},{tag:"td",cls:"total",html:C.dom.formatUsMoney((u-p)*a)}]};C.dom.removeAllChilds(j);C.dom.createDom(b,j);var l=this.getControl("t_results_table_note");if(!l){info("recalculate: note box not found");return}l.style.display="none";if(q.length<2){if(q.length>0&&q[0]["rep_is_not_highest"]){l.style.display=""}return}var g=w.childNodes;for(var t=g.length-1;t>=0;t--){if(g[t].className=="box-middle fixture_result"){w.removeChild(g[t])}}var s;for(var t=0;t<q.length;t++){s=q[t];w.appendChild(C.dom.createDom({tag:"tr",cls:"box-middle fixture_result",cn:[{tag:"td",cls:"left"},{tag:"td",cls:"center dash-line",html:'<div style="position: relative;"><h5 class="fixture abs">Fixture '+s.cur_dataIndex+'</h5><div class="clear"></div><table class="content-table"><tr><td class="invisible" width="160" style="text-align: right;">Fixture Type:</td><td width="402" style="text-align: left;">'+s.cur_number+" "+s.cur_name+'</td><td rowspan="2" width="82">'+C.dom.roundAsString(s.e_save,true)+'</td><td rowspan="2" width="82" style="color: #339966;">'+C.dom.roundAsString(s.co_save,true)+'</td><td rowspan="2" width="82">'+C.dom.formatUsMoney(s.money_save)+'</td></tr><tr><td class="invisible" style="text-align: right;">Replacement Fixture Type:</td><td style="text-align: left;">'+s.rep_number+" "+s.rep_name+(s.rep_is_not_highest?' <span style="color: red;">*</span>':"")+"</td></tr></table></div>"},{tag:"td",cls:"right"}]}))}f.style.display=""},_readRowValues:function(b){var a=["ct","cn","oh","rt","rn"];var e,d;for(var c=0;c<a.length;c++){d=this.getInput(a[c],b);if(d){e=this._readFieldValue(d,"number");if(e<1){d.value="1"}}}},_optionsProcessSections:function(e){var a=[];var b,c;for(var d=0;d<e.length;d++){if(b!=e[d]["section"]){b=e[d]["section"];c=this.SStore.getById(b);if(c){a.push({id:0,name:c.name,is_group:true})}}a.push(e[d])}return a},initSores:function(a){if(!a){info("initSores: list is empty");return false}var b=false;if(a.lights){this.LStore=new C.Store({fields:{id:true,name:true,watts:true,alternatives:true}},a.lights)}else{info("initSores: LIGHTS list is unassigned");b=true}if(a.alternatives){this.AStore=new C.Store({fields:{id:true,name:true,watts:true,section:true}},a.alternatives)}else{info("initSores: ALTERNATIVES list is unassigned");b=true}if(a.sections){this.SStore=new C.Store({fields:{id:true,name:true,watts:true,alternatives:true}},a.sections)}else{info("initSores: SECTIONS list is unassigned");b=true}return !b},setAutoCalculateMode:function(a){this.autoRecalculate=a?true:false;if(a){this.recalculate()}},maskFilter:function(c,a){if(!a){return true}var d=new C.EventObject(c);if(d.target.tagName!="INPUT"||d.target.type!="text"){return true}var b=d.getKey();if(!C.UA.isIE&&(d.isNavKeyPress()||b==d.BACKSPACE||(b==d.DELETE&&d.button==-1))){return true}var g=String.fromCharCode(d.getCharCode());if(C.UA.isIE&&(d.isSpecialKey()||!g)){return true}var f=d.target.value+g;if(!a.test(f)){return false}return true},getInputId:function(b,a){return this.el_ids_prefix+b+"_"+a},getDom:function(a){var b=document.getElementById(a);if(!b){info("getDom: ["+a+"] - not found");return null}return b},getInput:function(b,a){if(!a||!b){return null}if(!this.inputs[a]){this.inputs[a]={}}else{if(this.inputs[a][b]){return this.inputs[a][b]}}this.inputs[a][b]=this.getDom(this.getInputId(b,a));return this.inputs[a][b]},initContolListeners:function(){var d=this;var b=this.getControl("add_row_button");if(b){b.onclick=this.addRow.createDelegate(this)}else{info("initContolListeners: add row button not found")}var g=this.getControl("mode_switcher");if(g){g.onclick=function(i,h){if(!h){h=this}d.setAutoCalculateMode(h.checked)}}else{info("initContolListeners: mode switcher not found")}var e=this.getControl("recalculate_button");if(e){e.onclick=this.recalculate.createDelegate(this,[true])}else{info("initContolListeners: recalculate button not found")}var f=this.getControl("cost_input");if(f){f.onkeypress=function(i){if(!i){i=event}if(d.maskFilter(i,/^\d{0,2}(\.\d{0,1})?$/)){var h=i.target?i.target:i.srcElement;clearTimeout(h.tOut);h.tOut=setTimeout(h.oncange_delegate,300);return true}else{return false}};f.onchange=function(j,i){if(!i){i=this}var h=C.dom.readFieldValue(i,"float");if(h<d.costDefaultValue){C.dom.setFieldValue(i,d.costDefaultValue,true)}d.recalculate()};f.oncange_delegate=f.onchange.createDelegate(f)}else{info("initContolListeners: cost field not found")}var a=this.getControl("print_btn");if(a){a.onclick=this.onPrint.createDelegate(this)}else{info("initContolListeners: print button not found")}var c=this.getControl("find_my_rate");if(c){c.onclick=this.onFindMyRate.createDelegate(this)}else{info("initContolListeners: find my rate link not found")}},initHelpWindow:function(a){this.helpWindow=new C.HelpWindow({onSelectCallback:{fn:function(d,b){var c=this.getInput("ct",b);if(c){C.dom.setFieldValue(c,d,false)}},scope:this}},a);this.helpWindow.check()},onFindMyRate:function(){if(!this.rateWindow){this.rateWindow=new C.RateWindow({onSelectCallback:{fn:function(b){var a=this.getControl("cost_input");if(a){C.dom.setFieldValue(a,b,false)}},scope:this}})}this.rateWindow.show()},getControl:function(a){if(!this.controls[a]){if(!this.el_ids[a]){info("getControl: unknown control name - "+a);return null}var b=document.getElementById(this.el_ids[a]);if(!b){info("getControl: control not found - ["+a+"]:"+this.el_ids[a]);return null}this.controls[a]=b}return this.controls[a]},displayMessage:function(a){if(!a){return false}if(!this.messageWindow){this.messageWindow=new C.Dialog()}if(this.messageWindow.setBody(a)&&this.messageWindow.show()){return true}return false},onPrint:function(){var a=this.getControl("print_container");var b=this.getControl("print_source");if(!a){info("onPrint: print container not found");return false}if(!b){info("onPrint: print source not sound");return false}a.innerHTML='<img src="../images/banner_logo.gif" alt="" style="display: block;" height="50" width="102" /><br /><br />'+b.innerHTML;window.print()}};C.dataLists={tabLights:{lights:[["0","Please select your current fixture type",0,[]],[1,"4-foot, 1-T12 lamp w/ magnetic ballast",43,[1,2,3]],[2,"4-foot, 2-T12 lamps w/ magnetic ballast",72,[4,5,6]],[3,"4-foot, 3-T12 lamps w/ magnetic ballast",115,[7,8,9]],[18,"4-foot, 4-T8 lamps w/ electronic ballast",112,[11]],[4,"4-foot, 4-T12 lamps w/ magnetic ballast",114,[30,10,11,12,13,14]],[5,"8-foot, 1-T12 lamp w/ magnetic ballast",75,[4,5,15,6]],[6,"8-foot, 2-T12 lamps w/ magnetic ballast",123,[16,14,17]],[7,"2-T12 U-tube lamps w/ magnetic ballast",72,[18,19,20]],[8,"250 watt high pressure sodium fixture",295,[21,22]],[9,"400 watt high pressure sodium fixture",465,[23,24]],[10,"250 watt metal halide fixture",291,[21,22]],[11,"400 watt metal halide fixture",456,[23,24]],[12,"EXIT (incandescent w/ 2-15 watt lamps)",30,[25]],[13,"EXIT (incandescent w/ 2-40 watt lamps)",80,[25]],[14,"40 watt incandescent lamp",40,[26]],[15,"60 watt incandescent lamp",60,[27]],[16,"75 watt incandescent lamp",75,[28]],[17,"100 watt incandescent lamp",100,[29]]],alternatives:[[1,"4-foot, 1 28 watt T8 lamp w/ electronic ballast",25,1],[2,"4-foot, 1 28 watt T8 lamp w/ prog start electronic ballast",26,2],[3,"4-foot, 1 32 watt T8 lamp w/ electronic ballast",31,3],[4,"4-foot, 2 28 watt T8 lamps w/ prog start electronic ballast",49,1],[5,"4-foot, 2 28 watt T8 lamps w/ electronic ballast",52,2],[6,"4-foot, 2 32 watt T8 lamps w/ electronic ballast",58,3],[7,"4-foot, 2 32 watt T8 lamps w/ electronic ballast & reflector",58,1],[8,"4-foot, 3 28 watt T8 lamps w/ electronic ballast",76,2],[9,"4-foot, 3 32 watt T8 lamps w/ electronic ballast",85,3],[10,"4-foot, 2 28 watt T8 lamps w/ electronic ballast & reflector",52,1],[11,"4-foot, 2 32 watt T8 lamps w/ electronic ballast & reflector",58,2],[12,"4-foot, 4 28 watt T8 lamps w/ electronic ballast ",99,2],[13,"4-foot, 4 28 watt T8 lamps w/ prog start electronic ballast",99,2],[14,"4-foot, 4 32 watt T8 lamps w/ electronic ballast ",112,3],[15,"8-foot, 1 59 watt T8 lamp w/ electronic ballast",58,3],[16,"4-foot, 4 28 watt T8 lamps w/ electronic ballast ",99,1],[17,"8-foot, 2 59 watt T8 lamps w/ electronic ballast",109,3],[18,"2-foot, 2 17 watt T8 lamps w/ reflector",33,1],[19,"2-foot, 3 17 watt T8 lamps",47,2],[20,"2 32 watt T8 U-tube lamps w/ electronic ballast",59,3],[21,"4-foot, 4 32 watt T8 lamps w/ high output electronic ballast & reflector",154,1],[22,'4 45.8" T5 HO lamps w/ 2 programmed rapid start ballast',234,1],[23,"4-foot, 6 32 watt T8 lamps w/  2 high output electronic ballast & reflector",226,1],[24,'6 45.8" T5 HO lamps w/ 2 programmed rapid start ballast',351,1],[25,"NEW 9 watt LED Exit Sign",9,1],[26,"9 watt CFL",9,1],[27,"13 watt CFL",13,1],[28,"20 watt CFL",20,1],[29,"26 watt CFL",26,1],[30,"4-foot, 2 28 watt T8 lamps w/ prog start electronic ballast & reflector",49,1]],sections:[[1,"--- Highest Energy Savings ---"],[2,"--- Good Energy Savings ---"],[3,"--- Modest Energy Savings ---"]],helpWindow:{questions:[[1,"What type of lamps are in the fixture?",[1,2,3,4]],[2,"Number of lamps in each fixture?",[5,6,7,8]],[3,"What color is the light produced from the fixture?",[9,10]],[4,"What is the wattage of the lamps?",[11,12,13,14]],[5,"Length of lamps?",[15,16]],[6,"Length of lamps?",[17,18,19]],[7,"What is the wattage of the lamps?",[20,21]],[8,"What is the wattage of the lamps?",[22,23]],[9,"What is the wattage of the lamps?",[24,25]],[10,"Type of lamps?",[26,27]]],answers:[[1,"Fluorescent",{action:"next_question",id:2}],[2,'High-Intensity Discharge<br/><span style="line-height: 12px;">(Metal Halide or High-Pressure Sodium)</span>',{action:"next_question",id:3}],[3,"Exit Fixture",{action:"next_question",id:9}],[4,"Incandescent",{action:"next_question",id:4}],[5,"1",{action:"next_question",id:5}],[6,"2",{action:"next_question",id:6}],[7,"3",{action:"result",id:3}],[8,"4",{action:"next_question",id:10}],[9,"White",{action:"next_question",id:7}],[10,"Yellow",{action:"next_question",id:8}],[11,"40 watt",{action:"result",id:14}],[12,"60 watt",{action:"result",id:15}],[13,"75 watt",{action:"result",id:16}],[14,"100 watt",{action:"result",id:17}],[15,"4-foot",{action:"result",id:1}],[16,"8-foot",{action:"result",id:5}],[17,"4-foot",{action:"result",id:2}],[18,"8-foot",{action:"result",id:6}],[19,"U-tube",{action:"result",id:7}],[20,"250 watt",{action:"result",id:10}],[21,"400 watt",{action:"result",id:11}],[22,"250 watt",{action:"result",id:8}],[23,"400 watt",{action:"result",id:9}],[24,"15 watts",{action:"result",id:12}],[25,"40 watts",{action:"result",id:13}],[26,"T8",{action:"result",id:18}],[27,"T12",{action:"result",id:4}]]}}};var CPage={lTab:null,hTab:null,init:function(){this.initLightingTab()},initLightingTab:function(){if(!this.lTab){this.lTab=new C.Calculator({},C.dataLists.tabLights);this.lTab.addRow()}},initHVACTab:function(){}};