function getRecommends(sortid,top,type)//最新推荐
{
	document.getElementById("Recommends").innerHTML = "<span>读取数据...</span>";
	AjaxMethod("/_ajax/RecommendList.aspx", "get", "&sortid=" + sortid + "&top=" + top+"&type="+type, updateRecommends);
}

function updateRecommends(ajax)
{
	var obj = ajax.responseText;
	document.getElementById("Recommends").innerHTML = obj;
}

function getTopDowns(sortid,top,type)//最新下载排行
{
	document.getElementById("TopDowns").innerHTML = "<span>读取数据...</span>";
	AjaxMethod("/_ajax/TopDownList.aspx", "get", "sortid="+sortid + "&top=" + top+"&type=", updateTopDowns);
}

function updateTopDowns(ajax)
{
	var obj = ajax.responseText;
	document.getElementById("TopDowns").innerHTML = obj;
}

function getTopNews(sortid,top,type)//最新更新
{
	document.getElementById("TopNews").innerHTML = "<span>读取数据...</span>";
	AjaxMethod("/_ajax/TopNewsList.aspx", "get", "&sortid=" + sortid + "&top=" + top+"&type="+type, updateTopNews);
}

function updateTopNews(ajax)
{
	var obj = ajax.responseText;
	document.getElementById("TopNews").innerHTML = obj;
}

function getSorts(sortid)//类别列表
{
	document.getElementById("Sorts").innerHTML = "<span>读取数据...</span>";
	AjaxMethod("/_ajax/SortList.aspx", "get", "&bigclass=" + sortid, updateSorts);
}

function updateSorts(ajax)
{
	var obj = ajax.responseText;
	document.getElementById("Sorts").innerHTML = obj;
}

function getDownCount(id)//下载数
{
	document.getElementById("downcount").innerHTML ="<span>读取数据...</span>";
	AjaxMethod("/_ajax/ajax.ashx?method=GetDownCount", "get", "&id=" + id, updateDownCount);
}
function updateDownCount(ajax)
{
	var obj = ajax.responseText;
	document.getElementById("downcount").innerHTML =obj;
}

function getViewCount(id)//查看数
{
	document.getElementById("viewcount").innerHTML ="<span>读取数据...</span>";
	AjaxMethod("/_ajax/ajax.ashx?method=GetViewCount", "get", "&id=" + id, updateViewCount);
}
function updateViewCount(ajax)
{
	var obj = ajax.responseText;
	document.getElementById("viewcount").innerHTML =obj;
}

function getCommendSum(id)//读取支持与反对指数
{
	//document.getElementById("goodrate").innerHTML ="<span>读取数据...</span>";
	AjaxMethod("/_ajax/ajax.ashx?method=GetCommendSum", "get", "&id=" + id, CommendCount);
}
function CommendCount(ajax)
{
	var obj = ajax.responseText;
	var sum = new Array();
	sum = obj.split("|");
	document.getElementById("downcount").innerHTML =sum[2];
	//document.getElementById("goodrate").innerHTML =sum[0];
	//document.getElementById("badraterate").innerHTML =sum[1];
	showBar(sum[0],sum[1]);
}

function showBar(sum1,sum2)
{
	var total = parseInt(sum1)+parseInt(sum2);

	if (total!=0)
	{
		document.getElementById("goodrate").innerHTML ="<div class=\"p_rating\"><div id=\"PercentDiv1\" style=\"background:url(/images/loading_bg.gif) repeat-x; width: "+(sum1/total*100).toFixed(0)*1.3+"px; height: 6px; float:left\"></div></div><div class=\"p_rating1\">"+(sum1/total*100).toFixed(0)+"%(<span id=\"Percent1\">"+sum1+"</span>)</div>";

		document.getElementById("badraterate").innerHTML ="<div class=\"p_rating\"><div id=\"PercentDiv2\" style=\"background: url(/images/loading_bg.gif) repeat-x; width: "+(sum2/total*100).toFixed(0)*1.3+"px; height: 6px; float:left\"></div></div><div class=\"p_rating1\">"+(sum2/total*100).toFixed(0)+"%(<span id=\"Percent2\">"+sum2+"</span>)</div>";
	}
	else
	{
		document.getElementById("goodrate").innerHTML ="<div class=\"p_rating\"></div><div class=\"p_rating1\">0%(<span id=\"Percent1\">"+sum1+"</span>)</div>";

		document.getElementById("badraterate").innerHTML ="<div class=\"p_rating\"></div><div class=\"p_rating1\">0%(<span id=\"Percent2\">"+sum2+"</span>)</div>";
	}


}

