var Showbo={author:'ShowBo',homepage:'about:blank'};
//�Ƿ�Ϊie�����
Showbo.IsIE=!!document.all;
//ie�����汾
Showbo.IEVersion=(function(){if(!Showbo.IsIE)return -1;try{return parseFloat(/msie ([\d\.]+)/i.exec(navigator.userAgent)[1]);}catch(e){return -1;}})();
//��id��ȡ����
Showbo.$=function(Id,isFrame){
	var o;
	if("string"==typeof(Id))
	 {
	  if(document.getElementById(Id)!=null)
	   o= document.getElementById(Id);
	  else
	   o=null;
	 }
	 else if("object"==typeof(Id))
	  o= Id;
	 else return null;
	 return isFrame?(Showbo.IsIE?frames[Id]:o.contentWindow):o;
	}
	
//����ǩ��ƻ�ȡ����
//ҳ��ĸߺͿ�******************************
Showbo.isStrict=document.compatMode == "CSS1Compat";
Showbo.BodyScale={x:0,y:0,tx:0,ty:0};//��x��y������ǰ������������С  ��tx��ty�����ܵ�ҳ����Ⱥ͸߶�
Showbo.getClientHeight=function(){/*if(Showbo.IsIE)*/return Showbo.isStrict ? document.documentElement.clientHeight :document.body.clientHeight;/*else return self.innerHeight;*/}
Showbo.getScrollHeight=function(){var h=!Showbo.isStrict?document.body.scrollHeight:document.documentElement.scrollHeight;return Math.max(h,this.getClientHeight());}
Showbo.getHeight=function(full){return full?this.getScrollHeight():this.getClientHeight();}

Showbo.getClientWidth=function(){/*if(Showbo.IsIE)*/return Showbo.isStrict?document.documentElement.clientWidth:document.body.clientWidth;/*else return self.innerWidth;*/}
Showbo.getScrollWidth=function(){var w=!Showbo.isStrict?document.body.scrollWidth:document.documentElement.scrollWidth;return Math.max(w,this.getClientWidth());}
Showbo.getWidth=function(full){return full?this.getScrollWidth():this.getClientWidth();}

Showbo.initBodyScale=function(){//��ʼ������
	Showbo.BodyScale.x=Showbo.getWidth(false);
	Showbo.BodyScale.y=Showbo.getHeight(false);
	Showbo.BodyScale.tx=Showbo.getWidth(true);
	Showbo.BodyScale.ty=Showbo.getHeight(true);
  }
//ҳ��ĸߺͿ�******************************

