$(document).ready(function()
{
	$(".jq_comment").click(comment);
	$(".jq_jump").click(jump);
	$(".jq_star").mouseover(focusstar);
	$(".jq_star").click(subscore);
	$(".jq_starbar").mouseout(resetstar);
	$(".jq_paste_ubb").click(ubb);
	$(".jq_paste_html").click(html);
});


function ubb()
{
	var text = "[flash]http://js.tudouui.com/bin/hezuo/neotv/Neotv_0.swf?id="+$(".jq_index_oid").val()+"[/flash]";
	if(clipboardData.setData("text",text))
	{
		alert("已将转贴代码复制到剪切板");
	}
	return false;
}
function html()
{
	var text = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" type="application/x-shockwave-flash" data="http://js.tudouui.com/bin/hezuo/neotv/Neotv_0.swf" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="456" height="400" id="neotv">' +
			   '<param name="movie" value="http://js.tudouui.com/bin/hezuo/neotv/Neotv_0.swf" />' +
			   '<param name="quality" value="high" />' +
			   '<param name="wmode" value="transparent">' +
			   '<param name="flashvars" value="id='+ $(".jq_index_oid").val() +'">' +
			   '<param name="menu" value="false">' +
			   '<param name="scale" value="noscale">' +
			   '<param name="salign" value="tl">' +
			   '<param name="allowfullscreen" value="true">' +
			   '<param name="allowscriptaccess" value="always">' +
			   '<embed wmode="transparent" src="http://js.tudouui.com/bin/hezuo/neotv/Neotv_0.swf" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id='+ $(".jq_index_oid").val() +'" width="456" height="400"></embed>' +
			   '</object>';
	if(clipboardData.setData("text",text))
	{
		alert("已将转贴代码复制到剪切板");
	}
	return false;
}

function subscore()
{
	$.post("/videopl/score",
	{
		vid:$(".jq_index_vid").val(),
		score:$(this).attr("star")
	},
	function(html)
	{
		$(".jq_starbar").html(html);
		$(".jq_starbar").unbind();
	});
}

function resetstar()
{
	var score = $(".jq_starbar").attr("score");
	
	$(".jq_star").each(function()
	{
		if($(this).attr("star") < score)
		{
			$(this).attr("src","/images/d39.gif");
		}
		if($(this).attr("star") >= score)
		{
			$(this).attr("src","/images/d43.gif");
		}

	});

}
function focusstar()
{
	var num = $(this).attr("star");
	$(".jq_star").each(function()
	{
		if($(this).attr("star") <= num)
		{
			$(this).attr("src","/images/d39.gif");
		}
		if($(this).attr("star") > num)
		{
			$(this).attr("src","/images/d43.gif");
		}

	});
}

function comment()
{
	var c = $(".jq_c").val();
	if(c == "")
	{
		alert("请填写评论的内容");
		return false;
	}
	auth( send_comment , login_send_comment);
}

function jump()
{
	var page = $(this).attr("page");
	$.post("/videopl/page",
	{
		cid:$(".jq_index_cid").val(),
		page:page
	},
	function(html)
	{
		$(".jq_page").html(html);
		$(".jq_jump").click(jump);
	});
}

function login_send_comment()
{
	var u = $(".jq_u").val();
	var p = $(".jq_p").val();
	if( u  == "" || p == "")
	{
		alert("请填写用户名及密码");
		return;
	}
	login(u, p, send_comment, login_fail);
}
function login_fail()
{
	alert("用户名或密码错误");
}


function send_comment()
{
	var username = $.cookie('nt_username');
	$(".jq_nologin").html('<td width="260">欢迎您，'+username+'，请发表观点</td><td align="center"><img class="jq_comment" style="cursor:pointer" src="/images/d40.gif" width="115" height="28" /></td>');
	$(".jq_comment").click(comment);
	$.post("/videopl/comment",
	{
		cid: $(".jq_index_cid").val(),
		vid: $(".jq_index_vid").val(),
		content: $(".jq_c").val()
	},
	function(xml)
	{
		if(!check(xml))
		{
			alert("服务器正忙，请稍后再试.");
		}
		else
		{
			$(".jq_c").attr("value","");
			$.post("/videopl/page",
			{
				cid:$(".jq_index_cid").val()
			},
			function(html)
			{
				$(".jq_page").html(html);
				$(".jq_jump").click(jump);
			});
		}
	});
}
