/*
function g(namex){if (document.getElementById){return document.getElementById(namex);}else if (document.all){return document.all[namex];}else{return null;}}
function getAjaxUrl(index,requestFile){
	var index; var requestFile;
	ajaxObj[index] = new ajax();
	ajaxObj[index].method="GET";
	ajaxObj[index].responseType="Text";
	ajaxObj[index].loadingType = 2; 
	ajaxObj[index].requestFile=requestFile;
	ajaxObj[index].onCompletion = function(){ showAjaxUrl(index);};
	ajaxObj[index].loadXMLDoc();
	
}
function showAjaxUrl(index){
	//alert(index);
	//alert(ajaxObj[index].response);
	g('_div_rating_vote').innerHTML = ajaxObj[index].response;
}

function voteRating(fileID,voteScore,randID){
	//alert(fileID+" : "+voteScore);
	getAjaxUrl('voteRating_xxx','/Scripts/ajaxrating/voteRating.php?fileID=' + fileID +  '&voteScore=' + voteScore + "&randID=" + randID);
	//getAjaxUrl('voteRating_xxx','/Scripts/ajaxrating/test.php?fileID=' + fileID + '&voteScore=' + voteScore + "&randID=" + randID);

	//g('thongchai').innerHTML='<img src="/imgs/album/s1.gif" border="0" title="โหวต 1 คะแนน" style="cursor:hand"  id="rating_1" onmouseover="swapVoteStar(\'rating\',1,1);" onclick="voteRating(\'1665707\',1,8342);" onmouseout="swapVoteStar(\'rating\',1,0);"><img src="/imgs/album/s1.gif" border="0" title="โหวต 2 คะแนน" style="cursor:hand"  id="rating_2" onmouseover="swapVoteStar(\'rating\',2,1);" onclick="voteRating(\'1665707\',2,8342);" onmouseout="swapVoteStar(\'rating\',2,0);"><img src="/imgs/album/s1.gif" border="0" title="โหวต 3 คะแนน" style="cursor:hand"  id="rating_3" onmouseover="swapVoteStar(\'rating\',3,1);" onclick="voteRating(\'1665707\',3,8342);" onmouseout="swapVoteStar(\'rating\',3,0);"><img src="/imgs/album/s_half.gif" border="0" title="โหวต 4 คะแนน" style="cursor:hand"  id="rating_4" onmouseover="swapVoteStar(\'rating\',4,1);" onclick="voteRating(\'1665707\',4,8342);" onmouseout="swapVoteStar(\'rating\',4,0);"><img src="/imgs/album/s0.gif" border="0" title="โหวต 5 คะแนน" style="cursor:hand"  id="rating_5" onmouseover="swapVoteStar(\'rating\',5,1);"  onclick="voteRating(\'1665707\',4,8342);" onmouseout="swapVoteStar(\'rating\',5,0);">';
}
*/
	function voteRating(itemID,voteScore,randID,type){
			
			//use jquery for ajax
				
				
				$.get(baseURL+"/callback/rating_item", { itemID:itemID,type:type,voteScore:voteScore },
					  function(data){
					   		//alert(data);
							if(data != 'false'){
								$('#rating').html(data);
								alert('คุณได้ทำการ rating เรียบร้อยแล้วค่ะ');
							}else{
								alert('คุณได้เคยทำการ rating คอนเท้นนี้ไปแล้วค่ะ');	
							}
					  });
				
	}
	function swapVoteStar(name,no,original,op){
		var numCount;
		var imgArr = Array("s0.gif","s1.gif","s2.gif","s_half.gif");
		var imgSrc;
		if(op==1){
			imgSrc=baseURL+'/imgs/rate/' + imgArr[2];	
			numCount =no;
				for(i=1;i<=numCount;i++){
						document.getElementById(name + "_" + i).src=imgSrc;
				}
		}else{
			imgSrc=baseURL+'/imgs/rate/' + imgArr[original];
			//numCount=5;
			document.getElementById(name + "_" + no).src=imgSrc;
		}
			
			
	}

	function defaultVoteStar(name,unit,score){

				var numCount=2;
				var baseNum;
				var tmpMod;
				var currentNo=0;
				if(unit==0){
					baseNum= 0;
					tmpMod = 0;	
				}else{
					baseNum=parseInt(score/unit);
					tmpMod = score%unit ;
					
				}
				
				 
				for(i=1;i<=baseNum;i++){
						currentNo=currentNo+1;
						document.getElementById(name + "_" + i).src=baseURL+"/imgs/rate/s1.gif";
				}
			
				if(tmpMod != 0){
						currentNo=currentNo+1;
						//if((tmpMod * 2) >= unit){
						//		document.getElementById(name + "_" + currentNo).src=baseURL+"/imgs/rate/s1.gif";
						//}else{
								document.getElementById(name + "_" + currentNo).src=baseURL+"/imgs/rate/s_half.gif";
						//}
				}
				for(j=(currentNo+1);j<=5;j++){
					document.getElementById(name + "_" + j).src=baseURL+"/imgs/rate/s0.gif";
				}
				
	}