Showbo.Msg={
    INFO:'info',
    ERROR:'error',
    WARNING:'warning',
    IsInit:false,
    timer:null,
    dvTitle:null,
    dvCT:null,
    dvBottom:null,
    dvBtns:null,
    lightBox:null,
    dvMsgBox:null,
    defaultWidth:350,
    moveProcessbar:function(){
      var o_left=Showbo.$('dvProcessbar_left'),o_right=Showbo.$('dvProcessbar_right');
	  var w_left=o_left.style.width,w_right=o_right.style.width;

	  if(w_left=='')
	    w_left=0;
      else
	  {
        w_left=parseInt(w_left)+1;
        if(w_left>100)
		{ 
		 w_left=0;
		}
      }
      o_left.style.width=w_left+'%';
	  
	  },

	
    InitMsg:function(width){
      //ie�²���������¼���ѭ��4ִ�У�����Ҫע���ڵ���alert�ȷ���ʱҪ����Ƿ��Ѿ���ʼ��IsInit=true     
      var ifStr='<iframe src="javascript:false" style="position:absolute; visibility:inherit; top:0px;left:0px;width:100%; height:100%; z-index:-1;'
          +'filter=\'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)\';"></iframe>',
      html='<div class="top"><div class="right"><div class="title" id="dvMsgTitle"></div></div></div>'+
        '<div class="body"><div class="right"><div class="ct" id="dvMsgCT"></div></div></div>'+
        '<div class="bottom" id="dvMsgBottom"><div class="right"><div class="btn" id="dvMsgBtns"></div></div></div>';
		
      this.dvMsgBox=document.createElement("div");
      this.dvMsgBox.id="dvMsgBox";
      this.dvMsgBox.innerHTML+=html;      
      //document.body.appendChild(this.dvMsgBox);
	  //ʹ����������������Խ��Internet Explorer �޷��� Internet վ��......��
	  document.body.insertBefore(this.dvMsgBox,document.body.childNodes[0]);
	  
      this.lightBox=document.createElement("div");
      this.lightBox.id="ShowBolightBox";
      //document.body.appendChild(this.lightBox);
	  document.body.insertBefore(this.lightBox,document.body.childNodes[0]);
	  
      if(Showbo.IsIE&&Showbo.IEVersion<7){//��iframe������ie6���޷��ڸ�סselect������
        this.lightBox.innerHTML+=ifStr;
        this.dvMsgBox.innerHTML+=ifStr;
      }
      this.dvBottom=Showbo.$('dvMsgBottom');
      this.dvBtns=Showbo.$('dvMsgBtns');
      this.dvCT=Showbo.$('dvMsgCT');
      this.dvTitle=Showbo.$('dvMsgTitle');
      this.IsInit=true;
    },
    checkDOMLast:function(){//�˷����ǳ��ؼ�Ҫ���޷���ʾ����ڡ�}�����dvMsgBox��lightBox���봦��body�����}��ڵ���
      if(document.body.lastChild!=this.lightBox){
        //document.body.appendChild(this.dvMsgBox);
	    document.body.insertBefore(this.dvMsgBox,document.body.childNodes[0]);
        //document.body.appendChild(this.lightBox);
	    document.body.insertBefore(this.lightBox,document.body.childNodes[0]);
      }
    },
    createBtn:function(p,v,fn){
        var btn=document.createElement("input");
        btn.type="button";
        btn.className='btn';
        btn.value=v;
        btn.onmouseover=function(){this.className='btnfocus';}
        btn.onmouseout=function(){this.className='btn';}
        btn.onclick=function(){
          Showbo.Msg.hide();
          if(fn)fn(p);
        }
        return btn;
    },
	//)��Ĳ���
	iconfn:function(style){
	  if(!style)style="";
	  if(style=="ERROR")style=Showbo.Msg.ERROR;
	  if(style=="INFO")style=Showbo.Msg.INFO;
	  if(style=="WARNING")style=Showbo.Msg.WARNING;
	  return style;
	},
	//)��Ĳ��ֽ���
	
    alert:function(msgTitle,msgText,iconStyle,width,fn){
	  var msg="";
	  if(msgTitle!=""&&msgTitle!=null) msg='<font color=red><b>'+msgTitle+'</b></font><br>';
	  if(msgText!=""&&msgText!=null) msg+=msgText;
      this.show({title:'��ʾ',buttons:{yes:'ȷ ��'},msg:msg,icon:this.iconfn(iconStyle),width:width,fn:fn});
    },
	
    confirm:function(msg,iconStyle,width,fn){
      //fnΪ�ص�������show������һ��
      this.show({title:'��ʾ',buttons:{yes:'ȷ ��',no:'ȡ ��'},icon:this.iconfn(iconStyle),msg:msg,width:width,fn:fn});
    },
	
    prompt:function(labelWord_1,defaultValue_1,txtId_1,labelWord_2,defaultValue_2,txtId_2,iconStyle,width,fn){
	  var ShowTxtId_1=false,ShowTxtId_2=false,msg="";
	  msg=labelWord_1;
      //��һ�������
	  if(!labelWord_1)labelWord_1='�����룺';
      if(!defaultValue_1)defaultValue_1="";
      if(!txtId_1)
	   {txtId_1="msg_txtInput_1";}
	  else
	   {ShowTxtId_1=true;}
	  if(ShowTxtId_1==true)msg+='<input type="text" id="'+txtId_1+'" style="width:220px;height:20px;font-size:15px;" value="'+defaultValue_1+'"/>';
	  //�ڶ��������������������
      if(!labelWord_2)labelWord_2='�����룺';
      if(!defaultValue_2)defaultValue_2="";
      if(!txtId_2) 
	   {txtId_2="msg_txtInput_2";}
	  else
	   {ShowTxtId_2=true;}//��������˵ڶ���������ID������ʾ
	  if(ShowTxtId_2==true) msg+='<br>'+labelWord_2+'<input type="password" id="'+txtId_2+'" style="width:220px;height:20px;font-size:15px;" value="'+defaultValue_2+'"/>';
	  
      this.show({title:'��ʾ',msg:msg,icon:this.iconfn(iconStyle),buttons:{yes:'ȷ ��',no:'ȡ ��'},width:width,fn:fn});
    },
	
    wait:function(msg,title){
      if(!msg)msg='���ڴ���...';
	  if(!title)title='���Ժ�';
      this.show({title:title,msg:msg,buttons:{yes:'ȷ ��',no:'ȡ ��'},wait:true});
    },
	
    show:function(cfg){
      //cfg:{title:'',msg:'',wait:true,icon:'Ĭ��Ϊ��Ϣ',buttons:{yes:'',no:''},fn:function(btn){�ص���,btnΪ���İ�ť������Ϊyes��no},width:��ʾ��Ŀ�}
      //����ǵȴ���wait��������ò���Ҫ�ˡ�
      if(!cfg)throw("û��ָ�������ļ���");
      //��Ӵ����С�ı����
      if(Showbo.IsIE)window.attachEvent("onresize",this.onResize);
      else  window.addEventListener("resize",this.onResize,false);
      
      if(!this.IsInit)this.InitMsg();//��ʼ��dom����
      else this.checkDOMLast();//����Ƿ������
      
      //����Ƿ�Ҫָ���?Ĭ��Ϊ300
      if(cfg.width)this.defaultWidth=cfg.width;
      this.dvMsgBox.style.width=this.defaultWidth+'px';
      //����ֱ��ʹ��show����ֹͣΪ�����Ĵ���
      if(this.timer){clearInterval(this.timer);this.timer=null;}      
      this.dvTitle.innerHTML='';
	  
      if(cfg.title)this.dvTitle.innerHTML='<div class="titleICON">&nbsp;&nbsp;'+cfg.title+'</div>';
	  
      this.dvCT.innerHTML='';
      if(cfg.wait){
        if(cfg.msg)this.dvCT.innerHTML=cfg.msg;
		//dvProcessbar_rightδ�����ã�����������������������������������������
        this.dvCT.innerHTML+='<div class="pro"><div class="bg_left" id="dvProcessbar_left"></div><div class="bg_right" id="dvProcessbar_right"></div></div>';
        this.dvBtns.innerHTML='';
        this.dvBottom.style.height='10px';
        this.timer=setInterval(function(){Showbo.Msg.moveProcessbar();},30);
      }
      else{
        //if(!cfg.icon)cfg.icon=Showbo.Msg.INFO;
        if(!cfg.buttons||(!cfg.buttons.yes&&!cfg.buttons.no)){
          cfg.buttons={yes:'ȷ ��'};
        }
        if(cfg.icon)this.dvCT.innerHTML='<div class="icon '+cfg.icon+'"></div>';
        if(cfg.msg)this.dvCT.innerHTML+=cfg.msg+'<div class="clear"></div>';
        this.dvBottom.style.height='45px';
        this.dvBtns.innerHTML='<div class="height"></div>';
        if(cfg.buttons.yes){
          this.dvBtns.appendChild(this.createBtn('yes',cfg.buttons.yes,cfg.fn));
          if(cfg.buttons.no)this.dvBtns.appendChild(document.createTextNode('��'));
        }
        if(cfg.buttons.no)this.dvBtns.appendChild(this.createBtn('no',cfg.buttons.no,cfg.fn));
      }
      Showbo.initBodyScale();
      this.dvMsgBox.style.display='block';
      this.lightBox.style.display='block';
      this.onResize(false);
      if(cfg.wait!==true)this.dvBottom.getElementsByTagName('input')[0].focus();
    },
	
	
    hide:function(isOpenParent){
		//isOpenParent���ж������ظ����ڵ��ڸǲ㻹�ǵ�ǰ���ڵ�
		//1Ϊ�����ڣ�0Ϊ��ǰ����

        //������
		if(isOpenParent==1||isOpenParent=="1")
	    {
		 if(window.opener.dvMsgBox!=null) window.opener.dvMsgBox.style.display='none';
         if(window.opener.document.getElementById("ShowBolightBox")!=null) window.opener.document.getElementById("ShowBolightBox").style.display='none';
         if(window.opener.document.getElementById("ShowBolightBox")!=null) window.opener.document.getElementById("ShowBolightBox").innerHTML="";
         if(window.opener.timer!=null) {clearInterval(window.opener.timer);window.opener.timer=null;}
	    }
		
        //������
		if(this.dvMsgBox!=null) this.dvMsgBox.style.display='none';
        if(this.lightBox!=null) this.lightBox.style.display='none';
        if(this.timer!=null){clearInterval(this.timer);this.timer=null;}
        if(Showbo.IsIE!=null)window.detachEvent('onresize',this.onResize);
        else window.removeEventListener('resize',this.onResize,false);
    },
    onResize:function(isResize){
       if(isResize)Showbo.initBodyScale();
       Showbo.Msg.lightBox.style.width=Showbo.BodyScale.tx+'px';//��Ӱ�Ŀ��
       Showbo.Msg.lightBox.style.height=Showbo.BodyScale.ty+'px';//��Ӱ�ĸ߶�
       //Showbo.Msg.dvMsgBox.style.top=document.documentElement.scrollTop+Math.floor((Showbo.BodyScale.y-Showbo.Msg.dvMsgBox.offsetHeight)/2)+'px';
	   //ԭ����������һ�У����������ǣ�������Ļ����Ի���ᱻ��ס
       Showbo.Msg.dvMsgBox.style.top=document.body.scrollTop+Math.floor((Showbo.BodyScale.y-Showbo.Msg.dvMsgBox.offsetHeight)/2)+'px';
       Showbo.Msg.dvMsgBox.style.left=Math.floor((Showbo.BodyScale.x-Showbo.Msg.dvMsgBox.offsetWidth)/2)+'px';
    }
}
//iconStyle�����ֵ��ERROR�����󣩡�INFO����Ϣ����WARNING�����棩
//fn��ʾ����

