var star = new grede_star();

function grede_star()
{
    this.star_array = document.getElementsByName('poco_star');
	//星数组id
	this.star_cent = document.getElementById("grade");
	//提交评分隐藏值
    this.star_show = document.getElementById('collect_center');
    this.inner_star = document.getElementById('inner_star');

	this.s_star = s_star;
	//显亮星星
	this.c_star = c_star;
	//清除显亮星星
	this.s_start = s_start;
	//提交处理页
	this.s_show = s_show;
	this.s_close = s_close;
	this.s_repeat = s_repeat;
}

function s_star(cent)
{
	for(i=0; i<this.star_array.length; i++)
		{//循环出星星
			if( i< cent)
			{
				this.star_array[i].src = "/img/true_star.gif";
			}
			else {
				this.star_array[i].src = "/img/false_star.gif";
			}
		}
}

//复原星星
function c_star()
{
	for(i=0; i<this.star_array.length; i++)
	{
		if ((i>=solid_star && i) || solid_star == 10)
		{this.star_array[i].src = "/img/false_star.gif";}
		else{this.star_array[i].src = "/img/true_star.gif";}
	}
}
function s_start()
{
	document.form_template_poll.submit();
}
function s_show(docid,grade)
{	
	if (this.star_show != null)
	{
		this.star_show.innerHTML = "<div style='text-align:right;width:560px;line-height:40px;'><span class='mouse' onclick='star.s_close(2)'>X 关闭</span></div><iframe src='/doc.php?action=collect&docid="+docid+"&grade="+grade+"' height=360px frameborder=0 width=100% scrolling=no></iframe>";
		this.star_show.style.display = "block";
	}
}

function s_close(ipt)
{
	if (ipt==2)
	{
		this.star_show.innerHTML = null;
		this.star_show.style.display = "none";
	}else{
		var sign_show = document.getElementById('sign_center');
		sign_show.innerHTML = null;
		sign_show.style.display = "none";

		var nhref = window.parent.location.href;
		nhref = nhref.replace(/html\?(.*)/,'html');
		window.parent.location.reload(nhref);
	}
}

function s_repeat(stars,sign,docid,iscollect,uaction)
{	
	var phref='';
	var ehref='';
	if(uaction){
	phref = "<a href='http://www.tongtalk.com/doc/"+docid+".html?uaction="+uaction+"' target='_blank'>";
	ehref = "</a>";
	}

	this.inner_star.innerHTML = "评分:";
	if (stars == 10)
	{	for (i=1;i<=5;i++)
		{
			this.inner_star.innerHTML += phref+"<img src='/img/false_star.gif' onclick='sign_frame()' onmouseout='star.c_star()' onmouseover='star.s_star("+i+")' class='mouse' name='poco_star' alt='"+i+"分'>"+ehref;
		}
	}else
		{	this.inner_star.innerHTML = "<font color=red>你的评分:</font>";
			var star_solid = true;
			for (i=1;i<=5;i++)
			{
				if (i<=(stars)){srcname = "true_star.gif";}else{srcname = "false_star.gif";}
				if(!iscollect){
				this.inner_star.innerHTML += phref+"<img src='/img/"+srcname+"' onclick='star.s_show("+docid+","+i+")' onmouseout='star.c_star()' onmouseover='star.s_star("+i+")' class='mouse' name='poco_star' alt='"+i+"分'>"+ehref;
				}else{
				this.inner_star.innerHTML += phref+"<img src='/img/"+srcname+"' onclick='star.s_repeat("+i+",1,"+docid+",1)' onmouseout='star.c_star()' onmouseover='star.s_star("+i+")' class='mouse' name='poco_star' alt='"+i+"分'>"+ehref;
				}
			}
		}
	solid_star = stars;

	this.star_cent.value = solid_star;
}


function sign(s_no)
{
	for (i=1;i<=2 ;i++ )
	{
		var new_clear = document.getElementById("sign_in_"+i);
		if (new_clear)new_clear.innerHTML = "";
	}
	var new_sign = document.getElementById("sign_in_"+s_no);
	new_sign.innerHTML = ("	<h2 class=\'mar_tp1 mar_bt3\'>快速注册......　　　　　　　　或 <a href=\'/logging/\'>登录</a><\/h2><form id=\'registerform\' action=\'/register.php\' method=\'post\'><form id=\'registerform\' action=\'/register.php\' method=\'post\'><DIV id=userinfo><span class=\'userinfo_sign\'>你的email地址: <\/span><br \/><input name=\"email_addr\" type=\"text\" class=\"text\" id=\"mail\" title=\"{$lang.regEmail}\" onblur=\"check_email(this.value);\"\/><span id=\"checkemail\">登录用。<\/span><br \/><span class=\'userinfo_sign\'>给自己起个名号 (昵称): <\/span><br \/><input name=\"nick_name\" type=\"text\" id=\"author\" onblur=\"check_user_nick(this.value);\"\/><span id=\"checkusernick\">中、英文均可。<\/span><br \/><span class=\'userinfo_sign\'>设个登录用的密码: <\/span><br \/><input name=\"password\" type=\"password\" class=\"textinput\" id=\"password\" title=\"{$lang.regPassword}\" onblur=\"check_passwd(this.value)\"\/><span id=\"passwdinfo\">6~32位。<\/span><br\/><span class=\'userinfo_sign\'>劳驾填个验证码: <\/span><br\/><input name=\"check_code\" type=\"text\" id=\"usercode\" size=10 \/><span class=mouse>　<img alt=\"{$lang.regCaptcha}\" src=\"/captcha.php\" onClick=\"javascript:this.src=\'captcha.php?\'+Math.random()\" name=\"imgusercode\" id=\"imgusercode\" \/><\/span><input name=\"do[register]\" type=\"submit\" id=\"register\" value=\"完成注册\" \/><\/DIV><\/form>");
}

function sign_frame()
{
		var sign_show = document.getElementById('sign_center');
		sign_show.innerHTML = "<div style='text-align:right;width:560px;line-height:35px;'><a href='/logging' target='_parent'>登录点这里</a>　　　　<span class='mouse' onclick='star.s_close()'>关闭窗口 x</span></div><iframe src='/register.php?uaction=simple' height=360px frameborder=0 width=100% scrolling=no></iframe>";
		sign_show.style.display = "block";
}