//function initJS(){
//	ReImgSize() //自动缩放代码 
//	initAccessKey()  //转换AccessKey For IE

//}
//查找网页内宽度太大的图片进行缩放以及PNG纠正
 function ReImgSize(){
  for (i=0;i<document("zoom").images.length;i++)
   {
   if (document.all("zoom")){
	if (document.zoom.images[i].width>200)
	 {
       document.zoom.images[i].width="200"
       document.zoom.images[i].outerHTML='<a href="'+document.zoom.images[i].src+'" target="_blank" title="在新窗口打开图片">'+document.zoom.images[i].outerHTML+'</a>'
  	 }
   }
  else{
	if (document.zoom.images[i].width>200) {
	  document.zoom.images[i].title="在新窗口打开图片"
	  document.zoom.images[i].style.cursor="pointer"
	  document.zoom.images[i].onclick=function(e){window.open(this.src)}
	}
  }
  }
 }


//判断浏览器 true是IE false是ff
var isIe=(document.all)?true:false;
// AJAX类
function AJAXRequest() {
	var xmlObj = false;
	var CBfunc,ObjSelf;
	ObjSelf=this;
	try { xmlObj=new XMLHttpRequest; }
	catch(e) {
		try { xmlObj=new ActiveXObject("MSXML2.XMLHTTP"); }
		catch(e2) {
			try { xmlObj=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch(e3) { xmlObj=false; }
		}
	}
	if (!xmlObj) return false;
	this.method="POST";
	this.url;
	this.async=true;
	this.content="";
	this.callback=function(cbobj) {return;}
	this.send=function() {
		if(!this.method||!this.url||!this.async) return false;
		xmlObj.open (this.method, this.url, this.async);
		if(this.method=="POST") xmlObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlObj.onreadystatechange=function() {
			if(xmlObj.readyState==4) {
				if(xmlObj.status==200) {
					ObjSelf.callback(xmlObj);
				}
			}
		}
		if(this.method=="POST") xmlObj.send(this.content);
		else xmlObj.send(null);
	}
}

//弹出方法 弹出DIV
function showMessageBox(DivId,wTitle,mContent,wHeight,wWidth,contentType,showback){
	closeWindow(DivId);
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}


	var bWidth = parseInt(myWidth);
	var bHeight = parseInt(myHeight) > parseInt(document.documentElement.scrollHeight)? parseInt(myHeight) : parseInt(document.documentElement.scrollHeight);
	if(isIe){setSelectState('hidden');}
	var Content = (contentType == 1 ? "<iframe id='mIframe' src='' frameborder='0' width='100%' scrolling='no' height='" + (wHeight - 10) + "'>正在加载...</iframe>" : mContent);
	var styleStr = (showback == 0?("position:absolute;background:#000;width:" + (wWidth + 36) + "px;height:" + (wHeight + 60) + "px;left:" + (myWidth - wWidth - 20)/2 + "px;top:" + (myHeight - wHeight - 20)/2 + "px;z-index:999;"):("top:0px;left:0px;position:absolute;background:#666;width:" + "100%" + ";height:" + bHeight + "px" + ";z-index:999;"));
	styleStr += (isIe)?"filter:alpha(opacity=40);":"opacity:0.40;";
	if(document.getElementById('back') == null){
		var back = document.createElement("div");
		back.id = "back";
		back.style.cssText = styleStr;
		document.body.appendChild(back);
	}else{
		var back = document.getElementById('back');
		back.style.cssText = styleStr;
		back.style.visibility = "visible";
	}


	styleStr = "position:absolute;width:" + wWidth + "px;left:" + (myWidth - wWidth)/2 + "px;top: " + (myHeight - wHeight)/2 + "px;z-index:1000;";
	if(document.getElementById(DivId)==null){
		var mesW = document.createElement("div");
		mesW.id = DivId;
		mesW.className = "mesWindow";
		mesW.innerHTML = "<div class='mesWindowTop'><div class='mesWindowtitle'>" + wTitle + "</div><div class='mesWindowclose'><a href=\"javascript:void(0);\" onclick=\"closeWindow('" + DivId + "')\"></a></div></div>" + Content + "";
		mesW.style.cssText = styleStr;
		document.body.appendChild(mesW);
	}else{
		var mesW = document.getElementById(DivId);
		mesW.style.visibility = "visible";
		mesW.style.cssText = styleStr;
	}
	if(contentType == 1)$('mIframe').src = mContent;
}
//弹出DIV后的背影
function showBackground(obj,endInt){
	obj.filters.alpha.opacity+=5;
	if(obj.filters.alpha.opacity<endInt){
		setTimeout(function(){showBackground(obj,endInt)},8);
	}
}
//设置select的可见状态 
function setSelectState(state){
	var objl=document.getElementsByTagName('select');
	for(var i=0;i<objl.length;i++){
		objl[i].style.visibility=state;
	}
}
//关闭弹出窗口
function closeWindow(s){
	if(document.getElementById('back') != null){
		//document.getElementById('back').parentNode.removeChild(document.getElementById('back'));
		document.getElementById('back').style.visibility = "hidden";
	}
	if(document.getElementById(s) != null){
		//document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));
		document.getElementById(s).style.visibility = "hidden";
	}
	if(document.getElementById('mIframe') != null){
		document.getElementById('mIframe').src = "";
	}
	if(isIe){setSelectState('');}
}
//鹏。小猪 2008-4-1 v1.0
function $() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);
    if (arguments.length == 1) 
      return element;
    elements.push(element);
  }

  return elements;
}

