﻿var kg={
    fnTure:function(){return true;},
    fnFalse:function(){return false;}
};
kg.Class = {
    Create:function(){
        return function()
        {
            this.initialize.apply(this,arguments);
        }
    }
} ;  
if(typeof($)=="undefined")
{
    $=function(id)
    {
        return document.getElementById(id);
    }
}    
if(typeof($A)=="undefined")
{
    $A=function(arg)
    {
        var result = [];
        for(var i =0;i<arg.length;i++)
        {
            result.push(arg[i]);
        }
        return result;
    }        
}
kg.extend = function(arg)
{
    var srcs = $A(arguments);
    srcs.splice(0, 1);
    for (var i = 0; i < srcs.length; i++)
    {
        var src = srcs[i];
        for (var p in src)
        {
          arg[p] = src[p];
        }
     }
     return arg;
}
kg.Event = 
{
    stop: function(ent) 
    {           
        var e = ent||window.event;
        if (e.preventDefault) 
        {
          e.preventDefault();
          e.stopPropagation();
        } 
        else 
        {
          e.returnValue = false;
          e.cancelBubble = true;
        }
    },
    add:function(elem,name,fn,useCapture)
    {
        if(elem.addEventListener)
        {
            elem.addEventListener(name,fn,useCapture);
        }
        if(elem.attachEvent)
        {
            elem.attachEvent("on"+name,fn);
        }
    },
    remove:function(elem,name,fn,useCapture)
    {
        if(elem.removeEventListener)
        {
            elem.removeEventListener(name,fn,useCapture);           
        }
        else if(elem.detachEvent)
        {
            elem.detachEvent("on"+name,fn);
        }
    } 
     
}
kg.Va={
    validate:function(o,reg)
    {
      return new RegExp(reg).test(o.value);        
    }
}
kg.Page = {
  pointer: function(e) 
  {
    return {x: (e.pageX || e.clientX), y: (e.pageY || e.clientY)};
  },
  getWindowClientWidth: function() {
    return window.innerWidth 
        || document.documentElement.clientWidth
        || document.body.clientWidth
        || 0;
  },
  getWindowClientHeight: function() {
    return window.innerHeight 
        || document.documentElement.clientHeight
        || document.body.clientHeight
        || 0;
  },
  getWindowScrollWidth: function() {
    return window.scrollWidth 
        || document.documentElement.scrollWidth
        || document.body.scrollWidth;
  },
  getWindowScrollHeight: function() {
    return window.scrollHeight
        || document.documentElement.scrollHeight
        || document.body.scrollHeight;
  },
  getWindowScrollLeft: function() {
    if (window.scrollWidth) {
      return window.scrollLeft;
    } else if (document.documentElement.scrollWidth) {
      return document.documentElement.scrollLeft;
    } else if (document.body.scrollWidth) {
      return document.body.scrollLeft
    } else {
      return 0;
    }
  },
  getWindowScrollTop: function() {
    if (window.scrollWidth) {
      return window.scrollTop;
    } else if (document.documentElement.scrollWidth) {
      return document.documentElement.scrollTop;
    } else if (document.body.scrollWidth) {
      return document.body.scrollTop;
    } else {
      return 0;
    }
  },
  getObjOffsetWidth:function(o)
  {
    return o.offsetWidth;
  },
  getObjOffsetHeight:function(o)
  {
    return o.offsetHeight;
  },
  getRealLeft:function(o)
  {
     var l = 0;
     while(o)
     {
          l += o.offsetLeft - o.scrollLeft;
          o = o.offsetParent; 
     }
     return(l);
 },
setFocus:function()
{
    var colInputs =document.getElementsByTagName("input");   
    for (var i=0; i < colInputs.length; i++)
    {
        if (colInputs[i].type == "text" || colInputs [i].type == "password") 
        {
            colInputs[i].focus();
            break;
        }
    }   
},  
 getRealTop:function(o)
 {
     var t = 0;
     while(o)
      {
          t += o.offsetTop - o.scrollTop;
          o = o.offsetParent; 
      }
     return(t);
 }  
};

kg.index={};
kg.index.Alert = 
{
  id: "Alert",
  className: "win",
  btnClose: "win_Close",
  btnOk: "Alert_ok",
  content: "Alert_content",
  zIndex: "10000",
  title:"Alert_title",
  title_middle:"Alert_middle",
  head:"Alert_head"
};

