var QUANTID_SCORE=1;var QUANTID_YES_NO=10;var QUANTID_ENUM=11;var QUANTID_SET=12;function DIALOG(A,B){this.init(A,B)}DIALOG.prototype={content_el:null,fn_after_submit:null,nick_name_auto_fill:false,init:function(A,B){this.content_el=(typeof A=="string")?get_el(A):A;this.fn_after_submit=B},get_el:function(A,B){return get_child_el(this.content_el,A,B)},reset_form:function(C){var B=this.get_el("table","msg");if(B){B.style.display="none"}var E=this.content_el.getElementsByTagName("form");for(var G=0;G<E.length;++G){var F=E[G];reset_form(F);error_array_clear(F);if(C){for(var A in C){var D=get_child_el(F,"input",A);if(D){D.value=C[A]}}}}var I=this.get_el("div","xlt");if(I){var H=concat_collections(I.getElementsByTagName("input"),I.getElementsByTagName("textarea"));for(var G=0;G<H.length;++G){var D=H[G];if(D.type=="text"||D.type=="textarea"){D.value=""}else{if(D.type=="checkbox"){D.checked=false}}}}},switch_xlt:function(){var K=this.get_el("div","xlt");if(K){var J=get_child_el(K,"select","language_switch");var H=select_get_selected_value(J);var E=YAHOO.util.Dom.getElementsByClassName("warning","div",this.content_el)[0];E.style.display="none";E.innerHTML="";var C;var I=concat_collections(K.getElementsByTagName("input"),K.getElementsByTagName("textarea"));for(var D=0;D<I.length;++D){var F=I[D];var G=this.get_el("input",F.id+"--"+H);if(G){C=G.disabled;if(F.type=="checkbox"){F.checked=G.value-0;F.disabled=C;if(G.title){E.innerHTML=G.title;E.style.display=""}}else{F.value=G.value;F.readOnly=C}}}var B=get_child_el(K,"input","name");var A=get_child_el(K,"input","nick_name");this.nick_name_auto_fill=B&&A&&A.value==""}},change_xlt:function(A,E){var K=this.get_el("div","xlt");var H=get_child_el(K,"input","enable");if(!H.readOnly&&!E){H.checked=true}if(A.id=="nick_name"){this.nick_name_auto_fill=false}else{if(A.id=="name"){var B=this.get_el("input","nick_name");if(B){if(B.value==""){this.nick_name_auto_fill=true}if(this.nick_name_auto_fill){B.value=A.value}}}}var J=get_child_el(K,"select","language_switch");var G=select_get_selected_value(J);var I=concat_collections(K.getElementsByTagName("input"),K.getElementsByTagName("textarea"));for(var D=0;D<I.length;++D){var F=I[D];var C=this.get_el("input",F.id+"--"+G);if(C){if(F.type=="checkbox"){C.value=F.checked-0}else{C.value=F.value}C.title=""}}},apply_fetched_obj:function(E){if(E){var G=this.content_el.getElementsByTagName("form");for(var I=0;I<G.length;++I){var H=G[I];obj_to_form(H,E.data);if("xlt_array" in E){var A=E.xlt_array;var B=("_XLT_FALLBACK_LANGUAGE_" in E)?E._XLT_FALLBACK_LANGUAGE_:null;obj_array_to_form(H,A,B);for(var D=0;D<H.elements.length;++D){var F=H.elements[D];if(F.type=="hidden"){if(F.id.substr(0,8)=="enable--"){var C=F.id.substr(8);if(("_XLT_FALLBACK_WARNING_" in E)&&!(C in A)){F.title=E._XLT_FALLBACK_WARNING_}F.disabled=(C in A&&A[C]._XLT_READONLY_);if(F.disabled){F.title=E._XLT_READONLY_WARNING_}}}}this.switch_xlt()}}}},submit:function(E,A){var D=this.get_el("form","edit_form");var F=get_child_el(D,"input",A);var C=!parseInt(F.value);show_overlay("overlay",this.content_el);var B=this;AJAX_fetch_json(E,form_to_obj(D),function(M){hide_el("overlay");var L=B.get_el("table","msg");if(M.msg=="*"){error_array_clear(D);show_msg(L,EDIT_MSG_SUCCESS,"success");var H=YAHOO.util.Dom.getElementsByClassName("xlt_box_div","div",B.content_el);for(var J=0;J<H.length;++J){var G=H[J];var I=G.getElementsByTagName("input")[0];if(I.checked){var K=YAHOO.util.Dom.getElementsByClassName("warning","td",G)[0];K.innerHTML=""}}if("id" in M){F.value=M.id}if(B.fn_after_submit){B.fn_after_submit(M.id,"entry" in M?M.entry:null)}}else{if(M.msg){show_msg(L,M.msg,"error")}else{L.style.display="none"}error_array_apply(D,M.error_array)}})}};function CAT_DIALOG(A,B){this.init(A,B);this.dragdrop_parent_box=new YAHOO.util.DDTarget(get_el("cat_parent_box"))}YAHOO.extend(CAT_DIALOG,DIALOG,{create:function(B,A){this.reset_form({cat_id:0});this.get_el("input","allow_ranking").checked=true;this.get_el("input","rating_half_life_days").value=1000;var C=this.get_el("select","cat_parent_box");select_remove_all_options(C);if(B){select_add_option(C,B,A)}},apply:function(D,C){this.reset_form({cat_id:D});if(C){this.apply_fetched_obj(C);var B=this.get_el("select","cat_parent_box");select_remove_all_options(B);for(var A in C.parent_array){select_add_option(B,A,C.parent_array[A].name)}}},fetch:function(B){this.reset_form({cat_id:B});show_overlay("overlay",this.content_el);var A=this;AJAX_fetch_json(__URL__edit_ajax_cat_fetch,{cat_id:B},function(C){hide_el("overlay");A.apply(B,C)})},store:function(){this.submit(__URL__edit_ajax_cat_store,"cat_id")},parents_remove:function(){var A=this.get_el("select","cat_parent_box");select_remove_all_selected_options(A)},on_cat_dragdrop:function(C,D,B){if(C=="cat_parent_box"){var A=this.get_el("select","cat_parent_box");if(select_find_option_idx_by_value(A,D)<0){select_add_option(A,D,B)}}},on_change_parent_selection:function(C,E,D){var B=this.get_el("select","cat_parent_box");var F=select_find_option_idx_by_value(B,C);if(F>=0){B.remove(F)}var A=select_find_option_idx_by_value(B,E);if(A<0){select_add_option(B,E,D)}}});function CRIT_DIALOG(A,B){this.init(A,B)}YAHOO.extend(CRIT_DIALOG,DIALOG,{QUANTID_STATE:{ALL:0,LOCK_SELECTED:1,LIMIT_SCORE:2,LIMIT_PERFORMANCE:3,LIMIT_SPEC:4},create:function(C,A,B){this.reset_form({crit_id:0,cat_id:C,prod_id:A});this._apply_quantity_array(0,B);this.apply_quantity_parameters(true)},apply:function(A,C,B){this.reset_form({crit_id:A,cat_id:0,prod_id:0});if(C){if(C.data.crit_type<2){show_named_child_els(this.content_el,"show_crit_type",true);this._apply_quantity_array(C.data?C.data.quant_id:0,B?this.QUANTID_STATE.LOCK_SELECTED:this.QUANTID_STATE.ALL);this.apply_quantity_parameters(true)}this.apply_fetched_obj(C)}},fetch:function(B,C){this.reset_form({crit_id:B,cat_id:0,prod_id:0});show_named_child_els(this.content_el,"show_crit_type",false);show_named_child_els(this.content_el,"show_quant_id",false);show_named_child_els(this.content_el,"show_unit_id_si",false);show_named_child_els(this.content_el,"show_unit_id_us",false);show_named_child_els(this.content_el,"show_is_fraction",false);show_overlay("overlay",this.content_el);var A=this;AJAX_fetch_json(__URL__edit_ajax_crit_fetch,{crit_id:B},function(D){hide_el("overlay");A.apply(B,D,C)})},store:function(){this.submit(__URL__edit_ajax_crit_store,"crit_id")},apply_quantity_parameters:function(A){var C=this.get_el("select","quant_id");var B=select_get_selected_value(C);this._apply_unit_array("unit_id_si",0,B,A);this._apply_unit_array("unit_id_us",1,B,A);var D=(B>1&&B<10)||B>=20;show_named_child_els(this.content_el,"show_is_fraction",D)},select_quantity_from_unit:function(F,D){var H=this.get_el("select","quant_id");if(H.selectedIndex==0){var G=this.get_el("select",F);var C=select_get_selected_value(G);for(var E in EDIT_QUANTITY_ARRAY){unit_array=EDIT_QUANTITY_ARRAY[E].units[D];for(var B in unit_array){if(B==C){var A=select_find_option_idx_by_value(H,E);if(A>=0){H.selectedIndex=A;this.apply_quantity_parameters(false)}}}}}},_apply_quantity_array:function(E,D){var F=this.get_el("select","quant_id");select_remove_all_options(F);if(D==this.QUANTID_STATE.LOCK_SELECTED&&E){select_add_option(F,E,EDIT_QUANTITY_ARRAY[E].name);show_named_child_els(this.content_el,"show_quant_id",false)}else{if(D==this.QUANTID_STATE.LIMIT_SCORE){select_add_option(F,QUANTID_SCORE,EDIT_QUANTITY_ARRAY[QUANTID_SCORE].name);show_named_child_els(this.content_el,"show_quant_id",false)}else{var B=select_add_option(F,0,EDIT_CRIT_AUTO_SELECT);var G=false;for(var C in EDIT_QUANTITY_ARRAY){if((C==QUANTID_SCORE&&D!=this.QUANTID_STATE.LIMIT_SPEC&&D!=this.QUANTID_STATE.LIMIT_PERFORMANCE)||(C==QUANTID_SET&&D!=this.QUANTID_STATE.LIMIT_PERFORMANCE)||(C!=QUANTID_SCORE&&C!=QUANTID_SET)){var A=select_add_option(F,C,EDIT_QUANTITY_ARRAY[C].name);if(C==E){A.selected=true;G=true}}}if(!G){B.selected=true}show_named_child_els(this.content_el,"show_quant_id",true)}}},_apply_unit_array:function(I,C,B,K){var A=this.get_el("select",I);var H=select_get_selected_value(A);var G=false;select_remove_all_options(A);select_add_option(A,0,EDIT_UNIT_NONE);for(var J in EDIT_QUANTITY_ARRAY){if(B==0||J==B){var F=EDIT_QUANTITY_ARRAY[J].units[C];for(var E in F){var D=select_add_option(A,E,F[E]);if(E==H&&!K){D.selected=true}G=true}}}show_named_child_els(this.content_el,"show_"+I,G)}});function ENUM_DIALOG(A,B){this.init(A,B)}YAHOO.extend(ENUM_DIALOG,DIALOG,{create:function(A){this.reset_form({enum_id:0,crit_id:A})},apply:function(B,A,C){this.reset_form({enum_id:B,crit_id:A});if(C){this.apply_fetched_obj(C)}},fetch:function(C,B){this.reset_form({enum_id:C,crit_id:B});show_overlay("overlay",this.content_el);var A=this;AJAX_fetch_json(__URL__edit_ajax_enum_fetch,{enum_id:C,crit_id:B},function(D){hide_el("overlay");A.apply(C,B,D)})},store:function(){this.submit(__URL__edit_ajax_enum_store,"enum_id")}});function PROD_DIALOG(A,B){this.init(A,B);this.dragdrop_prod_cat_box=new YAHOO.util.DDTarget(this.get_el("select","prod_cat_box"));this.dragdrop_prod_prov_box=new YAHOO.util.DDTarget(this.get_el("select","prod_prov_box"));this.dragdrop_prod_reg_box=new YAHOO.util.DDTarget(this.get_el("select","prod_reg_box"))}YAHOO.extend(PROD_DIALOG,DIALOG,{create:function(E,B,C,D){this.reset_form({prod_id:0,prov_id:0});this._set_parent(C,D);var A=this.get_el("select","prod_cat_box");select_remove_all_options(A);if(E){select_add_option(A,E,B)}},apply:function(B,D){this.reset_form({prod_id:B});if(D){D.data.day_release=D.data.date_release?D.data.date_release.day:0;D.data.month_release=D.data.date_release?D.data.date_release.month:0;D.data.year_release=D.data.date_release?D.data.date_release.year:"";D.data.day_discontinuation=D.data.date_discontinuation?D.data.date_discontinuation.day:0;D.data.month_discontinuation=D.data.date_discontinuation?D.data.date_discontinuation.month:0;D.data.year_discontinuation=D.data.date_discontinuation?D.data.date_discontinuation.year:"";this.apply_fetched_obj(D);this._set_parent(D.data.prod_id_parent,D.parent_xlt?D.parent_xlt.name:null);var A=this.get_el("select","prod_cat_box");select_remove_all_options(A);for(var C in D.cat_array){select_add_option(A,C,D.cat_array[C].name)}var A=this.get_el("select","prod_prov_box");select_remove_all_options(A);for(var C in D.prov_array){select_add_option(A,C,D.prov_array[C].name)}var A=this.get_el("select","prod_reg_box");select_remove_all_options(A);for(var C in D.reg_array){select_add_option(A,C,D.reg_array[C].name)}}},fetch:function(B){this.reset_form({prod_id:B});show_overlay("overlay",this.content_el);var A=this;AJAX_fetch_json(__URL__edit_ajax_prod_fetch,{prod_id:B},function(C){hide_el("overlay");A.apply(B,C)})},store:function(){this.submit(__URL__edit_ajax_prod_store,"prod_id")},cat_remove:function(){var A=this.get_el("select","prod_cat_box");select_remove_all_selected_options(A)},reg_remove:function(){var A=this.get_el("select","prod_reg_box");select_remove_all_selected_options(A)},prov_clear:function(){var A=this.get_el("select","prod_prov_box");select_remove_all_options(A)},on_cat_dragdrop:function(C,D,B){if(C=="prod_cat_box"){var A=this.get_el("select","prod_cat_box");if(select_find_option_idx_by_value(A,D)<0){select_add_option(A,D,B)}}},on_reg_dragdrop:function(C,B,D){if(C=="prod_reg_box"){var A=this.get_el("select","prod_reg_box");if(select_find_option_idx_by_value(A,B)<0){select_add_option(A,B,D)}}},on_prov_dragdrop:function(D,C,B){if(D=="prod_prov_box"){var A=this.get_el("select","prod_prov_box");select_remove_all_options(A);select_add_option(A,C,B)}},_set_parent:function(C,E){var B=this.get_el("input","prod_id_parent");var A=this.get_el("span","prod_parent_name");var D=this.get_el("td","prod_variant_msg");if(C){B.value=C;A.innerHTML=E;D.style.display=""}else{B.value=0;D.style.display="none"}show_named_child_els(this.content_el,"prod_cat_box",!C);show_named_child_els(this.content_el,"prod_prov_box",!C)}});function UPC_DIALOG(A,B){this.init(A,B)}YAHOO.extend(UPC_DIALOG,DIALOG,{create:function(A){this.reset_form({prod_id:A})},apply:function(A,B){this.reset_form({prod_id:A});if(B){this.apply_fetched_obj(B)}},fetch:function(B){this.reset_form({prod_id:B});show_overlay("overlay",this.content_el);var A=this;AJAX_fetch_json(__URL__edit_ajax_upc_fetch,{prod_id:B},function(C){hide_el("overlay");A.apply(B,C)})},store:function(){this.submit(__URL__edit_ajax_upc_store,"prod_id")}});function LEAD_DIALOG(A,B){this.init(A,B);this._clear(null)}YAHOO.extend(LEAD_DIALOG,DIALOG,{create:function(A,B){this.reset_form({prod_id:A});this._clear(B)},apply:function(A,C,B){this.reset_form({prod_id:A});this._clear(C);if(B){this._insert_lead_array(B,true)}},fetch:function(B,C){this.reset_form({prod_id:B});this._clear(C);show_overlay("overlay",this.content_el);var A=this;AJAX_fetch_json(__URL__edit_ajax_lead_fetch,{prod_id:B,thread_id:EDIT_THREAD_ID},function(D){hide_el("overlay");A.apply(B,C,D)})},add_more:function(){show_overlay("overlay",this.content_el);var B=this.get_el("input","lead_query");var A=this;AJAX_fetch_json(__URL__edit_ajax_lead_suggest,{query:B.value,thread_id:EDIT_THREAD_ID},function(C){hide_el("overlay");A._insert_lead_array(C,false)})},store:function(){this.submit(__URL__edit_ajax_lead_store,"prod_id")},_clear:function(C){var B=this.get_el("table","lead_list");while(B.rows.length){B.deleteRow(0)}var A=this.get_el("input","lead_query");A.value=C},_insert_lead_array:function(E,H){var J=this.get_el("table","lead_list");for(var I in E){var F=E[I];var C="sel--"+F.partner_id+"-"+F.item_id;var D=get_child_el(this.content_el,"input",C);if(!D){var B=J.insertRow(J.rows.length);var A=B.insertCell(0);var K='<input type="checkbox" id="'+C+'"';if(H){K+=' checked="checked"'}K+=">";A.innerHTML=K;var G=B.insertCell(1);G.innerHTML='<a href="'+F.url+'" target="wikipik_lead_view">'+F.name+"</a>";G.title=C;G.className="r"}}}});function IMAGE_DIALOG(A,C,B){this.init(A,C);this._upload_in_progress=false;this._upload_dirty=false;this._store_in_progress=false;this._fn_store_2=B;this._update_counter=0}YAHOO.extend(IMAGE_DIALOG,DIALOG,{create:function(A){this.reset_form({image_id:0,prod_id:A});this._update_thumb(0,0)},apply:function(A,B){this.reset_form({image_id:A});if(B){this.apply_fetched_obj(B);this._update_thumb(A,B.file_id);this._upload_in_progress=false;this._upload_dirty=false}},fetch:function(B){this.reset_form({image_id:B,prod_id:0});show_overlay("overlay",this.content_el);var A=this;AJAX_fetch_json(__URL__edit_ajax_image_fetch,{image_id:B},function(C){hide_el("overlay");A.apply(B,C)})},store:function(){if(!this._upload_in_progress){this._store_in_progress=true;if(this._upload_dirty){this.on_acquire_click();this.content_el.getElementsByTagName("form")[0].submit()}else{if(this._fn_store_2){this._fn_store_2()}else{this.submit(__URL__edit_ajax_image_store_2,"image_id")}}}},on_store_finished:function(){this._store_in_progress=false},on_acquire_click:function(){this._upload_in_progress=true;this.get_el("img","image_thumb").src=__URL__STATIC_HOST+"/md5/6ge36ey341tv.gif"},on_acquired:function(B,A,D){this._upload_in_progress=false;var C=this.get_el("table","upload_msg");if(D==="*"){C.style.display="none";get_child_el(this.content_el.getElementsByTagName("form")[0],"input","image_id").value=B;get_child_el(this.content_el.getElementsByTagName("form")[1],"input","image_id").value=B;this._upload_dirty=false;if(this._store_in_progress){this.store()}}else{show_msg(C,D);this._store_in_progress=false}this._update_thumb(B,A)},set_upload_dirty:function(){this._upload_dirty=true},_update_thumb:function(G,B){var F=new RegExp("([0-9]+)/[0-9a-z]+\\.jpg");var E=this.content_el.getElementsByTagName("img");for(var A=0;A<E.length;++A){var D=E[A];if(D){var H=D.id;if(H=="image_thumb"){D.src=__URL__IMAGE_PATH+"90/"+B+".jpg"}else{if(H=="img_"+G){var C=F.exec(D.src);if(C&&C.length==2){D.src=__URL__IMAGE_PATH+C[1]+"/"+B+".jpg"}}}}}}});function PROV_DIALOG(A,B){this.init(A,B)}YAHOO.extend(PROV_DIALOG,DIALOG,{create:function(){this.reset_form({prov_id:0})},apply:function(A,B){this.reset_form({prov_id:A});if(B){this.apply_fetched_obj(B)}},fetch:function(B){this.reset_form({prov_id:B});show_overlay("overlay",this.content_el);var A=this;AJAX_fetch_json(__URL__edit_ajax_prov_fetch,{prov_id:B},function(C){hide_el("overlay");A.apply(B,C)})},store:function(){this.submit(__URL__edit_ajax_prov_store,"prov_id")}});function REG_DIALOG(A,B){this.init(A,B);this.dragdrop_parent_box=new YAHOO.util.DDTarget(get_el("reg_parent_box"))}YAHOO.extend(REG_DIALOG,DIALOG,{create:function(B,C){this.reset_form({reg_id:0});var A=this.get_el("select","reg_parent_box");select_remove_all_options(A);if(B){select_add_option(A,B,C)}},apply:function(A,D){this.reset_form({reg_id:A});if(D){this.apply_fetched_obj(D);var C=this.get_el("select","reg_parent_box");select_remove_all_options(C);for(var B in D.parent_array){select_add_option(C,B,D.parent_array[B].name)}}},fetch:function(B){this.reset_form({reg_id:B});show_overlay("overlay",this.content_el);var A=this;AJAX_fetch_json(__URL__edit_ajax_reg_fetch,{reg_id:B},function(C){hide_el("overlay");A.apply(B,C)})},store:function(){this.submit(__URL__edit_ajax_reg_store,"reg_id")},parents_remove:function(){var A=this.get_el("select","reg_parent_box");select_remove_all_selected_options(A)},on_reg_dragdrop:function(C,B,D){if(C=="reg_parent_box"){var A=this.get_el("select","reg_parent_box");if(select_find_option_idx_by_value(A,B)<0){select_add_option(A,B,D)}}},on_change_parent_selection:function(D,F,C){var B=this.get_el("select","reg_parent_box");var E=select_find_option_idx_by_value(B,D);if(E>=0){B.remove(E)}var A=select_find_option_idx_by_value(B,F);if(A<0){select_add_option(B,F,C)}}});function USER_DIALOG(A,B){this.init(A,B)}YAHOO.extend(USER_DIALOG,DIALOG,{create:function(A){this.reset_form({user_id:0})},apply:function(A,B){this.reset_form({user_id:A});if(B){this.apply_fetched_obj(B)}},fetch:function(A){this.reset_form({user_id:A});show_overlay("overlay",this.content_el);var B=this;AJAX_fetch_json(__URL__edit_ajax_user_fetch,{user_id:A},function(C){hide_el("overlay");B.apply(A,C)})},store:function(){this.submit(__URL__edit_ajax_user_store,"user_id")}});function SPEC_DIALOG(A,D,F,G,B){this.init(A,D);var C=this.get_el("input","prod_id");var E=this.get_el("input","cat_id");this.spec_table=new RATING_TABLE(this.get_el("table","prod_spec_table"),F,{quant_id_state:CRIT_DIALOG.prototype.QUANTID_STATE.LIMIT_SPEC,prod_id_el:C,cat_id_el:E},G,B)}YAHOO.extend(SPEC_DIALOG,DIALOG,{create:function(A){this.reset_form({prod_id:A});this.spec_table.reset()},update_enum:function(A,C,B){this.spec_table.update_enum(A,C,B)},update_criterion:function(A,B){this.spec_table.update_criterion(A,B)},apply:function(B,F){this.reset_form({prod_id:B});this.spec_table.reset();if(F){var G=F.crit_array;var A=F.spec_array;for(var C in G){var D=G[C];var E=(C in A)?A[C]:null;this.spec_table.add_criterion(C,D,E)}}},fetch:function(B,C){this.reset_form({prod_id:B});show_overlay("overlay",this.content_el);var A=this;AJAX_fetch_json(__URL__edit_ajax_spec_fetch,{prod_id:B,cat_id_array:C},function(D){hide_el("overlay");A.apply(B,D)})},reconcile:function(C,B){show_overlay("overlay",this.content_el);var A=this;AJAX_fetch_json(__URL__edit_ajax_spec_fetch,{prod_id:0,cat_id_array:C},function(D){hide_el("overlay");if(D){A.spec_table.reconcile(D.crit_array)}if(B){B()}})},store:function(){this.submit(__URL__edit_ajax_spec_store,"prod_id")}});function REVIEW_DIALOG(A,D,E,F,B){this.init(A,D);var C=this.get_el("input","prod_id");this.rating_table_array=[new RATING_TABLE(this.get_el("table","rating_table_0"),E,{quant_id_state:CRIT_DIALOG.prototype.QUANTID_STATE.LIMIT_SCORE,prod_id_el:C},F,B),new RATING_TABLE(this.get_el("table","rating_table_1"),E,{quant_id_state:CRIT_DIALOG.prototype.QUANTID_STATE.LIMIT_PERFORMANCE,prod_id_el:C},F,B)]}YAHOO.extend(REVIEW_DIALOG,DIALOG,{create:function(A){this.reset_form({review_id:0,prod_id:A})},update_enum:function(A,C,B){this.rating_table_array[1].update_enum(A,C,B)},update_criterion:function(B,C){var A=Number(C.quant_id!=QUANTID_SCORE);this.rating_table_array[A].update_criterion(B,C)},apply:function(D,H,F){this.reset_form({review_id:D,prod_id:H});if(F){this.apply_fetched_obj(F);for(var E=0;E<2;++E){var I=this.rating_table_array[E];I.reset();var J=F.crit_array;var C=F.rating_array;for(var B in J){var A=J[B];if(E!=(A.quant_id==QUANTID_SCORE)){var G=(B in C)?C[B]:null;I.add_criterion(B,A,G)}}}}},fetch:function(C,B){this.reset_form({review_id:C,prod_id:B});show_overlay("overlay",this.content_el);var A=this;AJAX_fetch_json(__URL__edit_ajax_review_fetch,{review_id:C,prod_id:B},function(D){hide_el("overlay");A.apply(C,B,D)})},store:function(){this.submit(__URL__edit_ajax_review_store,"review_id")}});function RATING_DIALOG(A,B,C){this.init(A,B);this.fn_on_enum_click=C}YAHOO.extend(RATING_DIALOG,DIALOG,{fn_on_enum_click:null,create:function(A){this.reset_form({rating_id:A})},update_enum:function(A,C,B){RATING_WIDGET.update_enum(this.content_el,A,C,B)},apply:function(A,C){this.reset_form({rating_id:A});if(C){var B=this.get_el("div","rating_widget");B.innerHTML="";RATING_WIDGET.create(B,C.crit_id,C.crit_entry,C.value_entry,this.fn_on_enum_click,false)}},fetch:function(C,B){this.reset_form({rating_id:C});show_overlay("overlay",this.content_el);var A=this;AJAX_fetch_json(__URL__edit_ajax_rating_fetch,{rating_id:C},function(D){hide_el("overlay");A.apply(C,D);if(B){show_inner_html(B,D.crit_entry.name)}})},store:function(){this.submit(__URL__edit_ajax_rating_store,"rating_id")}});function RATING_TABLE(A,D,C,E,B){this.init(A,D,C,E,B)}RATING_TABLE.prototype={table_el:null,empty_row_count:0,odd_flip:false,fn_on_crit_click:null,fn_on_enum_click:null,explicit_descriptions:false,init:function(A,E,D,F,C){this.table_el=(typeof A=="string")?get_el(A):A;this.empty_row_count=this.table_el.rows.length;this.odd_flip=false;this.fn_on_crit_click=E;this.fn_on_enum_click=F;this.explicit_descriptions=C;if(E&&this.empty_row_count>1){var B=this.table_el.rows[this.empty_row_count-1].getElementsByTagName("a")[0];if(B){D.crit_id=0;D.crit_name=EDIT_NEW_CRIT;YAHOO.util.Event.on(B,"click",this.fn_on_crit_click,D)}}},reset:function(){while(this.table_el.rows.length>this.empty_row_count){this.table_el.deleteRow(1)}this.odd_flip=false},update_enum:function(A,C,B){RATING_WIDGET.update_enum(this.table_el,A,C,B)},update_criterion:function(B,C){var A=get_child_el(this.table_el,"*","crit_label_"+B);if(A){A.innerHTML=C.name+":";if(C.description){A.title=C.description}}else{this.add_criterion(B,C,null)}},add_criterion:function(D,E,G){var F=this.table_el.insertRow(this.table_el.rows.length+1-this.empty_row_count);if((this.odd_flip=!this.odd_flip)){F.className="odd"}var A=F.insertCell(0);A.className="label";if(this.fn_on_crit_click){var C=document.createElement("a");C.id="crit_label_"+D;C.innerHTML=E.name+":";if(E.description){var B=E.wiki_text?"<h3>"+E.description+"</h3><p>"+E.wiki_text+"</p>":"<h3>"+E.description+"</h3>";YAHOO.util.Event.on(C,"mouseover",TOOLTIP_on_show,{anchor_el:C,inner_html:B,align_left:true});YAHOO.util.Event.on(C,"mouseout",TOOLTIP_on_hide,C);C.className="toolinfo"}YAHOO.util.Event.on(C,"click",this.fn_on_crit_click,{crit_id:D,crit_name:E.name,cat_id:E.cat_id});A.appendChild(C)}else{A.id="crit_label_"+D;A.innerHTML=E.name+":";if(E.description){A.title=E.description}}var A=F.insertCell(1);A.className="value";RATING_WIDGET.create(A,D,E,G,this.fn_on_enum_click,true);if(this.explicit_descriptions&&E.description){F=this.table_el.insertRow(this.table_el.rows.length+1-this.empty_row_count);F.className=this.odd_flip?"odd desc":"desc";var A=F.insertCell(0);A.colSpan=2;A.innerHTML=E.description}},reconcile:function(G){for(var C=0;C<this.table_el.rows.length;++C){var F=this.table_el.rows[C];var E=F.getElementsByTagName("*");for(var A=0;A<E.length;++A){var D=E[A];if(D.id.substr(0,11)=="crit_label_"&&!(parseInt(D.id.substr(11)) in G)){this.table_el.deleteRow(C--);break}}}for(var B in G){this.update_criterion(B,G[B])}}};var RATING_WIDGET={create:function(C,P,Q,M,U,N){var D=!!M;var Z=D?M.value:(Q.quant_id==QUANTID_SCORE)?5:"";var K=is_IE?"click":"change";var F;var b;switch(Q.quant_id){case QUANTID_SCORE:var A=this._score_slider_array[P]=new SCORE_SLIDER();A.clone(C,"widget_score_slider",P,D,Z,Q.is_bigger_better);b=A.chk_el;break;case QUANTID_YES_NO:F=get_el("widget_yes_no").cloneNode(true);b=get_child_el(F,"input","se");F.id="yesno_"+P;b.id="se--"+P;C.appendChild(F);var e,B;var c=F.getElementsByTagName("input");for(var V=0;V<c.length;++V){var d=c[V];if(d.name=="sv"){var S=D&&(d.value-0==Z-0);if(is_IE){var O=document.createElement('<input type="radio" name="sv--'+P+'" value="'+d.value+'"'+(S?' checked="checked"':"")+">");d.parentNode.insertBefore(O,d);d.parentNode.removeChild(d);d=O}else{d.name="sv--"+P;d.checked=S}YAHOO.util.Event.on(d,K,RATING_WIDGET_on_activate,{el:b});if(d.value=="1"){e=d}else{B=d}}}b.checked=D;YAHOO.util.Event.on(b,K,RATING_WIDGET_on_check_yes_no,{el:b,yes_el:e,no_el:B});break;case QUANTID_ENUM:case QUANTID_SET:var d,G;if(Q.quant_id==QUANTID_SET){F=get_el("widget_set").cloneNode(true);d=get_child_el(F,"input","sv");G=get_child_el(F,"select","ss");G.id="ss--"+P}else{F=get_el("widget_enum").cloneNode(true);d=get_child_el(F,"select","sv");G=d;select_add_option(G,0,"",false)}F.id="enum_"+P;b=get_child_el(F,"input","se");b.id="se--"+P;d.id="sv--"+P;C.appendChild(F);for(var T in Q.enum_array){var L=(typeof Z=="object")?(T in Z):false;select_add_option(G,T,Q.enum_array[T],L)}if(Q.quant_id==QUANTID_ENUM){var X=select_find_option_idx_by_value(G,Z);G.selectedIndex=X>0?X:0}b.checked=D;YAHOO.util.Event.on(G,K,RATING_WIDGET_on_activate,{el:b});YAHOO.util.Event.on(b,K,RATING_WIDGET_on_check_enum,{el:b,sel_el:G});if(U){var a=F.getElementsByTagName("a");YAHOO.util.Event.on(a[0],"click",U,{enum_id_el:null,crit_id:P,crit_name:Q.name});if(Q.quant_id!=QUANTID_SET){YAHOO.util.Event.on(a[1],"click",U,{enum_id_el:G,crit_id:P,crit_name:Q.name})}}break;default:var d;if(Q.quant_id in this._widget_map){F=get_el(this._widget_map[Q.quant_id]).cloneNode(true);b=get_child_el(F,"input","se");d=get_child_el(F,"input","sv");F.id="number_"+P;d.id="sv--"+P;b.id="se--"+P;C.appendChild(F);d.value=Z;b.checked=D;YAHOO.util.Event.on(d,"keyup",RATING_WIDGET_on_activate,{el:b})}else{F=get_el("widget_unit").cloneNode(true);b=get_child_el(F,"input","se");d=get_child_el(F,"input","sv");var Y=get_child_el(F,"select","su");F.id="quantity_"+P;d.id="sv--"+P;b.id="se--"+P;Y.id="su--"+P;C.appendChild(F);d.value=Z;b.checked=D;var J=M?M.unit_id:Q.unit_id;var W=EDIT_QUANTITY_ARRAY[Q.quant_id].units;if(W){for(var R in W){var E=W[R];for(var H in E){var I=select_add_option(Y,H,E[H]);if(H==J){I.selected=true}}}}YAHOO.util.Event.on(d,"keyup",RATING_WIDGET_on_activate,{el:b})}YAHOO.util.Event.on(b,K,RATING_WIDGET_on_check_number,{el:b,var_el:d});break}if(!N){b.style.display="none"}},update_enum:function(B,C,G,E){var D=get_child_el(B,"select","sv--"+C);if(!D){D=get_child_el(B,"select","ss--"+C)}if(D){var A=select_find_option_idx_by_value(D,G);if(A>=0){D.options[A].text=E}else{select_add_option(D,G,E,true)}var F=get_child_el(B,"input","se--"+C);if(F){F.checked=true}}},_widget_map:{2:"widget_number",3:"widget_factor",4:"widget_ratio",5:"widget_inv_ratio",6:"widget_percentage"},_score_slider_array:{}};function RATING_WIDGET_on_activate(B,A){A.el.checked=true}function RATING_WIDGET_on_check_number(B,A){if(A.el.checked){A.var_el.value=("__last_value__" in A.el)?A.el.__last_value__:""}else{A.el.__last_value__=A.var_el.value;A.var_el.value=""}}function RATING_WIDGET_on_check_yes_no(B,A){if(A.el.checked){if("__last_value__" in A.el){A.yes_el.checked=A.el.__last_value__;A.no_el.checked=!A.el.__last_value__}else{A.yes_el.checked=true;A.no_el.checked=false}}else{A.el.__last_value__=A.yes_el.checked;A.yes_el.checked=false;A.no_el.checked=false}}function RATING_WIDGET_on_check_enum(B,A){if(A.el.checked){if("__last_value__" in A.el){obj_to_select(A.sel_el,A.el.__last_value__)}}else{A.el.__last_value__=select_to_obj(A.sel_el);select_deselect_all(A.sel_el)}};
