var jq = jQuery; 
jq.noConflict(); 
(function() {
   var lb = function(a, b) {
      var c = a.fw; if(arguments.length > 2) {
         var d = Array.prototype.slice.call(arguments, 2); if(c) {
            d.unshift.apply(d, c)}
         c = d}
      b = a.hw || b; a = a.gw || a; var e, f = b || qa; if(c) {
         e = function() {
            var g = Array.prototype.slice.call(arguments); g.unshift.apply(g, c); return a.apply(f, g)}
         }
      else {
         e = function() {
            return a.apply(f, arguments)}
         }
      e.fw = c; e.hw = b; e.gw = a; return e}; var ArraySlice = Array.prototype.slice; Function.prototype.bind = function(a) {
      if(arguments.length > 1) {
         var b = ArraySlice.call(arguments, 1); b.unshift(this, a); return lb.apply(null, b)}
      else {
         return lb(this, a)}
      }; Function.prototype.partial = function() {
      var a = ArraySlice.call(arguments); a.unshift(this, null); return lb.apply(null, a)}; Function.prototype.inherits = function(a) {
      BV(this, a)}; var BV = function(a, b) {
      function c() {
         }
      c.prototype = b.prototype; a.F = b.prototype; a.prototype = new c; a.prototype.constructor = a}; Function.prototype.mixin = function(a, b) {
      var P = this.prototype; if(typeof b == 'undefined') {
         b = 1}
      if(b) {
         for(var i in a) {
            P[i] = a[i]; }
         }
      else {
         for(var i in a) {
            (!(i in P)) && (P[i] = a[i]); }
         }
      }; }
)(); 
function Dict(a) {
   for(var i in a) {
      this[i] = a[i]; 
      }
   }
Dict.mixin( {
   "keys" : function() {
      var b = []; for(var i in this) {
         b.push(i); }
      return b; }
   , "values" : function() {
      var b = []; for(var i in this) {
         b.push(this[i]); }
      return b; }
   , "items" : function() {
      var b = []; for(var i in this) {
         b.push([i, this[i]]); }
      return b; }
   }
); 
var isdebug = 0; 
function _log() {
   }
if(isdebug) {
   if(typeof console == "undefined") {
      res_load('js', 'firebug.js'); 
      }
   else {
      _log = function() {
         console.log.apply(console, arguments); 
         }; 
      }
   }
var dot_img = new Image(); 
dot_img.src = 'dot_blank.gif'; 
function fixpng_ie(elm) {
   }
if(jq.browser.msie) {
   fixpng_ie = function(elm) {
      try {
         if(!(elm && elm.tagName && elm.tagName.toLowerCase() == 'img')) {
            return; 
            }
         var pngSrc = elm.src, pngM = pngSrc.match(/png$/i),imgSize=[elm.offsetWidth,elm.offsetHeight];
         if(pngM && pngM.length > 0) {
            elm.width = imgSize[0]; 
            elm.height = imgSize[1]; 
            elm.src = dot_img.src; 
            elm.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod="scale", src="' + pngSrc + '")'; 
            }
         }
      catch(ex) {
         }
      }; 
   }

