﻿//对象原型扩展
Object.extend = function(destination, source) {
    for(property in source){
        destination[property] = source[property];
    }
    return destination;
};
//8、、扩展：去除字符串空格
Object.extend(String.prototype,{
	ltrim:function(){//去除左边空格
		var whitespace = new String(" \t\n\r");
		var s = new String(this);
		if (whitespace.indexOf(s.charAt(0)) != -1)
		{
			var j=0, i = s.length;
			while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
			{
				j++;
			}
			s = s.substring(j, i);
		}
		return s;
	},
	rtrim:function(){//去除右边空格
		var whitespace = new String(" \t\n\r");
		var s = new String(this);
		if (whitespace.indexOf(s.charAt(s.length-1)) != -1){
			var i = s.length - 1;
			while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1){
				i--;
			}
			s = s.substring(0, i+1);
		}
		return s;	
	},
	trim:function(){//去除两边空格
		var s = new String(this);
		s = s.ltrim().rtrim();
		return s;
	},
	Int:function(){//转成整数
		return parseInt(this);
	},
	Float:function(){//转成浮点数
		return parseFloat(this);
	},
	replaceAll:function (AFindText,ARepText){  
         var raRegExp = new RegExp(AFindText.replace(/([\(\)\[\]\{\}\^\$\+\-\*\?\.\"\'\|\/\\])/g,"\\$1"),"ig");
         return this.replace(raRegExp,ARepText);  
    }
});
function fnGetWindowWidth(){
    var vh = 0;
    var _dEt = document.documentElement;
    var _dBx = document.body;
    if(typeof window.innerWidth=='number')vh = window.innerWidth;
    else{
      if(_dEt&&_dEt.clientWidth)vh = _dEt.clientWidth;
      else{
           if(_dBx&&_dBx.clientWidth)vh = _dBx.clientWidth;
		    }
       }
    if(!vh||vh<100)vh =100;
     return vh;
}

function fnGetWindowHeight(){
    var vh = 0;
    var _dEt = document.documentElement;
    var _dBy = document.body;
    if(typeof window.innerHeight=='number')vh = window.innerHeight;
    else{
      if(_dEt&&_dEt.clientHeight)vh = _dEt.clientHeight;
      else{
           if(_dBy&&_dBy.clientHeight)vh = _dBy.clientHeight;
		    }
       }
    if(!vh||vh<100)vh =100;
     return vh;
}
function $(obj)
{
	if (typeof(obj) == 'object')
	{
		return obj;
	}
	else
	{
		return document.getElementById(obj);
	}	
}
function Send()
{
    var sTargetUrl = arguments[0];
    var sTarget    = arguments[1];
    var sMethod    = arguments[2];
    var oForm = document.createElement('form');
    oForm.action = sTargetUrl;
    oForm.target = sTarget;
    oForm.method = sMethod;
//    for(var i=3; i<arguments.length; i++)
//    {
//        oForm.innerHTML +='<input type="hidden" name="hid'+i+'" value="'+arguments[i]+'"/>';
//    }
    oForm.innerHTML +='<input type="hidden" name="address" value="'+arguments[3]+'"/>';
    oForm.innerHTML +='<input type="hidden" name="type" value="'+arguments[4]+'"/>';
    document.body.appendChild(oForm);
    oForm.submit();
    document.body.removeChild(oForm);        
}
function Search(txtid, url)
{
    if ($(txtid).value.length > 0)
    {
        window.location.href = url.replace('{$Keyword}', escape($(txtid).value));
    }
}

function KeyupSearch(txtid,url,evt)
{
    evt = window.event ? window.event : evt;
    if (evt.keyCode == 13)
    {
        if ($(txtid).value.length > 0)
        {
            window.location.href = url.replace('{$Keyword}', escape($(txtid).value));
        }
    }
}

        /*绑定搜索列表*/
    function  buildSearchResult(skinPath,cityCode,mapUrl,keyWord){
    

      if(searchData==null){return;}
      
      var xCoord= searchData.prototype.x;
      var yCoord= searchData.prototype.y;
      var sTitle=searchData.prototype.CompanyName;
      var iID=searchData.prototype.CompanyID;
      var sAddress=searchData.prototype.Address;
      var showInfo=searchData.prototype.ShowInfo;
      var iLST_ID=searchData.prototype.LST_ID;
      var sTel=searchData.prototype.Telephone;
      var sIntro= searchData.prototype.Introduction;
      var iVip=searchData.prototype.Vip;
      var iPageIndex=searchData.prototype.CurrentPage;//当前页码
      var iPageSize=searchData.prototype.pageSize ;//页记录数
      var iTotalCount=searchData.prototype.recordCount ; //总记录
      var sKerword=keyWord.split('|')[0];;//显示关键字
      
      
      document.getElementById("ResultStart").innerHTML="找到“<b><label>"+sKerword+"</label></b>”相关结果 <b><label>"+iTotalCount+"</label></b> 条";
      
      
      /*构建主题内容*/
      var iLength=iID.length;
       var container=document.getElementById("listDiv");
       container.innerHTML="";
      for(var i=0;i<iLength;i++){
      
         var title=document.createElement("div");
         title.className="ShopName";
         
         var shopUrl="";
         var oLST_ID=iLST_ID[i];
         var oID=iID[i];
         var oTitle=sTitle[i];
         var sStar="";
         
         if(iVip[i]!=null){
            var level=iVip[i];
            for(var j=0;i<level;j++){
               sStar+= "<img src='" + skinPath + "img/shops/ShopStar.gif' />";
            }
         }
         
         
         if(sTitle[i]!=null){
            oTitle=sTitle[i].replace(sKerword,"<span style='color:red;'>"+sKerword+"</span>");//替换标题中的关键字
         }
         if (oLST_ID != null &parseInt(oLST_ID) > 0)
         {
            shopUrl=skinPath+"VipStore/"+oLST_ID+"/Index.aspx?StoreID="+oID
                
            title.innerHTML="<a href='"+shopUrl+"' onclick=\"ShowCompanyPop("+oID+",'"+skinPath+"','"+mapUrl+"','"+cityCode+"');return false;\">"+oTitle+"<img src=\"" + skinPath + "images/Edian.gif\" /></a>"
         }
          else
         {
            shopUrl="ShopView.aspx?ID="+oID;
                
            title.innerHTML="<a href='"+shopUrl+"' onclick=\"ShowCompanyPop('"+oID+"','"+skinPath+"','"+mapUrl+"','"+cityCode+"');return false;\">"+oTitle+"</a>"
         }
         container.appendChild(title);
         
         var address=document.createElement("div");
         address.innerHTML="地址："+sAddress[i];
         address.className="ShopAdress";
         container.appendChild(address);
         
         var intro=document.createElement("div");
         if(showInfo[i]!=null){
             intro.innerHTML=showInfo[i].replace(sKerword,"<span style='color:red;'>"+sKerword+"</span>");//替换内容中的关键字
         }
         intro.className="ShopAdress";
         container.appendChild(intro);
         
         var dotLine=document.createElement("div");//点线
         dotLine.className="DotLine";
         container.appendChild(dotLine);
         
         var oInfo="";
         if(sIntro[i]!=null){
           oInfo=sIntro[i].replace("<[^>]*>|\r|\n","").substring(0,1000);
           oInfo=oInfo.replace("<","&lt");
         }
         _CompanyList.push({ID:oID,Title:sTitle[i],Tel:sTel[i],Address:sAddress[i],Info:oInfo,Level:sStar,Comment:'0',X:xCoord[i], Y:yCoord[i],Domain:shopUrl,Vip:iVip[i]});

      }
      
      
      /*构建翻页*/
      var pageContainer=document.getElementById("pagerDiv");
      var mod=iTotalCount%iPageSize;
      var iPageCount=parseInt(iTotalCount/iPageSize);
      
      if(mod>0){
       iPageCount+=1;//余数大于0，尾页加一
      }
      
      
      /*获取当前显示最大页码(1-6,5-11,11-16等)*/
      var iMaxPage;
      for(var i=1;i<iPageCount;i+=5){
         if(i>iPageIndex){
           iMaxPage=i;
           break;
         }
      }
         
           /*构建向前翻页链接*/
           if(iPageIndex>5){
              var prev=document.createElement("a");
              prev.innerHTML="&lt;&lt;";
              prev.href="/LocalSearch.aspx?keyword="+keyWord+"&pagenum="+(i-6);
              pageContainer.appendChild(prev);
            }
            
            /*构建页码链接*/
            for(var j=i-5;j<=i-1;j++){
              //防止负数和超出页码
              if(j>0&&j<=iPageCount){
                  var page=document.createElement("a");
                  if(j==iPageIndex){
                     page.innerHTML=j;//当前页无链接
                  }else{
                     page.innerHTML="["+j+"]";
                     page.href="/LocalSearch.aspx?keyword="+keyWord+"&pagenum="+j;
                  }
                pageContainer.appendChild(page);
              }
            }
            
            /*构建向后翻页链接*/
            if(i<=iPageCount){
               var next=document.createElement("a");
               next.innerHTML="&gt;&gt;";
               next.href="/LocalSearch.aspx?keyword="+keyWord+"&pagenum="+i;
               pageContainer.appendChild(next);
            }
      }
    


/***************************************************
查换子串.
***************************************************/
function Instr(sStr, sSubStr)
{
    var arrCheckedValue = sStr.split(',');
    for (var i=0; i<arrCheckedValue.length; i++)
    {
        if (arrCheckedValue[i] == sSubStr)
        {
            return true;
        }
    }
	return false;
}
function RemoveStr(sStr, sSubStr)
{
	var arrCheckedValue = sStr.split(',');
	var sNewStr = "";
    for (var i=0; i<arrCheckedValue.length; i++)
    {
        if (arrCheckedValue[i] != sSubStr)
        {
            if (sNewStr == "")
            {
				sNewStr = arrCheckedValue[i];
            }
			else
			{
				sNewStr += "," + arrCheckedValue[i];
			}
        }
    }
	return sNewStr;
}

function CheckCommentPost()
{
    if (typeof FCKeditorAPI == 'undefined')
        return false;
    var oEditor = FCKeditorAPI.GetInstance('txtCommentContent');
    var content = oEditor.GetXHTML(true); 
    content = content.replace(/\s/gi,'');
    if (content.length < 1)
    {
        alert('评论内容不能为空哦~');
        return false;
    }
    return true;
}
function CheckReplyPost()
{
    if (typeof FCKeditorAPI == 'undefined')
        return false;
    var oEditor = FCKeditorAPI.GetInstance('txtReplyContent');
    var content = oEditor.GetXHTML(true); 
    content = content.replace(/\s/gi,'');
    if (content.length < 1)
    {
        alert('回复内容不能为空哦~');
        return false;
    }
    return true;
}
function CheckBookPost()
{
    if (typeof FCKeditorAPI == 'undefined')
        return false;
    var oEditor = FCKeditorAPI.GetInstance('txtBookContent');
    var content = oEditor.GetXHTML(true); 
    content = content.replace(/\s/gi,'');
    if (content.length < 1)
    {
        alert('留言内容不能为空哦~');
        return false;
    }
    return true;
}

function ActiveTab(tabID)
{
    $("div1_l1").style.display = 'none';
    $("div1_l2").style.display = 'none';
    $("l1").className = 'TabNavOff';
    $("l2").className = 'TabNavOff';
    $("div1_" + tabID).style.display = 'block';
    $(tabID).className = 'TabNavOn';
}

function ShowShopCommentReply(cid, cityPath)
{
    if ($('fraReply' + cid).style.display == 'block')
    {
        $('fraReply' + cid).style.display = 'none';
    }
    else
    {
        $('fraReply' + cid).style.display = 'block';
    }
    if ($('fraReply' + cid).src == '')
    {
        $('fraReply' + cid).src = cityPath + 'Shop/CommentReply_' + cid + '.shtml';
    }
}
//企业纠错
function DebugCompany(rootpath, citycode,cid,cname)
{
    if (!$('DebugControl'))
    {
        var DebugControl = document.createElement("iframe");
        DebugControl.id = 'DebugControl';
        DebugControl.frameBorder = 0;
        DebugControl.allowTransparency = true;
        DebugControl.height = 280;
        DebugControl.width = 380;
        document.body.appendChild(DebugControl);
        
        window.onscroll = function(){
            $('DebugControl').style.top = document.documentElement.scrollTop + 200 + 'px';
            $('DebugControl').style.left = document.body.clientWidth/2 - 200 + 'px';
        }
    }
    else
    {
        DebugControl = $('DebugControl');
    }
    DebugControl.src = rootpath + 'DebugControl.aspx?City='+citycode+'&CompanyID='+cid+'&CompanyTitle='+cname;
    DebugControl.style.position = 'absolute';
    DebugControl.style.display = 'block';
    DebugControl.style.top = document.documentElement.scrollTop + 200 + 'px';
    DebugControl.style.left = document.body.clientWidth/2 - 200 + 'px';
    DebugControl.style.zIndex = 10009;
    CreatBackground();
}
function CloseDebugControl()
{
    $('DebugControl').style.display = 'none';
    CloseBackground();
}

//注册页js
//地图取点回调
function GetMapXY(x,y)
{
    document.getElementById('hdx').value = x;
    document.getElementById('hdy').value = y;
    document.getElementById('isGetMyPointdiv').className= 'AdressYes';
    document.getElementById('isGetMyPointdiv').innerHTML = '已选择';
    document.getElementById('isGetMyPointimg').src = document.getElementById('isGetMyPointimg').src.replace('/GetAdressNo.gif','/GetAdressYes.gif');
    CloseMapIframe();
}
//城市选择更改
function ClearMapXY()
{
    document.getElementById('hdx').value = '';
    document.getElementById('hdy').value = '';
    document.getElementById('isGetMyPointdiv').className= 'AdressNo';
    document.getElementById('isGetMyPointdiv').innerHTML = '未选择';
    document.getElementById('isGetMyPointimg').src = document.getElementById('isGetMyPointimg').src.replace('/GetAdressYes.gif','/GetAdressNo.gif');
}
//调出选点地图
function ChooseMyPlace(skinpath)
{
    var citycode = document.getElementById('dplCityCode').value.split('|')[0]
    CreateMapIframe(skinpath+citycode+'/Map/');
}
function ChooseOwner(citypath)
{
    CreateMapIframe(citypath+'Map/t_owner_');
}
//实体ID选择回调
function GetOwnerID(oid, title)
{
    $('txtMCI_OwnerName').value = title;
    $('txtMCI_OwnerID').value = oid;
    CloseMapIframe();
}
function CheckUserName(cityPath)
{
    if(document.getElementById('txtLoginName').value=="")
    {
        $('divUserNameTip').innerHTML ='4-16个字符(包括英文字母、数字、下划线)';
        return false;
    }
    var edushivalidate = new EdushiValidate();
    edushivalidate.inputString = document.getElementById('txtLoginName').value;
    if(!edushivalidate.isLoginName(4,16))
    {
        $('divUserNameTip').innerHTML ='<div class="No">请输入正确的用户名</div>';
        document.getElementById('txtLoginName').select();
        document.getElementById('txtLoginName').focus();
        return false;
    }
    var ajax = new Ajax();
    ajax.get(cityPath + 'DataHandler/GetData/checkusername?username=' + $('txtLoginName').value + "&rnd=" + Math.round(Math.random()*10000)
        ,function(xmlObj){
            if (xmlObj != null)
            {
                var arr = xmlObj.responseText;
                if(arr=="true")
                {
                    $('divUserNameTip').innerHTML = '<div class="Yes">恭喜你，该用户名可以使用。</div>';
                    $('husername').value = 'true';
                }
                else
                {
                    $('husername').value = 'false';
                    $('divUserNameTip').innerHTML ='<div class="No">用户名已经被人占用，请重新输入。</div>';
                    document.getElementById('txtLoginName').select();
                    document.getElementById('txtLoginName').focus();
                }
            }
            else
            {
                $('husername').value = 'true';
                $('divUserNameTip').innerHTML = '数据加载失败,请提交到后台验证。';
            }
        }
    );
}
//用户注册检测提交数据
function CheakRegisterData()
{
    var edushivalidate = new EdushiValidate();
    edushivalidate.inputString = document.getElementById('txtLoginName').value;
    if(!edushivalidate.isLoginName(4,16))
    {
        alert('请输入正确的用户名');
        document.getElementById('txtLoginName').focus();
        return false;
    }
    if($('husername').value!="true")
    {
        alert('请输入可以使用的用户名');
        document.getElementById('txtLoginName').focus();
        return false;
    }
    edushivalidate.inputString = document.getElementById('txtPassword').value;
    if(!edushivalidate.isPassword(6,20))
    {
        alert('请输入正确的密码');
        document.getElementById('txtPassword').focus();
        return false;
    }
    if(document.getElementById('txtPassword').value!=document.getElementById('txtRePassword').value)
    {
        alert('两次密码输入不一致。');
        document.getElementById('txtRePassword').focus();
        return false;
    }
    if(document.getElementById('hdx').value==''|| document.getElementById('hdy').value=='')
    {
        alert('请选择你的位置。');
        return false;
    }
   return true;
}
function LoadCity(provinceId,subtypeId, cityPath)
{
    
    var ajax = new Ajax();
    ajax.get(cityPath + 'DataHandler/GetData/citylist?ProvinceId=' + provinceId + "&rnd=" + Math.round(Math.random()*10000)
        ,function(xmlObj){
            if (xmlObj != null)
            {
                var count = $(subtypeId).options.length;
                for (var i=0; i<count; i++)
                {
                    $(subtypeId).remove(0);
                }
                
                var arr = eval(xmlObj.responseText);
                for (var i=0; i<arr.length; i++)
                {
                    var option = document.createElement('option');
                    $(subtypeId).options.add(option);
                    option.text = arr[i].CityName;
                    option.value = arr[i].CityCode;
                }
                ClearMapXY();
            }
            else
            {
                alert('数据加载失败.');
            }
        }
    );
}
function ShowProductPhoto(pid)
{
    var iCount = $('ltlProductCount').innerHTML * 1;
    var iCurrentIndex = $('spnCurrentIndex').innerHTML * 1;
    var o = null;
    if (pid > 0)
    {
        for (var i=0; i<_ProductList.length; i++)
        {
            if (_ProductList[i].ID == pid)
            {
                o = _ProductList[i];
                iCurrentIndex = o.Index;
                break;
            }
            $('pIndex' + i).style.border = 'solid 2px #ccc';
        }
    }
    else
    {
        if (pid == 0)
        {
            //下一张
            if (iCurrentIndex >= iCount)
            {
                iCurrentIndex = 1;
            }
            else
            {
                iCurrentIndex ++;
            }
            o = _ProductList[iCurrentIndex-1];
        }
        else
        {
            //上一张
            if (iCurrentIndex <= 1)
            {
                iCurrentIndex = iCount;
            }
            else
            {
                iCurrentIndex --
            }
            o = _ProductList[iCurrentIndex-1];
        }
    }
    if (o != null)
    {
        for (var i=0; i<_ProductList.length; i++)
        {
            $('pIndex' + i).style.border = 'solid 2px #ccc';
        }
        $('pIndex' + (iCurrentIndex-1)).style.border = 'solid 2px green';
        $('spnCurrentIndex').innerHTML = iCurrentIndex;
        $('ltlProductTitle').innerHTML = o.Title;
        $('ltlProductInfo').innerHTML = o.Info;
        $('imgProductPhoto').src = o.Photo;
    }
}

function LoadFck(textBox, rootPath, citycode)
{
    var oDiv = textBox.parentNode;
    var id = textBox.name;
    var city = citycode ? citycode : '';
    oDiv.innerHTML = '' +
    '<input type="hidden" id="' + id + '" name="' + id + '" value="' + textBox.value + '" /><input type="hidden" id="' + id + '___Config" value="HtmlEncodeOutput=false&FormatSource=true&EdushiCityCode=' + city + '" /><iframe id="' + id + '___Frame" src="' + rootPath + 'fckeditor/editor/fckeditor.html?InstanceName=' + id + '&Toolbar=Basic" width="' + textBox.style.width.replace('px','') + '" height="' + textBox.style.height.replace('px','') + '" frameborder="no" scrolling="no"></iframe>';
}

//验证贴子主题提交
function CheckTopicPost()
{
    if ($('txtTitle').value.length < 5)
    {
        alert('主题标题不能少于 5 个字符');
        $('txtTitle').focus();
        return false;
    }
    if ($('dplTopicSmallTypeList').options[$('dplTopicSmallTypeList').selectedIndex].value == '')
    {
        alert('您必须选择一个贴子小类');
        $('dplTopicSmallTypeList').focus();
        return false;
    }
    if (typeof FCKeditorAPI == 'undefined')
        return false;
    var oEditor = FCKeditorAPI.GetInstance('txtPostContent');
    var content = oEditor.GetXHTML(true); 
    if (content.length < 5)
    {
        alert('主题内容不能少于 5 个字符');
        return false;
    }
    return true;
}
function CheckNewsData()
{
    if ($('txtLT_Title').value.length < 1)
    {
        alert('资讯标题不能为空');
        $('txtLT_Title').focus();
        return false;
    }
    if ($('dplTopicSmallTypeList').options[$('dplTopicSmallTypeList').selectedIndex].value == '0')
    {
        alert('您必须选择一个资讯标签');
        $('dplTopicSmallTypeList').focus();
        return false;
    }
    if (typeof FCKeditorAPI == 'undefined')
        return false;
    var oEditor = FCKeditorAPI.GetInstance('txtPostContent');
    var content = oEditor.GetXHTML(true); 
    if (content.length < 1)
    {
        alert('资讯内容不能为空');
        return false;
    }
    return true;
}
//载入贴子分类
function LoadTopicType(iParentID, subtypeId,getHostUrl,topType)
{
    if (iParentID*1 < 1)
    {
        var l = $(subtypeId).options.length;
        for (var i=0; i<l; i++)
        {
            $(subtypeId).remove(0);
        }
        var option = document.createElement('option');
        $(subtypeId).options.add(option);
        option.text = '请选择小类';
        option.value = '';
        return;
    }
    var ajax = new Ajax();
    //增加分类数据Url
    if(!getHostUrl)
    {
        getHostUrl = '';
    }
    //获取不同的分类
    if(!topType)
    {
        topType = 'topictype';
    }
    ajax.get(getHostUrl+'DataHandler/GetDataHandler.aspx?type='+topType+'&ParentID=' + iParentID + "&rnd=" + Math.round(Math.random()*10000)
        ,function(xmlObj){
            if (xmlObj != null)
            {
                var count = $(subtypeId).options.length;
                for (var i=0; i<count; i++)
                {
                    $(subtypeId).remove(0);
                }
                
                var arr = eval(xmlObj.responseText);
                for (var i=0; i<arr.length; i++)
                {
                    var option = document.createElement('option');
                    $(subtypeId).options.add(option);
                    option.text = arr[i].Title;
                    option.value = arr[i].ID;
                }
            }
            else
            {
                alert('数据加载失败.');
            }
        }
    );
}

/**********************************************
Ajax类
***********************************************/
function Ajax() {
	var xmlObj = false;
	var CBfunc,ObjSelf;
	ObjSelf=this;
	try { xmlObj=new XMLHttpRequest; }
	catch(e) {
		try { xmlObj=new ActiveXObject("MSXML2.XMLHTTP"); }
		catch(e2) {
			try { xmlObj=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch(e3) { xmlObj=false; }
		}
	}
	if (!xmlObj) return false;
	if(arguments[0]) this.url=arguments[0]; else this.url="";
	if(arguments[1]) this.callback=arguments[1]; else this.callback=function(obj){return};
	if(arguments[2]) this.content=arguments[2]; else this.content="";
	if(arguments[3]) this.method=arguments[3]; else this.method="POST";
	if(arguments[4]) this.async=arguments[4]; else this.async=true;
	this.send=function() {
		var purl,pcbf,pc,pm,pa;
		if(arguments[0]) purl=arguments[0]; else purl=this.url;
		if(arguments[1]) pc=arguments[1]; else pc=this.content;
		if(arguments[2]) pcbf=arguments[2]; else pcbf=this.callback;
		if(arguments[3]) pm=arguments[3]; else pm=this.method;
		if(arguments[4]) pa=arguments[4]; else pa=this.async;
		if(!pm||!purl||!pa) return false;
		xmlObj.open (pm, purl, pa);
		if(pm=="POST") xmlObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlObj.onreadystatechange=function() {
			if(xmlObj.readyState==4) {
				if(xmlObj.status==200) {
					pcbf(xmlObj);
				}
				else {
					pcbf(null);
				}
			}
		}
		if(pm=="POST")
			xmlObj.send(pc);
		else
			xmlObj.send("");
	}
	this.get=function() {
		var purl,pcbf;
		if(arguments[0]) purl=arguments[0]; else purl=this.url;
		if(arguments[1]) pcbf=arguments[1]; else pcbf=this.callback;
		if(!purl&&!pcbf) return false;
		this.send(purl,"",pcbf,"GET",true);
	}
	this.post=function() {
		var fo,pcbf,purl,pc,pm;
		if(arguments[0]) fo=arguments[0]; else return false;
		if(arguments[1]) pcbf=arguments[1]; else pcbf=this.callback;
		if(arguments[2])
			purl=arguments[2];
		else if(fo.action)
			purl=fo.action;
		else
			purl=this.url;
		if(arguments[3])
			pm=arguments[3];
		else if(fo.method)
			pm=fo.method.toLowerCase();
		else
			pm="post";
		if(!pcbf&&!purl) return false;
		pc=this.formToStr(fo);
		if(!pc) return false;
		if(pm) {
			if(pm=="post")
				this.send(purl,pc,pcbf,"POST",true);
			else
				if(purl.indexOf("?")>0)
					this.send(purl+"&"+pc,"",pcbf,"GET",true);
				else
					this.send(purl+"?"+pc,"",pcbf,"GET",true);
		}
		else
			this.send(purl,pc,pcbf,"POST",true);
	}

	this.formToStr=function(fc) {
		var i,query_string="",and="";
		for(i=0;i<fc.length;i++) {
			e=fc[i];
			if (e.name!='') {
				if (e.type=='select-one') {
					element_value=e.options[e.selectedIndex].value;
				}
				else if (e.type=='checkbox' || e.type=='radio') {
					if (e.checked==false) {
						continue;	
					}
					element_value=e.value;
				}
				else {
					element_value=e.value;
				}
				element_value=encodeURIComponent(element_value);
				query_string+=and+e.name+'='+element_value;
				and="&";
			}
		}
		return query_string;
	}
}
function fnRequest(strName){
	var strHref = window.document.location.href;
	var intPos = strHref.indexOf("?");
	var strRight = strHref.substr(intPos + 1);
	var arrTmp = strRight.split("&");
	for(var i = 0; i < arrTmp.length; i++){
		var arrTemp = arrTmp[i].split("=");
		if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
	}
	return "";
}
//通用复制方法
function fnCopyToClipboard(txt,msg){
     if(window.clipboardData){
             window.clipboardData.clearData();
             window.clipboardData.setData("Text", txt);
     } else if(navigator.userAgent.indexOf("Opera") != -1) {
          window.location = txt;
     } else if (window.netscape){
          try {
               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
          } catch (e) {
               alert("您的浏览器未开启复制功能！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
               return false;
          }
          var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
          if (!clip){
               return;
          }
          var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
          if (!trans){
               return;
          }
          trans.addDataFlavor('text/unicode');
          var str = new Object();
          var len = new Object();
          var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
          var copytext = txt;
          str.data = copytext;
          trans.setTransferData("text/unicode",str,copytext.length*2);
          var clipid = Components.interfaces.nsIClipboard;
          if (!clip){
               return false;
          }
          clip.setData(trans,null,clipid.kGlobalClipboard);
     }
     else{
        alert('您的浏览器不支持拷贝功能。');
        return false;
     }
     if(msg!=null&&msg!=''){
        alert(msg);
     }
     return true;
}

function ENetwork(){};
ENetwork.GetExecutionID = function()
{
    var a = new Date, b = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate(),a.getHours(), a.getMinutes(), a.getSeconds(), a.getMilliseconds());
    b += Math.round(Math.random() * 1000000);
    return b
};
ENetwork.DownloadScriptCallback = function(a)
{
    if (a){
        a();
    }
};
ENetwork.DownloadScript = function(a, b, c)
{
    try{        
        if (a == null || a == "undefined" || a.length == 0){
            throw new ENetworkException("ENetwork:DownloadScript", "err_noscripturl",l24ht);
        }
        var elScript = document.createElement("script");
        elScript.type = "text/javascript";
        elScript.language = "javascript";
        elScript.id = typeof(c) == "undefined" ? ENetwork.GetExecutionID() : c;
        elScript.src = a;        
        if(document.getElementById(c)){
            ENetwork.GetAttachTarget().removeChild(document.getElementById(c));
        }
        ENetwork.GetAttachTarget().appendChild(elScript);
        if (navigator.userAgent.indexOf("IE") >= 0){
            elScript.onreadystatechange = function(){
                if (elScript && ("loaded" == elScript.readyState || "complete" == elScript.readyState)){
                    elScript.onreadystatechange = null;
                    ENetwork.DownloadScriptCallback(b);                    
                }
            }
        }
        else{
            elScript.onload = function(){
                elScript.onload = null;
                ENetwork.DownloadScriptCallback(b);
            }
        }        
        return elScript.id;
    }
    catch (e){
        alert('加载失败！');
    }
};
ENetwork.GetAttachTarget = function()
{
    if (document.getElementsByTagName("head")[0] != null){
        return document.getElementsByTagName("head")[0];
    }
    else{
        throw new ENetworkException("ENetwork:cstr", "err_noheadelement", l611ft);
    }
};
function ENetworkException(b, c, a)
{
    this.source = b;
    this.name = c;
    this.message = a;
}
ENetworkException.prototype.Name = this.name;
ENetworkException.prototype.Source = this.source;
ENetworkException.prototype.Message = this.message;
