var is_being_rated=false;
var yc_is_being_rated=false;
var yj_is_being_rated=false;
var eur_is_being_rated=false;
var euro_is_being_rated=false;
var yj_mouse_over=false;
var yc_mouse_over=false;
var eur_mouse_over=false;
var euro_mouse_over=false;
var postid=0;
var p=0;
function current_rating(fid,pn,str){
	postid=fid;
	p=pn;
	document.getElementById("ratings_"+fid+"_text").innerHTML=str;
}
function rate_post(surl) {
   if(!is_being_rated) {
      is_being_rated = true;
      var ajaxobj=new AJAXRequest;
			ajaxobj.method="GET";
			ajaxobj.url="/"+surl+"/vote.do?id="+postid+"&p="+p;
			ajaxobj.callback=function(xmlobj) {
			   var vnum=xmlobj.responseText;
			   //alert("vote_result_"+postid+":"+vnum);
			   if(vnum=="0") document.getElementById("vote_result_"+postid).innerHTML="(谢谢您的参与)";
			   else document.getElementById("vote_result_"+postid).innerHTML="("+vnum+")";
			}
			ajaxobj.send();
   } 
}
function ratings_off(rating_score, insert_half) {
  //if(!is_being_rated) is_being_rated = true;
}

function yc_current_rating(fid,pn,str){
	postid=fid;
	p=pn;
	 if(!yc_is_being_rated) {		
	    document.getElementById("ratings_"+fid+"_text").innerHTML=str;
	 }
}
function yc_rate_post(surl) {
   if(!yc_is_being_rated) {
      yc_is_being_rated = true;
      var ajaxobj=new AJAXRequest;
			ajaxobj.method="GET";
			ajaxobj.url="/"+surl+"/votepro.do?id="+postid+"&p="+p;
			ajaxobj.callback=function(xmlobj) {
			   var ycvnum=xmlobj.responseText.split("$");
			   //alert("vote_result_"+postid+":"+vnum);
			   if(ycvnum[0]=="0") document.getElementById("vote_result_"+postid).innerHTML="(谢谢您的参与)";
			   else 
				{
					document.getElementById("vote_result_"+postid).innerHTML="("+ycvnum[0]+")";
					ycscroe=ycvnum[1];
					if(ycscore>0 && ycscore<1)
					{
					 ycstartshow("starthalf","startem","startem","startem","startem");
					}
					else if(ycscore>1 && ycscore <2)
					{
					 ycstartshow("startall","starthalf","startem","startem","startem");
					}
					else if(ycscore==2.00)
					{
					 ycstartshow("startall","startall","startem","startem","startem");
					}
					else if(ycscore>2 && ycscore <3)
					{
					 ycstartshow("startall","startall","starthalf","startem","startem");
					}
					else if(ycscore==3.00)
					{
					 ycstartshow("startall","startall","startall","startem","startem");
					}
					else if(ycscore>3 && ycscore <4)
					{
					 ycstartshow("startall","startall","startall","starthalf","startem");
					}
					else if(ycscore==4.00)
					{
					 ycstartshow("startall","startall","startall","startall","startem");
					}
					else if(ycscore>4 && ycscore <5)
					{
					 ycstartshow("startall","startall","startall","startall","starthalf");
					}
			        document.getElementById("ratings_"+postid+"_text").innerHTML="";
			   }
			}
			ajaxobj.send();
   } else {
      //alert("你已经投过票了。");
      //document.getElementById("vote_result_"+postid).innerHTML="(你已经投过票了。)";
	  //document.getElementById("vote_result_"+postid).innerHTML="("+ycvnum+")";
   }
}

