var Browser={IE:!!(window.attachEvent&&!window.opera),Opera:!!window.opera,WebKit:navigator.userAgent.indexOf('AppleWebKit/')>-1,Gecko:navigator.userAgent.indexOf('Gecko')>-1&&navigator.userAgent.indexOf('KHTML')==-1,MobileSafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)};function $E(A){return document.getElementById(A);}function $F(A){return document.getElementById(A).value;}Object.extend=function(A,B){for(var C in B){A[C]=B[C];}return A;}Object.extend(Object,{keys:function(A){var B=[];for(var C in A)B.push(C);return B;},values:function(A){var B=[];for(var C in A)B.push(A[C]);return B;},toQueryString:function(A){var B=[];for(var C in A){B.push(encodeURI(C)+"="+encodeURI(A[C]));}return B.join("&");},clone:function(A){return Object.extend({},A);},isElement:function(A){return A&&A.nodeType==1;},isArray:function(A){return A&&A.constructor===Array;},isFunction:function(A){return typeofA=="function";},isString:function(A){return typeofA=="string";},isNumber:function(A){return typeofA=="number";},isUndefined:function(A){return typeofA=="undefined";}});if(Browser.Opera){Array.prototype.concat=function(){var A=[];for(var B=0,length=this.length;B<length;B++)A.push(this[B]);for(var B=0,length=arguments.length;B<length;B++){if(arguments[B].constructor==Array){for(var D=0,arrayLength=arguments[B].length;D<arrayLength;D++)A.push(arguments[B][D]);}else {A.push(arguments[B]);}}return A;}}if(!Array.prototype.indexOf)Array.prototype.indexOf=function(A){for(var B=0,length=this.length;B<length;B++){if(this[B]===A)return B;}return -1;};Function.prototype.bind=function(A){var B=this;return function(){return B.apply(A,arguments);}}Function.prototype.bindAsEventListener=function(A){var B=this;return function(event){return B.apply(A,[(event||window.event)].concat(arguments));}}var Try={these:function(){var A;for(var B=0,length=arguments.length;B<length;B++){var C=arguments[B];try{A=C();break;}catch(e){}}return A;}}var Class={create:function(){var A=null,properties={};if(arguments.length>0){if(Object.isFunction(arguments[0])){A=arguments[0];if(arguments.length>1)properties=arguments[1];}else {properties=arguments[0];}}function klass(){this.initialize.apply(this,arguments);}Object.extend(klass,Class.Methods);klass.superclass=A;klass.subclasses=[];if(A){var B=function(){};B.prototype=A.prototype;klass.prototype=new B;A.subclasses.push(klass);}klass.addMethods(properties);if(!klass.prototype.initialize)klass.prototype.initialize=function(){};klass.prototype.constructor=klass;return klass;}};Class.Methods={addMethods:function(A){var B=this.superclass&&this.superclass.prototype;var C=Object.keys(A);if(!Object.keys({toString:true}).length)C.push("toString","valueOf");for(var D=0,length=C.length;D<length;D++){var E=C[D],value=A[E];if(B&&Object.isFunction(value)&&value.argumentNames().first()=="$super"){var F=value,value=Object.extend((function(m){return function(){return B[m].apply(this,arguments)};})(E).wrap(F),{valueOf:function(){return F},toString:function(){return F.toString()}});}this.prototype[E]=value;}return this;}};var AjajRequest=Class.create();AjajRequest.List=[];AjajRequest.CUR_ID=0;AjajRequest.getHtmlHead=function(){try{return document.getElementsByTagName("head").item(0);}catch(e){return null;}}AjajRequest.onStateChange=function(A,B){var C=AjajRequest.List[A];if(C){C.state=1;C.data=B;}}Object.extend(AjajRequest.prototype,{initialize:function(A,B){var C={timeout:5000,onComplete:null,onError:null}this.options=Object.extend(C,B||{});this.id="ajaj"+AjajRequest.CUR_ID++;AjajRequest.List[this.id]=this;this.state=0;this.data=null;try{this.element=document.createElement("script");this.element.setAttribute("type","text/javascript");this.element.setAttribute("charset","utf-8");this.element.setAttribute("src",A+((A.indexOf("?")!=-1)?"&":"?")+"r="+(new Date()).getTime()+"&ajajId="+this.id);AjajRequest.getHtmlHead().appendChild(this.element);this.escapedTime=0;this.timer=setInterval(this.onTimer.bind(this),100);}catch(e){if(this.options.onError)this.options.onError();}},onTimer:function(){if(this.state!=0){clearInterval(this.timer);AjajRequest.getHtmlHead().removeChild(this.element);AjajRequest.List[this.id]=null;if(this.options.onComplete)this.options.onComplete(this.data);}else {this.escapedTime+=100;if(this.escapedTime>this.options.timeout){clearInterval(this.timer);AjajRequest.getHtmlHead().removeChild(this.element);AjajRequest.List[this.id]=null;if(this.options.onError)this.options.onError();}}}});var voted=false;var voteUrl="";var voteUpUrl="";var moodflag="";function getMoodData(A,B,C){moodflag="m"+B;voteUrl="http://hits.17173.com/mood/moodOpa.php?channel="+A+"&web_id="+B+"&kind="+C+"&action=0";new AjajRequest(voteUrl,{timeout:3000,onComplete:function(data){$E("moodPanel").innerHTML=showResult(A,B,C,data);},onError:function(){$E("moodPanel").innerHTML="It's time out!";}});}function mvoteUp(A,B,C,D){voteUpUrl="http://hits.17173.com/mood/moodOpa.php?channel="+A+"&web_id="+B+"&kind="+C+"&action=1&mood="+D;new AjajRequest(voteUpUrl,{onComplete:function(data){if(data=="9"){voted=true;setCookie(moodflag,"voted");getMoodData(A,B,C);showTopJs(D);}else {voted=true;setCookie(moodflag,"voted");getMoodData(A,B,C);showTopJs(D);}},onError:function(){$E("moodPanel").innerHTML="It's time out!";}});}function showResult(A,B,C,D){var E;var F;var G;var H;var I=0;var J=0;var K=getCookie(moodflag);var L=new Array();var M=new Array();var N=D.split(",");for(var O=0;O<7;O++){j=O+1;L=N[O].split("#");J=J+Number(L[1]);M[j]=Number(L[1]);if(M[j]>I)I=M[j];}E="<div>";E+="<table border='0' width='100%' class='mood'>";E+="<tr><td colspan='6' class='cQGray'>&nbsp;&nbsp;看完这篇新闻有何感觉？已经有<span class='cOrange'>"+J+"</span>人表态</td></tr>";E+="<tr>";for(var O=1;O<=7;O++){tiaoLen=Math.round(M[O]/J*80);if(M[O]==I)H="http://images.17173.com/news/hits/019.gif";else H="http://images.17173.com/news/hits/20.gif";switch(O){case1:F="http://ue1.17173.itc.cn/2009newsend/jiong_1.gif";itemDPic="http://ue1.17173.itc.cn/2009newsend/jiong_2.gif";G="囧";break;case2:F="http://ue1.17173.itc.cn/2009newsend/tu_1.gif";itemDPic="http://ue1.17173.itc.cn/2009newsend/tu_2.gif";G="恶心";break;case3:F="http://ue1.17173.itc.cn/2009newsend/se_1.gif";itemDPic="http://ue1.17173.itc.cn/2009newsend/se_2.gif";G="期待";break;case4:F="http://ue1.17173.itc.cn/2009newsend/ku_1.gif";itemDPic="http://i1.17173.itc.cn/2011/news/2011/05/19/ku2.gif";G="难过";break;case5:F="http://ue1.17173.itc.cn/2009newsend/bucuo_1.gif";itemDPic="http://ue1.17173.itc.cn/2009newsend/bucuo_2.gif";G="不错";break;case6:F="http://ue1.17173.itc.cn/2009newsend/guanzhu_1.gif";itemDPic="http://ue1.17173.itc.cn/2009newsend/guanzhu_2.gif";G="关注";break;case7:F="http://i3.17173.itc.cn/2011/news/2011/05/19/jy1.gif";itemDPic="http://i1.17173.itc.cn/2011/news/2011/05/19/jy2.gif";G="酱油";break;}E+="<td align='center' valign='bottom'>";if(K=="voted")E+=M[O]+"<br><img src='"+H+"' height='"+tiaoLen+"' width='20'><br><img  id='"+O+"' src='"+F+"' onmouseover='showDpic(\""+i+"\",\""+itemDPic+"\")' onmouseout='showDpic(\""+i+"\",\""+itemPic+"\")' onclick='votealert("+O+")' style='cursor: pointer;cursor:hand'><br>"+G;else E+=M[O]+"<br><img src='"+H+"' height='"+tiaoLen+"' width='20'><br><img  id='"+O+"' src='"+F+"' onmouseover='showDpic(\""+i+"\",\""+itemDPic+"\")' onmouseout='showDpic(\""+i+"\",\""+itemPic+"\")' onclick='mvoteUp("+A+","+B+","+C+","+O+")' style='cursor: pointer;cursor:hand'><br>"+G;E+="</td>";}E+="</tr>";E+="</table>";E+="</div>";return E;}function showTopJs(A){switch(A){case1:itemName="囧";break;case2:itemName="恶心";break;case3:itemName="期待";break;case4:itemName="难过";break;case5:itemName="不错";break;case6:itemName="关注";break;case7:itemName="酱油";break;}document.getElementById("moodItem").innerHTML='"'+itemName+'"新闻排行';for(i=1;i<=7;i++){document.getElementById("m"+i).style.display="none";}document.getElementById("moodItem").style.display="";id="m"+A;document.getElementById(id).style.display="";}function setCookie(A,B){var C=30;var D=new Date();D.setTime(D.getTime()+C*24*60*60*1000);document.cookie=A+'='+escape(B)+';expires='+D.toGMTString();}function getCookie(A){var B,C=new RegExp('(^| )'+A+'=([^;]*)(;|$)');if(B=document.cookie.match(C))return unescape(B[2]);else returnnull;}function votealert(A){showTopJs(A);alert("您已经投票过了，请不要重复投票！");}function showDpic(A,B){document.getElementById(A).src=B;}