kg.index.Alert.fnCreateElement = function() 
{
  var index = kg.index.Alert;
  var elem = document.createElement("DIV");
  elem.id = index.id;
  elem.className = index.className;
  elem.innerHTML = '\
	<div class="title" id="'+index.head+'">\
                <span class="left"><img alt=""  src="/images/window_bg_left_2.gif"/></span>\
                <span class="middle" id="'+index.title_middle+'">\
                    <span class="left font"id="'+index.title+'" >狗窝提示</span>\
                    <span class="right" style="padding-top:3px">\
                        <a href=""><img alt="" id="'+index.btnClose+'" src="/images/window_bg_close.gif"/></a>\
                    </span>\
                </span>\
                <span class="right"><img alt="" src="/images/window_bg_right.gif"/></span>\
            </div>\
            <div class="body">\
            <div class="content" id="'+index.content+'">\
              </div>\
            </div>\
            <div class="bottom">\
                <input class="winbtn font" id="'+index.btnOk+'" type="button"  value="确 定"/>\
            </div>';
  document.body.appendChild(elem);
}
kg.index.Confirm=
{
   id: "Confirm",
   className: "win",  
   title:"Confirm_title",
   title_middle:"Confirm_middle",
   btnClose: "win_Close",
   btnOk: "Confirm_ok",
   btnCancel:"Confirm_cancel",
   content: "Confirm_content", 
   zIndex: "10000",
   head:"Confirm_head"
};
kg.index.Confirm.fnCreateElement=function()
{
  var index = kg.index.Confirm;
  var elem = document.createElement("DIV");
  elem.id = index.id;
  elem.className = index.className;
  elem.innerHTML ='\
            <div class="title" id="'+index.head+'">\
                <span class="left"><img alt=""  src="/images/window_bg_left_2.gif"/></span>\
                <span class="middle" id="'+index.title_middle+'">\
                    <span class="left font"id="'+index.title+'" >狗窝提示</span>\
                    <span class="right" style="padding-top:3px">\
                        <a href=""><img alt="" id="'+index.btnClose+'" src="/images/window_bg_close.gif"/></a>\
                    </span>\
                </span>\
                <span class="right"><img alt="" src="/images/window_bg_right.gif"/></span>\
            </div>\
            <div class="body">\
            <div class="content" id="'+index.content+'">\
              </div>\
            </div>\
            <div class="bottom">\
                <input class="winbtn font" id="'+index.btnOk+'" type="button"  value="确 定"/>\
                <input class="winbtn font" id="'+index.btnCancel+'" type="button" value="取 消"/>\
            </div>';
  document.body.appendChild(elem);
}
kg.index.Information =
{
   id: "information",
   className: "win", 
   content: "index_information_content",   
   zIndex: "10000",
   head:"info_head",
   title_middel:"info_title_middel",
   title:"info_title"
};
kg.index.Information.fnCreateElement=function()
{
    var info = kg.index.Information;
    var elem = document.createElement("DIV");
    elem.id = info.id;
    elem.className=info.className;
    elem.innerHTML = '\
        <div class="title" id="'+info.head+'">\
                <span class="left"><img alt=""  src="/images/window_bg_left_2.gif"/></span>\
                <span class="middle" id="'+info.title_middle+'">\
                    <span class="left font"id="'+info.title+'" >狗窝提示</span>\
                </span>\
                <span class="right"><img alt="" src="/images/window_bg_right.gif"/></span>\
            </div>\
            <div class="login">\
            <div class="content" id="'+info.content+'">\
              </div>\
            </div>';
	document.body.appendChild(elem);
}
kg.index.Login=
{
   id: "login",
   className: "win",
   title:"Confirm_title",
   title_middle:"Confirm_middle", 
   btnClose: "win_Close",
   url: "",     
   zIndex: "10000",
   head:"Confirm_head",
   bodyHeight:"i_body"
}
kg.index.Login.fnCreateElement=function(url)
{
    var login = kg.index.Login;
    var elem = document.createElement("DIV");
    elem.id = login.id;
    elem.className=login.className;
    elem.innerHTML = '\
	<div class="title" id="'+login.head+'">\
        <span class="left"><img alt=""  src="/images/window_bg_left_2.gif"/></span>\
        <span class="middle" id="'+login.title_middle+'">\
            <span class="left font" id="'+login.title+'">用户登录</span>\
            <span class="right" style="padding-top:3px">\
                <a href=""><img alt="" id="'+login.btnClose+'" src="/images/window_bg_close.gif"/></a>\
            </span>\
        </span>\
        <span class="right"><img alt="" src="/images/window_bg_right.gif"/></span>\
    </div>\
	<div class="login" id="'+login.bodyHeight+'">\
	    <iframe frameborder=0 height="100%" width="100%"  scrolling="no"  src="'+ url +'"></iframe>\
	</div>';
	document.body.appendChild(elem);
}

