// JavaScript Document
//创建xmlHttp对象
function CreateXMLHttpRequest()
{
   var xmlHttp;
   if (window.XMLHttpRequest)
   {
       xmlHttp = new XMLHttpRequest();
   } 
   else if (window.ActiveXObject)
   {
       try
       {
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
         } 
       catch (e)
       {
                try
                {
                     xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                }  
                catch(e)
                {
                     newsstring = "对不起，您的浏览器不支持XMLHttpRequest对象！";}
          }   
   }
   return xmlHttp;
}

//得到对象
function $(objectId) {
 if(document.getElementById && document.getElementById(objectId)) 
 {
   // W3C DOM
   return document.getElementById(objectId);
 } 
 else if (document.all && document.all(objectId)) 
 {
   // MSIE 4 DOM
   return document.all(objectId);
 } 
 else if (document.layers && document.layers[objectId]) 
 {
   // NN 4 DOM.. note: this won't find nested layers
   return document.layers[objectId];
 } 
 else 
 {
   return false;
 }
}
function $$(url)
{
	location.href=url;
}


//去左空格
function ltrim(s){
    return s.replace( /^\\s*/, "");
}
//去右空格;
function rtrim(s){
    return s.replace( /\\s*$/, "");
}
//去左右空格;
function trim(s){
    return rtrim(ltrim(s));
}
//确认删除
function SureDel(url){
	if(confirm("确认删除？"))location.href=url;
}

//密码修改
function PassWord(f)
{
if(f.OldPwd.value=="")
{
alert("请输入原始密码！");
f.OldPwd.focus();
return false;
}
if(f.NewPwd.value=="")
{
alert("请输入新密码！");
f.NewPwd.focus();
return false;
}
if(f.NewPwdOk.value!=f.NewPwd.value)
{
f.NewPwd.value="";
f.NewPwdOk.value="";
alert("两次输入密码不相同！");
f.NewPwd.focus();
return false;
}
return true;
}

//全选
function checkAll(e, itemName) 
{ 
  var aa = itemName; 
  for (var i=0; i<aa.length; i++) 
   aa[i].checked = e.checked; 
} 

function checkItem(e, allName) 
{ 
  var flag=true;
   var aa = document.getElementsByName(e.name); 
  for (var i=0; i<aa.length; i++) {
		if(!aa[i].checked) {flag=false; break;} 	
	}
    allName.checked = flag; 
}
//全部删除
function Delete(f){
	if(confirm("确认删除？"))f.submit();
}

function showModal(strURL,width,height,fobj){
  var str=strURL;
  var rond="task="+new Date().getTime();
  if(str.indexOf("?")==-1){
	  str+="?"+rond;
	  }
else{
	str+="&"+rond;
	}
  var returnValue=window.showModalDialog(str,'window','dialogwidth='+width+'px;dialogheight='+height+'px;status=no;edge=raised;scroll=no');
  if(returnValue!=null&&returnValue!="default")
  	fobj.value=returnValue;
}

function showModalWin(strURL,width,height){
  var str=strURL;
  var rond="task="+new Date().getTime();
  if(str.indexOf("?")==-1){
	  str+="?"+rond;
	  }
else{
	str+="&"+rond;
	}
  var returnValue=window.showModalDialog(str,'window','dialogwidth='+width+'px;dialogheight='+height+'px;status=no;edge=raised;scroll=no');
  if(returnValue=="1")
  	window.location.reload();
}

function showModalScroll(strURL,width,height){
  var str=strURL;
  var rond="task="+new Date().getTime();
  if(str.indexOf("?")==-1){
	  str+="?"+rond;
	  }
else{
	str+="&"+rond;
	}
  var returnValue=window.showModalDialog(str,'window','dialogwidth='+width+'px;dialogheight='+height+'px;status=no;edge=raised;scroll=yes');
  if(returnValue=="1")
  	window.location.reload();
}



//图片预览
function ImageView(imgPath,fName){
	var win=fName+"?p="+imgPath;
	window.open(win);
}

//验证输入字符，正则
//如:/[^\d]+/ig
function ExpReplace(f,Exp,str)
{
f.value=f.value.replace(Exp,str);
}

function ExpReplaceNum(f)
{
	ExpReplace(f,/[^\d]+/ig,'');
}

function ExpReplaceMoney(f)
{
	ExpReplace(f,/[^\d+(\.\d\d)]+/ig,'');
}

function myconfirm(msg)
{
	if(confirm(msg))
		return true;
	else
		return false;
}

//广告js
function cf_h(flashsrc,flashwidth,flashheight,flashlink,title,nolink){
document.write("<table width="+flashwidth+" height="+flashheight+" border=0 cellpadding=0 cellspacing=0>");
document.write("<tr><td style='padding:0px;margin:0px;'>");
document.write("<div style=\"position:relative\">");
document.write("<embed style=\"position:absolute;z-index:0\" src="+flashsrc+" quality=\"high\" width="+flashwidth+" height="+flashheight+" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" wmode=\"opaque\"></embed>");
document.write("<div style=\"background:white;filter:alpha(opacity=0);-moz-opacity:0;position: relative;z-index:10;left:0pt;top:0pt;width:"+flashwidth+";height:"+flashheight+"px;\">");

if(nolink==0)
   document.write("<a title='"+title+"' href="+flashlink+" target=\"_blank\" style=\"cursor:pointer;display:block;width:"+flashwidth+";height:"+flashheight+"px;\"></a>"); 

document.write("</div>");
document.write("</div></td></tr></table>");
}