function killErrors() {return true;}
window.onerror = killErrors;
/*************************
定义全局变量
*************************/
var screenwidth
var screenheight
/*************************
为全局变量赋值
*************************/
screenwidth = screen.width     //屏幕宽度
screenheight = screen.height   //屏幕高度
/*************************
判断是否是空或者空格
*************************/
function checkspace(checkstr) {
	var str = '';for(i = 0; i < checkstr.length; i++) {str = str + ' ';}
	return (str == checkstr);
}
/*************************
 * 功能：判断是否在逗号分割的字符串内
 * 参数：逗号分割的字符串，字符串
*************************/
function checkStringInArrayStrings(strings,str)
{
    if(strings=="")return false;
    var arrayStrings=strings.split(",");
    for (j = 0; j < arrayStrings.length; j++)
    {if(str==arrayStrings[j]){return true;}}
    return false;
}
/*************************
 * 功能：去掉字符串右的逗号
 * 参数：字符串
*************************/
function TrimRightDot(str)
{
    if(str=="")return str;
    if(str.substring(str.length-1,str.length)==",")
    {return str.substring(0,str.length-1);}
    else{return str;}
}
/*************************
//检查邮箱是否正确
*************************/
function IsMail(ChkStr) 
{
var isEmail1    = /^\w+([\.\-]\w+)*\@\w+([\.\-]\w+)*\.\w+$/;
var isEmail2    = /^.*@[^_]*$/;
return ((isEmail1.test(ChkStr)) && (isEmail2.test(ChkStr)));
}
/*************************
 * 功能：复选框全选
 * 参数：checkBoxName
 *             复选框名字
 * 调用示例：
 *     页面复选框，如：
 *         struts标签 <html:multibox property="checkFlag">0</html:multibox>
 *         或html标签 <input type="checkbox" name="checkFlag" value="0">   
 *     按钮或者连接中增加onclick事件，如：
 * <input type="button" name="checkAll" value="全选" onclick="checkAll('checkFlag')">
*************************/
function checkAll(checkBoxName)
{
    var checkBox = document.getElementsByName(checkBoxName);
    for (var i = 0; i < checkBox.length; i++)
    {var temp = checkBox[i];temp.checked = true;}
}
/*************************
 * 功能：复选框全不选
 * 参数：checkBoxName
 *             复选框名字
*************************/
function checkNone(checkBoxName)
{
    var checkBox = document.getElementsByName(checkBoxName);
    for (var i = 0; i < checkBox.length; i++)
    {var temp = checkBox[i];temp.checked = false;}
}
/*************************
 * 功能：复选框反选
 * 参数：checkBoxName
 * 复选框名字
*************************/
function checkReverse(checkBoxName)
{
    var checkBox = document.getElementsByName(checkBoxName);
    for (var i = 0; i < checkBox.length; i++)
    {var temp = checkBox[i];temp.checked = !temp.checked;}
}
/*************************
展开和折叠层
*************************/
function deploy(ID)
{
	obj=document.getElementById(ID);
	if(obj.style.display=="none"){obj.style.display="";}
	else{obj.style.display="none";}
	return false;
}
/*************************
确保div有个最小值
*************************/
function minheight(ID,height){
	obj=document.getElementById(ID);
	if(obj)
	{
	    if(obj.offsetHeight <height){obj.style.height=height+"px";}
	}
}
//获取页面的内容
function GetAjax(url)
{
		var faileStr = "";
		var xmlHttp;
		try
		{
		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try{xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");}
			catch(e){return faileStr;}
		}
		try
		{
			xmlHttp.Open("GET",url,false);
			xmlHttp.Send();
			strRtn = xmlHttp.responseText;
			if(strRtn != null && strRtn != "")
			{
				return strRtn;
			}
		}
		catch(e)
		{
			return faileStr;
		}
		return faileStr;
}
/*************************
动态关闭div
*************************/
function closediv(o)
{  
    var Intervalclosediv;
    o.style.height = o.clientHeight 
    var cy = parseInt(o.style.height);
    if(cy > 5)
    {
        o.style.height = (cy - Math.ceil(cy/5)) +"px";
        Intervalclosediv = setInterval(function(){closediv(o)},100);
    }
    else
    {
        clearInterval(Intervalclosediv);
        o.style.display="none";
    }
}
/*更换显示样式*/ 
function setTab(name,cursel,n){ 
for(i=1;i<=n;i++){ 
var menu=document.getElementById(name+"_"+i); 
var con=document.getElementById(name+"_"+i+"_con"); 
menu.className=i==cursel?"hover":""; 
con.style.display=i==cursel?"block":"none"; 
} 
} 
function setTab1(name,cursel)
{ 
    var divObj=$(name);
    var arr=divObj.getElementsByTagName('li') ;  
    
    for(var i=0 ;i<arr.length+1;i++)
    {
        var menu=$(name+"_"+i); 
        var con=$(name+"_"+i+"_con"); 
        
        if(menu)
        menu.className=i==cursel?"hover":""; 
        if(con)
        con.style.display=i==cursel?"block":"none"; 
    }
}
/*************************
去掉字符串右边的，
*************************/
function GetRidOfRightDot(str)
{
	var rightdot=str.substring(str.length-1);
	if(rightdot==","){return str.substring(0,str.length-1);}
	else{return str;}
}
/*************************
打开窗口
*************************/
function windowopen(sUrl,iWidth,iHeight,sResize)
{
	if(iWidth==0)iWidth=600
	if(iHeight==0)iHeight=450	  
	if(sResize=="yes")
	{
		l = (screenwidth - iWidth)/2-5
		t = (screenheight - iHeight)/2-20
	}
	else
	{
		l = (screen.width - iWidth)/2-5
		t = (screen.height- iHeight)/2-20
		sResize = "no"
	}

	var ff_submain = window.open("","","scroll=auto,resizable=" + sResize + ",status=1,width="+iWidth+",height="+iHeight+",left="+l+",top="+t)

	if (sUrl!="")
	{
		ff_submain.document.location.href = sUrl
	}
}
/*************************
判断是否定义
*************************/
function isVarDefined(obj) {
	if(typeof(obj) == "undefined") {
		return false;
	} else {
		return true;
	}
}
/*************************
图片预先浏览
*************************/
function previewPhoto(pfile)
{
    var photoName=pfile.value;
    var i = photoName.lastIndexOf("."); //取得文件名中最后一个"."的索引  
    var strExt = photoName.substring(i); //获取文件扩展名  
    if (strExt.toLowerCase() == ".gif" || strExt.toLowerCase() == ".jpg" || strExt.toLowerCase() == ".jpeg")
    {
        var htm = "<img border=0 width=200px src='" + photoName + "' onload='DrawImage(this);' />";		
        document.getElementById("PicUpload1_divPhoto").innerHTML =htm;
    }
    else
    {
        document.getElementById("PicUpload1_divPhoto").innerHTML = "图片格式不正确，必须是gif、jpg或者jpeg";
    }
}
/*************************
约束图片宽度
*************************/
function fixImagesWidth(_id,_maxwidth)
{	
	var elem=document.getElementById(_id);
	var images=elem.getElementsByTagName("img");
	for(var i=0;i<images.length;i++)
	{
			if(images[i].offsetWidth > _maxwidth)
			{
				images[i].style.width=_maxwidth+"px";
			}
	}
}
/*************************
//图片按比例缩放
//调用：<img src="图片" onload="javascript:DrawImage(this)">
*************************/
function DrawImage(ImgD,iwidth,iheight)
{
		var image=new Image();
		image.src=ImgD.src;
		if(image.width>0 && image.height>0)
		{
				if(image.width/image.height>= iwidth/iheight)
				{
						if(image.width>iwidth)
						{ 
							ImgD.width=iwidth;
						}
				}
				else
				{
						if(image.height>iheight)
						{ 
							ImgD.height=iheight;
						}
				}
		}
} 
/*************************
打印函数
*************************/
function p$(string){document.write(string);}
/*************************
获取函数
*************************/
function $(id){return document.getElementById(id);}
/*************************
随机数
*************************/
function rnd(n){return Math.floor(Math.random()*n);}
/*************************
菜单操作
*************************/
function change_menu(id,content_id,num,total_ztc_menu,menu_on,menu_off){
for (var i=1;i<=total_ztc_menu;i++){
$(id+i).className=menu_off;
$(content_id+i).style.display='none';
}
$(id+num).className=menu_on;
$(content_id+num).style.display='block';
}

/*************************
对象的绝对位置
var x=getOJ(obj)[0];
var y=getOJ(obj)[1];
*************************/
function getOJ(e) //
{ 
    var t = [e.offsetLeft,e.offsetTop]; 
    if(e=e.offsetParent)
    {
    var r = getOJ(e);
    t[0] += r[0];
    t[1] += r[1];
    }
    return t;
}  
/*************************
复制
*************************/
    function copyToClipBoard(){
        var clipBoardContent="";
          clipBoardContent+=this.location.href;
        window.clipboardData.setData("Text",clipBoardContent);
        alert("复制成功，请粘贴到你的QQ/MSN上推荐给你的好友");
      } 
    function copyToClipBoard(clipBoardContent){window.clipboardData.setData("Text",clipBoardContent);}
/*************************
pop窗体
*************************/
function getPosition() { 
    var top = document.documentElement.scrollTop; 
    var left = document.documentElement.scrollLeft; 
    var height = document.documentElement.clientHeight; 
    var width = document.documentElement.clientWidth; 
    return {top:top,left:left,height:height,width:width}; 
} 
function showtkfpop(width,height)
{ 
    var obj = document.getElementById("tkfpop"); 
    obj.style.display = "block"; 
    obj.style.position = "absolute"; 
    obj.style.zindex = "999"; 
    obj.style.width = width + "px"; 
    obj.style.height = height + "px"; 
    var Position = getPosition(); 
    leftadd = (Position.width-width)/2; 
    topadd = (Position.height-height)/2; 
    obj.style.top = (Position.top + topadd) + "px"; 
    obj.style.left = (Position.left + leftadd) + "px"; 

//    window.onscroll = function ()
//    { 
//        var Position = getPosition(); 
//        obj.style.top = (Position.top + topadd) +"px"; 
//        obj.style.left = (Position.left + leftadd) +"px"; 
//    }; 
} 
function hidetkfpop(){ document.getElementById("tkfpop").style.display = "none"; } 
/*************************
上传图片pop窗体
*************************/
function showuppicpop(objtxtid,board,aimimg)
{
    var popwidth=480;
    var popheight=260;
    var d="<iframe frameborder='0'  width='"+popwidth+"px' height='"+(popheight-20)+"px' src='/control/uppic/index.aspx?aimImg="+aimimg+"&p="+board+"&isneedclosepop=1&txtPicPath="+objtxtid+"&zipWidth=100&zipHeight=100&k=500'></iframe>";
    $("tkfpopdata").className="m0";
    $("tkfpopdata").innerHTML=d;
    showtkfpop(popwidth,popheight);
}
/*************************
选择地区pop窗体
*************************/
function showselareapop(board,maxnum,txtids,txttitles,divhtml)
{
    var popwidth=580;
    var popheight=360;
    var d="<iframe frameborder='0'  width='"+popwidth+"px' height='"+(popheight-20)+"px' src='/control/selarea/index.aspx?txtids="+txtids+"&txttitles="+txttitles+"&divhtml="+divhtml+"&p="+board+"&isneedclosepop=1'></iframe>";
    $("tkfpopdata").className="m0";
    $("tkfpopdata").innerHTML=d;
    showtkfpop(popwidth,popheight);
}
//Colour pallete top offset
function getOffsetTop(elm) {
	var mOffsetTop = elm.offsetTop;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent){
		mOffsetTop += mOffsetParent.offsetTop;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetTop;
}

//Colour pallete left offset
function getOffsetLeft(elm) {
	var mOffsetLeft = elm.offsetLeft;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent) {
		mOffsetLeft += mOffsetParent.offsetLeft;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetLeft;
}