function UpdateCommendCount(id)//支持指数
{
	//document.getElementById("goodrate").innerHTML ="<span>提交数据...</span>";
	AjaxMethod("/_ajax/ajax.ashx?method=UpdateCommendSum", "get", "&id=" + id, updateCommendCount);
}

function updateCommendCount(ajax)
{
	var obj = ajax.responseText;
	var sum = new Array();
	sum = obj.split("|");
	//document.getElementById("downcount").innerHTML =sum[2];
	//document.getElementById("goodrate").innerHTML =sum[0];
	//document.getElementById("badraterate").innerHTML =sum[1];
	showBar(sum[0],sum[1]);
}

function UpdateCommendCount1(id)//反对指数
{
	//document.getElementById("badraterate").innerHTML ="<span>提交数据...</span>";
	AjaxMethod("/_ajax/ajax.ashx?method=UpdateCommendSum1", "get", "&id=" + id, updateCommendCount1);
}
function getCommendSum1(id)//反对指数
{
	document.getElementById("badraterate").innerHTML ="<span>读取数据...</span>";
	AjaxMethod("/_ajax/ajax.ashx?method=GetCommendSum1", "get", "&id=" + id, updateCommendCount1);
}

function updateCommendCount1(ajax)
{
	var obj = ajax.responseText;
	var sum = new Array();
	sum = obj.split("|");
	//document.getElementById("downcount").innerHTML =sum[2];
	//document.getElementById("goodrate").innerHTML =sum[0];
	//document.getElementById("badraterate").innerHTML =sum[1];
	showBar(sum[0],sum[1]);
}

//显示软件全部介绍

function displayMoreMemo()
{
	var temp = document.getElementById("memo_1").innerHTML;
	document.getElementById("memo_1").innerHTML = document.getElementById("memo").innerHTML;
	document.getElementById("memo").innerHTML = temp;
}
function moreMemo()
{
	var memoall = $("memo");
	var ovf = memoall.style.overflow;
	memoall.style.height = (ovf=="hidden")?"auto":"200px";
	if(memoall.scrollHeight<200)
	{
		//alert(memoall.style.height);
		memoall.style.height="auto";
		alert('没有更多介绍了');
	}
	$('moreButtonSpan').innerHTML='';
}
function showMoreButton()
{
	var memoall = $("memo");
	if(memoall.scrollHeight>200)
	{
		$('moreButtonSpan').innerHTML='<img src="/images/morememo.gif" alt="更多介绍" style="float:right; margin: 10px 0px 10px 0px;cursor:pointer;" onClick="moreMemo();">';
	}
	else
	{
		memoall.style.height = "auto";
	}
}


//复制宣传

 function copydocurl(obj)
 {
	 var rng = document.body.createTextRange();
	 rng.moveToElementText(obj);
	 rng.scrollIntoView();
	 rng.select();
	 rng.execCommand("Copy");
	 rng.collapse(false);
	 alert('该软件信息的Ubb代码已生成，到论坛直接粘贴即可。');
}
function makeUbbCode(objid)
{
	var str_info = '';
	str_info += document.getElementById('info_' + objid).innerHTML;
	document.getElementById('container').innerHTML =str_info;
	copydocurl(document.getElementById('container'));
	 
}
function selectAll(ckboxname)
{
	o=document.getElementsByName(ckboxname); 
	for(i=0;i<o.length;i++) 
		o[i].checked=event.srcElement.checked 
}





//URL,提交方法,参数,回调函数,聚焦控件ID
function AjaxMethod(url, method, parame, callBack, objID, allowCount)
{
//    if(parame==""){alert("参数为空");return;}
//    allowCount = allowCount || 0;
//    if(Ajax.activeRequestCount>allowCount)return;

	var option	=
    {
	    method:method||"get",
	    parameters: parame + "&" + Math.random(),
	    onFailure:function(){
		    //alert("提交服务器失败!");
	    },	
	    onSuccess:function(transport)
	    {
	        if(callBack!=null)callBack(transport, objID);
	    }
    }
    new Ajax.Request(url, option);
}





