function alertWin(title, msg, w, h){ 
	var iWidth = document.documentElement.scrollWidth; 
	var iHeight = document.documentElement.scrollHeight; 
	var bgObj = document.createElement("div");
	bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:101;";
	document.body.appendChild(bgObj); 
	
	var msgObj=document.createElement("div");
	msgObj.style.cssText = "position:absolute;FONT-SIZE: 12px;top:200px;left:"+(iWidth-w)/2+"px;width:"+w+"px;height:"+h+"px;text-align:center;z-index:102;";
	document.body.appendChild(msgObj);
	
	var table = document.createElement("table");
	msgObj.appendChild(table);
	table.style.cssText = "margin:0px;border:0px;padding:0px;height:28px;line-height:28px;background:#CFD7EC url("+path+"inc/title_bg_left.gif) no-repeat top left;";
	table.cellSpacing = 0;
	var tr = table.insertRow(-1);
	var titleBar = tr.insertCell(-1);
	titleBar.style.cssText = "width:"+(w-22-3)+"px;text-align:left;font-size:12px;font-weight:bold;color:#fff;padding-left:30px;background: url("+path+"inc/titleIco.gif) no-repeat 1px 1px;cursor:move;";
	titleBar.innerHTML = title;
	var moveX = 0;
	var moveY = 0;
	var moveTop = 0;
	var moveLeft = 0;
	var moveable = false;
	var docMouseMoveEvent = document.onmousemove;
	var docMouseUpEvent = document.onmouseup;
	titleBar.onmousedown = function() {
		var evt = getEvent();
		moveable = true; 
		moveX = evt.clientX;
		moveY = evt.clientY;
		moveTop = parseInt(msgObj.style.top);
		moveLeft = parseInt(msgObj.style.left);
		
		document.onmousemove = function() {
			if (moveable) {
				var evt = getEvent();
				var x = moveLeft + evt.clientX - moveX;
				var y = moveTop + evt.clientY - moveY;
				if ( x > 0 &&( x + w < iWidth) && y > 0 && (y + h < iHeight) ) {
					msgObj.style.left = x + "px";
					msgObj.style.top = y + "px";
				}
			}	
		};
		document.onmouseup = function () { 
			if (moveable) { 
				document.onmousemove = docMouseMoveEvent;
				document.onmouseup = docMouseUpEvent;
				moveable = false; 
				moveX = 0;
				moveY = 0;
				moveTop = 0;
				moveLeft = 0;
			} 
		};
	}
	
	var closeBtn = tr.insertCell(-1);
	closeBtn.style.cssText = "cursor:pointer;width:30px;background:url("+path+"inc/close.gif) no-repeat 0 center;";
	closeBtn.onclick = function(){ 
		document.body.removeChild(bgObj); 
		document.body.removeChild(msgObj); 
	}
	var rightBtn = tr.insertCell(-1);
	rightBtn.style.cssText = "padding:3px 3px 0px;height:28px;background:url("+path+"inc/title_bg_right.gif) no-repeat right top;";
	var msgBox = table.insertRow(-1).insertCell(-1);
	msgBox.style.cssText = "FONT-SIZE: 12px;background:#F0FAFF;color:#0076A9;border-right: 1px solid #2C99D2;border-bottom: 1px solid #2C99D2;border-left: 1px solid #2C99D2;";
	msgBox.colSpan  = 3;
	msgBox.innerHTML = msg;
	
    // 获得事件Event对象，用于兼容IE和FireFox
    function getEvent() {
	    return window.event || arguments.callee.caller.arguments[0];
    }
	
	document.getElementById("closew").onclick = function(){
	document.body.removeChild(bgObj); 
	document.body.removeChild(msgObj);
}

if(document.getElementById("sformovie")){
document.getElementById("sformovie").onclick = function onclick(){
var formovieobj=document.getElementById("formoviecontent").value;
if(formovieobj=="")
{
alert("影片描述");
return false;
}
var ajax=new AJAXRequest({
url: path+"inc/formovie.asp?formovie="+formovieobj,
method: "GET",
oncomplete: oncompletecontent,
charset: "GB2312"
});
ajax.get();
}
}

if(document.getElementById("serror")){
document.getElementById("serror").onclick = function (){
var errobj=document.getElementById("errmovie").getElementsByTagName("input");
var errTypeString="";
var errContent="";
var errmovienum="";
var t=false;
for(i=0;i<errobj.length;i++)
{
if(errobj[i].type=="radio" && errobj[i].checked==true)
{
errTypeString=errobj[i].value;
if(errobj[i].value=="其它情况")
{
t=true;
}
}
}
if(t)
{
for(i=0;i<errobj.length;i++)
{
if(errobj[i].type=="text")
{
if(errobj[i].value!="")
errContent=errobj[i].value;
else
{
alert("请填写其它原因");
errobj[i].focus();
return false;
}
break;
}
}
}
$h=true;
for(i=0;i<errobj.length;i++)
{
if(errobj[i].type=="radio" && errobj[i].checked==true)
{
$h=false;
}
}
if($h)
{
alert("请选择报错类型");
return false;
}

$j=true;
for(i=0;i<errobj.length;i++)
{
	if(errobj[i].type=="checkbox" && errobj[i].checked==true){
		$j=false;
	}
}
if($j){
	alert("请选择报错集数");
	return false;
}
var errmovienumid="";
for(i=0;i<errobj.length;i++){
	if(errobj[i].type=="checkbox" && errobj[i].checked==true){
		if(errobj[i].value.indexOf("全集")>-1){
			errmovienumid=errobj[i].id;
			errmovienum+=errobj[i].value+" ";
			}
		if(errobj[i].id==errmovienumid){continue}
		errmovienum+=errobj[i].value+" ";
	}
}

var ajax=new AJAXRequest({
url: path+"inc/movieerror.asp?errTypeString="+errTypeString+"&errContent="+errContent+"&movieid="+movieid+"&errmovienum="+errmovienum,
method: "GET",
oncomplete: oncompletecontent,
charset: "GB2312"
});
ajax.get();
}
}

function oncompletecontent(obj){
	if(obj.responseText){
		alert(obj.responseText);
		document.body.removeChild(bgObj); 
		document.body.removeChild(msgObj);
	}
}

} 

