/* 
NAVITIME Animation Gateway Interface Script
Copyright 2007 NAVITIME JAPAN CO.,LTD. All Rights Reserved.
Auther by myoshida@navitime.co.jp
Version1.0.0
*/
(function(){
Object.extend = function(destination, source) {
for (property in source) {
destination[property] = source[property];
}
return destination;
}
var Class = {
create: function() {
return function() {
this.initialize.apply(this, arguments);
}
}
}
var $A = Array.from = function(iterable) {
if (!iterable) return [];
if (iterable.toArray) {
return iterable.toArray();
} else {
var results = [];
for (var i = 0; i < iterable.length; i++)
results.push(iterable[i]);
return results;
}
}
Function.prototype.bind = function() {
var __method = this, args = $A(arguments), object = args.shift();
return function() {
return __method.apply(object, args.concat($A(arguments)));
}
}
function $() {
var Xf = new Array();
for (var i = 0; i < arguments.length; i++) {
var De = arguments[i];
if (typeof De == 'string')
De = document.getElementById(De);
if (arguments.length == 1)
return De;
Xf.push(De);
}
return Xf;
}
function Kd(a, b){
window[a] = b;
}
function An(a){
var b = a.parentNode;
var l = b.childNodes.length;
for(var i=0; i<l; i++){
if(b.childNodes[i]==a){
b.removeChild(b.childNodes[i]);
break;
}
}
}
function Qa(a){
var Ce = a.childNodes.length;
for(var i=Ce; i>=0; i--){
var Ce = 0;
try{
Lq = a.childNodes[i].childNodes['length'];
if(Lq> 0){
Qa(a.childNodes[i]);
}
a.removeChild(a.childNodes[i]);
}catch(e){
continue;
}
}
}
Hd= function(a,b){
var Qb = a.style;
if(new String(b).indexOf("+")==0 || new String(b).indexOf("-")==0){
b = eval("(Qb.MozOpacity|1)*100" + b);
}
Qb.MozOpacity = b/100;
Qb.opacity = b/100;
Qb.filter='progid:DXImageTransform.Microsoft.alpha(opacity='+b+')';
}
Wk = function(u,w,h){
var r = document.createElement("img");
if(u!=null && u!="")r.src = u;
if(w!=null) r.width = w;
if(h!=null)r.height = h;
return r;
}
Rx = function(url,b){
var a;
if(NTUserAgent.type==1 && NTUserAgent.version<7){
a = (b && b.src)?b.src:document.createElement("div");
var s = a.style;
s.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="+url+")";
if(b && b.width) s.width = b.width+"px";
if(b && b.height) s.height = b.height+"px";
if(b && b.classNm) a.className = b.classNm;
if(b && b.id) a.id = b.id;
}else{
a = Wk(url,(b.width||null),(b.height||null));
if(b && b.classNm) a.className = b.classNm;
if(b && b.id) a.id = b.id;
if(b && b.src){
b.src.appendChild(a);
b.src.style.width = "auto";
b.src.style.height = "auto";
if(NTUserAgent.type==4){
b.src.style.display = "inline";
}
}
}
return a;
}
Object.extend(Math, {
floor2: function(a){
var b=new String(a);
var c=b.indexOf(".")>-1?b.indexOf("."):b.length;
return new Number(b.substr(0,c));
}
});
var Iw=0;
function Ut(a){
a.prototype.setTimeout=function(timeoutHandler,elapseTime){
var Bw="tempVar"+Iw;
Iw++;
eval(Bw+" = this;");
var Nf=timeoutHandler.replace(/\\/g,"\\\\").replace(/\"/g,'\\"');
return window.setTimeout(Bw+'.Zf("'+Nf+'");'+Bw+" = null;",elapseTime);
};
a.prototype.Zf=function(bQ){
eval(bQ);
};
}
var NTEvent = function(){};
NTEvent.observers = [];
NTEvent.add = function(element, name, observer, useCapture){
var element = $(element);
useCapture = useCapture || false;
if (name == 'keypress' && (navigator.appVersion.match(/Konqueror|Safari|KHTML/) || element.attachEvent)){
name = 'keydown';
}
var hundler = function(e){
if(!e){
e=window.event;
}
if(e&&!e.target){
e.target=e.srcElement;
}
observer.call(element,e);
};
this._observeAndCache(element, name, hundler, useCapture);
};
NTEvent._observeAndCache = function(element, name, observer, useCapture) {
if (!this.observers){
this.observers = [];
}
if (element.addEventListener) {
this.observers.push([element, name, observer, useCapture]);
element.addEventListener(name, observer, useCapture);
} else if (element.attachEvent) {
this.observers.push([element, name, observer, useCapture]);
element.attachEvent('on' + name, observer);
}
};
NTEvent.unloadCache = function() {
if (!NTEvent.observers){
return;
}
for (var i = 0; i < NTEvent.observers.length; i++){
NTEvent.stopObserving.apply(this, NTEvent.observers[i]);
NTEvent.observers[i][0] = null;
}
NTEvent.observers = false;
};
NTEvent.remove = function(element, name){
if (!NTEvent.observers){
return;
}
var newObservers = [];
for (var i = 0; i < NTEvent.observers.length; i++){
if(NTEvent.observers[i][0] == element && (!name || (name && NTEvent.observers[i][1] == name))){
NTEvent.stopObserving.apply(this, NTEvent.observers[i]);
NTEvent.observers[i][0] = null;
}else{
newObservers[newObservers.length] = NTEvent.observers[i];
}
}
NTEvent.observers = newObservers;
};
NTEvent.stopObserving = function(element, name, observer, useCapture) {
var element = $(element);
useCapture = useCapture || false;
if (name == 'keypress' && (navigator.appVersion.match(/Konqueror|Safari|KHTML/) || element.detachEvent)){
name = 'keydown';
}
if (element.removeEventListener) {
element.removeEventListener(name, observer, useCapture);
} else if (element.detachEvent) {
element.detachEvent('on' + name, observer);
}
}
NTEvent.add(window, 'unload', NTEvent.unloadCache);
var NTUserAgent = function(){}
NTUserAgent.type="";
NTUserAgent.version="";
NTUserAgent.os="";
NTUserAgent.subtype="";
(function(){
var type=0;
var version=0;
var subtype=null;
var os=null;
var ua=navigator.userAgent.toLowerCase();
if(ua.indexOf("opera")!=-1){
type=4;
version=9;
if(ua.indexOf("opera/7")!=-1||ua.indexOf("opera 7")!=-1){
version=7;
}else if(ua.indexOf("opera/8")!=-1||ua.indexOf("opera 8")!=-1){
version=8;
}
}else if(ua.indexOf("msie")!=-1&&document.all){
type=1;
version=6;
if(ua.indexOf("msie 5")!=-1){
version=5;
}
}else if(ua.indexOf("safari")!=-1){
type=3;
}else if(ua.indexOf("mozilla")!=-1){
type=2;
if(ua.indexOf("firefox")!=-1){
subtype=1;
version=1.5;
if(ua.indexOf("firefox/1.0")!=-1){
version=1.0;
}
}else if(ua.indexOf("netscape")!=-1){
subtype=2;
}else if(ua.indexOf("seamonkey")!=-1){
subtype=4;
}else{
subtype=3;
version=1.8;
if(ua.indexOf("rv:1.7")!=-1){
version=1.7;
}
}
}
if(ua.indexOf("x11;")!=-1){
os=1;
}else if(ua.indexOf("macintosh")!=-1){
os=2;
}
NTUserAgent.type=type;
NTUserAgent.version=version;
NTUserAgent.os=os;
NTUserAgent.subtype=subtype;
})();
var Un = {
emptyFunction: function(){},
S: function(a,b){
var r = $(a).style[b];
if(r != "" && r.indexOf("px")!= -1 && r.indexOf("px") == r.length-2){
r=r.substr(0,r.indexOf("px"));
}
if(r != "" && r.indexOf("pt") != -1 && r.indexOf("pt") == r.length-2){
r=r.substr(0,r.indexOf("pt"));
}
return isNaN(r)?r:new Number(r);
},
P: function(a){return a+"px";},
C: function(e){
if(NTUserAgent.type==1){
window.event.cancelBubble=true;
window.event.returnValue=false;
}else{
e.cancelBubble=true;
if(e.preventDefault){
e.preventDefault();
}
if(e.stopPropagation){
e.stopPropagation();
}
}
}
}
Un.Resizer = Class.create();
Un.Resizer.prototype = {
initialize: function(a,b){
this.Tm = a;
this.setOption(b);
this.Fo = null;
if(this.Ob >=0)this.setTimeout("this.run()",this.Ob);
},
setOption: function(b){
if(this.Fo) this.stop();
var Qb = this.Tm.style;
if(b.endx)this.dK = Math.round(b.endx);
if(b.endy)this.Je = Math.round(b.endy);
if(b.startx) Qb.width = Un.P(b.startx);
if(b.starty) Qb.height = Un.P(b.starty);
this.Ax = (b.func||Un.emptyFunction);
this.Ob = (b.interval||0);
this.Gj = Math.floor(10/(b.speed||2)/((NTUserAgent.type==4 || NTUserAgent.type==2)?1.5:1.5));
},
run:function(a){
if(a) this.setOption(a);
var Qb = this.Tm.style;
Qb.cursor="default";
var x1 = new Number(Un.S(this.Tm,"width"));
var x2 = new Number(this.dK)-x1;
var x3 = Math.abs(x2/this.Gj)<1? x2/Math.abs(x2) : x2/this.Gj;
var y1 = new Number(Un.S(this.Tm,"height"));
var y2 = new Number(this.Je)-y1;
var y3 = Math.abs(y2/this.Gj)<1? y2/Math.abs(y2) : y2/this.Gj;
Qb.width = Un.P((Math.abs(x2)<=1) ? this.dK : Math.round(x1+x3));
Qb.height = Un.P((Math.abs(y2) <= 1) ? this.Je : Math.round(y1+y3));
if(Un.S(this.Tm,"width")==this.dK && Un.S(this.Tm,"height")==this.Je){
this.stop();
return this.Ax();
}
this.Fo = this.setTimeout("this.run()",10);
},
stop: function(){
clearTimeout(this.Fo);
this.Fo=null;
}
}
Un.Mover = Class.create();
Un.Mover.prototype = {
initialize: function(a,b){
this.Tm = a;
this.Tr = this.Tm.offsetLeft;
this.Tu = this.Tm.offsetTop;
this.setOption(b);
this.Fo = null;
if(this.Ob >=0) this.setTimeout("this.run()",this.Ob);
},
setOption: function(b){
if(this.Fo) this.stop();
if(b && b.left) this.Tr = Math.round(b.left);
if(b && b.top)this.Tu = Math.round(b.top);
this.Ax = (b.func||Un.emptyFunction);
this.Ob = (b.interval||0);
this.Gj = Math.floor(10/(b.speed||2)/((NTUserAgent.type==4 || NTUserAgent.type==2)?1.5:1.5));
},
run: function(a){
if(a) this.setOption(a);
var Qb = this.Tm.style;
Qb.cursor="default";
var x1 = new Number(Un.S(this.Tm,"left"));
var x2 = new Number(this.Tr)-x1;
var x3 = Math.abs(x2/this.Gj)<1? x2/Math.abs(x2) : x2/this.Gj;
var y1 = new Number(Un.S(this.Tm, "top"));
var y2 = new Number(this.Tu)-y1;
var y3 = Math.abs(y2/this.Gj)<1? y2/Math.abs(y2) : y2/this.Gj;
Qb.left = Un.P((Math.abs(x2)<=1) ? this.Tr : Math.round(x1 + x3));
Qb.top = Un.P((Math.abs(y2)<=1) ? this.Tu : Math.round(y1 + y3));
if(Un.S(this.Tm,"left")==this.Tr && Un.S(this.Tm,"top")==this.Tu){
this.stop();
return this.Ax();
}
this.Fo = this.setTimeout("this.run()",10);
},
stop: function(){
clearTimeout(this.Fo);
this.Fo = null;
}
};
Un.Transparencer = Class.create();
Un.Transparencer.prototype = {
initialize: function(a,b){
this.Tm=a;
this.setOption(b);
this.Fo = null;
if(this.Ob >=0) this.setTimeout("this.run()",this.Ob);
},
setOption: function(b){
if(this.Fo) this.stop();
if(!b) return;
this.Pf = (new Number(b.from)||100);
if(b.from!=null){
Hd(this.Tm,b.from);
}
this.Hq = (new Number(b.to)||0);
this.Ax = (b.func||Un.emptyFunction);
this.Ob = (b.interval||0);
this.Gj = Math.floor(15/(b.speed||2)/((NTUserAgent.type==4 || NTUserAgent.type==2)?1.5:1.5));
},
run: function(a){
if(a) this.setOption(a);
this.Tm.style.cursor="default";
this.Pf += (this.Hq - this.Pf)/this.Gj
Hd(this.Tm,this.Pf);
if(Math.abs(this.Hq-this.Pf)<0.5){
Hd(this.Tm,this.Hq);
this.stop();
return this.Ax();
}
this.Fo = this.setTimeout("this.run()",10);
},
stop: function(){
clearTimeout(this.Fo);
this.Fo = null;
}
};
Un.Object = function(){};
Un.Object.prototype = {
X: function(e){
if(NTUserAgent.type==1){
return e.x;
}else if(NTUserAgent.type==4){
return e.offsetX;
}else if(NTUserAgent.type==3){
return e.offsetX - Un.S(e.target,"left");
}else{
return e.target.x ? e.layerX - e.target.x : e.layerX;
}
},
Y: function(e){
if(NTUserAgent.type==1){
return e.y;
}else if(NTUserAgent.type==4){
return e.offsetY;
}else if(NTUserAgent.type==3){
return e.offsetY - Un.S(e.target,"top");
}else{
return e.target.y ? e.layerY - e.target.y : e.layerY;
}
},
copy: function(a){
var Fx = document.createElement(a.tagName);
a.parentNode.appendChild(Fx);
for(var i in a.style){
try{Fx.style[i] = a.style[i];}catch(e){}
}
var l = a.childNodes.length;
for(var i=0; i<l; i++){
var copyObject = this.copy(a.childNodes[i]);
Fx.appendChild(copyObject);
}
if(a.innerHTML) Fx.innerHTML = a.innerHTML;
return Fx;
},
W: function(a){return a.offsetWidth;},
H: function(a){return a.offsetHeight;}
}
Un.Object.Util = {
createPng: function(url,b){
return Rx(url,b);
},
setAlpha: function(a,b){
Hd(a,b);
},
removeElement: function(a){
Qa(a);
An(a);
},
windowSize: function(){
var Fu, Jd;
if (window.innerHeight && window.scrollMaxY) { 
Fu = document.body.scrollWidth;
Jd = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ 
Fu = document.body.scrollWidth;
Jd = document.body.scrollHeight;
} else { 
Fu = document.body.offsetWidth;
Jd = document.body.offsetHeight;
}
var Gk, Zr, $Da$, $Uv$;
if (self.innerHeight) { 
Gk = self.innerWidth;
Zr = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { 
Gk = document.documentElement.clientWidth;
Zr = document.documentElement.clientHeight;
} else if (document.body) { 
Gk = document.body.clientWidth;
Zr = document.body.clientHeight;
}
if(Jd < Zr){
Uv = Zr;
} else { 
Uv = Jd;
}
if(Fu < Gk){ 
Da = Gk;
} else {
Da = Fu;
}
return {windowWidth:Gk, windowHeight:Zr, pageWidth:Da, pageHeight:Uv};
},
scroll: function(){
if(NTUserAgent.type==1){
return document.body.scrollTop
}else{
return pageYOffset;
}
}
}
Un.Object.DragDrop = Class.create();
Un.Object.DragDrop.prototype = Object.extend(new Un.Object, {
initialize: function(a,b){
this.Tm = a;
this.Tm.style.position="absolute";
this.Hn = (b.trigger || this.Tm);
this.minPos = new Object, this.maxPos = new Object;
if(b && b.area){
this.minPos.x = b.area[0];
this.minPos.y = b.area[1];
this.maxPos.x = b.area[2];
this.maxPos.y = b.area[3];
}
this.Jp = b && b.clone;
var Kt = this.Hn.setCapture?this.Hn:window;
this.Xb = {x:0, y:0};
NTEvent.add(this.Hn, "mousedown", this.startDrag.bind(this));
NTEvent.add(Kt, "mouseup",this.stopDrag.bind(this));
NTEvent.add(Kt, "mousemove", this.move.bind(this));
this.Ug = (b.ondrag || function(){});
this.Jf = (b.onmove || function(){});
this.Af = (b.ondrop || function(){});
},
addEvent: function(dom,event,func){
NTEvent.add(dom, event, func);
},
startDrag: function(e){
if((e.button!=0 && e.button!=1)||e.target!=this.Hn){
Un.C(e);
return false;
}
if(this.Hn.setCapture) this.Pz = this.Hn.setCapture();
this.xR ={x:(e.clientX - this.X(e)), y:(e.clientY - this.Y(e))};
this.Fe ={x:Un.S(this.Tm, "left"), y:NTAgis.S(this.Tm, "top")};
this.Qv ={x:this.X(e), y:this.Y(e)};
this.Bt = true;
this.Xb = {x:0, y:0};
this.Hn.style.cursor = "move";
Un.C(e);
if(this.Jp){
this.Fz = this.copy(this.Tm);
this.Fz.style.zIndex=this.Tm.style.zIndex-1;
Hd(this.Tm, "-50");
}
this.Ug(this.Fe);
},
move: function(e){
var Qb = this.Tm.style;
if(!this.Bt){
NTAgis.C(e);
return;
}
var x,y;
x=e.clientX + this.Fe.x - this.Qv.x - this.xR.x;
y=e.clientY + this.Fe.y - this.Qv.y - this.xR.y;
if(this.minPos.x >= x){
Qb.left = Un.P(this.minPos.x);
this.Xb.x = this.minPos.x-this.Fe.x;
}else if(this.maxPos.x < x){
Qb.left = Un.P(this.maxPos.x);
this.Xb.x = this.maxPos.x-this.Fe.x;
}else{
Qb.left = Un.P(x);
this.Xb.x = x-this.Fe.x;
}
if(this.minPos.y > y){
Qb.top = Un.P(this.minPos.y);
this.Xb.y = this.minPos.y-this.Fe.y;
}else if(this.maxPos.y < y){
Qb.top = Un.P(this.maxPos.y);
this.Xb.y = this.maxPos.y-this.Fe.y;
}else{
Qb.top = Un.P(y);
this.Xb.y = y-this.Fe.y;
}
this.Jf({pos:{x:x,y:y}, moved:this.Xb});
},
stopDrag: function(e){
if(e.button!=0&&e.button!=1||this.Bt==false){
Un.C(e);
return false;
}
this.Qv = null;
this.Bt = false;
if(this.Hn.releaseCapture)this.Hn.releaseCapture(this.Pz);
if(this.Fz){
An(this.Fz);
Hd(this.Tm, "+50");
}
if(this.Xb.x == 0 && this.Xb.y == 0){
return false;
}
this.Hn.style.cursor = "default";
this.Fe = {x:Un.S(this.Hn,"left"),y:Un.S(this.Hn, "top")};
this.Af({x:Un.S(this.Tm, "left"), y:NTAgis.S(this.Tm, "top")});
return {x:-this.Xb.x,y:-this.Xb.y};
}
});
Un.Object.Button = Class.create();
Un.Object.Button.prototype = Object.extend(new Un.Object,{
initialize: function(a,b){
this.Tm = a;
if(b && b.image){
this.Ik = b.image;
this.Tm = Rx(this.Ik, {src: this.Tm, width: this.Tm.offsetWidth, height:this.Tm.offsetHeight});
}
this.Yt = (b.ratio||1.5);
this.Gr = {startx:this.W(a), starty:this.H(a), endx: Math.floor(this.W(a)*this.Yt), endy: Math.floor(this.H(a)*this.Yt), func:this.openAlt.bind(this)};
this.Ov = {endx:this.W(a), endy:this.H(a)};
if(b && b.alt){
this.alt = document.createElement("div");
this.alt.innerHTML = b.alt;
this.alt.style.position = "absolute";
this.alt.style.zIndex = 4000;
this.alt.style.fontSize="75%";
this.alt.style.top = Un.P(this.Tm.offsetTop + Math.floor(this.H(a)*this.Yt));
if(this.Tm.tagName=='IMG'){
this.alt.style.left = Un.P(this.Tm.parentNode.offsetLeft);
}else{
this.alt.style.left = Un.P(this.Tm.offsetLeft);
}
this.alt.style.border = "1px #AAA solid";
this.alt.style.backgroundColor="#EEE";
this.alt.style.padding = "2px";
this.alt.style.display = "none";
if(this.Tm.tagName=='IMG'){
this.Tm.parentNode.parentNode.appendChild(this.alt);
}else{
this.Tm.parentNode.appendChild(this.alt);
}
}
this.Ex = new Un.Resizer(this.Tm,{interval:-1});
if(b && b.click) this.Wv = b.click;
NTEvent.add(this.Tm, "mouseover", this.scaleup.bind(this));
NTEvent.add(this.Tm, "mouseout" , this.scaledown.bind(this));
NTEvent.add(this.Tm, "click", this.click.bind(this));
},
scaleup: function(e){
e.target.style.cursor="pointer";
this.Ex.setOption(this.Gr);
this.Ex.run();
},
openAlt: function(){
if(this.alt) this.alt.style.display = "block";
},
scaledown: function(e){
e.target.style.cursor="default";
if(this.alt) this.alt.style.display = "none";
this.Ex.setOption(this.Ov);
this.Ex.run();
},
click: function(e){
(this.Wv || Un.emptyFunction)();
}
});
Kd('NTAgis', Un);
Ut(Un.Resizer);
Ut(Un.Mover);
Ut(Un.Transparencer);
})();
