if(typeof jQuery == 'undefined'){ document.write(''); } var has_style=false,static_css='',static_css_prefix='',minimum_mode=false; if( document.styleSheets ) { for( var _wr_x = 0; _wr_x < document.styleSheets.length; _wr_x++ ) { if( typeof document.styleSheets[_wr_x] == 'undefined' ) continue; if( document.styleSheets[_wr_x].href && document.styleSheets[_wr_x].href.indexOf('php/widget-rating.php') + 1 ) { has_style=true; break; } } } if(!has_style){ var scrp = document.createElement('link'); scrp.type = 'text/css'; scrp.rel = 'stylesheet'; scrp.href = 'php/widget-rating.php?css'; try{ document.head.appendChild(scrp); } catch(err) { try{ document.body.appendChild(scrp); } catch(err) { try{ document.appendChild(scrp); } catch(err) {} } } } if(typeof widget_rating_obj == 'undefined'){ var widget_rating_obj = {}; var widget_rating_processing = {}; var widget_rating_click_callback = function(_wr_id,x,json_res,btn){ var val = json_res.val, o = widget_rating_obj[_wr_id]; if(typeof x == "undefined" || typeof o == "undefined"){ return; } $(btn).parent().parent().fadeOut(); $('.widget-rating-thanks',$(btn).parent().parent().parent()).html(json_res.message).fadeIn(); if(typeof o.settings['r'+x] != 'undefined'){ var ot = o.settings['r'+x].split(','); }else{ var ot = [ (val == 'up' || val == 'do') ? 'yn' : 's' ]; } switch(ot[0]){ case "s": if(typeof json_res.all_rating[x] != 'undefined'){ var w2 = parseFloat(json_res.all_rating[x]) * o.icon_width; $('.widget-rating-current',$(btn).parent().parent()).width(w2+'px'); } break; case "yn": if(typeof json_res.rating != 'undefined' && typeof json_res.rating[x] != 'undefined' && typeof json_res.rating[x][val] != 'undefined'){ $(btn).html(json_res.rating[x][val]); } break; } setTimeout(function(){ widget_rating_processing[_wr_id+'-'+x] = false; $(btn).parent().parent().fadeIn(); $('.widget-rating-thanks',$(btn).parent().parent().parent()).fadeOut(); }, 2000); }; var widget_rating_click = function(_wr_id,btn){ var val = $(btn).attr('rel'), x = $(btn).parent().parent().parent().attr('rel'), o = widget_rating_obj[_wr_id]; if(typeof x == "undefined" || typeof o == "undefined"){ return; } if(typeof widget_rating_processing[_wr_id+'-'+x] != 'undefined' && widget_rating_processing[_wr_id+'-'+x] == true){ return; } widget_rating_processing[_wr_id+'-'+x] = true; $.ajax({ type: "GET", url: "php/widget-rating.php?click="+escape(_wr_id)+"&x="+x+"&val="+val+"&m="+escape( (typeof o.thanks[x] != 'undefined') ? o.thanks[x] : 'Thanks!' ), dataType: "json", success: function(json_res){ widget_rating_click_callback(_wr_id,x,json_res,btn); }, error: function(){ alert('Widget Rating: Unable to record click for "'+_wr_id+'"'); } }); }; var widget_rating_callback = function(_wr_id,json_res){ var o = widget_rating_obj[_wr_id]; if(typeof json_res.rating != undefined){ o.rating = json_res.rating; }else{ o.rating = 0; } if(typeof json_res.all_rating != undefined){ o.all_rating = json_res.all_rating; }else{ o.all_rating = 0; } var count = parseInt(o.settings.r); var max_width = 0; static_css = ''; var exists = true, bound=false; if( $('.widget-rating-rate', o.holder).length<1){ exists = false; } if(exists){ if(typeof o.all_rating != 'undefined'){ for(var xxx in o.all_rating){ var rating = parseFloat(o.all_rating[xxx]); $('.widget-rating-'+xxx+' .widget-rating-current').width(rating * 25); } } if(typeof o.rating != 'undefined'){ for(var xxx in o.rating){ var rating_yn_up = 0,rating_yn_do = 0; if(typeof o.rating[xxx]['up'] != 'undefined'){ rating_yn_up = parseFloat(o.rating[xxx]['up']); } if(typeof o.rating[xxx]['do'] != 'undefined'){ rating_yn_do = parseFloat(o.rating[xxx]['do']); } $('.widget-rating-'+xxx+' .widget-rating-up a').html(rating_yn_up); $('.widget-rating-'+xxx+' .widget-rating-do a').html(rating_yn_do); } } }else{ for(var x = 0;x < count;x++){ if(!exists){ $(o.holder).append( '
' ); } var ot = o.settings['r'+x].split(','); o.thanks[x] = ( typeof o.thanks[x] != 'undefined' ) ? o.thanks[x] : "Thanks!"; if(!exists){ $('.widget-rating-'+x, o.holder).append(' '); } switch(ot[0]){ case "s": o.icon_width = 25; var rating=0; if(typeof o.all_rating != 'undefined' && typeof o.all_rating[x] != 'undefined'){ rating = parseFloat(o.all_rating[x]); } var w1 = parseInt(ot[2] * o.icon_width); max_width = Math.max(w1,max_width); var w2 = rating * o.icon_width; if(!exists){ var li_css = 'background-image: url('+ot[1]+');'; $('.widget-rating-'+x, o.holder).append(' '); var title = (typeof o.titles[x] != 'undefined') ? o.titles[x] : ''; $('.widget-rating-'+x, o.holder).append(' '+title+''); o.current = $(''); $('.widget-rating-'+x+' ul', o.holder).append(o.current); }else{ $('.widget-rating-'+x+' .widget-rating-current').width(w2); } if(!exists){ for(var cc = 0; cc < ot[2]; cc++){ if(!exists){ var t = $('