function formovie(){
	var forcontent='<p style="height:30px;width:95%;text-align:left;line-height:30px;margin:0px;padding:0px;">影片描述</p><p style="margin:0px;padding:0px;"><textarea id="formoviecontent" name="formoviecontent" style="height:150px;width:95%;"></textarea></p>';
	forcontent+='<p style="height:30px;line-height:30px;margin:0px;padding:0px;"><input type="button" value="确　定" id="sformovie" style="position:relative;background:url('+path+'inc/btn_bg.gif) no-repeat;width:80px;height:23px;line-height:23px;font-weight:bold;border:0;color:#fff;cursor:pointer;">　<input type="button" value="关　闭" id="closew" style="position:relative;background:url('+path+'inc/btn_bg.gif) no-repeat;width:80px;height:23px;line-height:23px;font-weight:bold;border:0;color:#fff;cursor:pointer;"></p>'
	alertWin('用户求片',forcontent,400,250);
}

function errmovie(){
	var errcontent='<div id="errmovie" style="margin:0px;OVERFLOW: hidden;"><p style="height:25px;width:95%;text-align:left;line-height:25px;margin:0px;padding:0px;">';
	errcontent+='<input name="errType" type="radio" id="errType" value="影片无法播放">影片无法播放!</p>';
	errcontent+='<p style="height:25px;width:95%;text-align:left;line-height:25px;margin:0px;padding:0px;"><input name="errType" type="radio" id="errType" value="影片播放画面与影片名称不符">影片播放画面与影片名称不符!</p>';
	errcontent+='<p style="height:25px;width:95%;text-align:left;line-height:25px;margin:0px;padding:0px;"><input name="errType" type="radio" id="errType" value="其它情况">其它情况</p>';
	errcontent+='<p style="height:25px;width:95%;line-height:25px;margin:0px;padding:0px;text-align:left;"><input name="errContent" type="text" id="errContent" size="36"></p>';
	errcontent+='<div id="errmovieurlname">正在加载影片集数请稍等</div>';
	errcontent+='<p style="height:30px;line-height:30px;margin:0px;padding:0px;"><input type="button" value="确　定" id="serror" style="position:relative;background:url('+path+'inc/btn_bg.gif) no-repeat;width:80px;height:23px;line-height:23px;font-weight:bold;border:0;color:#fff;cursor:pointer;">　<input type="button" value="关　闭" id="closew" style="position:relative;background:url('+path+'inc/btn_bg.gif) no-repeat;width:80px;height:23px;line-height:23px;font-weight:bold;border:0;color:#fff;cursor:pointer;"></p></div>';
	alertWin('用户报错',errcontent,350,185);
	var ajax = new AJAXRequest();ajax.get(path+"inc/movieurlerror.asp?movieid="+movieid,"errmovieurlname");
}

function commentsajax(page){
document.getElementById("moviecommentsdiv").innerHTML="正在加载";
var ajax=new AJAXRequest({
url: path+"inc/comments.asp?id="+movieid+"&templatestype="+templatestype+"&page="+page,
method: "GET",
oncomplete: oncompletecomments,
charset: "GB2312"
});
ajax.get();
}

function oncompletecomments(obj){
	if(obj.responseText){
	comments=obj.responseText.split('<*comments*>');
	document.getElementById("moviecommentsdiv").innerHTML=comments[0];
	var commentsobj=document.getElementsByName("commentspagediv");
		for(i=0;i<commentsobj.length;i++){
			commentsobj[i].innerHTML=comments[1];
		}
	}
}

function fbcomments(){
	if(document.getElementById("c_content").value.length<6 || document.getElementById("c_content").value.length>300){
	alert("评论内容不能小于6个字符 大于300个字符！");
	}else{
	document.getElementById("c_btn").disabled=true;
	document.getElementById("c_btn").value="正在发送数据";
	var ajax=new AJAXRequest({
	url: path+"inc/comments.asp?action=add&c_users="+document.getElementById("c_users").value+"&c_content="+document.getElementById("c_content").value+"&movieid="+movieid,
	method: "GET",
	oncomplete: commentscg,
	charset: "GB2312"
	});
	ajax.get();
	}
}
function commentscg(obj){
	if(obj.responseText){
		document.getElementById("c_btn").disabled=false;
		document.getElementById("c_btn").value="发表评论";
		alert(obj.responseText);
		commentsajax(1);
		document.getElementById("c_users").value="";
		document.getElementById("c_content").value="";
	}
}

function showcheckbox(cname,dname){
if(document.getElementById(cname).checked==true)
{
	document.getElementById(dname).style.display="none";
}
else
{
	document.getElementById(dname).style.display="block";
}
}