/*
 ### jQuery Star Rating Plugin v2.62 - 2009-03-12 ###
 * Home: http://www.fyneworks.com/jquery/star-rating/
 * Code: http://code.google.com/p/jquery-star-rating-plugin/
 *
	* Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 ###
*/
eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'([3-9i-mo-zA-Z]|1\\w)'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';6(window.J)(7($){6($.browser.msie)try{document.execCommand("BackgroundImageCache",false,true)}catch(e){}$.3={t:\'Cancel Rating\',K:\'\',l:0,L:16,5:{},z:0,8:{A:7(c,b,a,d){4.m(c);$(b).M(\'.u\'+c).N().o(\'star_\'+(d||\'O\'));k f=$(b).v(\'a\');9=f.w();6(a.P)a.P.B($.3.5[c].i[0],[9,f[0]])},m:7(c,b,a){$.3.5[c].i.siblings(\'.u\'+c).C(\'x\').C(\'star_hover\')},q:7(c,b,a){6(!$($.3.5[c].r).is(\'.t\'))$($.3.5[c].r).M(\'.u\'+c).N().o(\'x\');k d=$(b).v(\'a\');9=d.w();6(a.Q)a.Q.B($.3.5[c].i[0],[9,d[0]])},s:7(c,b,a){$.3.5[c].r=b;k d=$(b).v(\'a\');9=d.w();$.3.5[c].i.9(9);$.3.8.m(c,b,a);$.3.8.q(c,b,a);6(a.R)a.R.B($.3.5[c].i[0],[9,d[0]])}}};$.S.3=7(g){6(4.T==0)D 4;g=$.U({},$.3,g||{});$.3.z++;4.each(7(c){k b=$.U({},g||{},($.V?$(4).V():($.meta?$(4).data():null))||{});k a=(4.W||\'unnamed-3\').replace(/\\[|\\]+/g,"_");a=$.3.z+\'_\'+a;6(!$.3.5[a])$.3.5[a]={E:0};c=$.3.5[a].E;$.3.5[a].E++;$.3.5[a].p=$.3.5[a].p||b.p||$(4).attr(\'F\');6(c==0){$.3.5[a].i=$(\'<X Y="hidden" W="\'+a+\'" G=""\'+(b.p?\' F="F"\':\'\')+\'/>\');$(4).Z($.3.5[a].i);6($.3.5[a].p||b.required){}10{$(4).Z($(\'<y 11="t"><a H="\'+b.t+\'">\'+b.K+\'</a></y>\').12(7(){$.3.8.m(a,4,b);$(4).o(\'x\')}).13(7(){$.3.8.q(a,4,b);$(4).C(\'x\')}).s(7(){$.3.8.s(a,4,b)}))}};j=$(\'<y 11="14"><a H="\'+(4.H||4.G)+\'">\'+4.G+\'</a></y>\');$(4).after(j);6(b.half)b.l=2;6(typeof b.l==\'number\'&&b.l>0){k d=($.S.I?$(j).I():0)||b.L;k f=(c%b.l),h=Math.floor(d/b.l);$(j).I(h).find(\'a\').css({\'margin-left\':\'-\'+(f*h)+\'px\'})};$(j).o(\'u\'+a);6($.3.5[a].p)$(j).o(\'star_readonly\');10 $(j).o(\'star_live\').12(7(){$.3.8.m(a,4,b);$.3.8.A(a,4,b,\'O\')}).13(7(){$.3.8.m(a,4,b);$.3.8.q(a,4,b)}).s(7(){$.3.8.s(a,4,b)});6(4.checked)$.3.5[a].r=j;$(4).remove();6(c+1==4.T)$.3.8.q(a,4,b)});for(n in $.3.5)(7(c,b,a){6(!c)D;$.3.8.A(a,c,g||{},\'on\');$(b).9($(c).v(\'a\').w())})($.3.5[n].r,$.3.5[n].i,n);D 4};$(7(){$(\'X[Y=radio].14\').3()})})(J);',[],67,'|||rating|this|group|if|function|event|val|||||||||valueElem|eStar|var|split|drain||addClass|readOnly|reset|current|click|cancel|star_group_|children|text|star_on|div|calls|fill|apply|removeClass|return|count|disabled|value|title|width|jQuery|cancelValue|starWidth|prevAll|andSelf|hover|focus|blur|callback|fn|length|extend|metadata|name|input|type|before|else|class|mouseover|mouseout|star'.split('|'),0,{}))
var rate_form;
/*$j('document').ready(function(){
    $j('.auto-star').rating({ 
      callback: function(value, link){ 
        form = $j(link).parent()[0];
        while(form.tagName != "FORM"){
            form = $j(form).parent()[0];
        }
        
        sand_data = {'rank':value}
        $j(form).find("input[type='hidden']").each(function(){
            if(/^[0-9]+_/.test(this.name)) return;
            sand_data[this.name] = this.value;
        });
        
        $j.ajax({
            type:"POST",
            url:form.action,
            data:sand_data,
            success:function(val){
                if (/^redirect\:/.test(val)){
                    window.location = val.split(":")[1]
                    return;
                }
                val = val.split("-");
                $j(form).find(".rank").text(val[0]);
                $j(form).find(".num_voters").text(val[1]);
            }
        })
        
      } 
    });
    $j('.jshide').hide();
});*/

function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=200');");
}

$j('document').ready(function(){
    $j('.auto-star').rating({ 
      callback: function(value, link){ 
        form = $j(link).parent().parent()[0];
        
        //link = $j.create("a",{'href':'/' , 'class':'thickbox'}); 
        //var new_funct = tb_init.bind(tb_link);
        //new_funct(tb_link);
        //console.log(tb_link);
        //tb_link.fireEvent('click');
        //console.log(form);
        url = form.action + "&rank=" + value + "&width=260&height=280";
        //alert(url);
        rate_form = form;
        tb_show("Submit rating" , url , "");
        
        
        //console.log(url);
        //popUp(url);
        //console.log(send_data);
        
      } 
    });
    $j('.jshide').hide();
});
function catch_rate(){
    //alert(rate_form);
    var form = $j("#TB_ajaxContent form");
    form.bind("submit" , function(ev){
        ev.stopPropagation();
        ev.preventDefault();

        data = {
            "comment":form.find("textarea[name=comment]").attr("value"),
            "rating":form.find("input[name=rating]").attr("value"),
            "rank":form.find("input[name=rank]").attr("value")
        };
        
        $j.ajax({
            type:"POST",
            url:form.attr("action"),
            data:"comment=" + data.comment + "&rating=" + data.rating + "&rank=" + data.rank,
            success:function(inside){
                if(/[0-9\.]+\:[0-9]+/.test(inside)){
                    val = inside.split(":");
                    //console.log(rate_form);
                    $j(rate_form).find(".rank").text(val[0]);
                    $j(rate_form).find(".num_voters").text(val[1]);
                    tb_remove();
                }
                $j("#TB_ajaxContent").html(inside);
                catch_rate(rate_form);
            }
        });
        
        return false;
    })
}