kg.index.Iframe=
{
   id: "iframe",
   className: "win",
   title:"Iframe_title",
   title_middle:"Iframe_middle",  
   btnClose: "win_Close", 
   url: "",     
   zIndex: "10000",
   head:"Iframe_head",
   bodyHeight:"i_body"
}
kg.index.Iframe.fnCreateElement=function(url)
{
    var iframe = kg.index.Iframe;
    var elem = document.createElement("DIV");
    elem.id = iframe.id;
    elem.className=iframe.className;
    elem.innerHTML = '\
	<div class="title" id="'+iframe.head+'">\
        <span class="left"><img alt=""  src="/images/window_bg_left_2.gif"/></span>\
        <span class="middle" id="'+iframe.title_middle+'">\
            <span class="left font" id="'+iframe.title+'">用户登录</span>\
            <span class="right" style="padding-top:3px">\
            <a href="" style="display:none"><img alt="" id="'+iframe.btnClose+'" src="/images/window_bg_close.gif"/></a>\
            </span>\
        </span>\
        <span class="right"><img alt="" src="/images/window_bg_right.gif"/></span>\
    </div>\
	<div class="login" id="'+iframe.bodyHeight+'">\
	    <iframe frameborder=0 height="100%" width="100%"  scrolling="no"  src="'+ url +'"></iframe>\
	</div>';
	document.body.appendChild(elem);
}
kg.index.Blank=
{
   id: "blank",
   className: "win",  
    title:"blank_title",
   title_middle:"blank_middle",  
    btnClose: "win_Close", 
   url: "",
   head:"blank_head",     
   zIndex: "10000",   
   bodyHeight:"i_body"
}
kg.index.Blank.fnCreateElement=function(url)
{
    var blank = kg.index.Blank;
    var elem = document.createElement("DIV");
    elem.id = blank.id;
    elem.className=blank.className;
    elem.innerHTML = '\
	<div style="height:0px;"  id="'+blank.head+'">\
        <span ></span>\
        <span style="" id="'+blank.title_middle+'">\
            <span id="'+blank.title+'"></span>\
        </span>\
        <span><a href="" style="display:none"><img alt="" id="'+blank.btnClose+'" src="/images/window_bg_close.gif"/></a></span>\
    </div>\
	<div id="'+blank.bodyHeight+'">\
	    <iframe frameborder=0 height="100%" width="100%" allowTransparency="allowTransparency" scrolling="no"  src="'+ url +'"></iframe>\
	</div>';
	document.body.appendChild(elem);
}