//当获得鼠标指针时调用的方法
function ycswapImage(n)
{if(!yc_is_being_rated) {
	for(i=1;i<=n;i++)
	{  
		document.getElementById("yc_rating_3_"+i).src="images/fantimg/yc/startall.gif";
	 }
	 	for(j=5;j>n;j--)
	{
		document.getElementById("yc_rating_3_"+j).src="images/fantimg/yc/startem.gif";
	}
}
}
//当失去鼠标指针时调用的方法
function ycImgRestore(n)
{   
	for(i=1;i<=5;i++)
	{
		//var showImage = document.getElementById("rating_3_"+i);
		if(!yc_is_being_rated) {
             document.getElementById("yc_rating_3_"+i).src="images/fantimg/yc/startem.gif";
		 	 //document.getElementById("ratings_"+postid+"_text").innerHTML="";
			 document.getElementById("ratings_"+postid+"_text").innerHTML="点击星号评分";
			
		//if(i<=n)
		//{
		//	showImage.src="images/fantimg/yc/startem.gif";
		//}
		//else
		//{
		//	showImage.src="images/fantimg/yc/startem.gif";
		//}		
	}
 }
}
function ycstartshow(url1,url2,url3,url4,url5)
{
      document.getElementById("yc_rating_3_1").src="images/fantimg/yc/" + url1+".gif";
      document.getElementById("yc_rating_3_2").src="images/fantimg/yc/" + url2+".gif";
	  document.getElementById("yc_rating_3_3").src="images/fantimg/yc/" + url3+".gif";
	  document.getElementById("yc_rating_3_4").src="images/fantimg/yc/" + url4+".gif";
	  document.getElementById("yc_rating_3_5").src="images/fantimg/yc/" + url5+".gif";
}

function yj_current_rating(fid,pn,str){
	postid=fid;
	p=pn;
	 if(!yj_is_being_rated) {		
	    document.getElementById("ratings_"+fid+"_text").innerHTML=str;
	 }
}
function yj_rate_post(surl) {
   if(!yj_is_being_rated) {
      yj_is_being_rated = true;
      var ajaxobj=new AJAXRequest;
			ajaxobj.method="GET";
			ajaxobj.url="/"+surl+"/votepro.do?id="+postid+"&p="+p;
			ajaxobj.callback=function(xmlobj) {
			   var yjvnum=xmlobj.responseText.split("$");


			   //alert("vote_result_"+postid+":"+vnum);
			   if(yjvnum[0]=="0") document.getElementById("vote_result_"+postid).innerHTML="(谢谢您的参与)";
			   else 
				{
					document.getElementById("vote_result_"+postid).innerHTML="("+yjvnum[0]+")";
					yjscore=yjvnum[1];
					if(yjscore>0 && yjscore<1)
					{
					 yjstartshow("starthalf","startem","startem","startem","startem");
					}
					else if(yjscore>1 && yjscore <2)
					{
					 yjstartshow("startall","starthalf","startem","startem","startem");
					}
					else if(yjscore==2.00)
					{
					 yjstartshow("startall","startall","startem","startem","startem");
					}
					else if(yjscore>2 && yjscore <3)
					{
					 yjstartshow("startall","startall","starthalf","startem","startem");
					}
					else if(yjscore==3.00)
					{
					 yjstartshow("startall","startall","startall","startem","startem");
					}
					else if(yjscore>3 && yjscore <4)
					{
					 yjstartshow("startall","startall","startall","starthalf","startem");
					}
					else if(yjscore==4.00)
					{
					 yjstartshow("startall","startall","startall","startall","startem");
					}
					else if(yjscore>4 && yjscore <5)
					{
					 yjstartshow("startall","startall","startall","startall","starthalf");
					}

			      document.getElementById("ratings_"+postid+"_text").innerHTML="";
			   }
			}
			ajaxobj.send();
   } else {
      //alert("你已经投过票了。");
      //document.getElementById("vote_result_"+postid).innerHTML="(你已经投过票了。)";
	  //document.getElementById("vote_result_"+postid).innerHTML="("+yjvnum+")";
   }
}


