//----------------全局变量设置------------------------
var gbook_use=true //true为求片和建议自动转到新的留言本功能，false为保持原来的不变




//----------------全局变量设置------------------------



var xmlHttp;
var bgObj=title=msgObj=null;
//var baocuo_L=100;  //子数限制
//var baocuo_dir=""; //虚拟目录
function qingtiandy_cxhr()
{
	try{
		xmlHttp=new XMLHttpRequest();
		}
	catch(e){
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}	
}
function qingtiandy_$(id){
	return document.getElementById(id);	
}
String.prototype.qingtiandy_Trim = function() { return this.replace(/(^\s*)|(\s*$)/g, "")}
function qingtiandy_bytes(str){
	if(typeof(str)!='string'){
		str = str.value;
	}
	var len = 0;
	for(var i = 0; i < str.length; i++){
		if(str.charCodeAt(i) > 127){
			len++;
		}
		len++;
	}
	return len;
}
function qingtiandy_gbook(v,v2,tag){ 
	if(gbook_use){
		if(tag=="1"){
			qingtiandy_gbook2(v,v2,tag)
			return false
		}else{
			qingtiandy_gbook3(v,v2,tag)
			return false		
		}
	}else{
		if(tag=="1"){
			qingtiandy_gbook2(v,v2,tag)
			return false
		}		
	}
	var msgw,msgh,bordercolor,bgcolor; 
	var titlebordercolor,titlecolor,titlebgcolor,titlefontcolor,buttonstyle,textareastyle
	var str_1
	msgw=400;//提示窗口的宽度 
	msgh=200;//提示窗口的高度 
	titleheight=25 //提示窗口标题高度 
	bordercolor="#C9C9C9";//提示窗口的边框颜色
	bgcolor="#FFFFFF"//提示窗口的背景颜色
	
	titlebordercolor="#FF0000"//提示窗口的标题边框颜色
	titlecolor="#0000FF";//提示窗口的标题颜色 
	titlebgcolor="#00FF00"; //提示窗口的标题字背景颜色
	titlefontcolor="#000000"; //提示窗口的标题字颜色
	
	buttonstyle="BORDER-RIGHT: #c3c1c2 1px solid; BORDER-TOP: #c3c1c2 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #c3c1c2 1px solid; COLOR: #000; BORDER-BOTTOM: #c3c1c2 1px solid; FONT-FAMILY: \"宋体\"; HEIGHT: 22px; BACKGROUND-COLOR: #dbdada; TEXT-ALIGN: center"
	
	textareastyle="BORDER-RIGHT: #c3c1c2 1px solid; BORDER-TOP: #c3c1c2 1px solid; BORDER-LEFT: #c3c1c2 1px solid; BORDER-BOTTOM: #c3c1c2 1px solid; width:88%;margin-bottom:5px"
	
	var sWidth,sHeight; 
	sWidth=document.body.scrollWidth; 
	sHeight=document.body.scrollHeight; 
	bgObj=document.createElement("div"); 
	bgObj.setAttribute('id','bgDiv'); 
	bgObj.style.position="absolute"; 
	bgObj.style.top="0"; 
	bgObj.style.background="#777"; 
	bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75"; 
	bgObj.style.opacity="0.6"; 
	bgObj.style.left="0"; 
	bgObj.style.width=sWidth + "px"; 
	bgObj.style.height=sHeight + "px"; 
	bgObj.style.zIndex = "10000"; 
	document.body.appendChild(bgObj); 

	msgObj=document.createElement("div") 
	msgObj.setAttribute("id","msgDiv"); 
	msgObj.setAttribute("align","center"); 
	msgObj.style.background=bgcolor; 
	msgObj.style.border="1px solid " + bordercolor; 
	msgObj.style.position = "absolute"; 
	msgObj.style.left = (document.documentElement.scrollLeft+document.documentElement.offsetWidth/2-msgw/2)+"px"; 
	msgObj.style.top = (document.documentElement.scrollTop+document.documentElement.offsetHeight/2-msgh/2)+"px"; 
	msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif"; 
	//msgObj.style.marginLeft = "-180px" ; 
	//msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px"; 
	msgObj.style.width = msgw + "px"; 
	msgObj.style.height =msgh + "px"; 
	//msgObj.style.textAlign = "center"; 
	msgObj.style.lineHeight ="25px"; 
	msgObj.style.margin="0";
	msgObj.style.zIndex = "10001"; 

	document.body.appendChild(msgObj); 
 
	
	var txt=document.createElement("div"); 
	txt.style.margin="1em 0" 
	txt.setAttribute("id","msgTxt"); 
	str_1="<textarea name=\"n_content_m\" cols=\"50\" rows=\"10\" style=\""+textareastyle+"\"  id=\"n_content_m\"></textarea><p>"
	str_1=str_1+"<input type='button' value='提交"+qingtiandy_baocuo_type(tag)+"' onclick=\"qingtiandy_m_x_ok('"+v+"',qingtiandy_$('n_content_m').value,"+tag+");\" id=n_content_m_b style='"+buttonstyle+"'>"
	str_1=str_1+"&nbsp;&nbsp;&nbsp;&nbsp;"
	str_1=str_1+"<input type='button' value='关闭' onclick=\"qingtiandy_title_on();\" style='"+buttonstyle+"' id='n_content_m_b2'>"
	txt.innerHTML=str_1
	document.getElementById("msgDiv").appendChild(txt); 
} 
function qingtiandy_title_on(){ 
	document.body.removeChild(bgObj); 
	//document.getElementById("msgDiv").removeChild(title); 
	document.body.removeChild(msgObj); 
}