var Drag;(function(){var jq_b=jq.browser,ua=navigator.userAgent;var Browser=new Object();Browser.isMozilla=jq_b.mozilla;Browser.isIE=jq_b.msie;Browser.isGecko=ua.indexOf("Gecko")!=-1;Browser.isOpera=jq_b.opera;

function fixE(a) {
   if(typeof a == "undefined") {
      a = window.event; 
   }
   if(typeof a.layerX == "undefined")a.layerX = a.offsetX; 
   if(typeof a.layerY == "undefined")a.layerY = a.offsetY; 
   if(typeof a.which == "undefined")a.which = a.button; 
   if(!a.target && a.srcElement)a.target = a.srcElement; 
   if(jq.browser.safari && a.target.nodeType == 3)a.target = a.target.parentNode; 
   return a
}

function emptyFn(){}

var ig_d = {
   obj : null, init : function(a, b) {
      a.onmousedown = ig_d.start; 
      a.obj = b; 
      if(isNaN(parseInt(b.style.left, 10)))b.style.left = "0px"; 
      if(isNaN(parseInt(b.style.top, 10)))b.style.top = "0px"; 
      b.onDragStart = emptyFn; 
      b.onDragEnd = emptyFn; 
      b.onDrag = emptyFn; 
      }
   , uninit : function(a, b) {
      window.clearInterval(b.qa); 
      a.onmousedown = null; 
      a.obj = null; 
      b.onDragStart = null; 
      b.onDragEnd = null; 
      b.onDrag = null}
   , start : function(a) {
      a = fixE(a); 
     if(a.target != this) {
         return}
      var b = ig_d.obj = this.obj; 
 	  
      if(a.which != 1) {
         return true}
      b.onDragStart(a); 
      var c = a.clientY; 
      if(!jq.browser.safari) {
         c += document.body.scrollTop}
      b.lastMouseX = a.clientX; 
      b.lastMouseY = c; 
      b.offsetMouseX = parseInt(b.style.left, 10) - a.clientX; 
      b.offsetMouseY = parseInt(b.style.top, 10) - c; 
      document.onmouseup = ig_d.end; 
      document.onmousemove = ig_d.drag; 
      return false}
   , drag : function(a) {
      a = fixE(a); 
      if(a.which == 0) {
         return ig_d.end()}
      var b = ig_d.obj, c = a.clientY; 
      if(!jq.browser.safari) {
         c += document.body.scrollTop}
      var d = a.clientX; 
      if(b.lastMouseX == d && b.lastMouseY == c) {
         return false}
      var e = d + b.offsetMouseX, f = c + b.offsetMouseY; 
      b.style.left = e + "px"; 
      b.style.top = f + "px"; 
      b.lastMouseX = d; 
      b.lastMouseY = c; 
      b.onDrag(e, f); 
      return false}
   , end : function(a) {
      a = fixE(a); 
      document.onmousemove = null; 
      document.onmouseup = null; 
      window.clearInterval(ig_d.obj.qa); 
      var b = ig_d.obj.onDragEnd(); 
      ig_d.obj = null; 
      return b}
   }; 
Drag = ig_d; 

function movescrollbar(){var elem=Drag.obj;var body_clientHeight=getclientHeight();var body_scrollHeight=getscrollHeight();var body_scrollTop=document.body.scrollTop;var body_scrollvalue=body_scrollTop;var winvalue=elem.root.offsetTop;var body_Height=document.body.offsetHeight;var step=10;var winTop=body_clientHeight*0.05;var winDown=body_clientHeight-winTop;if(elem.lastMouseY<=winTop){winvalue=Math.max(0,elem.root.offsetTop-step);body_scrollvalue=Math.max(0,body_scrollTop-step);}else if(elem.lastMouseY>=winDown){winvalue=Math.min(body_scrollHeight-elem.offsetHeight,elem.root.offsetTop+step);body_scrollvalue=Math.min(body_scrollHeight-body_clientHeight,body_scrollTop+step);}
var ig_l=body_scrollvalue-body_scrollTop;if(ig_l!=0){if((body_scrollHeight-winvalue)<elem.root.offsetHeight)winvalue=body_scrollHeight-elem.root.offsetHeight;elem.root.style.top=winvalue+"px";document.body.scrollTop=body_scrollvalue;}}})();function getclientHeight(){if(window.innerHeight<document.body.clientHeight){return window.innerHeight}
return document.body.clientHeight}
function getscrollHeight(){if(document.body.scrollHeight>document.documentElement.clientHeight){return document.body.scrollHeight}
else{return document.documentElement.clientHeight}}
function updateDisplay(){};if(jq.browser.opera||jq.browser.msie){(function(){var updateMore=null,hasSet=null;updateDisplay=function(el){if(hasSet===null){var needUpdate=jq('#ad-links-3');hasSet=needUpdate.length;if(hasSet==1){needUpdate=needUpdate[0].style;updateMore=function(){needUpdate.zoom="1";needUpdate.zoom="100%";};}else if(hasSet>1){updateMore=function(){needUpdate.css('zoom',"1").css('zoom',"100%");};}}
var elm=el.parentNode.firstChild;while(elm){var dnd=elm.DND_Module;if(dnd&&dnd.type=='tab'){dnd=dnd.h.style;dnd.zoom="1";dnd.zoom="100%";}
elm=elm.nextSibling;}
if(hasSet>0){updateMore();}};})();}
var _P='prototype';
var hp={};
hp.dragTip='移动/拆分/组合,打造属于你自己的主页!'
hp.initfinish=0;
hp.cols=[];
hp.mds=[];
hp.ctx=null;
hp.mds.removeMd = function(md) {
   var hpMdsLen = this.length; 
   for(var i = 0; i < hpMdsLen; i++) {
      if(this[i] == md) {
         this[i] = this[hpMdsLen - 1];
		 this.length = hpMdsLen - 1; 
         return md; 
         }
      }
   return null; 
}; 
function emptyfn(){}
hp.set_layout_default=function(){if(confirm('确认恢复默认布局吗？')){hp.cookie('hp_layout','');hp.cookie('hp_theme_id','');location.reload();}};

hp.cookie = function(cn, cv) {
   var args = Array.prototype.slice.apply(arguments), argsLen = args.length; 
   if(argsLen == 0) {
      alert("default cookie = " + document.cookie);
      return String(document.cookie); 
   }
   else if(argsLen == 1) {
      var Tp = ';', c = cn + '=', d = String(document.cookie); 
      for(var e =- 1; (e = d.indexOf(c, e + 1)) >= 0; ) {
         var f = e; 
         while(--f >= 0) {
            var g = d.charAt(f); 
            if(g == Tp) {
               f =- 1; 
               break
            }
         }
         if(f ==- 1) {
            var h = d.indexOf(Tp, e); 
            if(h < 0) {
               h = d.length
            }
            return d.substring(e + c.length, h)
         }
      }
      return null; 
   }
   else {
      var date = new Date(); 
      date.setTime(date.getTime() + (args[2] * 24 * 60 * 60 * 1000)); 
      document.cookie = cn + '=' + cv + ';expires=' + date.toGMTString(); 
   }
}; 