kg.MaskWindow = kg.Class.Create();
kg.extend(kg.MaskWindow.prototype,{    
    initialize:function()
    {    
         this.mask = document.createElement("DIV");                    
            this.mask.id ="Mask";
            kg.extend(this.mask.style, 
            {              
      	      display: "none",
		      position: "absolute",
		      backgroundColor: "#000",
		      zIndex: "9999",
		      opacity: "0.10",
		      filter: "Alpha(Opacity=10)",
		      left:"0px",
		      top:"0px"
            });
            this.b_Iframe = document.createElement("IFRAME");
            this.b_Iframe.id="b_Iframe";           
            this.b_Iframe.style.allowTransparency = "allowTransparency"; 
            this.mask.appendChild(this.b_Iframe);          
           document.body.appendChild(this.mask); 
           this.elem =typeof(this.id) =="string"?$(this.id):this.id;
           if(this.btnClose)
           {    
                var self = this;
                $(this.btnClose).onclick = function(event)
                {
                    kg.Event.stop(event);
                    self.hide();                   
                }
           }          
    }, 
    setMessage:function(msg,icon)
    {       
        this.content?$(this.content).innerHTML = this.setIcon(icon)+msg:kg.fnTure();
    }, 
    setIcon:function(icon)
    {
        var DivIcon="";
        if(icon){
        switch(icon)
        {
            case "ok":DivIcon = "<img alt='' src='/images/true.gif'/>";break;
            case "error":DivIcon = "<img alt='' src='/images/error.gif'/>";break;
            case "note":DivIcon = "<img alt='' src='/images/note.gif'/>";break;
            case "why":DivIcon = "<img alt='' src='/images/why.gif'/>";break;                   
        }}
        return DivIcon+"&nbsp;";        
    },    
    hide:function()
    {  
       document.body.removeChild(this.elem);     
       document.body.removeChild(this.mask);
    },
    HideIframe:function(o)
    {           
       document.body.removeChild(this.elem);   
       document.body.removeChild(this.mask);      
    },
    setVisible:function()
    {
         this.mask.style.display="";
         this.elem.style.display="";      
    },
    setWidth:function(){ 
        this.b_Iframe.style.width =  kg.Page.getWindowScrollWidth()+"px";       
        this.mask.style.width = kg.Page.getWindowScrollWidth()+"px";
       
    },
    setHeight:function(){ 
        this.b_Iframe.style.height =  kg.Page.getWindowScrollHeight()+"px";
        this.mask.style.height = kg.Page.getWindowScrollHeight()+"px";
       
    },
    setLeft:function(x){
        this.elem.style.left = x+"px";
    },
    setTop:function(y){
        this.elem.style.top=y+"px";
    },
    setCenter:function(){
        this.setLeft(kg.Page.getWindowScrollLeft()+(kg.Page.getWindowClientWidth()-kg.Page.getObjOffsetWidth(this.elem))/2);
        this.setTop(kg.Page.getWindowScrollTop()+(kg.Page.getWindowClientHeight()-kg.Page.getObjOffsetHeight(this.elem))/2);
    },   
    setTitleWidth:function(h){
        $(this.head)?$(this.head).style.width=h>=400?h+"px":$(this.head).style.width:kg.fnTure();
        this.elem?this.elem.style.width=h>=400?h+"px":this.elem.style.width:kg.fnTure();
        $(this.title_middle)?$(this.title_middle).style.width=h>=400?(h-35)+"px":$(this.title_middle).style.width:kg.fnTure();    
    },
    setBodyHeight:function(h){
        $(this.bodyHeight)?$(this.bodyHeight).style.height = h+"px":kg.fnTure();
    },
    setBtnOkValue:function(v){ $(this.btnOk)?v?$(this.btnOk).value = v:$(this.btnOk).value:kg.fnTure();},
    setBtnCancelValue:function(v){ $(this.btnCancel)?v?$(this.btnCancel).value=v:$(this.btnCancel).value:kg.fnTure();},
    setTitle:function(t){$(this.title)?$(this.title).innerHTML=t?t:$(this.title).innerHTML:kg.fnTure();},
    setMove:function()
    {
       var move = new MoveResize("dragresize",{minWidth:100,minHeight:100,minTop:0,maxLeft:1000,minZIndex:9999,maxZIndex:10010});
       var o =  $(this.title_middle);
       o.style.cursor="move";
       move.AddObject({canMove:true,canResize:false,element:this.elem,handle:o});
    }
});

kg.MaskWindow.LoginWindow = kg.Class.Create();
kg.extend(kg.MaskWindow.LoginWindow.prototype,kg.MaskWindow.prototype,
{
    initialize:function()
    {
        kg.extend(this,kg.index.Login);       
        kg.index.Login.fnCreateElement(arguments[0]);       
        kg.MaskWindow.prototype.initialize.apply(this,arguments);        
    }   
}
);

kg.MaskWindow.IframeWindow = kg.Class.Create();
kg.extend(kg.MaskWindow.IframeWindow.prototype,kg.MaskWindow.prototype,
{
    initialize:function()
    {
        kg.extend(this,kg.index.Iframe);       
        kg.index.Iframe.fnCreateElement(arguments[0]);       
        kg.MaskWindow.prototype.initialize.apply(this,arguments);        
    }   
}
);

kg.MaskWindow.AlertWidow = kg.Class.Create();
kg.extend(kg.MaskWindow.AlertWidow.prototype,kg.MaskWindow.prototype,
{
    initialize:function()
    {
        kg.extend(this,kg.index.Alert);
        kg.index.Alert.fnCreateElement();
        kg.MaskWindow.prototype.initialize.apply(this,arguments);
        var self = this;
        $(self.btnOk).onclick=function(e)
        {
            e = e||window.event;
            self.hide();
            self.fnOk(e);                              
        }              
    },   
    fnOk:function(e){ return true;}
});

