// Utilities
var _anagoUtil=new Object({
 query2Object:function(q){
  var args=new Object();
  if(typeof q!='string')q=location.search.substring(1);
  var pairs=q.split("&");
  for(var i=0;i<pairs.length;i++){
   var pos=pairs[i].indexOf('=');
   if(pos==-1)continue;
    var argName=pairs[i].substring(0,pos);
    var value=pairs[i].substring(pos+1);
    value=decodeURIComponent(value);
    args[argName]=value;
  }
  return args;
 },
 object2Query:function(obj,sp){
  if(typeof obj!='object')return '';
  if(!sp)sp='&';
  var q='',b=false;
  for(var i in obj){
   var f=i+'=';
   switch(typeof obj[i]){
   case 'string':
    f+=encodeURIComponent(obj[i]);
    break;
   case 'number':
    if(isFinite(obj)){
     f+=obj[i];
    }else{
     continue;
    }
    break;
   case 'boolean':
    f+=String(obj[i]);
    break;
   case 'object':
    f+=this.object2Query(obj[i]);
    break;
   case 'function':
   case 'null':
   case 'undefined':
    continue;
   }
   if(b){q+=sp+f;}
   else{q+=f;}
   b=true;
  }
  return q;
 },
 getRef:function(e){
  var tmp=e;
  var ref=null;
  var c=0;
  while(tmp!=undefined&&tmp!=null&&c<3){
   if(tmp.nodeName.toLowerCase()=='body')break;
   if(tmp.nodeName.toLowerCase()=='#document'||tmp.nodeName.toLowerCase()=='#text'){
    tmp=tmp.parentNode;
    continue;
   }
   ref=tmp.getAttribute("fp:r");
   if(ref){
    break;
   }
   tmp=tmp.parentNode;
   c++;
  }
  return ref;
 },
 makeXpath:function(e){
  var tmp=e;
  var path='';
  while(tmp!=undefined&&tmp!=null){
   if(tmp.nodeName.toLowerCase()=='body')break;
   if(tmp.nodeName.toLowerCase()=='#document'||tmp.nodeName.toLowerCase()=='#text'){
    tmp=tmp.parentNode;
    continue;
   }
   if(tmp.attributes&&tmp.id){
    path='/'+tmp.nodeName.toLowerCase()+'[@id=\''+tmp.id+'\']'+path;
   }else{
    var p=this._p(tmp);
    if(p==1){path='/'+tmp.nodeName.toLowerCase()+path;}
    else{path='/'+tmp.nodeName.toLowerCase()+'['+p+']'+path;}
   }
   tmp=tmp.parentNode;
  }
  return path;
 },
 xpathQuery:function(node,expr){
  var res=[];
//  if (window.ActiveXObject){
//  }else if (document.implementation && document.implementation.createDocument){
   var resolv=function(prefix){var ns={'fp':'http://potaru.com/ns/footprint'};return ns[prefix]||null;};
   var nodes=document.evaluate(expr,node,resolv,XPathResult.ANY_TYPE,null);
   var n=nodes.iterateNext();
   while(n){
    res.push(n);
    n=nodes.iterateNext();
   }
//  }
  return res;
 },
 _p:function(el){
  var pos=1;
  var org=el.nodeName;
  while(el!=undefined&&el!=null){
   el=el.previousSibling;
   if(typeof el!='object'||el==null)break;
   if(org==el.nodeName)pos=pos+1;
  }
  return pos;
 },
 token:function(len){
  var a='abcdefghijklmnopqrstuvwxyz'
       +'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
       +'0123456789';
  a=a.split('');
  var s='';
  for(var i=0;i<len;i++){
   s+=a[Math.floor(Math.random()*a.length)];
  }
  return s;
 }
});
// Event handler
var _anagoHandler=new Object({});
if (document.addEventListener) {
 _anagoHandler.add=function(el,eventType,hnd){
  el.addEventListener(eventType,hnd,false);
//  el.addEventListener(eventType,function(){alert(eventType+' '+el.getAttribute('fp:r'));},false);
 };
 _anagoHandler.remove=function(el,eventType,hnd){
  el.removeEventListener(eventType,hnd,false);
 };
}
else if(document.attachEvent) {
 _anagoHandler.add=function(el,eventType,hnd){
  if(_anagoHandler._find(el,eventType,hnd)!=-1)return;
  var wrappedHandler=function(e){
   if(!e)e=window.event;
   var event={
    _event:e,
    type:e.type,
    target:e.srcElement,
    currentTarget:el,
    relatedTarget:e.fromElement?e.fromElement:e.toElement,
    eventPhase: (e.srcElement==el)?2:3,
    clientX:e.clientX,clientY:e.clientY,
    screenX:e.screenX,screenY:e.screenY,
    altKey:e.altKey, ctrlKey:e.ctrlKey,
    shiftKey:e.shiftKey,charCode:e.keyCode,
    stopPropagation:function(){this._event.cancelBubble=true;},
    preventDefault:function(){this._event.returnValue=false;}
   };
   if(Function.prototype.call) 
    hnd.call(el,event);
   else {
    el._currentHandler=hnd;
    el._currentHandler(event);
    el._currentHandler=null;
   }
  };
  el.attachEvent("on"+eventType,wrappedHandler);
  var h={
   el:el,
   eventType:eventType,
   handler:hnd,
   wrappedHandler:wrappedHandler
  };
  var d=el.document||el;
  var w=d.parentWindow;
  var id=_anagoHandler._uid();
  if(!w._allHandlers){w._allHandlers={}};
  w._allHandlers[id]=h;
  if(!el._handlers)el._handlers=[];
  el._handlers.push(id);
  if(!w._onunloadHandlerRegistered){
   w._onunloadHandlerRegistered=true;
   w.attachEvent("onunload",_anagoHandler._removeAllHandlers);
  }
 };
 _anagoHandler.remove=function(el,eventType,hnd){
  var i=_anagoHandler._find(el,eventType,hnd);
  if (i==-1)return;
  var d=el.document||el;
  var w=d.parentWindow;
  var handlerId=element._handlers[i];
  var h=w._allHandlers[handlerId];
  el.detachEvent("on"+eventType,h.wrappedHandler);
  el._handlers.splice(i,1);
  delete w._allHandlers[handlerId];
 };
 _anagoHandler._find=function(el,eventType,hnd){
  var handlers=el._handlers;
  if (!handlers)return -1;
  var d=el.document || el;
  var w=d.parentWindow;
  for(var i=handlers.length-1;i>=0;i--) {
   var handlerId=handlers[i];
   var h=w._allHandlers[handlerId];
   if (h.eventType==eventType&&h.handler==hnd) 
    return i;
  }
  return -1;
 };
 _anagoHandler._removeAllHandlers=function(){
  var w=this;
  for(id in w._allHandlers) {
   var h=w._allHandlers[id]; 
   h.el.detachEvent("on"+h.eventType,h.wrappedHandler);
   delete w._allHandlers[id];
  }
 }
 _anagoHandler._cnt=0;
 _anagoHandler._uid=function(){return "h"+_anagoHandler._cnt++;};
}
// JSON
var _anagoJson=new Object({
 esc:function(str){
  var code,pref={1:'\\u000',2:'\\u00',3:'\\u0',4:'\\u'};
  return str.replace(/\W/g,function(c){return pref[(code=c.charCodeAt(0).toString(16)).length]+code;});
 },
 encode:function(obj){
  var r='';
  switch(typeof(obj)){
  case 'string':
   return '"'+this.esc(obj)+'"';
  case 'number':
   return isFinite(obj)?String(obj):'null';
  case 'boolean':
   return String(obj);
  case 'null':
   return 'null';
  case 'object':
   if(obj instanceof Array){
    var buf=['['],b=false;
    for(var i=0;i<obj.length;i++){
     val=obj[i];
     val=this.encode(val);
     if(typeof val=='string'){
      if(b){
       buf[buf.length]=',';
      }
      buf.push(val);
      b=true;
     }
    }
    buf[buf.length]=']';
    return buf.join('');
   }else{
    var buf=['{'],val,b=false;
    for(var i in obj){
     val=obj[i];
     val=this.encode(val);
     if(typeof val=='string'){
      if(b){
       buf[buf.length]=',';
      }
      buf.push(this.encode(i),':',val);
      b=true;
     }
    }
    buf[buf.length]='}';
    return buf.join('');
   }
  case 'function':
   return 'null';
  }
 },
 decode:function(str){
  return eval('('+str+')');
 }
});
// AJAX
var _anagoAjax=new Object({
 transport:null,
 sendPost:function(url,obj){
  if(!_anagoAjax.transport){
   return false;
  }
  _anagoAjax.resetHandler();
  var q='';
  if(typeof obj=='object'){
   if(typeof obj['onsucess']=='function'){
    _anagoAjax.onsucess=obj['onsucess'];
   }
   if(typeof obj['onfailure']=='function'){
    _anagoAjax.onfailure=obj['onfailure'];
   }
   if(typeof obj['params']=='object'){
    q=_anagoUtil.object2Query(obj);
   }
  }
  _anagoAjax.transport.open("POST", url, true);
  _anagoAjax.transport.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
  _anagoAjax.transport.setRequestHeader("Content-Length", String(q.length));
  _anagoAjax.transport.setRequestHeader('X-Requested-With','XMLHttpRequest');
  _anagoAjax.transport.send(q);
  _anagoAjax.transport.onreadystatechange=_anagoAjax.onreadystatechange;
 },
 sendGet:function(url,obj){
  if(!_anagoAjax.transport){
   return false;
  }
  _anagoAjax.resetHandler();
  var q='';
  if(typeof obj=='object'){
   if(typeof obj['onsucess']=='function'){
    _anagoAjax.onsucess=obj['onsucess'];
   }
   if(typeof obj['onfailure']=='function'){
    _anagoAjax.onfailure=obj['onfailure'];
   }
   if(typeof obj['params']=='object'){
    q='?'+_anagoUtil.object2Query(obj);
   }
  }
  _anagoAjax.transport.open("GET",url+q,true);
  _anagoAjax.transport.setRequestHeader('X-Requested-With','XMLHttpRequest');
  _anagoAjax.transport.onreadystatechange=_anagoAjax.onreadystatechange;
 },
 sendJson:function(url,obj){
  if(!_anagoAjax.transport){
   return false;
  }
  _anagoAjax.resetHandler();
  var json="null";
  if(typeof obj=='object'){
   if(typeof obj['onsucess']=='function'){
    _anagoAjax.onsucess=obj['onsucess'];
   }
   if(typeof obj['onfailure']=='function'){
    _anagoAjax.onfailure=obj['onfailure'];
   }
   if(typeof obj['params']=='object'){
    json=_anagoJson.encode(obj['params']);
   }
  }
  _anagoAjax.transport.open("POST",url,true);
  _anagoAjax.transport.setRequestHeader("Content-Type","application/json");
  _anagoAjax.transport.setRequestHeader("Content-Length", String(json.length));
  _anagoAjax.transport.setRequestHeader('X-Requested-With','XMLHttpRequest');
  _anagoAjax.transport.send(json);
  _anagoAjax.transport.onreadystatechange=_anagoAjax.onreadystatechange;
 },
 onreadystatechange:function(){},
 onsucess:function(transport){},
 onfailure:function(transport){},
 resetHandler:function(){
  _anagoAjax.onsucess=function(transport){};
  _anagoAjax.onfailure=function(transport){};
 }
});
if(window.ActiveXObject){
 try {
  _anagoAjax.transport = new ActiveXObject("Msxml2.XMLHTTP");
 }catch(e){
  try {
   _anagoAjax.transport = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
   _anagoAjax.transport = null;
  }
 }
} else if(window.XMLHttpRequest){
 _anagoAjax.transport = new XMLHttpRequest();
}else{
 _anagoAjax.transport = null;
}
// Geometry
var _anagoGeometry=new Object({
 getElementPos:function(e){
  function getPosX(e){
   var x=0;
   while(e){
    x+=e.offsetLeft;
    e =e.offsetParent;
   }
   return x;
  };
  function getPosY(element){
   var y=0;
   for(var e=element;e;e=e.offsetParent)
    y+=e.offsetTop;
   for(e=element.parentNode;e&&e!=document.body;e=e.parentNode)
    if(e.scrollTop)y-=e.scrollTop;
   return y;
  };
  return new Object({x:getPosX(e),y:getPosY(e)});
 },
 getElementSize:function(e){
  return new Object({w:e.offsetWidth,h:e.offsetHeight});
 }
});
if(window.screenLeft){//IEなど
 _anagoGeometry.getWindowX=function(){return window.screenLeft;};
 _anagoGeometry.getWindowY=function(){return window.screenTop;};
}else if(window.screenX){//Firefoxなど
 _anagoGeometry.getWindowX=function(){return window.screenX};
 _anagoGeometry.getWindowY=function(){return window.screenY};
}
if (window.innerWidth) {
 _anagoGeometry.getViewportWidth=function(){return window.innerWidth; };
 _anagoGeometry.getViewportHeight=function(){return window.innerHeight; };
 _anagoGeometry.getHorizontalScroll=function(){return window.pageXOffset; };
 _anagoGeometry.getVerticalScroll=function(){return window.pageYOffset; };
}else if (document.documentElement.clientWidth) {
 _anagoGeometry.getViewportWidth=function(){return document.documentElement.clientWidth;};
 _anagoGeometry.getViewportHeight=function(){return document.documentElement.clientHeight;};
 _anagoGeometry.getHorizontalScroll=function(){return document.documentElement.scrollLeft;};
 _anagoGeometry.getVerticalScroll=function(){return document.documentElement.scrollTop;};
}else if (document.body.clientWidth) {
 _anagoGeometry.getViewportWidth=function(){return document.body.clientWidth;};
 _anagoGeometry.getViewportHeight=function(){return document.body.clientHeight;};
 _anagoGeometry.getHorizontalScroll=function(){return document.body.scrollLeft;};
 _anagoGeometry.getVerticalScroll=function(){return document.body.scrollTop;};
}
if (document.documentElement && document.documentElement.scrollWidth){
 _anagoGeometry.getDocumentWidth=function(){return document.documentElement.scrollWidth;};
 _anagoGeometry.getDocumentHeight=function(){return document.documentElement.scrollHeight;};
}else if(document.body.scrollWidth){
 _anagoGeometry.getDocumentWidth=function(){return document.body.scrollWidth;};
 _anagoGeometry.getDocumentHeight=function(){return document.body.scrollHeight;};
}
// Anago
var _anago = new Object({
 base:'potaru.com',
 win:window,
 doc:document,
 body:document.getElementsByTagName('body')[0],
 opts:{},
 sid:null,
 aid:null,
 fpid:null,
 schema:(("https:" == document.location.protocol) ? "https://" : "http://"),
 hostname:document.location.hostname,
 location:document.location.href,
 inTime:null,
 browser:{
  name:navigator.appName,
  version:parseInt(navigator.appVersion),
  userAgent:navigator.userAgent,
  platform:navigator.platform,
  isIE:!!(window.attachEvent && navigator.userAgent.indexOf('Opera') === -1),
  isOpera:navigator.userAgent.indexOf('Opera') > -1,
  isWebKit:navigator.userAgent.indexOf('AppleWebKit/') > -1,
  isGecko:navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') === -1,
  isMobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
 },
 blockTags:[
//  'div'
  'p','pre','h1','h2','h3','h4','h5','h6','hr','frameset','frame','noframes','address','blockquote',
  'style','div','center','ul','ol','dl','dir','menu','form','fieldset','table','noscript'
 ],
 inlineTags:[
  'br','a','bdo','iframe','abbr','acronym','q','cite','em','strong','code','dfn','kbd','samp','var','span',
  'img','font','basefont','big','small','b','i','s','strike','u','tt','sub','sup','form','input','button',
  'textarea','select','label','isindex','caption','object','applet','script','ruby','rb','rt','rp'
 ],
 emptyTags:[
  'br'
 ],
 evt:[
  /*  0  */'abort',     /*  1  */'blur',     /*  2  */'change',    /*  3  */'click',
  /*  4  */'dbclick',   /*  5  */'error',    /*  6  */'focus',     /*  7  */'keydown',
  /*  8  */'keypress',  /*  9  */'keyup',    /*  10 */'load',      /*  11 */'mousedown',
  /*  12 */'mousemove', /*  13 */'mouseout', /*  14 */'mouseover', /*  15 */'mouseup',
  /*  16 */'reset',     /*  17 */'resize',   /*  18 */'select',    /*  19 */'submit',
  /*  20 */'unload'
 ],
 evtmap:{
  //          0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
  A         :[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  ABBR      :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  ACRONYM   :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  ADDRESS   :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  //APPLET    :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  AREA      :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  B         :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  BASE      :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  BASEFONT  :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  //BDO       :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  BGSOUND   :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  BIG       :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  BLINK     :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  BLOCKQUOTE:[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  BODY      :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  //BR        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  BUTTON    :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  CAPTION   :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  CENTER    :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  CITE      :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  CODE      :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  COL       :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  COLGROUP  :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  COMMENT   :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  DD        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  DEL       :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  DFN       :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  DIR       :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  DIV       :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  DL        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  DT        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  EM        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  EMBED     :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  FIELDSET  :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  //FONT      :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  FORM      :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
  //FRAME     :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  //FRAMESET  :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  H1        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  H2        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  H3        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  H4        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  H5        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  H6        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  //HEAD      :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  HR        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  //HTML      :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  I         :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  //IFRAME    :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  ILAYER    :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  IMG       :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  INPUT     :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  INS       :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  //ISINDEX   :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  KBD       :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  LABEL     :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  LAYER     :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  LEGEND    :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  LI        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  LINK      :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  LISTING   :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  MAP       :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  MARQUEE   :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  MENU      :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  //META      :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  MULTICOL  :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  NOBR      :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  NOEMBED   :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  NOFRAMES  :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  NOLAYER   :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  NOSCRIPT  :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  OBJECT    :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  OL        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  OPTION    :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  P         :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  PARAM     :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  PLAINTEXT :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  PRE       :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  Q         :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  RB        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  RP        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  RT        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  RUBY      :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  S         :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  SAMP      :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  SCRIPT    :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  SELECT    :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  SMALL     :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  SPACER    :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  SPAN      :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  STRIKE    :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  STRONG    :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  //STYLE     :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  SUB       :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  SUP       :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  TABLE     :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  TBODY     :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  TD        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  TEXTAREA  :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  TFOOT     :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  TH        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  THEAD     :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  TITLE     :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  TR        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  TT        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  U         :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  UL        :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  VAR       :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  WBR       :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  XMP       :[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
 },
 evtbuf:{},
 evttimer:null,
 evtproperty:{
  'type'   :'ev','keycode' :'kc','shiftkey':'sk','ctrlkey':'ck','altkey'   :'ak','button':'bt',
  'screenx':'sx','screeny' :'sy','clientx' :'cx','clienty':'cy','x'        :'x' ,'y'    :'y' ,
  'offsetx':'ox','offsety' :'oy','data'    :'dt','which'  :'wh','modifiers':'mo','pagex' :'px',
  'pagey'  :'py','width'   :'wd','height'  :'ht','layerx' :'lx','layery'   :'ly','detail':'de',
  'metakey':'mk','charcode':'cc'
 },
 defined:function(n){
  if(typeof(window[n])!='undefined'){
   return true;
  }else{
   return false;
  }
 },
 include:function(src){
  var script=document.createElement('script');
  script.src=src;
  script.type='text/javascript';
  this.getHead().appendChild(script);
 },
 beacon:function(src,func){
  var img=new Image(1,1);
  img.src=src;
  if(typeof func=='function')img.onload=func;
  this.getBody().appendChild(img);
 },
 getHead:function(){
  return document.getElementsByTagName('head')[0];
 },
 getBody:function(){
  return document.getElementsByTagName('body')[0];
 },
 attachEvent:function(a,b,c){
  if (a.addEventListener){
   a.addEventListener(b,c,false);
   return true;
  } else if(a.attachEvent){
   var r=a.attachEvent("on"+b,c);
   return r;
  } else {
   return false;
  }
 },
 mappedEvent:function(){
  var el=this.getBody().getElementsByTagName("*");
  for(var i=0;i<el.length;i++){
   var tn=el[i].tagName;
   if(this.evtmap[tn]){
    for(var j=0;j<this.evtmap[tn].length;j++){
     if(this.evtmap[tn][j]!=0){
      _anagoHandler.add(el[i],this.evt[j],this.handleEvents);
     }
    }
   }
   //_anagoHandler.add(el[i],'mouseup',this.handleTextSelection);
  }
  //_anagoHandler.add(this.win,'resize',_anago.handleWindowResize,false);
  //_anagoHandler.add(this.win,'scroll',_anago.handleWindowScroll,false);
  //if(window.addEventListener)
  // _anagoHandler.add(this.win,'DOMMouseScroll',_anago.handleMouseWheel,false);
  //_anagoHandler.add(this.win,'mousewheel',_anago.handleMouseWheel,false);
  //_anagoHandler.add(this.doc,'mousewheel',_anago.handleMouseWheel,false);
  this.evttimer=setTimeout(_anago.handleEventTimer,3000);
 },
 handleWindowResize:function(e){
  e = e||window.event;
  var buf=new Object();
  buf.type="window";
  buf.ev="resize";
  buf.tm=new Date().getTime();
  //buf.wx=_anagoGeometry.getWindowX();
  //buf.wy=_anagoGeometry.getWindowY();
  buf.vw=_anagoGeometry.getViewportWidth();
  buf.vh=_anagoGeometry.getViewportHeight();
  buf.hs=_anagoGeometry.getHorizontalScroll();
  buf.vs=_anagoGeometry.getVerticalScroll();
  buf.dw=_anagoGeometry.getDocumentWidth();
  buf.dh=_anagoGeometry.getDocumentHeight();
  _anago.evtbuf[buf.tm+':window/resize']=buf;
 },
 handleWindowScroll:function(e){
  e = e||window.event;
  var buf=new Object();
  buf.type="window";
  buf.ev="scroll";
  buf.tm=new Date().getTime();
  //buf.wx=_anagoGeometry.getWindowX();
  //buf.wy=_anagoGeometry.getWindowY();
  buf.vw=_anagoGeometry.getViewportWidth();
  buf.vh=_anagoGeometry.getViewportHeight();
  buf.hs=_anagoGeometry.getHorizontalScroll();
  buf.vs=_anagoGeometry.getVerticalScroll();
  buf.dw=_anagoGeometry.getDocumentWidth();
  buf.dh=_anagoGeometry.getDocumentHeight();
  _anago.evtbuf[buf.tm+':window/scroll']=buf;
 },
 handleMouseWheel:function(e){
  e = e||window.event;
  if(!e.target.tagName)return;
  var delta=0;
  if(e.wheelDelta){
   delta = e.wheelDelta/120;
   if (_anago.win.opera)
    delta=-delta;
  }else if(e.detail){
   delta=-e.detail/3;
  }
  var buf=new Object();
  buf.type="window";
  buf.ev="mousewheel";
  buf.tm=new Date().getTime();
  //buf.wx=_anagoGeometry.getWindowX();
  //buf.wy=_anagoGeometry.getWindowY();
  buf.vw=_anagoGeometry.getViewportWidth();
  buf.vh=_anagoGeometry.getViewportHeight();
  buf.hs=_anagoGeometry.getHorizontalScroll();
  buf.vs=_anagoGeometry.getVerticalScroll();
  buf.dw=_anagoGeometry.getDocumentWidth();
  buf.dh=_anagoGeometry.getDocumentHeight();
  buf.delta=delta;
  _anago.evtbuf[buf.tm+':window/mousewheel']=buf;
 },
 handleTextSelection:function(e){
  e = e||window.event;
  element=e.target;
  var selection='';
  if(_anago.win.getSelection){
   selection=_anago.win.getSelection().toString();
  }else if(_anago.doc.getSelection){
   selection=_anago.doc.getSelection();
  }else if(_anago.doc.selection){
   selection=_anago.doc.selection.createRange().text;
  }
  if(!selection.length) return;
  var buf=new Object();
  buf.type="window";
  buf.ev='selection';
  buf.tm=new Date().getTime();
  //buf.xp=_anagoUtil.makeXpath(element);
  buf.selection=selection;
  _anago.evtbuf[buf.tm+':window/selection']=buf;
 },
 handleEvents:function(e){
  e = e||window.event;
  element=e.target;
  var buf=new Object();
  buf.type="element";
  buf.xp=_anagoUtil.makeXpath(element);
  if(element.innerText) {
    buf.text=element.innerText;
  }else if(element.text) {
    buf.text=element.text;  	
  }
  buf.tag=element.tagName.toLowerCase();
  buf.tm=new Date().getTime();
  for(var k in e){
   var type=typeof e[k];
   if((type=='number'||type=='string'||type=='boolean')){
    var j=k.toLowerCase();
    if(_anago.evtproperty[j]){
     buf[_anago.evtproperty[j]]=e[k];
    }
   }
  }
  buf.ref=_anagoUtil.getRef(element);
  _anago.evtbuf[buf.tm+':'+_anagoUtil.token(8)]=buf;
 },
 handleEventTimer:function(){
  _anago.sendEvent();
  _anago.evttimer=setTimeout(_anago.handleEventTimer, 3000);
 },
 handleInit:function(e){
  _anago.mappedEvent();
  _anago.anagolize();
 },
 handleExit:function(e){
  _anago.sendEvent();
  clearTimeout(_anago.evttimer);
 },
 handleBeforeUnload:function(e){
  var element=_anago.doc.activeElement;
  var jsonObj=new Object({});
  var tag=element.tagName.toLowerCase();
  var buf=new Object();
  buf.type="window";
  //buf.xp=_anagoUtil.makeXpath(element);
  buf.tag=element.tagName.toLowerCase();
  buf.tm=new Date().getTime();
  buf.ev='unload';
  buf.stayTime=buf.tm-_anago.inTime;
//  switch(tag){
//  case 'a':
//   buf.url=element.href;
//   buf.method='GET';
//   break;
//  case 'body':
//   return;
//  case 'input':
//   buf.url=element.form.action;
//   buf.method=element.form.method;
//   break;
//  }
  _anago.evtbuf[buf.tm+':'+_anagoUtil.token(8)]=buf;
//  _anago.sendEvent();
 },
 sendEvent:function(){
  var jsonObj=new Object({ver:"1.0",sid:this.sid,aid:this.aid,fpid:this.fpid,frmt:"evts",data:[]});
  for(var id in this.evtbuf){
   jsonObj.data.push(this.evtbuf[id]);
  }
  if(jsonObj.data.length){
   _anagoAjax.sendJson(this.schema+this.base+'/anago.php?evts',{params:jsonObj});
  }
  this.evtbuf={};
 },
 anagolize:function(){
  if(typeof(this.aid)=='string'){
   if(("https:" != document.location.protocol)){
    this.include('http://anago.actbank.net/anago/set?anagoId='+encodeURIComponent(this.aid));
   }
  }else{
   return false;
  }
  var jsonObj=new Object({ver:"1.0",sid:this.sid,aid:this.aid,fpid:this.fpid,frmt:"page",data:{}});
  jsonObj.data.browser=this.browser;
  jsonObj.data.geo=new Object({
   //wx:_anagoGeometry.getWindowX(),
   //wy:_anagoGeometry.getWindowY(),
   vw:_anagoGeometry.getViewportWidth(),
   vh:_anagoGeometry.getViewportHeight(),
   hs:_anagoGeometry.getHorizontalScroll(),
   vs:_anagoGeometry.getVerticalScroll(),
   dw:_anagoGeometry.getDocumentWidth(),
   dh:_anagoGeometry.getDocumentHeight()
  });
  /*
  jsonObj.data.blocks=new Array();
  for(var i=0;i<this.blockTags.length;i++){
   var elements=this.doc.getElementsByTagName(this.blockTags[i]);
   for(var j=0;j<elements.length;j++){
    var e=elements[j];
    var nm=e.getAttribute('name');
    if(nm==null){nm='';}
    var pos=_anagoGeometry.getElementPos(e);
    var siz=_anagoGeometry.getElementSize(e);
    var block=new Object({
     tag:this.blockTags[i],
     id:e.id,
     nm:nm,
     //xp:_anagoUtil.makeXpath(e),
     x:pos.x,
     y:pos.y,
     w:siz.w,
     h:siz.h
    });
    jsonObj.data.blocks.push(block);
   }
  }
  */
  //_anagoAjax.sendJson(this.schema+this.base+'/anago.php?page',{params:jsonObj});
 },
 startup:function(opts){
  if(typeof opts!='object'){
   throw "anago initialize failure!!";
  }else{
   this.opts=opts||{};
   if(!this.opts.aid)this.opts.aid=this.cookie("aid");
  }
  this.inTime=new Date().getTime();
  this.sid=this.opts.siteId;
  this.fpid=this.opts.footprintId;
  this.aid=this.opts.anagoId;
  this.attachEvent(this.win,'load',_anago.handleInit);
  this.attachEvent(this.win,'unload',_anago.handleExit);
  this.attachEvent(this.win,'beforeunload',_anago.handleBeforeUnload);
 }
});
_anago.cookie=function(name, value, options) {
 if (typeof value != 'undefined') {
  options=options||{};
  if (value===null) {
   value='';
   options.expires=-1;
  }
  var expires='';
  if (options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){
   var date;
   if (typeof options.expires=='number'){
    date=new Date();
    date.setTime(date.getTime()+(options.expires*24*60*60*1000));
   } else {
    date=options.expires;
   }
   expires='; expires='+date.toUTCString();
  }
  var path=options.path?'; path='+(options.path):'';
  var domain=options.domain?'; domain='+(options.domain):'';
  var secure=options.secure?'; secure':'';
  document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');
 }else{
  var cookieValue = null;
  if (document.cookie&&document.cookie!='') {
   var cookies = document.cookie.split(';');
   for(var i=0;i<cookies.length;i++) {
    var cookie=(cookies[i]||"").replace(/^\s+|\s+$/g, "");
    if (cookie.substring(0,name.length+1)==(name+'=')) {
     cookieValue=decodeURIComponent(cookie.substring(name.length+1));
     break;
    }
   }
  }
  return cookieValue;
 }
};