hp.ca = "HP_pageDivMaskId"; 
hp.ba = "HP_moduleDivMaskId"; 
hp.va = function(a) {
   hp.oa(); 
   var b = jq('<div>&nbsp;</div>').css('height', document.body.offsetHeight).attr('id', hp.ca).appendTo(document.body)[0]; 
   if(0 && a.Ia) {
      b = b.cloneNode(true); 
      b.id = hp.ba; 
      b.style.height = a.a.offsetHeight - a.h.offsetHeight + "px"; 
      b.style.top = a.h.offsetHeight + "px"; 
      a.a.appendChild(b)}
   }; 
hp.oa = function() {
   var a = [hp.ba, hp.ca], c; 
   for(var b = 0; b < a.length; b++) {
      c = document.getElementById(a[b]); 
      if(c) {
         c.parentNode.removeChild(c); 
         }
      }
   a = c = null; 
   }; 
hp.wa = function(a) {
   for(var b = 0; b < hp.mds.length; b++) {
      var c = hp.mds[b]; 
      c.a.pagePosLeft = c.md.posInPage(true); 
      c.a.boxWidth = c.a.offsetWidth; 
      c.a.pagePosRight = c.a.pagePosLeft + c.a.boxWidth; 
      c.a.boxHeight = c.a.offsetHeight; 
      c.a.pagePosTop = c.md.posInPage(false); 
      c.a.pagePosBottom = c.a.pagePosTop + c.a.boxHeight; 
      }
   var d = a.a.nextSibling, aRootHeight = a.a.offsetHeight + 10; 
   while(d) {
      d.pagePosTop -= aRootHeight; 
      d.pagePosBottom -= aRootHeight; 
      d = d.nextSibling}
   }; 

hp.Sa = function() {
   if(!hp.initfinish) {
      return
   }
   var lay = {}; 
   _log('保存布局 s'); 
   hp.cols.each(function(idx, col) {
      
      var colid = parseInt(col.id.substring(7), 10), mids = []; 
      jq('>div.md', col).each(function(idx, md) {
         var dnd = md.DND_Module; 
         if(dnd.type == 'normal') {
            var mid = parseInt(dnd.h.id.substring(2), 10); 
         }
         else if(dnd.type == 'tab') {
           mid = []; 
           jq.each(dnd.subMds, function(idx, subMd) {mid.push(parseInt(subMd.tab.find('h2')[0].id.substring(2), 10));}); 
           mid.push(dnd.activeMd.tabIdx); 
         }
         mids.push(mid); 
      }); 
      lay[colid] = mids; 
   }); 
   hp.cookie('hp_layout', json.stringify(lay), 365); 
   _log('保存布局 e'); 
   return; 
   _xsetp("mp=" + _esc(a))
}; 

function Module_P_uninit() {
   if(this.h) {
      if(this.d) {
         this.d.onclick = null; 
         this.d.onmouseup = null; 
         this.d = null}
      Drag.uninit(this.h, this.a); 
      this.a.onDragStart = null; 
      this.a.onDrag = null; 
      this.a.onDragEnd = null; 
      this.h = null}
   this.btnMin.unbind('click', this._minClick); 
   this.btnDel.unbind('click', this._delClick); 
   for(var i in this) {
      if(this.hasOwnProperty(i)) {
         this[i] = null; 
      }
   }
}

function Module_P__dragStart(a) {
   hp.wa(this); 
   this.origNextSibling = this.a.nextSibling; 
   var b = divGhost, c = this.a.offsetHeight; 
   c -= 4; 
   var d = this.a.offsetWidth, e = this.md.posInPage(true), f = this.md.posInPage(false); 
   this.md.css('width', d); 
   b.style.height = c + "px"; 
   this.a.parentNode.insertBefore(b, this.a.nextSibling); 
   this.a.style.position = "absolute"; 
   this.a.style.zIndex = 10000; 
   this.a.style.left = e + "px"; 
   this.a.style.top = f + "px"; 
   hp.va(this); 
   this.v = false; 
   updateDisplay(this.a); 
   return false
}

function Module_P__drag(a, b) {
   if(!this.v) {
      this.a.style.filter = "alpha(opacity=60)"; 
      this.a.style.opacity = 0.6; 
      this.v = true; 
}

var c = null, d = 100000000; 
var theA = this.a; 
this.inModule = null; 
var k = divGhost; 
var mousePosY = theA.lastMouseY + jq.getPageOffset()[1]; 
for(var e = 0; e < hp.mds.length; e++) {
   var f = hp.mds[e], fa = f.a, g = a; 
   
   if(this.lastInModule) {
      divGhostForMerge.css('display', 'none'); 
      this.lastInModule = null; 
      }
   //只允许同一列组合
   if(f != this && (this.type == 'normal') && (f.type == 'normal' || f.type == 'tab') && theA.lastMouseX >= fa.pagePosLeft && theA.lastMouseX <= fa.pagePosRight && mousePosY >= (fa.pagePosTop + 0) && mousePosY <= (fa.pagePosBottom - 0)
     && this.md.parent().attr("id") == f.md.parent().attr("id")) {
      this.inModule = this.lastInModule = f; 
      divGhostForMerge.css('display', '').css('left', fa.pagePosLeft - 2).css('top', fa.pagePosTop - 2).css('width', fa.boxWidth).css('height', fa.boxHeight); 
      if(k.parentNode != null) {
         k.style.display = 'none'; 
         updateDisplay(k); 
         k.parentNode.removeChild(k); 
         }
      break; 
      }
   if(document.body.dir == "rtl" && fa.offsetWidth == 1) {
      g += theA.offsetWidth}
   var h = Math.sqrt(Math.pow(g - fa.pagePosLeft, 2) + Math.pow(b - fa.pagePosTop, 2)); 
   if(f == this)continue; 
   if(isNaN(h))continue; 
   if(h < d) {
      d = h; 
      c = f}
   }
   //只允许同一列拖动
if(this.inModule === null && c !== null && k.nextSibling != c.a && this.md.parent().attr("id") == c.md.parent().attr("id")) {
   k.style.display = 'none'; 
   updateDisplay(k); 
   c.a.parentNode.insertBefore(k, c.a); 
   k.style.display = ''; 
   updateDisplay(k); 
   }
}

