// JavaScript Document
function wait(str,time)
{
Interval_control=setTimeout(str,time);
}
/*
作者：网络转载
功能：png透明
*/
function correctPNG()  
{ 
for(var i=0; i<document.images.length; i++) 
{ 
  var img = document.images[i] 
  var imgName = img.src.toUpperCase() 
  if (imgName.substring(imgName.length-3, imgName.length) == "PNG") 
  { 
   var imgID = (img.id) ? "id='" + img.id + "' " : "" 
   var imgClass = (img.className) ? "class='" + img.className + "' " : "" 
   var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " 
   var imgStyle = "display:inline-block;" + img.style.cssText  
   if (img.align == "left") imgStyle = "float:left;" + imgStyle 
   if (img.align == "right") imgStyle = "float:right;" + imgStyle 
   if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle   
   var strNewHTML = "<span " + imgID + imgClass + imgTitle 
   + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" 
  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" 
   + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"  
   img.outerHTML = strNewHTML 
   i = i-1 
  } 
} 
} 
window.attachEvent("onload", correctPNG); 
/*jquery实例
$.ajax({
    url: 'ajax.php?tag=test',
    type: 'post',
    dataType: 'html',
	data:"bb=aa",
    timeout: 5000,
    error: function(){alert('Error loading XML document');},
    success: function(html){alert(html);}
});
*/
/*层覆盖*/
function showceng()
{
width=$('#showall').width();
height=$('#showall').height();
$('#showall').append("<div id='ttp' style='width:"+width+";height:"+height+"px;position:absolute;z-index:1;top:0px;left:0px;background-color:#000000;opacity: 0.70;filter: Alpha(Opacity=70);'></div>");
} 
/*消除覆盖层*/
function outceng(){ $("#ttp").replaceWith("");}
/*
浏览器类型判断
*/
        var Sys = {};
        var ua = navigator.userAgent.toLowerCase();
        window.ActiveXObject ? Sys.ie = ua.match(/msie ([\d.]+)/)[1] :
        document.getBoxObjectFor ? Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1] :
        window.MessageEvent && !document.getBoxObjectFor ? Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1] :
        window.opera ? Sys.opera = ua.match(/opera.([\d.]+)/)[1] :
        window.openDatabase ? Sys.safari = ua.match(/version\/([\d.]+)/)[1] : 0;
/*
按钮上传时用的函数
*/
            var temppath;
            function printup()
            {document.getElementById('filepath').value=xmlhttp.responseText;}
            function upvalue(temp)
            {
             temppath=temp;
             document.getElementById('upfilediv').style.display='block';
             document.getElementById('filepath').value=document.getElementById(temp).value;
            }
            function editupvalue()
            {
             document.getElementById('editupfilediv').style.display='block';
            }

/*
可以移动的层
*/
var drag_=false
var D=new Function('obj','return document.getElementById(obj);')
var oevent=new Function('e','if (!e) e = window.event;return e')
function Move_obj(obj){
 var x,y;
 D(obj).onmousedown=function(e){
  drag_=true;
  with(this){
   style.position="absolute";var temp1=offsetLeft;var temp2=offsetTop;
   x=oevent(e).clientX;y=oevent(e).clientY;
   document.onmousemove=function(e){
    if(!drag_)return false;
    with(this){
     style.left=temp1+oevent(e).clientX-x+"px";
     style.top=temp2+oevent(e).clientY-y+"px";
    }
   }
  }
  document.onmouseup=new Function("drag_=false");
 }
}
function stopMove_obj(obj)
{ 
 D(obj).onmousedown=function(e){document.onmousemove=function(e){}}
}
/*
捕获控件位置
*/
function  divcome(id,e,top,left,iframename,height)
 {    
  l   =   e.offsetLeft;   
  t   =   e.offsetTop;   
  while(   e=e.offsetParent   )   
  {   
  l   +=   e.offsetLeft;   
  t   +=   e.offsetTop;   
  }   
//document.getElementById(id).style.display="block"; 
$("#"+id).show(300);
//$("#"+id)[0].focus();
document.getElementById(iframename).style.height=height+"px";
document.getElementById(id).style.position="absolute";
document.getElementById(id).style.top=t+top+'px';
document.getElementById(id).style.left=l+left+'px';
 }
