// JavaScript Document
/*
作者：网络转载
功能：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 
  } 
} 
alert();
}
//////////////////////////////////////////
//可以移动的层
//////////////////////////////////////////
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){}}
}
////////////////////////////////////////
//捕获控件位置
//////////////////////////////////////////
var MOUSEX=0;var MOUSEY=0;
function divcome(e)
 {    
  l   =   e.offsetLeft;   
  t   =   e.offsetTop;   
  while(   e=e.offsetParent   )   
  {   
  l   +=   e.offsetLeft;   
  t   +=   e.offsetTop;   
  }   
document.getElementById('upfilediv').style.position="absolute";
document.getElementById('upfilediv').style.top=t-50+'px';
document.getElementById('upfilediv').style.left=l-200+'px';
 }
/*
捕获控件位置
*/
function  divcomemenu(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"; 
document.getElementById(id).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';
 }
///////////////////////////////////////////////////////////////////////////////
//按钮上传时用的函数
///////////////////////////////////////////////////////////////////////////////
            var temppath;
            function printup()
            {document.getElementById('filepath').value=xmlhttp.responseText;
            }
            function upvalue(temp)
            { 
             document.getElementById('message').innerHTML="<center><strong><font color=blue>当前状态：等待上传！</font></strong></center>";
             temppath=temp;
             document.getElementById('upfilediv').style.display='';
             document.getElementById('filepath').value=document.getElementById(temp).value;
            }
            function editupvalue()
            {
             document.getElementById('editupfilediv').style.display='block';
            }
 
///////////////////////////////////////////////////////////////////////////////
//函数名：setajax(tag,canshu)
//功能：发送ajax请求
//参数：tag指明ajax.php中的case值，canshu ajax.php中需要处理的参数,func用来接受的函数
//调用范例：setajax("addweb","qq="+qq,prinaddweb,'userinto2.php')
///////////////////////////////////////////////////////////////////////////////
var ajaxfuncname;
function setajax(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，推荐使用Internet Explorer 浏览器访问本站！");location=otherpage;return false;}
xmlhttp.open("GET","ajax.php?tag="+tag+"&"+canshu,true);
xmlhttp.onreadystatechange=reception;
xmlhttp.send(null);
}
///////////////////////////////////////////////////////////////////////////////
//函数名：reception()
//功能：接受ajax
//////////////////////////////////////////////////////////////////////////////
function reception()
{
	if(xmlhttp.readyState==4)
    {
    if(xmlhttp.status==200)
      {
		  ajaxfuncname();
	  //temp();
	  }
    else alert("您请求的页面有异常");
  }

}

/////////////////////////////////////////
//函数名：isNumber(oNum)              
//参数：oNum                          
//功能：判断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;
}
////////////////////////////////////////////////
//函数名：mbStringLength(s）
//功能：返回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;
      } 
/////////////////////////////////////////////////////
//函数名： CheckStrLen(obj,n)
//功能：判断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;
} 
////////////////////////////////////////////////////
//函数名：CheckStrLen2(obj,n)
//功能：检查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;
}
///////////////////////////////////////////////////
//函数名：kongzhijiancha(obj)
//功能：判断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;
}
////////////////////////////////////////////////
//函数名：checkstr(id,tempArray,num)
//功能：检查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;
}
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;
}
/*载入flash动画*/
function LoadFlash(url,wmode,width,Height)
{ 
document.write(
   '<embed src="' + url + '" wmode=' + wmode +
   ' quality="high" pluginspage=http://www.macromedia.com/go/getflashplayer type="application/x-shockwave-flash" width="' + width + 
   '" height="' + Height + '"></embed>');   
}

