var executeCompeleted = null;
var GYL = {username:'游客', filmId:0};

$(document).ready(function() {
	if (document.location.href.indexOf('flag=gyjjl') == -1) return;
	
	var s = document.location.href;
	GYL.filmId = s.substring(s.indexOf('/vod/')+5, s.indexOf('.shtml'));
	
	if ($('#div_logined').css('display') != 'none') {
		GYL.username = $('#logined_username').text();
		if (GYL.username.length <= 0) GYL.username = '游客';
	}
	
	//提交
	GYL.TJ = function() {
		var hh = $('input[name="GYL_HH"]:checked').val();
		$.ajax({
			type : 'GET',
			url : 'http://www.m1905.com/pubfunc/gradevote.php?dosubmit=1&point=1&specialid=634&pageid=' + GYL.filmId + '&typeid=' + hh,
			async : false,
			dataType : 'json',
			
			success : function(data) {
				hh = data.status == 'ok' ? 'ok' : data.msg;
			}
		});
		
		var ly = $.trim($('#GYL_LY').val());
		if (ly != '') $.ajax({
			type : 'POST',
			url : 'http://www.m1905.com/comment/',
			data : {action:'ajaxComment', keyid:'phpcms-content-title-'+GYL.filmId, comment:ly},
			async : false,
			dataType : 'json',
			
			success : function(data) {
				ly = data.status == 'ok' ? 'ok' : data.msg;
			}
		});
		
		if (hh == 'ok' || ly == 'ok') {
			alert('谢谢参与！');
			window.onbeforeunload = null;
			GYL.GB();
		}else {
			alert(hh);
		}
	}
	
	//关闭
	GYL.GB = function() {
		$('#divGYL').css('display', 'none');
		$('#live_SWF').css('display', '').parent().css('height', 'auto');
	}
	
	//展示
	GYL.ZS = function() {
		$('#live_SWF').css('display', 'none').parent().css('height', '400px');
		$('#divGYL').css('display', '');
	}
	executeCompeleted = GYL.ZS;
	
	var oDiv = document.createElement('div');
	oDiv.id = 'divGYL';
	oDiv.style.display = 'none';
	document.body.appendChild(oDiv);
	
	s = '\
<style type="text/css">\
.tanchu_box{z-index:121; width:668px; height:398px;background:url(../m_images/css/special/gyjjl/images/tanchu_d.jpg)  no-repeat; position:absolute; top:400px; left:500px;}\
.tachu_titile{ width:94%; padding-left:3%; font-size:14px; font-weight:bold; color:#fff; height:30px; line-height:30px;}\
.tachu_titile span{ float:right; padding-top:5px;}\
.tcbox_left{ width:180px; padding-left:10px; padding-top:12px; float:left;}\
.tcbox_left h4{ padding-left:10px; height:30px; line-height:30px; font-size:12px; color:#010101; margin:0px;color:#000;}\
.tcbox_left h4 a,.tcbox_left dl p a,.tcbox_right dl dd a{ color:#000;}\
.tcbox_left dl{ padding-top:6px;}\
.tcbox_left dl img{ border:1px solid #bababa; padding:1px;}\
.tcbox_left dl p{ margin-top:8px; width:100%; text-align:center; height:20px; line-height:20px;}\
.tcbox_right{ width:455px; height:310px; padding-right:15px; padding-top:13px; float:right;}\
.tcbox_right h4{ padding-left:10px; height:30px; line-height:30px; font-size:13px; color:#010101; margin:0px;color:#000; text-align:center; font-weight:normal; display:block;}\
.tcbox_right h4 span{ margin:0px 10px 0px 8px;}\
.tcbox_right h4 span input{ padding-right:4px;}\
.tcbox_right dl{ padding-top:10px; width:100%; margin:0px; }\
.tcbox_right dl dt{ width:200px; height:280px; padding-top:14px; line-height:20px; color:#666666; text-indent:2em;padding-left:18px; float:left;}\
.tcbox_right dl dt div{height:250px;}\
.tcbox_right dl dt samp{background:url(../m_images/css/special/gyjjl/images/tc_dt01.jpg) no-repeat; width:120px; height:28px; line-height:28px; text-align:center; display:inline-block; float:right; text-indent:0;}\
.tcbox_right dl dd{ width:214px; float:right; display:block;}\
.tcbox_right dl .dundong{ height:260px; width:214px; border:1px solid #e3e3e3; line-height:22px; color:#666666;  }\
.tcbox_right dl dd span{background:url(../m_images/css/special/gyjjl/images/tc_dt02.jpg) no-repeat; width:73px; height:28px; line-height:28px; text-align:center; display:inline-block; margin-top:8px; margin-right:10px; float:right;}\
</style>\
<div class="tanchu_box">\
  <div class="tachu_titile"><span style="cursor:pointer"><a onclick="GYL.GB();"><img src="../m_images/css/special/gyjjl/images/chazi.jpg" /></a></span>电影江湖红黑榜</div>\
  <div class="tcbox_left">\
    <h4><a>' + GYL.username + '</a></h4>\
    <dl><a><img width="175" height="250" src="../m_images/css/special/gyjjl/images/tc_img.jpg" alt="" /></a><p><a href="http://www.m1905.com/zhuanti/gyjjl/" target="_blank">返回专题首页</a></p></dl>\
  </div>\
  <div class="tcbox_right">\
    <h4>您对此片的评价:<span><input id="GYL_HH1" name="GYL_HH" type="radio" value="1" checked/><label for="GYL_HH1">好片</label></span><span><input id="GYL_HH0" name="GYL_HH" type="radio" value="2"/><label for="GYL_HH0">坏片</span></label></h4>\
     <dl>\
       <dt>\
         <div>如果想对影片发表一句话影评，请在右侧文本框中输入您的影评，然后发表留言即可。同时，电影网特举办暑期档影评大赛活动，您可以点击我要参加影评大赛按钮，进入您的博客写出您对本部影片的精彩影评，然后将博文地址贴到影评大赛的活动地址：<a href="http://bbs.m1905.com/thread-599722-1-1.html" target="_blank">http://bbs.m1905.com/thread-599722-1-1.html</a> 即有机会赢取千元大奖，还等什么，快来参与吧！</div>\
         <samp><a href="http://bbs.m1905.com/thread-599722-1-1.html" target="_blank">我要参加影评大赛</a></samp>\
       </dt>\
       <dd class="dundong">\
         <textarea id="GYL_LY" style="border:0; color:#666666; height:240px; overflow-y:scroll; width:200px; padding:8px; font-size:12px;"></textarea>\
       </dd>\
       <dd><span><a style="cursor:pointer" onclick="GYL.TJ();">提交</a></span></dd>\
       </dl>\
  </div>\
</div>\
<div style="background-color:rgb(240,240,240); position:absolute; left:0; top:0; padding:0; margin:0; opacity:0.5; z-index:120; width:1664px; height:1017px; filter:alpha(opacity=10);" id="pbc"></div>\
';
	$('#divGYL').html(s);
	$('.tanchu_box').css('left', ($(window).width() - 668) / 2  + 'px');
	$('#pbc').css('width', $(document).width() + 'px').css('height', $(document).height() + 'px');
	
	window.onbeforeunload = function() {
		GYL.ZS();
		return '请评价后再离开本页';
	}
});