/*
作者：易行
功能：判断文件是否存在
参数：file、文件路径
*/
function okfile(file)
{ 
if(window.XMLHttpRequest)
{xmlhttp=new XMLHttpRequest();
 if(xmlhttp.overrideMimeType)xmlhttp.overrideMimeType('text/xml')
 }
else if(window.ActiveXObject)
{try{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}//测试是否IE
   catch (e)
           {
		     try{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}//是否IE5.5
				 catch(e2)
				 {
				 xmlhttp=false;
				 }
            }
 }
  xmlhttp.open("GET",file,false);
  xmlhttp.send(null);
  if(xmlhttp.readyState==4)
  { 

  if(xmlhttp.status==200)
    {return 1;
    }
  else 
    {return 0;
    } 
  } 
}
/*
作者：易行
功能：发送ajax请求
参数：tag、ajax.php中的case值
          canshu 、ajax.php中需要处理的参数
          func、用来接收返回的函数
          otherpage、不支持ajax跳转的网页
调用范例：setajax('Ajax.php',"addweb","qq="+qq,prinaddweb,'userinto2.php')
var ajaxfuncname;
function setajax(page,tag,canshu,func,otherpage)
{ 
//---------------------------------------------------------
ajaxfuncname=func;
if(window.XMLHttpRequest)
{xmlhttp=new XMLHttpRequest();
 if(xmlhttp.overrideMimeType)xmlhttp.overrideMimeType('text/xml')
 }
else if(window.ActiveXObject)
{try{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}//测试是否IE
   catch (e)
           {
		     try{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}//是否IE5.5
				 catch(e2)
				 {
				 xmlhttp=false;
				 }
            }
 }
//----------------------------------------------------------

if(!xmlhttp){alert("本页面采用ajax技术，您的浏览器不支持ajax，即将跳转到没有采用ajax技术的注册页面！");location=otherpage;return false;}
//alert(page+"?tag="+tag+"&"+canshu);
xmlhttp.open("GET",page+"?tag="+tag+"&"+canshu,true);
xmlhttp.onreadystatechange=reception;
xmlhttp.send(null);
}
/*
接收ajax返回
 
function reception()
{   //alert(xmlhttp.readyState);
	if(xmlhttp.readyState==4)
    {
    if(xmlhttp.status==200)
      {
		  ajaxfuncname();
	  //temp();
	  }
    else alert(xmlhttp.status);
  }

}
*/
/*
判断oNum是否数字              
*/
function isNumber(oNum)
{
  if(!oNum) return false;
  var strP=/^\d+(\.\d+)?$/;
  if(!strP.test(oNum)) return false;
  try{
  if(parseFloat(oNum)!=oNum) return false;
  }
  catch(ex)
  {
   return false;
  }
  return true;
}
/*
返回s所占用的字节数（utf8）
*/
function mbStringLength(s) {
        var totalLength = 0;
        var i;
        var charCode;
        for (i = 0; i < s.length; i++) {
          charCode = s.charCodeAt(i);
          if (charCode < 0x007f) {
            totalLength = totalLength + 1;
          } else if ((0x0080 <= charCode) && (charCode <= 0x07ff)) {
            totalLength += 2;
          } else if ((0x0800 <= charCode) && (charCode <= 0xffff)) {
            totalLength += 3;
          }
        }
        //alert(totalLength);
        return totalLength;
      } 
/*
功能：判断obj是否超过n个字节utf8
参数：obj'标签的id名称    n'数字
*/
function CheckStrLen(obj,n)
{ 
 if(mbStringLength(document.getElementById(obj).value)>n)
 {alert('已经超过限定的字节数，请减少字符！');
  document.getElementById(obj).focus(); 
  return   1;
 }
 return 0;
} 
/*
功能：检查obj删除左右空格后是否超n个符
参数：obj'标签的id名称    n'数字
*/
function CheckStrLen2(obj,n)
{ 
 if(document.getElementById(obj).value.replace( /^\s*/, "").replace( /\s*$/, "").length>n)
 {
 document.getElementById(obj).value=document.getElementById(obj).value.replace( /^\s*/, "").replace( /\s*$/, "");
  alert("本输入框最多只能输入"+n+"个字符，请删除"+(document.getElementById(obj).value.replace( /^\s*/, "").replace( /\s*$/, "").length-n)+"字符！");
  document.getElementById(obj).focus(); 
  return   1;
 }
 return 0;
}
/*
功能：判断obj删除左右空格后是否为空
参数：obj'标签的id名称 
*/
function kongzhijiancha(obj)//空值检查
{
 if(!(document.getElementById(obj).value.replace( /^\s*/, "")))
   {
   alert('本输入框不能为空！');
   document.getElementById(obj).value='';
   document.getElementById(obj).focus();
   return   1;
   }
 return 0;
}
/*
功能：检查id里是否有tempArray字符
参数：id'标签的id名称  tempArray'需要查找的字符数组  num tempArray中字符个数 
*/
function checkstr(id,tempArray,num)//检查是否含有非法字符
{
var str=document.getElementById(id).value;
for(k=0;k<num;k++)
   { 
     if(str.indexOf(tempArray[k])<0)//表示没有找到
     {
      continue;
	 
     }
	 else//找到了
	 {
	 //break;
	 alert('找到非法字符【'+tempArray[k]+"】,请删除！");
	 document.getElementById(id).focus();
     return 0;
	 break;
	 }
   }
return 1;
}
/*
chat:反馈给前台的提示
*/
function checkstrtishi(id,tempArray,num,chat)//检查是否含有非法字符
{
var str=document.getElementById(id).value;
for(k=0;k<num;k++)
   { 
     if(str.indexOf(tempArray[k])<0)//表示没有找到
     {
      continue;
	 
     }
	 else//找到了
	 {
	 //break;
	 if(!confirm('在“'+chat+'”中发现字符   '+tempArray[k]+'   ,而本文本框仅接受<font><a>这两个标签,其它的使用   '+tempArray[k]+'   的标签会被删除！您确定吗？'))
	     {document.getElementById(id).focus();
         return 0;
		 }
	 break;
	 }
   }
return 1;
}
