﻿/**
*创建名空间
*/
function createNameSpace(str) {
        var strs = str.split(".");
        var strT = strs[0];
        if (window[strT] == undefined) {
                window[strT] = new Object();
        }
        for (var i = 1; i < strs.length; i++) {
                if (eval(strT)[strs] == undefined) {
                        eval(strT)[strs] = new Object();
                }
                strT += "." + strs;
        }
}
createNameSpace("shenghuohui");
createNameSpace("HD");//头部
function HashTable() 
{         
    this.Items=[]; 
    this.Count=function(){return this.Items.length;};        //长度                 
    this.DictionaryEntry=function(key,value) 
    { 
            this.Key=key||null; 
            this.Value=value||null; 
    } 
    this.Add=function(key,value){this.Items.push(new this.DictionaryEntry(key,value));} 
    this.Clear=function(){this.Items.length=0;} 
    this.Remove=function(key) 
    {
            var index=this.GetIndexWithKey(key); 
            if(index>-1)
                this.Items.splice(index,1); 
    } 
    this.GetItem=function(key) 
    { 
            var index=this.GetIndexWithKey(key); 
            if(index>-1)
                return this.Items[index]; 
    }
    this.GetValue=function(key) 
    { 
            var index=this.GetIndexWithKey(key); 
            if(index>-1)
                return this.Items[index].Value; 
    }
    this.SetValue=function(key,value)
    {
        if(this.ContainsKey(key))
        {
            this.Remove(key);
        }
        this.Items.push(new this.DictionaryEntry(key,value));
    }
    this.ContainsKey=function(key) 
    { 
            if(this.GetIndexWithKey(key)>-1)
                return true; 
            return false; 
    } 
    this.ContainsValue=function(value) 
    { 
            if(this.GetIndexWithValue(value)>-1)
                return true; 
            return false; 
    } 
    this.Keys=function() 
    { 
            var iLen=this.Count(); 
            var resultArr=[]; 
            for(var i=0;i<iLen;i++)
                resultArr.push(this.Items[i].Key); 
            return resultArr; 
    } 
    this.Values=function() 
    { 
            var iLen=this.Count(); 
            var resultArr=[]; 
            for(var i=0;i<iLen;i++) 
                resultArr.push(this.Items[i].Value); 
            return resultArr; 
    } 
    this.IsEmpty=function(){return this.Count()==0;} 
    this.GetIndexWithKey=function(key) 
    { 
            var iLen=this.Count(); 
            for(var i=0;i<iLen;i++)
                if(this.Items[i].Key===key)
                    return i; 
            return -1; 
    } 
    this.GetIndexWithValue=function(value) 
    { 
            var iLen=this.Count(); 
            for(var i=0;i<iLen;i++)
                if(this.Items[i].Value===value)
                    return i; 
            return -1; 
    }
	this.toString=function(delim){
		return this.Items.join((delim||","));
	};
}
// JavaScript实现的ArrayList类
ArrayList=function(/* array? */arr){
	//	Returns a new object of type dojo.collections.ArrayList
	var items=[];
	if(arr) items=items.concat(arr);
	this.count=items.length;
	this.add=function(/* object */obj){
		//	Add an element to the collection.
		items.push(obj);
		this.count=items.length;
	};
	this.addRange=function(/* array */a){
		//	Add a range of objects to the ArrayList
		if(a.getIterator){
			var e=a.getIterator();
			while(!e.atEnd()){
				this.add(e.get());
			}
			this.count=items.length;
		}else{
			for(var i=0; i<a.length; i++){
				items.push(a[i]);
			}
			this.count=items.length;
		}
	};
	this.clear=function(){
		//	Clear all elements out of the collection, and reset the count.
		items.splice(0, items.length);
		this.count=0;
	};
	this.clone=function(){
		//	Clone the array list
		return new dojo.collections.ArrayList(items);	//	dojo.collections.ArrayList
	};
	this.contains=function(/* object */obj){
		//	Check to see if the passed object is a member in the ArrayList
		for(var i=0; i < items.length; i++){
			if(items[i] == obj) {
				return true;	//	bool
			}
		}
		return false;	//	bool
	};
	this.forEach=function(/* function */ fn, /* object? */ scope){
		//	functional iterator, following the mozilla spec.
		var s=scope||dj_global;
		if(Array.forEach){
			Array.forEach(items, fn, s);
		}else{
			for(var i=0; i<items.length; i++){
				fn.call(s, items[i], i, items);
			}
		}
	};
	this.getIterator=function(){
		//	Get an Iterator for this object
		return new dojo.collections.Iterator(items);	//	dojo.collections.Iterator
	};
	this.indexOf=function(/* object */obj){
		//	Return the numeric index of the passed object; will return -1 if not found.
		for(var i=0; i < items.length; i++){
			if(items[i] == obj) {
				return i;	//	int
			}
		}
		return -1;	// int
	};
	this.insert=function(/* int */ i, /* object */ obj){
		//	Insert the passed object at index i
		items.splice(i,0,obj);
		this.count=items.length;
	};
	this.item=function(/* int */ i){
		//	return the element at index i
		return items[i];	//	object
	};
	this.remove=function(/* object */obj){
		//	Look for the passed object, and if found, remove it from the internal array.
		var i=this.indexOf(obj);
		if(i >=0) {
			items.splice(i,1);
		}
		this.count=items.length;
	};
	this.removeAt=function(/* int */ i){
		//	return an array with function applied to all elements
		items.splice(i,1);
		this.count=items.length;
	};
	this.reverse=function(){
		//	Reverse the internal array
		items.reverse();
	};
	this.sort=function(/* function? */ fn){
		//	sort the internal array
		if(fn){
			items.sort(fn);
		}else{
			items.sort();
		}
	};
	this.setByIndex=function(/* int */ i, /* object */ obj){
		//	Set an element in the array by the passed index.
		items[i]=obj;
		this.count=items.length;
	};
	this.toArray=function(){
		//	Return a new array with all of the items of the internal array concatenated.
		return [].concat(items);
	}
	this.toString=function(/* string */ delim){
		//	implementation of toString, follows [].toString();
		return items.join((delim||","));
	};
};
//判断浏览器是否ie
function isIE(){ //ie? 
   if (window.navigator.userAgent.toLowerCase().indexOf("msie")>=1) 
    return true; 
   else 
    return false; 
}
if(!isIE()){ //firefox innerText define
   HTMLElement.prototype.__defineGetter__(     "innerText",
    function(){
     var anyString = "";
     var childS = this.childNodes;
     for(var i=0; i<childS.length; i++) {
      if(childS[i].nodeType==1)
       anyString += childS[i].tagName=="BR" ? '\n' : childS[i].innerText;
      else if(childS[i].nodeType==3)
       anyString += childS[i].nodeValue;
     }
     return anyString;
    }
   );
   HTMLElement.prototype.__defineSetter__(     "innerText",
    function(sText){
     this.textContent=sText;
    }
   );
}
function addBookmark(title, url) {
    try {
        if (window.sidebar) {
            window.sidebar.addPanel(title, url, "");
        } else if (document.all) {
            window.external.AddFavorite(url, title);
        } else if (window.opera && window.print) {
            return true;
        }
    }
    catch (e) {
        alert("加入收藏失败，请使用Ctrl+D进行添加");
    }
}
function copyToClipboard(txt) {
    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'");
        }
        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);

    } alert("复制成功！");
}
function CopytheText(id) {
    var obj = document.getElementById(id);
    copyToClipboard(obj.value);
}
function Json_FindItem(json,key,value){
    for(i=0;i<eval(json).length;i++)
    {
        if(eval(json)[i][key]==value)
        {
            return eval(json)[i];
        }
    }
}
//限制文本框输入字符长度
// onkeypress="textlen(this,document.getElementById('add_count'),140);"
function textlen(textarea,label,len)
{
    try
    {
        if (textarea.value.length>=len)
            textarea.value=(textarea.value.substring(0,len))
        if(label!=null)
        label.innerText = len-textarea.value.length;
    }
    catch(e)
    {
        alert('已到达最大长度！');
    }
}
//限制文本框输入中英文绝对字符长度
function textlenCN(textarea,len,label)
{
    try
    {
        if (textarea.value.lengthCN>=len)
            textarea.value=(textarea.value.substring(0,len))
        if(label!=null)
        label.innerText = len-textarea.value.lengthCN;
    }
    catch(e)
    {
        return false;
    }
}
//显示遮罩层
function showMask()
{
    Mask=document.createElement("div");
    Mask.id = "MaskDiv";
    Mask.className="DialogMask";
    Mask.style.zIndex=10099;
    document.body.appendChild(Mask);
    Mask.style.width=document.body.scrollWidth+"px";
    Mask.style.height=document.body.scrollHeight+"px";
    iframe=document.createElement("iframe");
    iframe.style.width=dialogMask.style.width;
    iframe.style.height=dialogMask.style.height;
    iframe.frameborder="0px";
    iframe.className="MaskIframe";
    iframe.style.zIndex=10088;
    Mask.appendChild(iframe);
}
//关闭遮罩层
function closeMask()
{
    Mask=document.getElementById("MaskDiv");
    if (Mask)
    {
      Mask.style.display="none";
      document.body.removeChild(Mask);
    }
}
//无提示关闭网页浏览器
function Close() {
    var ua = navigator.userAgent
    var ie = navigator.appName == "Microsoft Internet Explorer" ? true : false
    if (ie) {
        var IEversion = parseFloat(ua.substring(ua.indexOf("MSIE ") + 5, ua.indexOf(";", ua.indexOf("MSIE "))))
        if (IEversion < 5.5) {
            var str = '<object id=noTipClose classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">'
            str += '<param name="Command" value="Close"></object>';
            document.body.insertAdjacentHTML("beforeEnd", str);
            document.all.noTipClose.Click();
        }
        else {
            window.opener = null;
            window.close();
        }
    }
    else {
        window.close();
    }
}
//图片加载并按比例缩小到合适大小
//<img src=""  width="80" height="80" onload="DownImage(this,80,80,0,0);">
function DownImage(ImgD,MaxWidth,MaxHeight,alignX,alignY)
{   
	alignX=alignX||1;
	alignY=alignY||1;
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0)
	{
		var rate = (MaxWidth/image.width < MaxHeight/image.height)?MaxWidth/image.width:MaxHeight/image.height;
		var wid=0;
		var hid=0;
		if(rate <= 1)
		{
			wid=ImgD.width=image.width*rate;
			hid=ImgD.height=image.height*rate;
		}
		else
		{
			wid=ImgD.width=image.width;
			hid=ImgD.height=image.height;
		}
		if(alignX==1)
		{
			var ii=(MaxWidth-wid)/2;
			ImgD.style.marginLeft=ImgD.style.marginRight=ii+"px";
		}
		if(alignY==1)
		{
			var ii=(MaxHeight-hid)/2;
			ImgD.style.marginTop=ImgD.style.marginBottom=ii+"px";
		}
    }
}
//图片加载并按比例缩小到合适宽度
//<img src=""  width="80" onload="DownImageWidth(this,80,0,0);">
function DownImageWidth(ImgD,MaxWidth,alignX,alignY)
{    
	alignX=alignX||1;
	alignY=alignY||1;
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0)
	{
		var rate = MaxWidth/image.width;
		var wid=0;
		var hid=0;
		if(rate <= 1)
		{
			wid=ImgD.width=image.width*rate;
			hid=ImgD.height=image.height*rate;
		}
		else
		{
			wid=ImgD.width=image.width;
			hid=ImgD.height=image.height;
		}
    }
}
function ShowWithElementoffsetXY(ElementId,WithElementId,offsetX,offsetY)
{
    var elem = getAbsoluteLocation(document.getElementById(ElementId));
	var welem = document.getElementById(WithElementId);
	welem.style.left = (elem.absoluteLeft+offsetX)+"px";
	welem.style.top = (elem.absoluteTop+offsetY)+"px";
}
//ie6下隐藏元素防遮挡浮动层
function hideElementAll(){
	HideElement("SELECT");
	//HideElement("OBJECT");
	//HideElement("IFRAME");
}
function showElementAll(){
	ShowElement("SELECT");
	//ShowElement("OBJECT");
	//ShowElement("IFRAME");
}
function HideElement(strElementTagName){
	try{
		for(i=0;i<window.document.getElementsByTagName(strElementTagName).length; i++){
			var objTemp = window.document.getElementsByTagName(strElementTagName)[i];
			if(objTemp.id.indexOf("LoginHeader")==-1)
			    objTemp.style.visibility = "hidden";
		}
	}catch(e){
		alert(e.message);
	}
}
function ShowElement(strElementTagName){
	try{
		for(i=0;i<window.document.getElementsByTagName(strElementTagName).length; i++){
			var objTemp = window.document.getElementsByTagName(strElementTagName)[i];
			objTemp.style.visibility = "visible";
		}
	}catch(e){
		alert(e.message);
	}
}
//attach(window,"load",function(){alert('111')})
function attach(o,e,f){
   if (document.attachEvent)
     o.attachEvent("on"+e,f);
   else if (document.addEventListener)
     o.addEventListener(e,f);
}
function addEvent(obj, evtType, func, cap) {
    cap = cap || false;
    if (obj.addEventListener) {
        obj.addEventListener(evtType, func, cap);
        return true;
    } else if (obj.attachEvent) {
        if (cap) {
            obj.setCapture();
            return true;
        } else {
            return obj.attachEvent("on" + evtType, func);
        }
    } else {
        return false;
    }
}
function getPageScroll() {
    var xScroll, yScroll;
    if (self.pageXOffset) {
        xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollLeft) {
        xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {
        xScroll = document.body.scrollLeft;
    }
    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {
        yScroll = document.documentElement.scrollTop;
    } else if (document.body) {
        yScroll = document.body.scrollTop;
    }
    arrayPageScroll = new Array(xScroll, yScroll);
    return arrayPageScroll;
}
function GetPageSize() {
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) {
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else {
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }
    var windowWidth, windowHeight;
    if (self.innerHeight) {
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) {
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
    if (yScroll < windowHeight) {
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }
    if (xScroll < windowWidth) {
        pageWidth = windowWidth;
    } else {
        pageWidth = xScroll;
    }
    arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight)
    return arrayPageSize;
}
function tabs(Id,Ids,activeClass,normalClass)
{
    for(var i=0;i<Ids.length;i++)
    {
        if(Ids[i]==Id)
        {
            document.getElementById('tab'+Id).className=activeClass;
        }
        else
        {  
            document.getElementById('tab'+Ids[i]).className=normalClass;
        }   
    }  
}
//tabpanel面板
//     var divIds1=["001001003005001","001001003005002","001001003005003","001001003005004","001001003005005"];
//     var divIds2=["001001003006001","001001003006002","001001003006003","001001003006004"];
//<a id="span001001003005001" class="ac_span" href="javascript:displayDiv('001001003005001',divIds1,'ac_span','');"></a>
//<div id="div001001003005001"></div>
function tabpanels(Id,Ids,activeClass,normalClass)
{
    for(var i=0;i<Ids.length;i++)
    {
        if(Ids[i]==Id)
        {
            document.getElementById('div'+Id).style.display='block';
            document.getElementById('span'+Id).className=activeClass;
        }
        else
        {
            document.getElementById('div'+Ids[i]).style.display='none';   
            document.getElementById('span'+Ids[i]).className=normalClass;
        }   
    }
}
function tabpanels2(Id, Ids, activeClass, normalClass) {
    for (var i = 0; i < Ids.length; i++) {
        if (Ids[i] == Id) {
            document.getElementById('ul' + Id).style.display = 'block';
            document.getElementById('span' + Id).className = activeClass;
        }
        else {
            document.getElementById('ul' + Ids[i]).style.display = 'none';
            document.getElementById('span' + Ids[i]).className = normalClass;
        }
    }
}
function tabdisplay(Id,Ids)
{
    for(var i=0;i<Ids.length;i++)
    {
        if(Ids[i]==Id)
        {
            document.getElementById('div'+Id).style.display='block';
            document.getElementById('span'+Id).style.display='none';  
        }
        else
        {
            document.getElementById('div'+Ids[i]).style.display='none';   
            document.getElementById('span'+Ids[i]).style.display='block';
        }   
    }  
}
function tabnodisplay(Id,Ids)
{
    for(var i=0;i<Ids.length;i++)
    {
        if(Ids[i]==Id)
        {
            document.getElementById('div'+Id).style.display='none';
            document.getElementById('span'+Id).style.display='block';  
        }
        else
        {
            document.getElementById('div'+Ids[i]).style.display='none';   
            document.getElementById('span'+Ids[i]).style.display='block';
        }   
    }  
}
function changeclass(Id,Class)
{
    document.getElementById(Id).style.classname=Class;
}

//一维数组的排序
// type 参数 
// 0 字母顺序（默认） 
// 1 大小 比较适合数字数组排序
// 2 拼音 适合中文数组
// 3 乱序 有些时候要故意打乱顺序，呵呵
// 4 带搜索 str 为要搜索的字符串 匹配的元素排在前面
Array.prototype.SortBy=function(type,str)
{ 
    switch (type)
    {
        case 0:this.sort(); break;
        case 1:this.sort(function(a,b){ return a-b; }); break;
        case 2:this.sort(function(a,b){ if(a.length>b.length)return 1; else if(a.length==b.length)return a.localeCompare(b); else return -1; }); break;
        case 3:this.sort(function(){ return Math.random()>0.5?-1:1; }); break;
        case 4:this.sort(function(a,b){ return a.indexOf(str)==-1?1:-1; }); break;
        default:this.sort();
    }
}
Array.prototype.Exist=function(str)
{ 
    if(this.length==0)
        return false;
    for(var i=0;i<this.length;i++)
    {
        if(this[i]==str)
            return true;
    }
    return false;
}
String.prototype.Exist=function(str)
{ 
    if(this.length==0)
        return false;
    for(var i=0;i<this.length;i++)
    {
        if(this[i]==str)
            return true;
    }
    return false;
}

String.prototype.lengthCN=function(){ 
    return this.replace(/[^\x00-\xff]/g,"**").length; 
};
//window.onerror=function(sErr,sSrc,nLine){
//    var oFun=window.onerror.caller
//    var sMsg=sErr+"\n"
//    sMsg+="位于"+sSrc+"\n"
//    sMsg+="第"+nLine+"行\n"
//    if(!oFun){
//        sMsg+="未捕获到源函数(函数外错误或非IE)"
//    }
//    while(oFun!=null){
//        var oArgs=oFun.arguments;
//        var sArgs=""
//        for(var i=0;i<oArgs.length;i++){
//            sArgs += (sArgs!=""?",":"")+oArgs[i];
//        }
//        
//        sMsg+="实参:"+sArgs+"\n";
//        sMsg+=oFun+"\n";
//        oFun=oFun.caller;
//    }
//    alert(sMsg);
//    return true;
//}
function openWindow(url,title,prams,returnEvent)
{
    if (window.showModalDialog!=null)//IE判断
    {          
         var returnValue = window.showModalDialog(url,title,prams);
         if(returnValue!=null)
         {
            returnEvent(returnValue);
         }
        return;
    }
    else
    {
        this.returnAction=function(returnValue){
         if(returnValue!=null)
         {
            returnEvent(returnValue);
         }
        }
        window.open(url,title,prams);
        return;
    }
}
function QueryString(sName)
{
    var sSource = String(window.document.location);
    var sReturn = "";
    var sQUS = "?";
    var sAMP = "&";
    var sEQ = "=";
    var iPos;
    iPos = sSource.indexOf(sQUS);
    var strQuery = sSource.substr(iPos, sSource.length - iPos);
    var strLCQuery = strQuery.toLowerCase();
    var strLCName = sName.toLowerCase();
    iPos = strLCQuery.indexOf(sQUS + strLCName + sEQ);
    if (iPos == -1)
    {
        iPos = strLCQuery.indexOf(sAMP + strLCName + sEQ);
            if (iPos == -1)
                return "";
     }
    sReturn = strQuery.substr(iPos + sName.length + 2,strQuery.length-(iPos + sName.length + 2));
    var iPosAMP = sReturn.indexOf(sAMP);
    if (iPosAMP == -1)
        return sReturn;
            else
        {
            sReturn = sReturn.substr(0, iPosAMP);
        }
            return sReturn;
}
function trim(s)  
{  
    var  i,b=0,e=s.length;  
    for(i=0;i<s.length;i++) 
         if(s.charAt(i)!=' '){b=i;break;}  
    if(i==s.length)  
        return  "";  
    for(i=s.length-1;i>b;i--)  
        if(s.charAt(i)!=' '){e=i;break;}  
    return  s.substring(b,e+1);  
}
function goBack(num) {
    if(num!=null)
    {
        history.go(num);
        return;
    }
    if(QueryString("reurl")!="")
    {
        window.location = QueryString("reurl");
        return;
    }
    if(document.referrer!="")
        window.location = document.referrer;
}
//option操作
function Options_Clear(eid){
    var oSelect = document.getElementById(eid);
    var length = oSelect.options.length;
    for(i=length-1;i>=0;i--)
        oSelect.options[i]=null;
}
function setOptions(oSelect,eText,eValue,eSValue){
    var oOption = document.createElement("option");
    oSelect.options.add(oOption);
    oOption.text = eText;
    oOption.value = eValue;
    if(eValue == eSValue)
        oOption.selected = true;
}
//拖动层支持
function Dialog(diviId,x,y,width,height)
{
	var object=this;
	var dialogMask;
	this.id = diviId;
	this.Width=width?width:300;
    this.Height=height?height:200;
    var dialog=this.Dialog=document.getElementById(diviId);
    
	dialog.style.zIndex=99991;
	this.State="Expand";
	
	this.SetPositon=function()
	{
        this.X=x?x:((document.documentElement.clientWidth-this.Width)/2);
        this.Y=y?y:(document.documentElement.scrollTop+(document.documentElement.clientHeight-this.Height)/2);
        dialog.style.left=this.X+"px";
	    dialog.style.top=this.Y+"px";
	}
	this.SetPositon();
    this.SetXY=function (x,y)
    {
       this.X=x;
       this.Y=y;
       dialog.style.left=this.X+"px";
       dialog.style.top=this.Y+"px";
    }     
    this.SetWithElementoffsetXY=function (ElementId,offsetX,offsetY)
    {
       var elem = getAbsoluteLocation(document.getElementById(ElementId));
	   this.SetXY(elem.absoluteLeft+offsetX,elem.absoluteTop+offsetY);
    }     
    this.SetRange=function (width,height)
    {
        this.Width=width;
        this.Height=height;
        dialog.style.width=this.Width+"px";
        dialog.style.top=this.Height+"px";
    }
    
    this.Show=function ()
    {
        this.SetPositon();
       dialog.style.display="block";
       //hideElementAll();
       //this.showModelessDialog();
    }    
    this.ShowAndDorp=function ()
    {
        this.SetPositon();
       dialog.style.display="block";
       //hideElementAll();
       //this.showModelessDialog();
    }   
    this.ShowAndMask=function ()
    {
        this.SetPositon();
       dialog.style.display="block";
       this.showModelessDialog();
       //dialogMask.style.display="block";
    }
    this.Hide=function ()
    {
       if (dialogMask)
       {
          dialogMask.style.display="none";
          document.body.removeChild(dialogMask);
       }
       dialog.style.display="none";
       showElementAll();
    }
    
    this.Alert=function ()
    {
       
    }
    this.Confirm=function ()
    {
    
    }
    this.showModelessDialog=function ()
    {
        dialogMask=document.createElement("div");
        dialogMask.className="DialogMask";
        document.body.appendChild(dialogMask);	
        dialogMask.style.width=document.body.scrollWidth+"px";
        dialogMask.style.height=document.body.scrollHeight+"px";
        iframe=document.createElement("iframe");
        iframe.style.width=dialogMask.style.width;
        iframe.style.height=dialogMask.style.height;
        iframe.frameborder="0px";
        iframe.className="DialogMaskIframe";
        iframe.style.zIndex=10088;
        dialogMask.appendChild(iframe);
    }

    this.Expand=function(img,contentId)
    {
        var content = document.getElementById(contentId);
   		window.event.cancelBubble = true;  
		if (this.State=="Expand")
		{    	   	   
       		this.title="展开";
      		this.State="Collapse";
			content.style.display="none";
		}
		else
		{
			this.title="折叠";
      		this.State="Expand";
			content.style.display="block";
		}
  		//this.src="/blog/images/"+this.getAttribute("State")+"_hover.gif"; 
    }
    
    this.Drag=function (header,e)
	{		
		if (e)
		{
			window.event=e;
			window.event.srcElement=e.target;      
		}
		window.event.returnValue = true;   
		header.style.cursor="move";
		var offsetX=window.event.clientX-GetLeft(dialog);
		var offsetY=window.event.clientY-GetTop(dialog);
		document.onmousemove=function (e)
		{
			if (e)
			{
				window.event=e;
				window.event.srcElement=e.target;      
			}
    		window.event.returnValue = true;   
    		object.SetXY(window.event.clientX-offsetX,window.event.clientY-offsetY);
         }
         document.onmouseup=function (e)
	     {
	        header.style.cursor="move";
		    document.onmousemove=null;
		    document.onmouseup=null;
	     }
    }

}
function GetLeft(src){
	var left=0;
	while(src){
		left+=src.offsetLeft;
		src=src.offsetParent;
	}
	return left;
}
function GetTop(src){
	var top=0;
	while(src){
		top+=src.offsetTop;
		src=src.offsetParent;
	}
	return top;
}
function getAbsoluteLocation(element)
{
    if ( arguments.length != 1 || element == null )
    {
        return null;
    }
    var elmt = element;
    var offsetTop = elmt.offsetTop;
    var offsetLeft = elmt.offsetLeft;
    var offsetWidth = elmt.offsetWidth;
    var offsetHeight = elmt.offsetHeight;
    var scrollWidth = elmt.scrollWidth;//滚动条宽度
    
    while( elmt = elmt.offsetParent )
    {
        if ( elmt.style.position == 'absolute' || elmt.style.position == 'relative' 
            || ( elmt.style.overflow != 'visible' && elmt.style.overflow != '' ) )
        {
            break;
        } 
        offsetTop += elmt.offsetTop;
        offsetLeft += elmt.offsetLeft;
    }
    return { absoluteTop: offsetTop, absoluteLeft: offsetLeft,
        offsetWidth: offsetWidth, offsetHeight: offsetHeight, scrollWidth: scrollWidth };
}
function ClickOnKey(e,btnid)
{
    var key = window.event ? e.keyCode:e.which;
    if(key==13)
        $("#"+btnid).click();
}
//修正ie6下png背景不透明
function correctPNG(eid) {
    for (var i = 0; i < document.getElementById(eid).getElementsByTagName("img").length; i++) {
        var img = document.getElementById(eid).getElementsByTagName("img")[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.parentNode.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
        };
    };
};
function checkload(eid, fnloading,fnloaded) {
    if ($("#" + eid))
        fnloaded();
    else
        fnloading;
}
function isImages(obj) {
    var regImg = new RegExp(/\.(gif|GIF|jpg|JPG|jpeg|JPEG|png|PNG|bmp|BMP)$/);
    if (obj.match(regImg)) {
        return true;
    }
    else {
        return false;
    }
}
function resizeimg(eid,width) {
    var imgs = $("#" + eid + " img");
    for (i = 0; i < imgs.length; i++) {
        imgs[i].width = "";
        imgs[i].height = "";
        DownImageWidth(imgs[i], width);
    }
}
function zoomimg(_eid, src,width) {
    try {
        width = width||455;
        var e = $("#" + _eid);
        e.hide();
        if (e.length > 0 && $("#big" + e.attr("id")).length < 1) {
            var html = "<span class='zoomToolBar'><span class='bar'><a href=\"javascript:hidezoomimg(\'" + _eid + "\')\">收起</a></span><span class='line'></span><span class='bar'><a href='" + src + "' target='_blank'>查看原图</a></span></span>";
            html += "<a href=\"javascript:hidezoomimg(\'" + _eid + "\')\"><img title='点击收起' onload=\"DownImageWidth(this," + width + ")\" width=\"" + width + "\" src='" + src + "'/></a>";
            e.after($("<div id='big" + _eid + "' class=\"zoomBig\" style=\"width:" + width + "px\"/>").html(html));
        }
        else {
            $("#big" + e.attr("id")).show();
        }
    }
    catch (er) {
        alert(er);
    }
}
function hidezoomimg(_eid) {
    try {
        $("#" + _eid).show();
        $("#big" + _eid).hide();
    }
    catch (er) { }
}
function textLength(strTemp) {
    var i, sum;
    sum = 0;
    for (i = 0; i < strTemp.length; i++) {
        if ((strTemp.charCodeAt(i) >= 0) && (strTemp.charCodeAt(i) <= 255))
            sum = sum + 1;
        else
            sum = sum + 2;
    }
    return sum;
}
function AddBookmark() {
    addBookmark(document.title, document.location.href);
}
var PartSite = "";
HD.ShowChangeCity = function(divid, eid, offsetHeight) {
    if ($("#" + divid).length > 0)
        return;
    var id = divid;
    var scrollHeight = "300px";
    var e = $("#" + eid);
    var element = $("<div id=\"" + id + "\" style=\"background-color:#FFF;padding:5px;width:400px;border:solid 1px #F7AB00;line-height:20px;\">数据加载中...</div>")
        .hide()
        .addClass("selectcity")
        .css("position", "absolute")
        .appendTo(document.body);
    var local = window.location.href;
    if (local.indexOf("?url=") > 0)
        local = "http://www.shenghuohui.com";
    else
        local = encodeURIComponent(local);
    function OnSuccess(result) {
        if (result != null) {
            $(result).find("part").each(function(n) {
                PartSite += "<a class=\"blue\" title=\"" + $(this).find("desc").text() + "\" href=\"http://" + $(this).find("url").text() + (($(this).find("url").text().indexOf('?') < 0) ? "?" : "&") + "url=" + local + "\">[" + $(this).find("name").text() + "]</a>";
            });
            PartSite += "&nbsp;&nbsp;<a class=\"blue\" href=\"javascript:HD.Remove('cc1',0)\">关闭</a>";
            element = $("#" + id);
            element.html(PartSite);
        }
    }
    if (PartSite == "") {
        $.ajax({
            type: "Get",
            async: true,
            url: "/xml/PartSite.xml",
            dataType: "xml",
            success: OnSuccess
        });
    }
    else
        element.html(PartSite);
    var offset = $("#" + eid).parent().offset();
    element.css({
        top: offset.top + offsetHeight + 20,
        left: offset.left
    }).show();
}
HD.Remove = function(eid, time) {
    if (time)
        window.setTimeout(function(){ $("#" + eid).remove() }, time);
    else
        $("#" + eid).remove();
}
/*
 * Date Format 1.2.3
 * (c) 2007-2009 Steven Levithan <stevenlevithan.com>
 * MIT license
 *
 * Includes enhancements by Scott Trenda <scott.trenda.net>
 * and Kris Kowal <cixar.com/~kris.kowal/>
 *
 * Accepts a date, a mask, or a date and a mask.
 * Returns a formatted version of the given date.
 * The date defaults to the current date/time.
 * The mask defaults to dateFormat.masks.default.
 */

var dateFormat = function () {
	var	token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
		timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
		timezoneClip = /[^-+\dA-Z]/g,
		pad = function (val, len) {
			val = String(val);
			len = len || 2;
			while (val.length < len) val = "0" + val;
			return val;
		};

	// Regexes and supporting functions are cached through closure
	return function (date, mask, utc) {
		var dF = dateFormat;

		// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
		if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
			mask = date;
			date = undefined;
		}

		// Passing date through Date applies Date.parse, if necessary
		date = date ? new Date(date) : new Date;
		if (isNaN(date)) throw SyntaxError("invalid date");

		mask = String(dF.masks[mask] || mask || dF.masks["default"]);

		// Allow setting the utc argument via the mask
		if (mask.slice(0, 4) == "UTC:") {
			mask = mask.slice(4);
			utc = true;
		}

		var	_ = utc ? "getUTC" : "get",
			d = date[_ + "Date"](),
			D = date[_ + "Day"](),
			m = date[_ + "Month"](),
			y = date[_ + "FullYear"](),
			H = date[_ + "Hours"](),
			M = date[_ + "Minutes"](),
			s = date[_ + "Seconds"](),
			L = date[_ + "Milliseconds"](),
			o = utc ? 0 : date.getTimezoneOffset(),
			flags = {
				d:    d,
				dd:   pad(d),
				ddd:  dF.i18n.dayNames[D],
				dddd: dF.i18n.dayNames[D + 7],
				m:    m + 1,
				mm:   pad(m + 1),
				mmm:  dF.i18n.monthNames[m],
				mmmm: dF.i18n.monthNames[m + 12],
				yy:   String(y).slice(2),
				yyyy: y,
				h:    H % 12 || 12,
				hh:   pad(H % 12 || 12),
				H:    H,
				HH:   pad(H),
				M:    M,
				MM:   pad(M),
				s:    s,
				ss:   pad(s),
				l:    pad(L, 3),
				L:    pad(L > 99 ? Math.round(L / 10) : L),
				t:    H < 12 ? "a"  : "p",
				tt:   H < 12 ? "am" : "pm",
				T:    H < 12 ? "A"  : "P",
				TT:   H < 12 ? "AM" : "PM",
				Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
				o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
				S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
			};

		return mask.replace(token, function ($0) {
			return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
}();

// Some common format strings
dateFormat.masks = {
	"default":      "ddd mmm dd yyyy HH:MM:ss",
	shortDate:      "m/d/yy",
	mediumDate:     "mmm d, yyyy",
	longDate:       "mmmm d, yyyy",
	fullDate:       "dddd, mmmm d, yyyy",
	shortTime:      "h:MM TT",
	mediumTime:     "h:MM:ss TT",
	longTime:       "h:MM:ss TT Z",
	isoDate:        "yyyy-mm-dd",
	isoTime:        "HH:MM:ss",
	isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
	isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};

// Internationalization strings
dateFormat.i18n = {
	dayNames: [
		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
	],
	monthNames: [
		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
		"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
	]
};

// For convenience...
Date.prototype.format = function (mask, utc) {
	return dateFormat(this, mask, utc);
};