function Module_P__dragEnd() {
   hp.oa(); 
   var needSave = 0; 
   if(this.Da()) {
      needSave = 1; 
   }
   
   //组合功能
   if(this.inModule) {
      divGhostForMerge.css('display', 'none'); 
      this.lastInModule = null; 
      switch(this.inModule.type) {
         case'normal':TabModule.fromModules(this.inModule, this); 
         needSave = 1; 
         break; 
         case'tab':this.inModule._addSubMd(this); 
         needSave = 1; 
         break;
      }
   }
   if(needSave) {
      hp.Sa()}
   return true
}

function Module_P_Da() {
   var a = false; 
   this.a.style.position = ""; 
   this.a.style.width = ""; 
   this.a.style.zIndex = ""; 
   this.a.style.filter = ""; 
   this.a.style.opacity = ""; 
   window.scrollBy(0, 0); 
   var k = divGhost; 
   if(k.parentNode != null) {
      //增加k.nextSibling != null判断
      if(k.nextSibling != null && k.nextSibling != this.origNextSibling) {
         k.parentNode.insertBefore(this.a, k.nextSibling); 
         a = true; 
         }
      k.parentNode.removeChild(k); 
      }
   updateDisplay(this.a); 
   return a
}

function ModulePix(a) {
   this.type = "pix"; 
   this.md = a; 
   this.uninit = function() {
      this.md = this.a = null}; 
   this.a = a[0]; 
   this.a.innerHTML = "<br />"; 
   }
function Module(a) {
   this.v = false; 
   this.md = a; 
   this.a = a[0]; 
   this.a.DND_Module = this; 
   this.init(); 
   }
Module.mixin( {
   type : "normal", init : function() {
      this.mh = this.md.find('>h2'); this.h = this.mh[0]; this.h.title = hp.dragTip; this.mb = this.md.find('>.mb'); this.Ia = this.mb.find('iframe'); if(this.Ia.length < 1) {
         delete this.Ia; }
      this._minClick = this._minClick.bind(this); this._delClick = this._delClick.bind(this)

this.btnMin=this.mh.find('>i.min');if(this.btnMin.length<1){this.mh.append('<i class="del" title="关闭">X</i><i class="min" title="折叠/展开">_</i>');this.btnMin=this.mh.find('>i.min');}
this.btnMin.bind('click', this._minClick); 
this.btnDel = this.mh.find('>i.del').bind('click', this._delClick); 
if(this.h) {
   Drag.init(this.h, this.a); 
   this.a.onDragStart = this._dragStart.bind(this); 
   this.a.onDrag = this._drag.bind(this); 
   this.a.onDragEnd = this._dragEnd.bind(this); 
   }
}
, _urlMouseUp : emptyfn, _urlMouseDown : emptyfn, _urlClick : emptyfn, uninit : Module_P_uninit, Da : Module_P_Da, _dragStart : Module_P__dragStart, _drag : Module_P__drag, _dragEnd : Module_P__dragEnd, _minClick : function() {
    this.mb.toggleClass('hide'); 
    this.md.parent().css('display', 'none').css('display', ''); 
}
, _delClick : function() {
   if(confirm('确认关闭')) {
      jq("#column_0").append(this.md); 
      hp.Sa();
      this.md.remove();
	  location.reload();
      }
   }
}
);

function TabModuleSub(a, b, pmd, idx, tabnum) {
   this.tab = a; 
   this.active = this.active.bind(this); 
   this.deactive = this.deactive.bind(this); 
   this._expClick = this._expClick.bind(this); 
   this.btn = a.find('a').bind('click', this.active); 
   (idx == 0) ? a.addClass("first") : a.removeClass("first"); 
   (idx == tabnum) ? a.addClass("last") : a.removeClass("last"); 
   this.btnExp = a.find('i.exp'); 
   if(this.btnExp.length < 1) {
      this.tab.find('h2').append('<i class="exp" title="拆分">X</i>'); 
      this.btnExp = a.find('i.exp'); 
      }
   this.btnExp.bind('click', this._expClick); 
   this.mb = b; 
   if(this.tab.hasClass('cur')) {
      this.mb.removeClass('hide'); 
      }
   else {
      this.mb.addClass('hide'); 
      }
   this.pmd = pmd; 
   this.tabIdx = idx; 
   if(b.length) {
      this.Ia = b.find('iframe'); 
      if(this.Ia.length < 1) {
         delete this.Ia; 
         }
   }
}

