/******************
blinkhash.js
ver. 2007-0214_0.9
(C) 2005-2007 WATARU, Wings-Winds
http://wi-wi.jp/
******************/
function _BLINK(){
	this.BlinkSpeed=200;
	this.BlinkTimes=3;
	this.Bar=['h1','h2','h3','h4','h5','h6','h7','caption'];
	this.HighlightStyle={};
	this.ScrollPixels=100;
	this.ScrollSpeed=10;
	this.ConstLeft=true;
	this.ConstTop=false;
	this.UseParent=true;

this.DefaultStyle={};//do not change;
return this;
}

function _Blink(){
var wlo=window.location || document.location;
this.host=wlo.host;
this.protocol=wlo.protocol;
this.agt=navigator.userAgent.toLowerCase();
this.platform=navigator.platform.toLowerCase();
this.path=_getPath(wlo.pathname);
this.filename=_getFilename(wlo.pathname);
this.location=this.protocol+"//"+this.host+this.path+this.filename;
this.tim=null;
this.toX=0;
this.toY=0;
this.scrollx=0;
this.scrolly=0;
this.lights=0;
this.hash=null;
this.bar=null;
this.Compare=function(anchor){
var loc='';
if(!anchor){return false;}
var url=_getLocation(anchor);
if(!url){return true;}//anchor='#xxx', same as the document
if(url.indexOf('://')>=0){
loc=url;
}else if(url.indexOf('/')==0){
loc=this.protocol+'://'+this.host+url;
}else{
var dirs=this.path.split('/');
var udirs=url.split('/');
for(var i=0;i<udirs.length;i++){
if(udirs[i]=='..'){
dirs.length--; //macie, < ie5.5
//dirs.pop();
}else if(udirs[i]=='.'){
; // none
}else{
dirs[dirs.length]=udirs[i]; //macie, < ie5.5
//dirs.push(udirs[i]);
}
}
loc=this.protocol+'://'+this.host+'/'+dirs.join('/');
}
if(this.location==loc){
return true;
}
return false;
};//
this.doClick=function(e){
e=e||window.event;
Blink._Do(e);
return false;
};//
this.doKeydown=function(e){
e=e||window.event;
if(e.keyCode!=13){return true;}
Blink._Do(e);
return false;
};//
this._Do=function(e){
var tar=e.target||e.srcElement;
while(!!tar && (tar.nodeName!='A')){// && !tar.href){
tar=tar.parentNode;
}
if(!tar)return;
Blink.hash=_getHash(tar.href);
if(!Blink.hash)return;//need?
var o=null;
var ha=GetElement(Blink.hash);
if(!ha)return;
if(e.preventDefault){
e.preventDefault();
e.stopPropagation();
}else{
e.returnValue=false;
e.cancelBubble=true;
}
if(Blink.tim){Blink.Reset();clearTimeout(Blink.tim);}
Blink.scrollx=_MAX(window.scrollX,document.body.scrollLeft,document.documentElement.scrollLeft);
Blink.scrolly=_MAX(window.scrollY,document.body.scrollTop,document.documentElement.scrollTop);
var p;
if(window.opera && ha.nodeName.toUpperCase()=='A' && ha.innerHTML==''){
var ns=ha.nextSibling;
while(!!ns && ns.nodeType!=1){
ns=ns.nextSibling;
}
if(!!ns){
p=_Pos(ns);
}else{
return;
}
}else{
p=_Pos(Blink.hash);
}
if(this.agt.indexOf('safari') != -1){
p.y-=50;
if(p.y<0)p.y=0;
}
if(BLINK.ConstLeft){
Blink.toX=Blink.scrollx;
}else{
var docw=_MAX(document.width,document.body.offsetWidth,document.body.clientWidth);
var winw=(document.all && !window.opera)?_MAX(document.documentElement.offsetWidth):_MAX(window.innerWidth);
if(doch==winh){
Blink.toX=p.x;
}else{
var n=docw-winw;
Blink.toX=(n<p.x)?n:p.x;
}
}
if(BLINK.ConstTop){
Blink.toY=Blink.scrolly;
}else{
var doch=_MAX(document.height,document.body.offsetHeight,document.body.clientHeight);
var winh=(document.all && !window.opera)?_MAX(document.documentElement.offsetHeight):_MAX(window.innerHeight);
if(doch==winh){
Blink.toY=p.y;
}else{
var n=doch-winh;
Blink.toY=(n<p.y)?n:p.y;
}
}
SEARCHBAR:do{
if(BLINK.UseParent && ha.nodeName.toUpperCase()=='A'){
var b=ha.parentNode;
var nodeName=b.nodeName.toUpperCase();
for(i=0;i<BLINK.Bar.length;i++){
if(nodeName==BLINK.Bar[i]){
o=b;
break SEARCHBAR;
}
}
b=ha.nextSibling;
while(b && b.nodeType!=1){
b=b.nextSibling;
}
if(!!b){
var nodeName=b.nodeName.toUpperCase();
for(i=0;i<BLINK.Bar.length;i++){
if(nodeName==BLINK.Bar[i]){
o=b;
break SEARCHBAR;
}
}
}
}//if(UseParent)
for(i=0;i<BLINK.Bar.length;i++){
var b=ha.getElementsByTagName(BLINK.Bar[i]);
if(!b){continue;}
o=b[0];
if(!!o)break SEARCHBAR;
}
}while(false);//SEARCHBAR
if(!o){o=ha;}
Blink.bar=o;
for(var i in BLINK.HighlightStyle){
BLINK.DefaultStyle[i]=_getStyle(o, i);
}
Blink._Scroll();
};//
this._Scroll=function(){
clearTimeout(Blink.tim);
if(Blink.scrolly==Blink.toY && Blink.scrollx==Blink.toX){
Blink.lights=0;
if(this.platform.indexOf('mac')!=-1){
if((this.agt.indexOf('msie')<0) && (this.agt.indexOf('safari')<0)){
location.hash=Blink.hash;
}
}
if (this.agt.indexOf('opera 8.01') != -1) {
document.location.reload();
}
Blink._Blink();
return;
}
if(Blink.scrolly==Blink.toY){
;
}else if(Blink.scrolly<Blink.toY){
Blink.scrolly+=Math.min(Math.ceil((Blink.toY-Blink.scrolly)/2),BLINK.ScrollPixels);
}else{
Blink.scrolly-=Math.min(Math.ceil((Blink.scrolly-Blink.toY)/2),BLINK.ScrollPixels);
}
if(Blink.scrollx==Blink.toX){
;
}else if(Blink.scrollx<Blink.toX){
Blink.scrollx+=Math.min(Math.ceil((Blink.toX-Blink.scrollx)/2),BLINK.ScrollPixels);
}else{
Blink.scrollx-=Math.max(Math.ceil((Blink.scrollx-Blink.toX)/2),BLINK.ScrollPixels);
}
window.scrollTo(Blink.scrollx, Blink.scrolly);
Blink.tim=setTimeout("Blink._Scroll()",BLINK.ScrollSpeed);
};
this._Blink=function(){
clearTimeout(Blink.tim);
if(Blink.lights>=BLINK.BlinkTimes){//finish scroll and blink
Blink.Reset();
if(this.platform.indexOf('mac')!=-1){
if((this.agt.indexOf('msie')!=-1) || (this.agt.indexOf('safari')!=-1)){
location.hash=Blink.hash;
}
}
return;
}
if(++Blink.lights%2!=0){
Blink.Highlight();
}else{
Blink.Reset();
}
Blink.tim=setTimeout("Blink._Blink()",BLINK.BlinkSpeed);
};
this.Reset=function(){
var os=Blink.bar.style;
for(var i in BLINK.DefaultStyle){
os[i]=BLINK.DefaultStyle[i];
}
};
this.Highlight=function(){
var os=Blink.bar.style;
for(var i in BLINK.HighlightStyle){
os[i]=BLINK.HighlightStyle[i];
}
};
function _getPath(url){
var str=url.toString();
var agt=(!this.agt)?navigator.userAgent.toLowerCase():this.agt;
var platform=(!this.platform)?navigator.platform.toLowerCase():this.platform;
if((platform.indexOf('mac')!=-1) && (agt.indexOf('msie')!=-1)){
var RE=/(.*\/)([^\/]+)$/;
if(RE.test(str)){
return RegExp.$1;
}
}else{
var RE=RegExp("(.*\/)([^\/]+)$", ""); //>=NN4.0, FF, >=IE4.0
if(RE.exec(str)){
return RegExp.$1;
}
}
return str;
}//
function _getLocation(url){
var loc=url.toString();
loc=loc.replace(/#.*/, "");
loc=loc.replace(/\?.*/, "");
return loc;
}//
function _getHash(url){
var str=url.toString();
var p=str.indexOf('#');
if(p>=0){return str.substring(p+1, str.length);}
else{return '';}
}//
function _getFilename(url){
var str=url.toString();
var agt=(!this.agt)?navigator.userAgent.toLowerCase():this.agt;
var platform=(!this.platform)?navigator.platform.toLowerCase():this.platform;
if((platform.indexOf('mac')!=-1) && (agt.indexOf('msie')!=-1)){
var RE=/([^\/]+)$/; // macie
if(RE.test(str)){
return RegExp.$1;
}
}else{
var RE=RegExp("([^/]+)$",""); //>=NN4.0, >=IE4.0, FF
if(RE.exec(str)){
return RegExp.$1;
}
}
return "";
}//
function _MAX(){
var mx=0;for(var i=0;i<_MAX.arguments.length;i++){if(isNaN(_MAX.arguments[i]))continue;if(mx<_MAX.arguments[i]){mx=_MAX.arguments[i];}}return mx;
}//
function _getStyle(el, prop){
if(el.style[prop]){
return el.style[prop];
}else if(document.defaultView && document.defaultView.getComputedStyle){
prop=prop.replace(/([A-Z])/g, "-$1");
prop=prop.toLowerCase();
return document.defaultView.getComputedStyle(el,"").getPropertyValue(prop);
}else if(el.currentStyle){
return el.currentStyle[prop];
}else{
return null;
}
}//
function _Pos(id){
var el=GetElement(id);
var pos={x:0,y:0,w:0,h:0};
var platform=(!this.platform)?navigator.platform.toLowerCase():this.platform;
if(el.getBoundingClientRect){
var rect=el.getBoundingClientRect();
var top=_MAX(document.body.scrollTop,document.documentElement.scrollTop,window.scrollY);
var left=_MAX(document.body.scrollLeft,document.documentElement.scrollLeft,window.scrollX);
var width=_MAX(rect.width,el.clientWidth);
var height=_MAX(rect.height,el.clientHeight);
pos={x:left+rect.left,y:top+rect.top,w:width,h:height};
}else if(document.getBoxObjectFor){
var rect=document.getBoxObjectFor(el);
var top=_MAX(parseInt(_getStyle(el, "borderTopWidth")),0);
var left=_MAX(parseInt(_getStyle(el, "borderLeftWidth")),0);
var width=_MAX(rect.width,el.clientWidth);
var height=_MAX(rect.height,el.clientHeight);
pos={x:rect.x-left,y:rect.y-top,w:width,h:height};
}else{
pos.w=el.clientWidth;
pos.h=el.clientHeight;
while (el) {
pos.x += parseInt(el.offsetLeft);
pos.y += parseInt(el.offsetTop);
el = el.offsetParent;
}
pos.x-=document.body.offsetLeft; // -1* html margin-left
pos.y-=document.body.offsetTop; // -1* html margin-top
if (platform.indexOf("mac")!=-1){
pos.x+=document.body.offsetLeft;
pos.y+=document.body.offsetTop;
}
}
return pos;
}//
function GetElement(en) {
if(!document.getElementById || !document.getElementsByName){ return null; }
if(typeof en != 'string'){ return en; }
var els=document.getElementById(en);
if(!!els){return els;}
var els=document.getElementsByName(en);
if(!els){
return null;
}else if(!!els.length && els.length==1){
return els[0];
}else if(!!els.item){
if(els.item.length==0 || els.item.length>1){
return null;
}else{
return els.item(0);
}
}else{
return null;
}
}//
this.Create=function(){
var o=document.body||document.documentElement||document;
if(!o)return;
Parse(o);
if(!!window.RemoveEventListener){
window.RemoveEventListener('load', Blink.Create, false);
}else if(!!window.dettachEvent){
window.dettachEvent('onload', Blink.Create);
}
BLINK.BlinkTimes*=2;
if(!!window.location.hash){
var hash=location.hash.substring(1, location.hash.length);
Blink._Do({target:{href:'#'+hash,nodeName:'A'}});
}
};
function Parse(o){
if(o.hasChildNodes){
for(var i=0;i<o.childNodes.length;i++){
oc=o.childNodes[i];
if(!!oc && oc.nodeType==1){
Parse(oc);
}
}
}
while(!!o && o.nodeType!=1){
o=o.nextSibling;
}
if(!o)return;
var hre=o.href;
if(!Blink.Compare(hre)){return;}
hre=(hre.indexOf('#')>=0)?hre.substring(hre.indexOf('#')+1, hre.length):hre;
var to=GetElement(hre);
if(!to) return;
if(!!o.addEventListener){
o.addEventListener('click', Blink.doClick, false);
o.addEventListener('keydown', Blink.doKeydown, false);
}else if(!!o.attachEvent){
o.attachEvent('onclick', Blink.doClick);
o.attachEvent('onkeydown', Blink.doKeydown);
}else{
o.onclick=Blink.doClick;
o.onkeydown=Blink.doKeydown;
}
o=o.nextSibling;
}//
}//_Blink
_Blink.prototype.BlinkInit=function(){
var RE=new RegExp("(.*)\-([a-z])(.*)");
for(var i in HighlightStyle){
var v=i;
while(RE.test(v)){
v=RegExp.$1+RegExp.$2.toUpperCase()+RegExp.$3;
}
HighlightStyle[v]=HighlightStyle[i];
//HighlightStyle[i]=null;//ng in IE
//delete HighlightStyle[i];//ng in IE
}
for(i=0;i<BLINK.Bar.length;i++){
BLINK.Bar[i]=BLINK.Bar[i].toUpperCase();
}
if(!!window.addEventListener){
window.addEventListener('load', Blink.Create, false);
}else if(!!window.attachEvent){
window.attachEvent('onload', Blink.Create);
}else{
// mac-ie etc.
setTimeout('Blink.Create()', 1000);
}
return true;
};
var BLINK=_BLINK();
var Blink=new _Blink();
Blink.BlinkInit();
