var beforID="Latest";
//是否全选
var isSelect = true;
//本视频是否投票
var isVotes = false;
var nowSelect='';
var fristRun = true;
var searchURL = "http://search.jongo.com";
function changeList(id)
{
	
	nowSelect = id;
	isSelect = true;
	document.getElementById(beforID).className = "";
	//需要高亮的DIV
	document.getElementById(id).className = "ClassOn";
	//document.getElementById('select_id').innerHTML = "Select All";
	beforID = id;
	document.getElementById('Content').innerHTML = "<div align='center'><img src='"+imageUrl+"images/icons/indicator_medium.gif'></div>";
	if (id=="top20")
	{
		document.getElementById('left_tip').innerHTML = "&nbsp;This week's top 10 videos.";
		ajaxForGet('getTop20');
	}else if (id=="Latest")
	{
		document.getElementById('left_tip').innerHTML = "&nbsp;Latest Uploaded Videos.";
		ajaxForGet('getLatestVideo');
		fristRun = false;
	}else if (id=="Related")
	{
		var keyword = document.getElementById('video_tags').value;
		
		document.getElementById('left_tip').innerHTML = "&nbsp;Videos with similar tags.";
		ajaxForGet('getResultForVideo&keyword='+keyword);
		
	}else if (id=="History")
	{
		document.getElementById('left_tip').innerHTML = "&nbsp;Editor's choice.";	
		ajaxForGet('getEditorChoice&vid='+historyView);
	}
    
}
function ajaxForGet(url)
{

	var action = url;
	new Ajax.Request('ajaxAPI.php?action='+url, {
		onSuccess:function(request)
		{
			resultForGet = request.responseText;
			document.getElementById('Content').innerHTML = resultForGet;
			//clearInterval (callid);
			//eval(action)(resultForGet);
			//showResult(resultForGet);
		}
	});
} 
function showstar(x){
	if (!isVotes)
	{
		for (var i=1; i<x; i++)
		{
			document.getElementById("star"+i).src=imageUrl+"images/common/5star_on.gif";

		}
		document.getElementById("star"+x).src=imageUrl+"images/common/5star_on.gif";
		document.getElementById('votes').title="Total scores:"+x*2;
		document.getElementById('votes').name=x*2;
	}
}

function votes(num)
{
	if (!isVotes)
	{
		isVotes = true;
		new Ajax.Request('ajaxAPI.php?action=votes&vid='+playVid+'&rate='+num, {
			onSuccess:function(request)
			{
				resultForGet = request.responseText;
				if (resultForGet!="b")
				{
					document.getElementById('viewRate').innerHTML='('+Math.round(resultForGet.split('|')[0])+')' +getStart(resultForGet);
					alert('Thanks for rating!');
				}else
				{
					alert('The vote fails!');
					isVotes = false;
				}
			}
		});
	}
}

function clearstar()
{
	if (!isVotes)
	{
		for (var i=1; i<6; i++)
		{
			document.getElementById("star"+i).src=imageUrl+"images/common/5star_off.gif";
		}
	}
}