TabModuleSub.mixin( {
   type : "tabsub", active : function(ev) {
      this.btn[0].blur(); if(this.pmd.activeMd == this) {
         return true; }
      this.tab.addClass('cur'); this.mb.removeClass('hide'); this.pmd.activeMd && this.pmd.activeMd.deactive(); this.pmd.activeMd = this; this.Ia && jq.browser.msie && this.Ia.each(function(idx, mb_iframe) {
         mb_iframe.src = mb_iframe.src; }
      ); updateDisplay(this.pmd.a); hp.Sa(); return false; }
   , deactive : function() {
      this.tab.removeClass('cur'); this.mb.addClass('hide'); if(this.pmd.activeMd == this) {
         this.pmd.activeMd = null; }
      }
   , _expClick : function() {
      this.pmd._delSubMd(this); }
   , uninit : function() {
      this.btn.unbind('click', this.active); this.btnExp.unbind('click', this._expClick); for(var i in this) {
         if(this.hasOwnProperty(i)) {
            this[i] = null; }
         }
      }
}); 

TabModule.fromModules = function() {
   var mds = Array.prototype.slice.apply(arguments), mdsLen = mds.length; 
   if(mdsLen < 2) {
      return; 
   }
   var refMd = null; 
   var tabMd = jq('<div class="md"/>'), tabMdTab = jq('<ul class="mh"><li class="i"><i class="min">_</i><i class="del">X</i></li></ul>').appendTo(tabMd), tabMdMb = jq('<div class="mb">').appendTo(tabMd); 
   try {
      for(var i = 0; i < mdsLen; i++) {
         var _md = mds[i]; 
         if(_md.type != 'normal') {
            continue}
         var _mdMh = _md.mh, _mdMb = _md.mb, _mdMd = _md.md; 
         hp.mds.removeMd(_md); 
         if(refMd === null) {
            refMd = _mdMd; 
         }
         _md.uninit(); 
         var licls = []; 
         if(i == 0) {
            licls.push('first'); 
            }
         else if(i == mdsLen - 1) {
            licls.push('last cur'); 
            }
         licls = licls.join(' '); 
         var liMh = jq('<li class="' + licls + '"/>'); 
         _mdMh.find('>i.min').remove(); 
         _mdMh.find('>i.del').attr('class', 'exp').attr('title', '拆分'); 
         liMh.append(_mdMh).appendTo(tabMdTab); 
         var mbcls = ['mbsub']; 
         if(i != mdsLen - 1) {
            mbcls.push('hide'); 
            }
         _mdMb.attr('class', mbcls.join(' ')).appendTo(tabMdMb); 
         if(refMd != _mdMd) {
            _mdMd.remove(); 
            }
         }
      tabMd.insertBefore(refMd); 
      refMd.remove(); 
      var tabModule = new TabModule(tabMd); 
      hp.mds.push(tabModule); 
      return tabModule; 
      }
   catch(ex) {
      _log(ex); 
      }
}; 

function TabModule(a) {
   this.v = false; 
   this.md = a; 
   this.a = a[0]; 
   this.a.DND_Module = this; 
   this.init(); 
}
   
