
if(!Masque.L){Masque.L={};}
Masque.L.ImageRating=Class();Masque.L.ImageRating.extend({initialize:function(RatingBox,options){this.option={Filter:"img",LightImage:"/images/Rating1.jpg",DarkImage:"/images/Rating0.jpg",Outer:"",DefaultText:"",Event:"mouseover",TitleFormat:"",Reselect:true,OnSelect:null,SelectedIndex:-1};this.RatingBox=$(RatingBox);this.option.DarkImage=this.RatingBox.find(this.option.Filter).eq(0).attr("src");this.SetOption(options);if(!this.option.DefaultText||this.option.DefaultText==""){if(this.option.Outer){this.option.DefaultText=$(this.option.Outer).html();}}
this.__bindEvents();this.__setState();if(this.option.SelectedIndex>-1){var i=this.option.SelectedIndex;this.option.SelectedIndex=-1;this.____Hover(i);this.option.SelectedIndex=i;}},__bindEvents:function(first){var event;var me=this;var sts=this.RatingBox.find(this.option.Filter);if(this.option.Event.toLowerCase()=="mouseover"){sts.bind("mouseover",me,me.__EventHover).bind("mouseout",me,me.__EventClearHover);}
sts.bind("click",me,me.__EventSelect);},__setState:function(){var me=this;this.RatingBox.find(this.option.Filter).each(function(index,el){var e=$(el);if(me.option.TitleFormat!=""){e.attr("title",me.option.TitleFormat.replace('{0}',index+1));}
e.attr("src",me.option.DarkImage);});this.__SetOuter(this.option.DefaultText);},__EventSelect:function(handler){var rating=handler.data;if(rating.option.Reselect!=true&&rating.option.SelectedIndex>=0)
return;rating.option.SelectedIndex=-1;var index=rating.RatingBox.find(rating.option.Filter).index(this);rating.____Hover(index);rating.option.SelectedIndex=index;if(rating.option.OnSelect!=null){rating.option.OnSelect(index,rating);}},__SetOuter:function(str){if(this.option.Outer)
$(this.option.Outer).html(str);},____Hover:function(index){if(this.option.SelectedIndex>=0)
return;if(isNaN(index))
index=-1;var me=this;this.RatingBox.find(this.option.Filter).each(function(idx,el){e=$(el);if(idx<=index){e.attr("src",me.option.LightImage);if(idx==index){me.__SetOuter(e.attr("title"));}}
else
e.attr("src",me.option.DarkImage);});if(index<0){this.__SetOuter(this.option.DefaultText);}},__EventHover:function(handler){var rating=handler.data;var index=rating.RatingBox.find(rating.option.Filter).index(this);rating.____Hover(index);},__EventClearHover:function(handler){var rating=handler.data;rating.____Hover(rating.option.SelectedIndex);},Hover:function(index){this.____Hovert(index);},Reset:function(option){this.SelectIndex==-1;this.Hover(-1);},Value:function(){return this.option.SelectedIndex+1;}});