kg.MaskWindow.ConfirmWindow = kg.Class.Create();
kg.extend(kg.MaskWindow.ConfirmWindow.prototype,kg.MaskWindow.prototype,
{
    initialize:function()
    {
        kg.extend(this,kg.index.Confirm);
        this.fnCreateElement();
        kg.MaskWindow.prototype.initialize.apply(this,arguments);        
        var self = this;
        $(this.btnOk).onclick=function(e)
        {
           e = e||window.event;
           self.hide(e);
           self.fnOk(e);
        }
        $(this.btnCancel).onclick=function(e)
        {
            e = e||window.event;
            self.hide(e);
            self.fnCancel(e);            
        }
    },   
    fnOk:function(e){return true;},
    fnCancel:function(e){return true;}
});

kg.MaskWindow.InfoWindow = kg.Class.Create();
kg.extend(kg.MaskWindow.InfoWindow.prototype,kg.MaskWindow.prototype,
{
    initialize:function()
    {
       kg.extend(this,kg.index.Information);
       this.fnCreateElement();
       kg.MaskWindow.prototype.initialize.apply(this,arguments);       
    },
    autoHide:function(time)
    {    
        var w = this;   
        setTimeout(function(){w.hide();},time);  
    }
});

kg.MaskWindow.Blank = kg.Class.Create();
kg.extend(kg.MaskWindow.Blank.prototype,kg.MaskWindow.prototype,
{
    initialize:function()
    {
       kg.extend(this,kg.index.Blank);
       this.fnCreateElement(arguments[0]);
       kg.MaskWindow.prototype.initialize.apply(this,arguments);       
    }    
});

kg.CallBack={
    alert:
    {
        getCallBack:function()
        {
            return this.fnCallBack;
        }
    },
    confirm:
    {
        getCallBack:function()
        {
            return this.fnCallBack;
        }
    },
    Information:
    {
        getCallBack:function()
        {
            return this.fnCallBack;
        }
    },
    login:
    {
        getCallBack:function()
        {
            return this.fnCallBack;
        }
    },
    iframe:
    {
        getCallBack:function()
        {
            return this.fnCallBack;
        }
    },
    blank:
    {
        getCallBack:function()
        {
            return this.fnCallBack;
        }
    }
};
kg.CallBack.alert.fnCallBack= function(msg,title,fnOk,w,Ok,icon,move)
{
   Alert  = new kg.MaskWindow.AlertWidow();
   Alert.fnOk = fnOk ? ((fnOk instanceof Function) ? fnOk : ((typeof(fnOk)=="string") ? new Function("e",fnOk):kg.fnTure)):kg.fnTure;
   kg.SetObj(Alert,msg,title,w,Ok,0,icon,move);  
}
kg.CallBack.confirm.fnCallBack=function(msg,title,fnOk,fnCancel,w,Ok,Cancel,icon,move)
{
    Confirm = new kg.MaskWindow.ConfirmWindow();
    Confirm.fnOk=fnOk ? ((fnOk instanceof Function) ? fnOk : ((typeof(fnOk)=="string") ? new Function("e",fnOk):kg.fnTure)):kg.fnTure;
    Confirm.fnCancel=fnCancel ? ((fnCancel instanceof Function) ? fnCancel : ((typeof(fnCancel)=="string") ? new Function("e",fnCancel):kg.fnTure)):kg.fnTure;    
    kg.SetObj(Confirm,msg,title,w,Ok,Cancel,icon,move);  
}
kg.CallBack.Information.fnCallBack=function(msg,time,w)
{
    info = new kg.MaskWindow.InfoWindow(); 
    kg.SetObj(info,msg,"",w);  
    info.autoHide(time);  
}
kg.CallBack.login.fnCallBack=function(url,title,w,h,move)
{
    Login = new kg.MaskWindow.LoginWindow(url);
    kg.SetObj(Login,"",title,w,null,null,null,move,h);
   
}
kg.CallBack.iframe.fnCallBack=function(url,title,w,h,move)
{
    Iframe = new kg.MaskWindow.IframeWindow(url);
    kg.SetObj(Iframe,"",title,w,null,null,null,move,h);   
}
kg.CallBack.blank.fnCallBack=function(url,w,h)
{
    Blank = new kg.MaskWindow.Blank(url);
    kg.SetObj(Blank,"",null,w,null,null,null,false,h);   
}
kg.SetObj=function(o,msg,title,w,Ok,Cancel,icon,move,h)
{     
    o.setTitleWidth(w);
    h?o.setBodyHeight(h):kg.fnTure(); 
    o.setMessage(msg,icon);
    o.setCenter();
    o.setVisible();    
    o.setHeight(); 
    o.setWidth();    
    o.setTitle(title);
    o.setBtnOkValue(Ok);
    o.setBtnCancelValue(Cancel);    
    move?o.setMove(name):kg.fnTure();

}

