  
var Mw = { 
      $ : function(id){
          return document.getElementById(id); 
      },
      create : function(option){ 
           var vv = this.getCookie();  
           if(vv == 2){
               return;
           }  
           if(!option) option = {};     
           this.setBox("msnW");   
	   this.id = 'msnW'; 
           this.setHandler();
           var that = this;
           if(vv == 1){ 
		that.$('mWcB').style.display = 'none';  
		that.$('mWshow').className = 'mWfh';
		that.$('mWshow').onmouseover = function(){this.className = 'mWfh'} 
		that.$('mWshow').onmouseout = function(){this.className = 'mWf'}			
           //}else if(vv == 2){   
           //     that.$('mWcityList').style.display = 'none'; 
           }else{ 
		this.$('mWcB').style.display = 'block';
                this.$('mWshow').className = 'mWh';
                this.$('mWshow').onmouseover = function(){this.className = 'mWhh'} 
                this.$('mWshow').onmouseout = function(){this.className = 'mWh'}
                this.setCookie(1); 
           }
     
              
      },

      setBox : function(){   
            var doc = document.createElement("div");  
            doc.id = "msnW";  
            var html = '<div id="mWtop">'  
        	     + '<h4  id="msnW_title">寿光房产网看房团快速报名</h4>'     
        	     + '<div id="mWclose"></div>'
                     + '<div id="mWshow" class="mWf"></div>'     
                     + '</div>'
                     + '<div id="mWcB">'
        	     + '<div id="mWcP">'  
            	     + '<div id="the_ct">'
        + '<form onSubmit="return checktuangou(this);">'
	 + '<table border=0 cellpadding=0 cellspacing=0>'
           + '<tr > '
            + '<td align=right>您的姓名：</td>'
            + '<td><input  name=C_Name type=text class=inputtext size=20> '
              + '<font color=#FF3300> *</td>'
         + ' </tr>'
          + '<tr> '
           + ' <td align=right>联系电话：</td>'
           + ' <td><input  name=C_Tel type=text class=inputtext size=20> '
           + ' <font color=#FF3300>*</td>'
          + '</tr>'
          + '<tr> '
            + '<td align=right>了解途径：</td>'
            + '<td><input name=tujing type=text class=inputtext size=20>'
              + '<font color=#FF3300>*</td>'
          + '</tr>'
          + '<tr> '
           + ' <td align=right>参加人数：</td>'
           + ' <td><input class=inputtext  type=text name=num size=20>'
             + ' <font color=#FF3300>*</td>'
          + '</tr>'
          + '<tr> '
           + ' <td align=right>关注楼盘：</td>'
           + ' <td><textarea name=C_TxtContent cols=20 rows=3 style="width:150px; height:60px" id=C_TxtContent></textarea> '
            + '  <font color=#FF3300>*<font color=#FF0000>&nbsp;</td>'
         + ' </tr>'
          + '<tr> '
           + ' <td height=29 align=right>&nbsp;</td>'
            + '<td>此处填写意向楼盘名称<br><input type=image src=button.gif width=97 height=27>'
             + ' ( <a href="http://www.iwjia.com/kanfangtuan/"><font color=#0099FF>完整版发布</a>)</td>'
         + ' </tr>'
+ '</table>'
      + '  </form>'
                     + '</div></div>';      
            doc.innerHTML = html;
            document.body.appendChild(doc); 
            
      },
      setCookie : function(v){
           var sCookie = "_mw_=" + encodeURIComponent(v); 
    
           var date = new Date();
   	   date.setTime(date.getTime()+3*60*60*1000);  
           sCookie += "; expires="+date.toGMTString() ; 
           sCookie += "; path=/";
           sCookie += "; domain= www.iwjia.com";
           document.cookie = sCookie;  
      },
      getCookie : function(){
          var arrStr = document.cookie.split("; ");
          var objName = '_mw_';
	  for(var i = 0;i < arrStr.length;i ++){
		if(arrStr[i].indexOf('=') != -1){
			var indexA = arrStr[i].indexOf('=');
			var name = arrStr[i].substring(0,indexA);
			if(name == objName){
				var str = unescape(arrStr[i].substring(indexA+1));
				return str.replace(/\+/g,'%2B');
			}
		 }
	   } 
           return null;
      },
      setHandler : function(){
   		 var that = this;
              var msnW = document.getElementById('msnW');
	      this.$('mWclose').onmouseover = function(){this.className = 'mWch'} 
	      this.$('mWclose').onmouseout = function(){this.className = ''} 
	      this.$('mWshow').onmouseover = function(){this.className = 'mWfh'} 
	      this.$('mWshow').onmouseout = function(){this.className = 'mWf'} 
	      this.$('mWclose').onclick = function(){that.setCookie(2); msnW.style.display = 'none'} 
             
             
              this.$('mWtop').onclick = function(e){     
				if(that.$('mWcB').style.display != 'block'){
					var evt = that.Evt(e);
					that.stopBubble(evt);
					that.$('mWcB').style.display = 'block';
					that.$('mWshow').className = 'mWh';
					that.$('mWshow').onmouseover = function(){this.className = 'mWhh'} 
					that.$('mWshow').onmouseout = function(){this.className = 'mWh'}   
  					
					}
				
			} 
              this.$('mWshow').onclick = function(e){ 
				if(that.$('mWcB').style.display == 'block'){
					var evt = that.Evt(e);
					that.stopBubble(evt);
					that.$('mWcB').style.display = 'none';  
					that.$('mWcityList').style.display = 'none';
					that.$('mWshow').className = 'mWfh';
					that.$('mWshow').onmouseover = function(){this.className = 'mWfh'} 
					that.$('mWshow').onmouseout = function(){this.className = 'mWf'}
					
				}
			}
              var Interval = 0.3;//设置秒数
	     // addEvent(window, 'scroll', function(){Mw.fixBtm(););	      
addEvent(window, 'scroll', function(){setInterval('Mw.fixBtm()',Interval*1000)}, false);
      },
      Evt : function(e){
	     return e || window.event;
      },
      fixBtm : function(){
	      if(!window.XMLHttpRequest){ 
			var scrollY = document.documentElement.scrollTop;
			var viewportHeight = document.documentElement.clientHeight;
			var BtmDiv = Mw.$(Mw.id);
			BtmDiv.style.top =  (viewportHeight + scrollY - BtmDiv.clientHeight) + 'px';  
	      }
      },
      stopBubble : function(evt){
	     if(evt.stopPropagation){evt.stopPropagation()}
	     else {evt.cancelBubble = true }
      },

        setTitle : function(data){  
             this.$('the_ct').innerHTML = data+'<div id="mWC"></div>'; 
             this.request(this.urls[1]);
        },
        setTopData : function(data){  
             this.$('mWC').innerHTML = data;
             this.request(this.urls[2]);
        },
        setBottomData : function(data){
             this.$('mWC').innerHTML += data;
        }

}


function addEvent(node, type, listener, useCapture){
   if(!node) return false;
   if(typeof node.addEventListener != 'undefined'){
       node.addEventListener(type, listener, useCapture);
       return true;
   }else if(typeof node.attachEvent != 'undefined'){
       return node.attachEvent('on'+type, listener);
   }
   return false;
}
addEvent(window, 'load', function(){
     Mw.create();
}, false);  

