﻿Array.prototype.remove=function(dx)
{
    if(isNaN(dx)||dx>this.length){return false;}
    for(var i=0,n=0;i<this.length;i++)
    {
        if(this[i]!=this[dx])
        {
            this[n++]=this[i]
        }
    }
    this.length-=1
}

String.prototype.Trim = function() 
{ 
return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 

String.prototype.LTrim = function() 
{ 
return this.replace(/(^\s*)/g, ""); 
} 

String.prototype.RTrim = function() 
{ 
return this.replace(/(\s*$)/g, ""); 
} 
function getssdtop(){
	var vchild = window;
	var vtop = window.parent;
	try{
		while(vtop.name != 'SSDTop'){
			if (vtop.parent == null) break;
			if (vtop == vtop.parent) break;
			vchild = vtop;
			vtop = vtop.parent;
		}
	}catch(e){
		return vchild;
	}
	return vtop;
}

function pmatopen(apm, func){
    apm.attachEvent("onopened", func);            
}

function pmdtopen(apm, func){
    apm.detachEvent("onopened", func);            
}

function createpm(){
    var div = document.createElement("div");
    div.style.display = "none";
    document.body.appendChild(div);
    div.innerHTML = "<object classid='clsid:24389722-6591-42CE-8D08-66D4D1230320' id='PageMaster'></object>";
    var pm = document.getElementById("PageMaster");
    if(pm.object != null){
        pm.start();
        pm.GetASPXID();
        pm.attachEvent("onopenerr", doopenerr);
        return pm;
    } else {
        hintdownload();
        return null;
    }
}

function hintdownload(){
    var BackgroundPanel;
	if (BackgroundPanel == null){
		BackgroundPanel = document.createElement("div");
		BackgroundPanel.style.display = "none"
		document.body.appendChild( BackgroundPanel );
		BackgroundPanel.style.position = "absolute";
		BackgroundPanel.style.zIndex = "10";
		BackgroundPanel.style.left = "0px";
		BackgroundPanel.style.top = "0px";
		//BackgroundPanel.style.width = document.body.scrollWidth + "px";
		//BackgroundPanel.style.height = document.body.scrollHeight + "px";
		//BackgroundPanel.style.width = "100%";
		//BackgroundPanel.style.height = "100%";
		BackgroundPanel.style.backgroundColor = "black";
		BackgroundPanel.style.filter = "Alpha(Opacity=30);";
	}
	BackgroundPanel.style.width = document.body.scrollWidth + "px"; 
	if (document.body.scrollHeight < document.body.clientHeight)
	    BackgroundPanel.style.height = document.body.clientHeight + "px";
	else
	    BackgroundPanel.style.height = document.body.scrollHeight + "px";
	BackgroundPanel.style.display = "";
	
	var div = document.getElementById("divdownload");
	if(div != null){
	    div.style.display = "block";
	    div.style.top = document.body.scrollTop+(document.body.clientHeight- div.clientHeight)/2;
	    div.style.left = document.body.scrollLeft+(document.body.clientWidth- div.clientWidth)/2;
	}
}

function doopenerr(AUrl, AHtml){
    if(AHtml.substr(0, 13) == "EOleException"){
        var content = window.frames.frameContent;
        if (content == null) content = ssdtop.frames.frameContent;
        if (content == null) content = window;
        var location = content.location.toString();
        if(location.toLowerCase().indexOf("dbhelp.aspx") == -1){
            content.location = "/User/DBHelp.aspx?ac=compress";
        }
    }else{
        //alert("发送如下错误：" + AHtml + "\n请联系客服。");
        var vdocument = document;
        if (window.frames.frameContent != null) vdocument = window.frames.frameContent.document;
        vdocument.execCommand("refresh");
    }
}
        
function lcopen(AUrl, ABody, ASync, APM)
{
    var pm;
    if(APM != null) pm = APM; else pm = ssdtop.pm;
    pm.open(AUrl, ABody, ASync);
}

//Cookie读写////////////////////////////////////////////////////////////////////////////////////
function SetCookie(sName, sValue)
{
  //date = new Date();
  document.cookie = sName + "=" + escape(sValue) + "; expires=Fri, 31 Dec 3000 23:59:59 GMT;"// expires=" + date.toGMTString();
}

function GetCookie(sName)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
    {
	    if (aCrumb.length==2) return unescape(aCrumb[1]);
	    else return "";
	}
  }

  // a cookie with the requested name does not exist
  return null;
}

//删除后，GetCookie取出的值为null
function DelCookie(sName)
{
  document.cookie = sName + "=; expires=Fri, 31 Dec 1899 23:59:59 GMT;";
}
//Cookie读写////////////////////////////////////////////////////////////////////////////////////

function getssdtop(){
	var vchild = window;
	var vtop = window.parent;
	try{
		while(vtop.name != 'SSDTop'){
			if (vtop.parent == null) break;
			if (vtop == vtop.parent) break;
			vchild = vtop;
			vtop = vtop.parent;
		}
	}catch(e){
		return vchild;
	}
	return vtop;
}
var ssdtop = getssdtop();


function IsInt(AStr)
{
  if ((AStr.Trim()=="")||(AStr.Trim()=="0")) return false;
  var checkOK = "0123456789";
  var checkStr = AStr;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  return allValid;
}

var SelectFLNameObj, SelectFLIdObj, SelectFLIdsObj;
function SelectFenLei(a,b,c,tb,cclass,msel,maxsel){
    SelectFLNameObj = a;
    SelectFLIdObj = b;
    SelectFLIdsObj = c;
    if(!maxsel) maxsel = 0;
    showModalDialog("/Dialog/SelectFenLei.aspx?tb="+tb+"&class="+cclass+"&msel="+msel+"&maxsel="+maxsel
        ,window
        ,"dialogHeight: 500px; dialogWidth: 700px; edge: Raised; center: Yes; help: No; resizable: No; status: yes;");
}

var SelSJmsel,SelSJuatype,SelSJdroplist,SelSJforfabu;
function SelectSJ(msel,uatype,droplist,forfabu){
    SelSJmsel = msel;
    SelSJuatype = SelSJuatype;
    SelSJdroplist = droplist;
    SelSJforfabu = forfabu;
    var url = "/Dialog/SelectSJ1.aspx";
    if(msel) url+="?msel=true";else url+="?msel=false";
    url+="&uatype="+uatype;
    return showModalDialog(url, window
        ,"dialogHeight: 400px; dialogWidth: 700px; edge: Raised; center: Yes; help: No; resizable: No; status: yes;");
}

//xmldoc
function getxmldoc(xml, ole){
    var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
    xmlDoc.async = false;
    if (xml != null) xmlDoc.loadXML(xml);
    else if(ole != null) xmlDoc.load(ole);
    return xmlDoc;
}

//xmldoc
function getxmlroot(xml, ole){
    var xmlDoc = getxmldoc(xml, ole);
    return xmlDoc.documentElement;
}