/********************************************************
 *                  警告框 (alert)                      *
 *------------------------------------------------------* 
 * msg:         提示信息
 * title:       窗口标题,可以为空
 * fnOk:        点击ok按钮的回调函数
 *  w:          窗口的宽度,默认值为400
 *  Ok:         OK 按钮的提示文本
 * icon:        图标 可填ok/error/note
 * move:        是否可托动(true/false)
 ********************************************************/
kg.Alert=function(msg,title,fnOk,w,Ok,icon,move)
{
   kg.CallBack.alert.getCallBack()(msg,title,fnOk,w,Ok,icon,move);
  
}


/********************************************************
 *                  确认框  (Confirm)                   *
 *------------------------------------------------------* 
 * msg:         提示信息
 * title:       窗口标题,可以为空
 * fnOk:        点击ok按钮的回调函数
 * fnCancel:    点击cancel按钮的回调函数
 *  w:          窗口的宽度,默认值为400
 *  Ok:         OK 按钮的提示文本
 * Cancel:      Cancel  按钮的提示文本     
 * icon:        图标 可填ok/error/note
 * move:        是否可托动(true/false)
 ********************************************************/
kg.Confirm=function(msg,title,fnOk,fnCancel,w,Ok,Cancel,icon,move)
{    
   kg.CallBack.confirm.getCallBack()(msg,title,fnOk,fnCancel,w,Ok,Cancel,icon,move);
}


/********************************************************
 *                      提示框                          *
 *------------------------------------------------------* 
 * msg:         提示信息
 * time:        自动关闭的时间
 *  w:          窗口宽度  
 ********************************************************/
kg.Info= function(msg,time,w)
{
   kg.CallBack.Information.getCallBack()(msg,time,w);
}



/********************************************************
 *        内嵌网页框 (在弹出窗口内嵌一个iframe)         *
 *------------------------------------------------------* 
 * url:         内嵌页面地址
 * title:       窗口标题
 *  w:          窗口宽度
 *  h:          窗口body高度
 * move:        是否可托动(true/false)
 *******************************************************/
kg.Login = function(url,title,w,h,move)
{
    kg.CallBack.login.getCallBack()(url,title,w,h,move);
}

/********************************************************
 *     内嵌网页框 (在弹出窗口内嵌一个iframe,无关闭按钮) *
 *------------------------------------------------------* 
 * url:         内嵌页面地址
 * title:       窗口标题
 *  w:          窗口宽度
 *  h:          窗口body高度
 * move:        是否可托动(true/false)
 *******************************************************/
 
kg.Iframe = function(url,title,w,h,move)
{
    kg.CallBack.iframe.getCallBack()(url,title,w,h,move);
}

/********************************************************
 *          内嵌网页框 (在弹出窗口内嵌一个iframe)       *
 *------------------------------------------------------* 
 * url:         内嵌页面地址
 *  w:          窗口宽度
 *  h:          窗口body高度
 *******************************************************/
 kg.Blank = function(url,w,h)
 {
    kg.CallBack.blank.getCallBack()(url,w,h);
 }

/********************************************************
 *              从内嵌网页框内关闭当前窗口              *
 *------------------------------------------------------* 
 *                      无参数
 *******************************************************/
kg.Close = function()
{
   if(document.all)
   {
	    window.parent.document.getElementById("win_Close").click();   
   }
   else
   {
        var evt = document.createEvent("MouseEvents");
        evt.initEvent("click",true,true);
	    window.parent.document.getElementById("win_Close").dispatchEvent(evt);       
   }
}
kg.TopClose = function()
{
    if(document.all)
   {
        document.getElementById("win_Close").click();  
   }
   else
   {
        var evt = document.createEvent("MouseEvents");
        evt.initEvent("click",true,true);
        document.getElementById("win_Close").dispatchEvent(evt);       
   }
}
