var pjed = false;
function pj(st,softId)
{
	if(pjed==true)
	{
		alert('评价过了。');
		return;
	}
	var pjUrl = "/soft_pj.php?st="+st+"&id="+softId;
	ajx.FuncCall = 'default2';
	ajx.fget(pjUrl,pjBack);
	pjed=true;
}

function pjBack(oo)
{
	if (oo.state=="success")
	{
		var msg = decodeURIComponent(oo.msg);
		score = getInnerText($("rowpj"+oo.st));
		var txt = parseInt( score ) + 1 ;
		setInnerText($("rowpj"+oo.st),txt);
	
		document.getElementById('width1').style.width = oo.width1;		
		document.getElementById('width2').style.width = oo.width2;
		var h=document.getElementById('hpl').style.width = oo.width1;
		var f=document.getElementById('fpl').style.width = oo.width2;
		setInnerText($('hpl'),h);
		setInnerText($('fpl'),f);
		alert('感谢你的投票')
	}
	else if(oo.state=="fail")
	{
		alert(oo.msg);
	}
	else
	{
		alert( '未知错误' );
	}
}

function getInnerText(obj){
  return document.all?obj.innerText:obj.textContent;
}

function setInnerText(obj,txt){
  return document.all?obj.innerText=txt:obj.textContent=txt;
}

function updateScore()
{
	goodScore = parseInt( $("Percent1").innerText );
	badScore = parseInt( $("Percent2").innerText );
	newt = parseInt($( "totalPjScore" ).value)+1;
	$('PercentDiv1').style.width = parseInt((goodScore/newt)*150) + "px";
	$('PercentDiv2').style.width = parseInt((badScore/newt)*150) + "px";
	//alert( newt + "\n" + badScore + " = "+ goodScore);
}

function softCount(vid)
{
	//return;
	var request_url = "/softCount.php?id="+vid;
	$('downClick').src=request_url;
}
function thundDown(vid,a)
{
	softCount(vid);
	return OnDownloadClick_Simple(a,2,4);
}

function fgDown(_fga,_fgb,_fgc,vid)
{
	softCount(vid);
	return ConvertURL2FG(_fga,_fgb,_fgc);
}

function ConvertURL2FG(url,fUrl,uid)
{	
	try{
		FlashgetDown(url,uid);
	}catch(e){location.href = fUrl;}
}
function Flashget_SetHref(obj,uid){obj.href = obj.fg;}

function postToBbs(vid)
{
	ie = (document.all)? true:false
	if (ie){
		fShowWaiting();
		var obj = document.getElementById('softDetailBbsPost');
		var d=obj.innerText; 
		window.clipboardData.setData('text', d);
		window.setTimeout(hiddenMsg,1000);
	}
}

function hiddenMsg()
{
	var obj = document.getElementById('tbMsg');
	obj.style.display="none";
}

function fShowWaiting(){
	try{
		var msg = document.getElementById("tbMsg");
		var o = get_position();
		msg.style.left=o.x;
		msg.style.top=o.y;
		msg.style.display = "";
	}catch(e){

	}
}
function get_position(){
	var e = window.event.srcElement;
	var e1=e;
	var l=e.offsetLeft;t=e.offsetTop; 
	while(e=e.offsetParent){t+=e.offsetTop;l+=e.offsetLeft;};
	l+=e1.scrollWidth; 
	t+=e1.scrollHeight;
	return {x: l, y: t};
}


//显示软件全部介绍
function moreContent()
{
	var c_all = $("content_all");
	var ovf = c_all.style.overflow;
	c_all.style.height = (ovf=="hidden")?"auto":"400px";
	if(c_all.scrollHeight<400)
	{
		//alert(c_all.style.height);
		c_all.style.height="auto";
		alert('没有更多介绍了');
	}
	c_all.style.overflow = (ovf=="hidden")?"visible":"hidden";
	if(c_all.style.overflow == "hidden")
	{
		$('moreButtonSpan').innerHTML='<div class="gnr_bu"><a href="javascript:moreContent();" style="color:red"><img src="/templets/default/img/wimg.gif"></a></div>';
	}
	else
	{
				$('moreButtonSpan').innerHTML='<div class="gnr_bu"><a href="javascript:moreContent();" style="color:red"><img src="/templets/default/img/wimg1.gif"></a></div>';

	}
}
function showMoreButton()
{
	var c_all = $("content_all");
	if(c_all.scrollHeight>400)
	{
		//$('moreButtonSpan').innerHTML='[<a href="javascript:moreContent();" class="cRed">完整介绍</a>]';
		$('moreButtonSpan').innerHTML='<div class="gnr_bu"><a href="javascript:moreContent();" style="color:red"><img src="/templets/default/img/wimg.gif"></a></div>';
		
	}
	else
	{
		c_all.style.height = "auto";
	}
}
