

// old school cookie functions
var Cookies = {};
Cookies.set = function(name, value){
     var argv = arguments;
     var argc = arguments.length;
     var expires = (argc > 2) ? argv[2] : null;
     var path = (argc > 3) ? argv[3] : '/';
     var domain = (argc > 4) ? argv[4] : null;
     var secure = (argc > 5) ? argv[5] : false;
     document.cookie = name + "=" + escape (value) +
       ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
       ((path == null) ? "" : ("; path=" + path)) +
       ((domain == null) ? "" : ("; domain=" + domain)) +
       ((secure == true) ? "; secure" : "");
};

Cookies.get = function(name){
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	var j = 0;
	while(i < clen){
		j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return Cookies.getCookieVal(j);
		i = document.cookie.indexOf(" ", i) + 1;
		if(i == 0)
			break;
	}
	return null;
};

Cookies.clear = function(name) {
  if(Cookies.get(name)){
    document.cookie = name + "=" +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
};

Cookies.getCookieVal = function(offset){
   var endstr = document.cookie.indexOf(";", offset);
   if(endstr == -1){
       endstr = document.cookie.length;
   }
   return unescape(document.cookie.substring(offset, endstr));
};



    
    function CloseMessageBoxBg()
    {
        try
        {
            $("msgbgiframe").style.display="none";
        }catch(eeee){}
    }
    


    if(Ext!=undefined)
    {
        oldAlert=window.alert;
        window.alert=function(showmsg,title,fun,width)
        {
            var w=width;
            if(!w || w<230)
            {
                w=230;
            }
            
//            if(fun==null || fun==undefined || typeof(fun)!="function")
//            {
//                fun=CloseMessageBoxBg;
//            }
//            
//            
//            $("msgbgiframe").style.display="block";
            
            Ext.MessageBox.show({
                   width: w,
                   title: title,
                   msg: showmsg,
                   buttons: Ext.MessageBox.OK,
                   fn: fun,
                   icon: Ext.MessageBox.INFO,
                   style:'z-index:99999;'
            });
            var win=Ext.MessageBox.getDialog();
            win.on("move",function(thisobj,x,y){
                var obj=$("msgbgiframe");
                thisobj.setZIndex(99999);
                if(obj.style.left!=x || obj.style.top!=y)
                {
                    obj.style.left=x;
                    obj.style.top=y;
                }
                if(obj.style.display!="block")
                {
                    obj.style.display="block";
                    obj.style.width=thisobj.getWidth();
                    obj.style.height=thisobj.getHeight();
                }
            });
             win.on("hide",function(thisobj,x,y){
                thisobj.setZIndex(99999);
                var obj=$("msgbgiframe");
                $("msgbgiframe").style.display="none";
            });
             win.on("show",function(thisobj,x,y){
                thisobj.setZIndex(99999);
                var obj=$("msgbgiframe");
                obj.style.display="block";
                obj.style.width=thisobj.getWidth();
                obj.style.height=thisobj.getHeight();
            });
            try
            { 
                win.setZIndex(99999);
                var posobj=win.getPosition();
                var obj=$("msgbgiframe");
                win.setPosition(posobj[0]+1,posobj[1]); 
            }catch(eevv){}
            
        }
        
       
        window.alertChose=function(showmsg)
        {
            return Ext.MessageBox.show({
                   width: 230,
                   title: title,
                   msg: showmsg,
                   buttons: Ext.MessageBox.YES | Ext.MessageBox.NO,
                   icon: Ext.MessageBox.INFO
            });
        }
        
        window.alertXml=function(showmsg,title,fun)
        {
            showmsg=showmsg.replace(/[<]/g,"&lt;");
            Ext.MessageBox.show({
                   width: 230,
                   title: title,
                   msg: showmsg,
                   buttons: Ext.MessageBox.OK,
                   fn: fun,
                   icon: Ext.MessageBox.INFO
            });
        }
}