//Showbo.Msg.alert(msgTitle,msgText,iconStyle,width,fn);//����yes
//Showbo.Msg.confirm(msg,iconStyle,width,fn); 
//labelWord�����ǰ�����֣�defaultValue������Ĭ��ֵ��txtId������ID�����txtIdδ���룬Ĭ��Ϊ��msg_txtInput��
//Showbo.Msg.prompt(labelWord_1,defaultValue_1,txtId_1,labelWord_2,defaultValue_2,txtId_2,iconStyle,width,fn);
//Showbo.Msg.wait(msg,title);
//Showbo.Msg.hide()
function readData()
 {
	 Showbo.Msg.wait("���ڶ�ȡ��ݣ����Ժ�...","ϵͳ��ʾ");
 }


///���û������⣡�������� 
function DeleteConfirm()
 {
	 	 Showbo.Msg.prompt("<span style=color:red;font-weight:bold;>ȷ��ɾ��</span><br>��С�Ĳ���ɾ���ǲ��ɷ��أ�<br>ȷ��ɾ�������롰OK����",null,"_checkdelete","  ",null,null,"WARNING","400",function(btn){if(btn=='yes'){
		if(Showbo.$(_checkdelete).value.toUpperCase()!="OK")
		 {
		   Showbo.Msg.alert("����д��OK��}����ĸ��","","ERROR","240",function(btn){if(btn=="yes"){DeleteConfirm();return false;}});
		 }
		else
		{
		  return true;
		 }
	 }
	});
	return false;
 }