function qingtiandy_m_x_ok(v,c,tag)
{
	if (qingtiandy_$("n_content_m").value.qingtiandy_Trim()=="")
		alert(qingtiandy_baocuo_type(tag)+"内容不能为空！");
	else
		if (qingtiandy_bytes(qingtiandy_$("n_content_m").value.qingtiandy_Trim())>baocuo_L)
			alert(qingtiandy_baocuo_type(tag)+"内容不能超过"+baocuo_L+"个字节！");	
		else{
			qingtiandy_$("n_content_m_b").value="正在提交......";
			qingtiandy_$("n_content_m_b").disabled="true";
			qingtiandy_$("n_content_m_b2").disabled="true";
			qingtiandy_cxhr();	
			var url=baocuo_dir+"p_inc/baocuo/e_save.asp";
			var t_post="id="+v+"&n_content_m="+escape(document.getElementById("n_content_m").value)+"&tag="+tag;
			xmlHttp.open("post",url,true);
			xmlHttp.onreadystatechange=qingtiandy_m_hsc_ok;
			xmlHttp.setRequestHeader("Content-Length",t_post.length);
			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
			xmlHttp.send(t_post);
		}
}

function qingtiandy_m_hsc_ok()
{
	if(xmlHttp.readyState==4)
	{	
		if (xmlHttp.status==200)
		{
			var temp_x=xmlHttp.responseText;
			var temp_x1,temp_x2,temp_x3,temp_x4,temp_xx;
			if(temp_x.indexOf("########")==-1){
				temp_x1="";
				temp_x2="";
				temp_x3=temp_x;			
				temp_x4="";
			}
			else{
				temp_xx=temp_x.split("########");
				temp_x1=temp_xx[0];//m_id
				temp_x2=temp_xx[1];//m_name
				temp_x3=temp_xx[2];//OK
				temp_x4=temp_xx[3];//1,2,3
			}
			
			if (temp_x3=="ok"){
				if(temp_x1!=""){
					if(g_b_1_2){
						G_go(escape(temp_x1),escape($("n_content_m").value),temp_x4);
					}
				}
				alert("提交成功，谢谢您的参与！")
				qingtiandy_$("n_content_m").value="";
				qingtiandy_$("n_content_m_b").disabled=false;
				qingtiandy_$("n_content_m_b2").disabled=false;
				qingtiandy_title_on();
				
			}
			else{
				if (temp_x3=="##"){
					alert("提交的太频繁，30秒后重试！")
					qingtiandy_$("n_content_m_b").value="提交"
					qingtiandy_$("n_content_m_b").disabled=false;	
					qingtiandy_$("n_content_m_b2").disabled=false;					
				}
				else{
					alert("未能成功提交")
					qingtiandy_$("n_content_m_b").value="提交"
					qingtiandy_$("n_content_m_b").disabled=false;	
					qingtiandy_$("n_content_m_b2").disabled=false;
				}
			}
		}
	}
}

function qingtiandy_baocuo_type(v){
	if(v==1)	
		return "报错"
	else if (v==2)
		return "求片"
	else if (v==3)
		return "建议"
}

function G_go(id,content,tag){
	content="来源：<a href='"+window.location.href+"' target=_blank>"+window.location.href+"</a><br>"+content;
	var h="id="+id+"&n_content_m="+escape(content)+"&tag="+tag;
	//document.write("http://movie.qingtiandy.cn/p_inc/baocuo/Ge_save.asp?"+h+"&it="+Math.random())
	document.getElementById("check_id_1").src="http://movie.qingtiandy.cn/p_inc/baocuo/Ge_save.asp?"+h+"&it="+Math.random();	
}
document.write('<iframe name="check_id_1" id="check_id_1" width="0" height="0" src="_blank" style="display:none"></iframe> ')


function qingtiandy_gbook2(v,v2,tag){
	widthv = "200";
	heightv = "350";	
	xposition = (screen.width - widthv)/2;
	yposition = (screen.height - heightv)/2;
	window.open(baocuo_dir+'p_inc/baocuo/baocuo.asp?m2='+escape(window.location.href)+'&m='+v2,'报错','toolbar=no,Directories=no,location=no,Status=no,,menubar=no,resizable=no,scrollbars=no,width='+widthv+',height='+heightv+',left='+xposition+',top='+yposition)
	
}

function qingtiandy_gbook3(v,v2,tag){
	window.open(baocuo_dir+'gbook/')
	
}