//当获得鼠标指针时调用的方法
function yjswapImage(n)
{if(!yj_is_being_rated) {
	for(i=1;i<=n;i++)
	{  
		document.getElementById("yj_rating_3_"+i).src="images/fantimg/yc/startall.gif";
	 }
	 	for(j=5;j>n;j--)
	{
		document.getElementById("yj_rating_3_"+j).src="images/fantimg/yc/startem.gif";
	}
}
}
//当失去鼠标指针时调用的方法
function yjImgRestore(n)
{   
	for(i=1;i<=5;i++)
	{
		//var showImage = document.getElementById("rating_3_"+i);
		if(!yj_is_being_rated) {
			 document.getElementById("yj_rating_3_"+i).src="images/fantimg/yc/startem.gif";
			  document.getElementById("ratings_"+postid+"_text").innerHTML="点击星号评分";
		 //document.getElementById("ratings_"+postid+"_text").innerHTML="";
		//if(i<=n)
		//{
		//	showImage.src="images/fantimg/yc/startem.gif";
		//}
		//else
		//{
		//	showImage.src="images/fantimg/yc/startem.gif";
		//}		
	}
 }
}
function yjstartshow(url1,url2,url3,url4,url5)
{
      document.getElementById("yj_rating_3_1").src="images/fantimg/yc/" + url1+".gif";
      document.getElementById("yj_rating_3_2").src="images/fantimg/yc/" + url2+".gif";
	  document.getElementById("yj_rating_3_3").src="images/fantimg/yc/" + url3+".gif";
	  document.getElementById("yj_rating_3_4").src="images/fantimg/yc/" + url4+".gif";
	  document.getElementById("yj_rating_3_5").src="images/fantimg/yc/" + url5+".gif";
}


function eur_current_rating(fid,pn,str){
	postid=fid;
	p=pn;
	 if(!eur_is_being_rated) {		
	    document.getElementById("ratings_"+fid+"_text").innerHTML=str;
	 }
}
function eur_rate_post(surl) {
   if(!eur_is_being_rated) {
      eur_is_being_rated = true;
      var ajaxobj=new AJAXRequest;
			ajaxobj.method="GET";
			ajaxobj.url="/"+surl+"/votepro.do?id="+postid+"&p="+p;
			ajaxobj.callback=function(xmlobj) {
			   var eurvnum=xmlobj.responseText.split("$");
			   //alert("vote_result_"+postid+":"+vnum);
			   if(eurvnum[0]=="0") document.getElementById("vote_result_"+postid).innerHTML="(谢谢您的参与)";
			   else 
				{
					document.getElementById("vote_result_"+postid).innerHTML="("+eurvnum[0]+")";
					eurscore = eurvnum[1];
					if(eurscore>0 && eurscore<1)
					{
					 eurstartshow("starthalf","startem","startem","startem","startem");
					}
					else if(eurscore>1 && eurscore <2)
					{
					 eurstartshow("startall","starthalf","startem","startem","startem");
					}
					else if(eurscore==2.00)
					{
					 eurstartshow("startall","startall","startem","startem","startem");
					}
					else if(eurscore>2 && eurscore <3)
					{
					 eurstartshow("startall","startall","starthalf","startem","startem");
					}
					else if(eurscore==3.00)
					{
					 eurstartshow("startall","startall","startall","startem","startem");
					}
					else if(eurscore>3 && eurscore <4)
					{
					 eurstartshow("startall","startall","startall","starthalf","startem");
					}
					else if(eurscore==4.00)
					{
					 eurstartshow("startall","startall","startall","startall","startem");
					}
					else if(eurscore>4 && eurscore <5)
					{
					 eurstartshow("startall","startall","startall","startall","starthalf");
					}
			      document.getElementById("ratings_"+postid+"_text").innerHTML="";
			   }
			}
			ajaxobj.send();
   } else {
      //alert("你已经投过票了。");
      //document.getElementById("vote_result_"+postid).innerHTML="(你已经投过票了。)";
	  //document.getElementById("vote_result_"+postid).innerHTML="("+eurvnum+")";
   }
}