TabModule.inherits(Module); 
TabModule.mixin( {
   type : "tab", init : function() {
      this.mh = this.md.find('>ul.mh'); this.h = this.mh[0]; this.h.title = hp.dragTip; this.mb = this.md.find('>.mb'); this._minClick = this._minClick.bind(this); this._delClick = this._delClick.bind(this); this.btnMin = this.mh.find('>li.i>i.min'); if(this.btnMin.length < 1) {
         this.mh.prepend('<li class="i"><i class="min" title="折叠/展开">_</i><i class="del" title="关闭">X</i></li>'); this.btnMin = this.mh.find('>li.i>i.min'); }
      this.btnMin.bind('click', this._minClick); this.btnDel = this.mh.find('>li.i>i.del').bind('click', this._delClick); if(this.h) {
         try {
            Drag.init(this.h, this.a); 
            this.a.onDragStart = this._dragStart.bind(this); 
            this.a.onDrag = this._drag.bind(this); 
            this.a.onDragEnd = this._dragEnd.bind(this); 
            this.subMds = []; 
            this.subTabs = this.mh.find('>li').not('.i'); 
            this.subMbs = this.mb.find('>div.mbsub'); 
            this.activeMd = null; 
            var tabnum = this.subTabs.length - 1; 
            this.subTabs.each(function(idx, tab) {
               tab = this.subTabs.eq(idx); 
               this.subMds[idx] = new TabModuleSub(tab, this.subMbs.eq(idx), this, idx, tabnum); 
               //this.subMds[idx].h = this.subMds[idx].getElementsByTagName("h2")[0];
               (this.activeMd === null) && tab.hasClass('cur') && (this.activeMd = this.subMds[idx]); 
             }.bind(this)); 
             this.subTabs = this.subMbs = null; 
             (this.activeMd === null) && this.subMds[0].active();
         }
         catch(ex) {
            _log(ex); }
         }
      }
   , uninit : function() {
      this.btnMin.unbind('click', this._minClick); this.btnDel.unbind('click', this._delClick); if(this.h) {
         Drag.uninit(this.h, this.a); this.a.onDragStart = this.a.onDrag = this.a.onDragEnd = null; }
      for(var i in this) {
         if(this.hasOwnProperty(i)) {
            this[i] = null; }
         }
      }
   , _addSubMd : function(md) {
      if(md.type == 'normal') {
         var mdMh = md.mh, mdMb = md.mb, mdMd = md.md; hp.mds.removeMd(md); md.uninit(); mdMh.find('>i.del').attr('class', 'exp').attr('title', '拆分'); mdMh.find('>i.min').remove(); mdMb.attr('class', 'mbsub'); var mTab = jq('<li/>'), tabIdx = this.subMds.length; this.mh.append(mTab.append(mdMh)); this.mb.append(mdMb); mdMd.remove(); this.subMds[tabIdx] = new TabModuleSub(mTab, mdMb, this, tabIdx); this.subMds[tabIdx].active(); return this; }
      return null; }
   , _delSubMd : function(subMd) {
      var smTab = subMd.tab, smMb = subMd.mb, idx = subMd.tabIdx, subMds = this.subMds, subMdsLen = subMds.length, tLen = subMdsLen - 1, hpMds = hp.mds, hpMdsLen = hpMds.length; function buildModule(tab, mb, tabMd) {
         var mh = tab.find('h2'); mh.find('i.exp').attr('class', 'del').attr('title', '关闭').after(jq('<i class="min" title="折叠/展开">_</i>')); mb = mb.attr('class', 'mb'); return jq('<div class="md"/>').append(mh).append(mb).insertAfter(tabMd.md); }
      for(var i = idx + 1; i < subMdsLen; i++) {
         var tIdx = i - 1; subMds[i].tabIdx = tIdx; if(tIdx == 0) {
            subMds[i].tab.addClass('first')}
         if(tIdx == tLen - 1) {
            subMds[i].tab.addClass('last')}
         if(tIdx == idx) {
            subMds[i].active(); }
         subMds[tIdx] = subMds[i]; }
      if(idx == subMdsLen - 1) {
         subMds[tLen - 1].active(); }
      subMds.length = tLen; subMd.uninit(); var newMd = new Module(buildModule(smTab, smMb, this)); smTab.remove(); hpMds.push(newMd); subMdsLen = tLen; if(subMdsLen < 2) {
         subMd = subMds[0]; smTab = subMd.tab; smMb = subMd.mb; subMd.deactive(); subMd.uninit(); newMd = new Module(buildModule(smTab, smMb, this)); hpMds.push(newMd); hpMds.removeMd(this); this.md.remove(); this.uninit(); }
      if(newMd && newMd.a) {
         updateDisplay(newMd.a); }
      hp.Sa(); }
}); 