function setCookie (name, value) {
	   var Days = 30; //此 cookie 将被保存 30 天
       var exp = new Date();
	   exp.setTime(exp.getTime() + 1000);
	   if(value==""||value=="null"||value=="null"||value==" "){}else{
       document.cookie = name + "="+ escape(value) +";expires=Sun, 17-Jan-2038 19:14:07 GMT";
	   }
}
function getCookie(sName){
    var aCookie = document.cookie.split("; ");
    for (var i=0; i < aCookie.length; i++)
    {
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0])
        {
            return aCrumb[1];
        }
    }
    return null;
}

function doZoom(size){
	document.getElementById('zoom').style.fontSize=size+'px'
}


function $(id) {
	return document.getElementById(id);	
}
function echo(obj,text) {
	$(obj).innerHTML=text;
}
var xmlhttp;
function createxmlhttp() {
	xmlhttp = false;
	if(window.XMLHttpRequest) { 
		xmlhttp = new XMLHttpRequest();
		if (xmlhttp.overrideMimeType) {
			xmlhttp.overrideMimeType("text/xml");
		}
	}
	else if (window.ActiveXObject) {
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	return xmlhttp;
}
function getdata(url,obj,fun)
{
	xmlhttp=createxmlhttp();
	if(!xmlhttp) {
		alert("请更新你的IE浏览器");
		return;
	}
	if(fun=="") {
		xmlhttp.onreadystatechange=requestdata;
	} else {
		xmlhttp.onreadystatechange=fun;
	}
	xmlhttp.open("get",url,true);
	xmlhttp.setRequestHeader("If-Modified-Since","0");
	xmlhttp.send(null);
	function requestdata() {		
		if(xmlhttp.readyState==4) {
			if(xmlhttp.status==200) {
				echo(obj,xmlhttp.responseText);
			}
			else { 
				alert('访问的页面有问题');
			}
		}		
	}
}
function user(id,index) {
	getdata("/user.asp","userinfo","");
}
function goto(id,index,classid,u,rcount) {
	getdata("/comment.asp?id="+id+"&page="+index+"&u="+u+"&classid="+classid,"comment","");
}
function goldgoto(id,index,rcount) {
	getdata("/comment.asp?id="+id+"&page="+index,"comment","");
}
function checkComment(form) {
  if(form.Content.value.length==0) {
    alert("内容不能为空！");
    form.Content.focus();
    return false;
  }
  if(form.Content.value.length>300) {
    alert("内容太长了！");
    return false;
  }
  return true;
}

function swfprint(furl,fwidth,fheight,transoption)	{
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ fwidth +'" height="' + fheight +'" align="middle">');
	document.write('<param name="movie" value="'+ furl +'"/>');
	if (transoption == "t")	{
		document.write('<param name="wmode" value="transparent"/>');
	} else if	(transoption == "o")	{
		document.write('<param name="wmode" value="opaque"/>');
	}
	document.write('<!-- Hixie method -->');
	document.write('<!--[if !IE]> <-->');
	document.write('<object type="application/x-shockwave-flash" data="'+ furl +'" width="'+ fwidth +'" height="' + fheight +'"');
	if (transoption == "t")	{
		document.write(' wmode="transparent"');
	} else if	(transoption == "o")	{
		document.write(' wmode="opaque"');
	}
	document.write('></object>');
	document.write('<!--> <![endif]-->');
	document.write('</object>');
}