//当获得鼠标指针时调用的方法
function eurswapImage(n)
{if(!eur_is_being_rated) {
	for(i=1;i<=n;i++)
	{  
		document.getElementById("eur_rating_3_"+i).src="images/fantimg/yc/startall.gif";
	 }
	 	for(j=5;j>n;j--)
	{
		document.getElementById("eur_rating_3_"+j).src="images/fantimg/yc/startem.gif";
	}
}
}
//当失去鼠标指针时调用的方法
function eurImgRestore(n)
{   
	for(i=1;i<=5;i++)
	{
		//var showImage = document.getElementById("rating_3_"+i);
		if(!eur_is_being_rated) {
			document.getElementById("eur_rating_3_"+i).src="images/fantimg/yc/startem.gif";
			 document.getElementById("ratings_"+postid+"_text").innerHTML="点击星号评分";
		 	//document.getElementById("ratings_"+postid+"_text").innerHTML="";
		//if(i<=n)
		//{
		//	showImage.src="images/fantimg/yc/startem.gif";
		//}
		//else
		//{
		//	showImage.src="images/fantimg/yc/startem.gif";
		//}		
	}
 }
}
function eurstartshow(url1,url2,url3,url4,url5)
{
      document.getElementById("eur_rating_3_1").src="images/fantimg/yc/" + url1+".gif";
      document.getElementById("eur_rating_3_2").src="images/fantimg/yc/" + url2+".gif";
	  document.getElementById("eur_rating_3_3").src="images/fantimg/yc/" + url3+".gif";
	  document.getElementById("eur_rating_3_4").src="images/fantimg/yc/" + url4+".gif";
	  document.getElementById("eur_rating_3_5").src="images/fantimg/yc/" + url5+".gif";
}

function euro_current_rating(fid,pn,str){
	postid=fid;
	p=pn;
	 if(!euro_is_being_rated) {		
	    document.getElementById("ratings_"+fid+"_text").innerHTML=str;
	 }
}
function euro_rate_post(surl) {
   if(!euro_is_being_rated) {
      euro_is_being_rated = true;
      var ajaxobj=new AJAXRequest;
			ajaxobj.method="GET";
			ajaxobj.url="/"+surl+"/votepro.do?id="+postid+"&p="+p;
			ajaxobj.callback=function(xmlobj) {
			   var eurovnum=xmlobj.responseText.split("$");
			   //alert("vote_result_"+postid+":"+vnum);
			   if(eurovnum[0]=="0") document.getElementById("vote_result_"+postid).innerHTML="(谢谢您的参与)";
			   else 
				{
					document.getElementById("vote_result_"+postid).innerHTML="("+eurovnum[0]+")";
					euroscroe=eurovnum[1];
					if(euroscore>0 && euroscore<1)
					{
					 eurostartshow("starthalf","startem","startem","startem","startem");
					}
					else if(euroscore>1 && euroscore <2)
					{
					 eurostartshow("startall","starthalf","startem","startem","startem");
					}
					else if(euroscore==2.00)
					{
					 eurostartshow("startall","startall","startem","startem","startem");
					}
					else if(euroscore>2 && euroscore <3)
					{
					 eurostartshow("startall","startall","starthalf","startem","startem");
					}
					else if(euroscore==3.00)
					{
					 eurostartshow("startall","startall","startall","startem","startem");
					}
					else if(euroscore>3 && euroscore <4)
					{
					 eurostartshow("startall","startall","startall","starthalf","startem");
					}
					else if(euroscore==4.00)
					{
					 eurostartshow("startall","startall","startall","startall","startem");
					}
					else if(euroscore>4 && euroscore <5)
					{
					 eurostartshow("startall","startall","startall","startall","starthalf");
					}
			        document.getElementById("ratings_"+postid+"_text").innerHTML="";
			   }
			}
			ajaxobj.send();
   } else {
      //alert("你已经投过票了。");
      //document.getElementById("vote_result_"+postid).innerHTML="(你已经投过票了。)";
	  //document.getElementById("vote_result_"+postid).innerHTML="("+ycvnum+")";
   }
}