function enableDrag() {
   window.divGhost = jq('<div class="md_replace" />')[0]; 
   window.divGhostForMerge = jq('<div class="md_activeborder" style="display:none;"/>').appendTo(document.body); 
   for(var i = 0; i < columnids.length; i++) {
      columnids[i] = "#" + columnids[i]; 
      }
   hp.cols = jq(columnids.join(",")); 
   function getmdinpage(mhid, autofix) {
      var _mh = jq("#m_" + mhid); 
      var r = {
         }; 
      if(_mh.length) {
         var _md = _mh.parent(); 
         if(_md.is("div.md")) {
            r.type = "normal"; 
            r.md = _md; 
            r.mh = _mh; 
            r.mb = _md.find(">.mb"); 
            }
         else if(_md.is("li")) {
            var idx = null; 
            r.type = "tabsub"; 
            r.mh = _mh; 
            r.tab = _md; 
            _mh = r.tab.parent(); 
            _md = _mh.parent(); 
            var elm_h2 = r.mh[0]; 
            jq.each(_mh[0].getElementsByTagName("h2"), function(_i, h2) {
               if(elm_h2 == h2) {
                  idx = _i; return false; }
               }
            ); 
            r.md = _md; 
            var t = null; 
            jq.each(_md[0].childNodes, function(_i, div) {
               if(div && div.className && div.className == 'mb') {
                  t = div; return false; }
               }
            ); 
            var mbsubIdx = 0; 
            jq.each(t.childNodes, function(_i, div) {
               if(div && div.className && div.className.indexOf('mbsub') !=- 1) {
                  if(mbsubIdx == idx) {
                     r.mb = jq(div); return false; }
                  mbsubIdx += 1; }
               }
            ); 
            r.autoFix = function() {
               var _mbs = _md.find("div.mbsub"); 
               if(_mbs.length == 1) {
                  _md.after(jq('<div class="md"/>').append(_mh.find('h2')).append(_mbs.attr("class", "mb"))); 
                  try {
                     _md.remove(); 
                     _mbs = _md = null; 
                     }
                  catch(ex) {
                     _log(ex)}
                  }
               }; 
            }
         return r; 
         }
      else {
         return null; 
         }
      }

   var hp_layout = hp.cookie('hp_layout'); 
   if(hp_layout) {
      _log('cookie 分析前：', hp_layout); 
      hp_layout = json.parse(hp_layout); 
      _log('cookie 分析后：', hp_layout); 
      if(hp_layout) {
         for(var i in hp_layout) {
            var colid = "#column_" + i, col = jq(colid); 
            _log("i", i); 
            if(!col.length) {
               continue}
            var mhids = hp_layout[i]; 
            for(var j = 0; j < mhids.length; j++) {
               var mhid = mhids[j]; 
               _log("mhid", mhid); 
               if(mhid instanceof Array) {
                  var curIdx = mhid.pop(); 
                  var lastTab = lastMb = null; 
                  var themd = null, _mds = [], m; 
                  for(var k = 0; k < mhid.length; k++) {
                     m = jq('#m_' + mhid[k]); 
                     if(m && m.length) {
                        _mds.push(mhid[k]); 
                        }
                     }
                  if(_mds.length == 0) {
                     continue; 
                     }
                  else if(_mds.length == 1) {
                     var m = getmdinpage(_mds[0]); 
                     if(m && m.type) {
                        if(m.type == "normal") {
                           col.append(m.md); 
                           }
                        else if(m.type == "tabsub") {
                           col.append(jq('<div class="md"/>').append(m.mh).append(m.mb.attr("class", "mb"))); 
                           m.tab.remove(); 
                           m.autoFix(); 
                           delete m.tab; 
                           }
                        }
                     m = null; 
                     }
                  else if(_mds.length > 1) {
                     if(curIdx > _mds.length - 1) {
                        curIdx = _mds.length - 1; 
                        }
                     for(k = 0; k < _mds.length; k++) {
                        var m = getmdinpage(_mds[k]); 
                        if(k == 0) {
                           if(m.type == "normal") {
                              m.tab = jq('<li/>').append(m.mh); 
                              m.md.append(jq('<ul class="mh"/>').append(m.tab)).append(jq('<div class="mb"/>').append(m.mb.attr("class", "mbsub"))); 
                              }
                           else if(m.type == "tabsub") {
                              m.tab.appendTo(m.tab.parent()); 
                              m.mb.appendTo(m.mb.parent()); 
                              }
                           themd = m.md; 
                           lastTab = m.tab; 
                           lastMb = m.mb; 
                           }
                        else {
                           if(m.type == "normal") {
                              m.tab = jq('<li/>').append(m.mh); 
                              lastTab.after(m.tab); 
                              lastMb.after(m.mb.attr("class", "mbsub")); 
                              m.md.remove(); 
                              delete m.md; 
                              }
                           else if(m.type == "tabsub") {
                              lastTab.after(m.tab); 
                              lastMb.after(m.mb); 
                              if(m.md != themd) {
                                 m.autoFix(); 
                                 delete m.md; 
                                 }
                              }
                           lastTab = m.tab; 
                           lastMb = m.mb; 
                           }
                        (k === curIdx) ? m.tab.addClass("cur") : m.tab.removeClass("cur"); 
                        }
                     col.append(themd); 
                     }
                  }
               else {
                  var m = getmdinpage(mhid); 
                  if(m && m.type) {
                     if(m.type == "normal") {
                        _log("col", col); 
                        col.append(m.md); 
                        }
                     else if(m.type == "tabsub") {
                        col.append(jq('<div class="md"/>').append(m.mh).append(m.mb.attr("class", "mb"))); 
                        m.tab.remove(); 
                        m.autoFix(); 
                        delete m.tab; 
                        }
                     }
                  m = null; 
                  }
               }
            }
         }
      }
   hp.cols.each(function(idx, col) {
      for(var i = 0; i < col.childNodes.length; i++) {
         var c = col.childNodes[i]; if(c.nodeType != 1) {
            col.removeChild(c); }
         }
      var md = jq('<div class="md_dm"/>').appendTo(col); hp.mds.push(new ModulePix(md)); }
   ); 
   jq('>div.md', hp.cols).each(function(idx, md) {
      md = jq(md); if(md.find('> h2').length) {
         hp.mds.push(new Module(md)); }
      else if(md.find('> ul.mh').length) {
         if(md.find('> ul.mh > li').length) {
            hp.mds.push(new TabModule(md)); }
         else {
            md.remove(); md = null; }
         }
      else {
         md.remove(); md = null; }
      }
   ); 
   hp.initfinish = 1; 
   if(jq.browser.msie) {
      with(document.body.style) {
         display = "none"; 
         display = ""; 
         }
      }
   hp.Sa(); 
   }

var json=(function(){var a={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},b={"boolean":function(c){return String(c)},number:function(c){return isFinite(c)?String(c):"null"},string:function(c){if(/["\\\x00-\x1f]/.test(c)){c=c.replace(/([\x00-\x1f\\"])/g,function(d,e){var f=a[e];if(f){return f}
f=e.charCodeAt();return"\\u00"+Math.floor(f/16).toString(16)+(f%16).toString(16)})}
return'"'+c+'"'},object:function(c){if(c){var d=[],e,f,g,h,i;if(c instanceof Array){d[0]="[";h=c.length;for(g=0;g<h;g+=1){i=c[g];f=b[typeof i];if(f){i=f(i);if(typeof i=="string"){if(e){d[d.length]=","}
d[d.length]=i;e=true}}}
d[d.length]="]"}else if(typeof c.hasOwnProperty==="function"){d[0]="{";for(g in c){if(c.hasOwnProperty(g)){i=c[g];f=b[typeof i];if(f){i=f(i);if(typeof i=="string"){if(e){d[d.length]=","}
d.push(b.string(g),":",i);e=true}}}}
d[d.length]="}"}else{return}
return d.join("")}
return"null"}};return{copyright:"(c)2005 JSON.org",license:"http://www.JSON.org/license.html",stringify:function(c){var d=b[typeof c];if(d){c=d(c);if(typeof c=="string"){return c}}
return null},parse:function(c){try{return!/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(c.replace(/"(\\.|[^"\\])*"/g,""))&&eval("("+c+")")}catch(d){return false}}}})();var _id;(function(){var idcount=0
_id=function(obj,forceId){switch(typeof obj.__id__){case"undefined":if(obj instanceof String||typeof obj=='string'){return'$'+obj;}else if(obj instanceof Number||typeof obj=='number'){return'#'+obj;}else if(forceId){obj.__id__='@'+(idcount++);return obj.__id__;}
case"function":return obj.__id__();default:return obj.__id__;}}})();function Set(elem){this.items={};var argLen=arguments.length;if(argLen>1){for(var i=0;i<argLen;i++){this.add(arguments[i]);}}else if(argLen==1){var elems=arguments[0];if(elems instanceof Array){for(var i=0;i<elems.length;i++){this.add(elems[i]);}}else{this.add(elems);}}}
Set.prototype={constructor:Set,add:function(item){this.items[_id(item)]=item;return item;},remove:function(item){var h=_id(item);if(_id(item)in this.items){item=this.items[h];delete this.items[h];return item;}else{throw new Error("没有这个项");}},discard:function(item){var h=_id(item);var _items=this.items;if(h in _items){item=_items[h];delete _items[h];return item;}
return null;},contains:function(item){return(_id(item)in this.items);},isSubset:function(setObj){for(var n in this.items){if(setObj.contains(this.items[n])==false){return false;}}
return true;},isSuperset:function(setObj){return setObj.isSubset(this);},equals:function(setObj){return(this.isSubset(setObj)&&setObj.isSubset(this));},__eq__:function(setObj){if(setObj.isSubset!==undefined){return this.equals(setObj);}else{return false;}},union:function(setObj){var ns=this.copy();ns.unionUpdate(setObj);return ns;},intersection:function(setObj){var ns=new Set();for(var n in this.items){var item=this.items[n];if(setObj.contains(item)){ns.add(item);}}
return ns;},difference:function(setObj){var ns=new Set();for(var n in this.items){var item=this.items[n];if(!setObj.contains(item)){ns.add(item);}}
return ns;},symmDifference:function(setObj){var ns=this.difference(setObj);return ns.unionUpdate(setObj.difference(this));},unionUpdate:function(setObj){for(var n in setObj.items){this.add(setObj.items[n]);}
return this;},intersectionUpdate:function(setObj){for(var n in this.items){var item=this.items[n];if(setObj.contains(item)==false){this.remove(item);}}
return this;},differenceUpdate:function(setObj){for(var n in this.items){var item=this.items[n];if(setObj.contains(item)){this.remove(item);}}
return this;},symmDifferenceUpdate:function(setObj){var union=setObj.difference(this);this.differenceUpdate(setObj);return this.unionUpdate(union);},copy:function(){var ns=new Set();return ns.unionUpdate(this);},clear:function(){this.items={};},toArray:function(){var _items=this.items,a=[];for(var n in _items){a.push(_items[n]);}
return a;},__str__:function(){var _items=this.items,items=[];for(var n in _items){items.push(_items[n]);}
return"{"+items.join(",")+"}";}};function hp_img_transform(rootQ,elmQ){var rootElm=jq(rootQ),elms=jq(elmQ,rootElm),total=elms.length;var timer=null,curIdx=0;var showElm=elms.eq(0);var htmls=[];for(var i=0;i<total;i++){var elm=elms[i];htmls[i]=elm.innerHTML;if(i!=0){elm.parentNode.removeChild(elm);}}
function to_next(){curIdx+=1;(curIdx==total)&&(curIdx=0);showElm.stop().animate({'opacity':0},{'duration':350,'easing':'linear','complete':function(){showElm.html(htmls[curIdx]).animate({'opacity':1},{'duration':300,'easing':'linear'});}});}
timer=setInterval(to_next,5000);showElm.hover(function(){clearInterval(timer);},function(){timer=setInterval(to_next,5000);});}
function popLogoFunny(img){if(!jq)return;var p=jq(img).parent().find('>div.pop-funny');if(!p.length)return;try{p.css('display','block');if(!p[0]._binded){p[0]._binded=1;p.bind('mouseout',function(){p.css('display','none');});}}catch(ex){}}