//当获得鼠标指针时调用的方法
function euroswapImage(n)
{if(!euro_is_being_rated) {
	for(i=1;i<=n;i++)
	{  
		document.getElementById("euro_rating_3_"+i).src="images/fantimg/yc/startall.gif";
	 }
	 	for(j=5;j>n;j--)
	{
		document.getElementById("euro_rating_3_"+j).src="images/fantimg/yc/startem.gif";
	}
}
}
//当失去鼠标指针时调用的方法
function euroImgRestore(n)
{   
	for(i=1;i<=5;i++)
	{
		//var showImage = document.getElementById("rating_3_"+i);
		if(!euro_is_being_rated) {
             document.getElementById("euro_rating_3_"+i).src="images/fantimg/yc/startem.gif";
		 	 //document.getElementById("ratings_"+postid+"_text").innerHTML="";
			 document.getElementById("ratings_"+postid+"_text").innerHTML="点击星号评分";
			
		//if(i<=n)
		//{
		//	showImage.src="images/fantimg/yc/startem.gif";
		//}
		//else
		//{
		//	showImage.src="images/fantimg/yc/startem.gif";
		//}		
	}
 }
}
function eurostartshow(url1,url2,url3,url4,url5)
{
      document.getElementById("euro_rating_3_1").src="images/fantimg/yc/" + url1+".gif";
      document.getElementById("euro_rating_3_2").src="images/fantimg/yc/" + url2+".gif";
	  document.getElementById("euro_rating_3_3").src="images/fantimg/yc/" + url3+".gif";
	  document.getElementById("euro_rating_3_4").src="images/fantimg/yc/" + url4+".gif";
	  document.getElementById("euro_rating_3_5").src="images/fantimg/yc/" + url5+".gif";
}





/** 
 * AJAX类
 * @author tangh
 */
function AJAXRequest() {
	var xmlObj = false;
	var CBfunc,ObjSelf;
	ObjSelf=this;
	
	if (window.XMLHttpRequest) {       // 在Mozilla, Safari,...非Microsoft浏览器中创建XMLHttpRequest对象
	    xmlObj = new XMLHttpRequest();
	    if (xmlObj.overrideMimeType) {
	        xmlObj.overrideMimeType('text/xml;charset=gbk');
	    }
	} else if (window.ActiveXObject) { // IE,通过MS ActiveX创建XMLHttpRequest
	    try {
	    	// 尝试按新版IE方法创建
	        xmlObj = new ActiveXObject("Msxml2.XMLHTTP");
	    } catch (e) {
	        try {
	        	// 创建请求的ActiveX对象失败,尝试按老版IE方法创建
	            xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
	        } catch (e) {
	        	xmlObj=false;	
	        }
	    }
	}
	
	if (!xmlObj) return false;
	this.method="GET";        //请求方法，字符串，POST或者GET，默认为GET
	this.url;                 //请求URL，字符串，默认为空
	this.async=true;          //是否异步，true为异步，false为同步，默认为true
	this.content="";          //请求的内容，如果请求方法为POST需要设定此属性，默认为空
	this.callback=function(cbobj) {return;} //回调函数，即返回响应内容时调用的函数，默认为直接返回，回调函数有一个参数为XMLHttpRequest对象，即定义回调函数时要这样：function mycallback(xmlobj)
	this.send=function() {    //发送请求，无参数
		if(!this.method||!this.url||!this.async) return false;
		xmlObj.open (this.method, this.url, this.async);
		if(this.method=="POST"){
			 xmlObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); //POST方法,指示请求体包含form数据
		}else{
			xmlObj.setRequestHeader("Content-Type", "text/html; charset=gbk");
		}
		xmlObj.onreadystatechange=function() {
			//alert("ready:"+xmlObj.readyState);
			if(xmlObj.readyState==4) {                //如果请求的状态是“完成”
				//alert("status:"+xmlObj.status);
				if(xmlObj.status==200) {              //检查是否成功接收了服务器响应
					ObjSelf.callback(xmlObj);
				}
			}
		}
		if(this.method=="POST") xmlObj.send(this.content);
		else xmlObj.send(null); //GET方法不用发送
	}
}