/**
*
* Animation Gateway Interface Script
* @auther Masakazu Yoshida
* @version 1.0.0
* @since 1 Nov 2006
* @mail tropical_garpike@yahoo.co.jp
*
**/
(function(){
function Rr(a, b){
window[a] = b;
}
function Ap(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 Im(a){
var Sb = a.childNodes.length;
for(var i=Sb; i>=0; i--){
var Sb = 0;
try{
Hl = a.childNodes[i].childNodes['length'];
if(Hl> 0){
Im(a.childNodes[i]);
}
a.removeChild(a.childNodes[i]);
}catch(e){
continue;
}
}
}
Ke= function(a,b){
var Ed = a.style;
if(new String(b).indexOf("+")==0 || new String(b).indexOf("-")==0){
b = eval("(Ed.MozOpacity|1)*100" + b);
}
Ed.MozOpacity = b/100;
Ed.opacity = b/100;
Ed.filter='progid:DXImageTransform.Microsoft.alpha(opacity='+b+')';
}
Vh = 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;
}
Yh = 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 = Vh(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;
}
var Sv=0;
function Ro(a){
a.prototype.setTimeout=function(timeoutHandler,elapseTime){
var Ef="tempVar"+Sv;
Sv++;
eval(Ef+" = this;");
var Vd=timeoutHandler.replace(/\\/g,"\\\\").replace(/\"/g,'\\"');
return window.setTimeout(Ef+'.Cu("'+Vd+'");'+Ef+" = null;",elapseTime);
};
a.prototype.Cu=function(Kn){
eval(Kn);
};
}
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 Ee = {
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();
}
}
}
}
Ee.Resizer = Class.create();
Ee.Resizer.prototype = {
initialize: function(a,b){
this.Tw = a;
this.setOption(b);
this.As = null;
if(this.So >=0)this.setTimeout("this.run()",this.So);
},
setOption: function(b){
if(this.As) this.stop();
var Ed = this.Tw.style;
if(b.endx)this.hV = Math.round(b.endx);
if(b.endy)this.Fg = Math.round(b.endy);
if(b.startx) Ed.width = Ee.P(b.startx);
if(b.starty) Ed.height = Ee.P(b.starty);
this.Dg = (b.func||Ee.emptyFunction);
this.So = (b.interval||0);
this.Zs = Math.floor(10/(b.speed||2)/((NTUserAgent.type==4 || NTUserAgent.type==2)?1.5:1.5));
},
run:function(){
var Ed = this.Tw.style;
Ed.cursor="default";
var x1 = new Number(Ee.S(this.Tw,"width"));
var x2 = new Number(this.hV)-x1;
var x3 = Math.abs(x2/this.Zs)<1? (x2>0)?1:-1 : x2/this.Zs;
var y1 = new Number(Ee.S(this.Tw,"height"));
var y2 = new Number(this.Fg)-y1;
var y3 = Math.abs(y2/this.Zs)<1? (y2>0)?1:-1 : y2/this.Zs;
Ed.width = Ee.P((Math.abs(x2)<=1) ? this.hV : Math.round(x1+x3));
Ed.height = Ee.P((Math.abs(y2) <= 1) ? this.Fg : Math.round(y1+y3));
if(Ee.S(this.Tw,"width")==this.hV && Ee.S(this.Tw,"height")==this.Fg){
this.stop();
return this.Dg();
}
this.As = this.setTimeout("this.run()",10);
},
stop: function(){
clearTimeout(this.As);
this.As=null;
}
}
Ee.Mover = Class.create();
Ee.Mover.prototype = {
initialize: function(a,b){
this.Tw = a;
this.Zm = this.Tw.offsetLeft;
this.Oq = this.Tw.offsetTop;
this.setOption(b);
this.As = null;
if(this.So >=0) this.setTimeout("this.run()",this.So);
},
setOption: function(b){
if(this.As) this.stop();
if(b && b.left != null) this.Zm = b.left;
if(b && b.top != null)this.Oq = b.top;
this.Dg = (b.func||Ee.emptyFunction);
this.So = (b.interval||0);
this.Zs = Math.floor(10/(b.speed||2)/((NTUserAgent.type==4 || NTUserAgent.type==2)?1.5:1.5));
},
run: function(){
var Ed = this.Tw.style;
Ed.cursor="default";
var x1 = new Number(this.Tw.offsetLeft);
var x2 = new Number(this.Zm)-x1;
var x3 = Math.abs(x2/this.Zs)<1? (x2>0)?1:-1 : x2/this.Zs;
var y1 = new Number(this.Tw.offsetTop);
var y2 = new Number(this.Oq)-y1;
var y3 = Math.abs(y2/this.Zs)<1? (y2>0)?1:-1 : y2/this.Zs;
Ed.left = Ee.P((Math.abs(x2)<=1) ? this.Zm : Math.round(x1 + x3));
Ed.top = Ee.P((Math.abs(y2)<=1) ? this.Oq : Math.round(y1 + y3));
if(this.Tw.offsetLeft==this.Zm && this.Tw.offsetTop==this.Oq){
this.stop();
return this.Dg();
}
this.As = this.setTimeout("this.run()",10);
},
stop: function(){
clearTimeout(this.As);
this.As = null;
}
};
Ee.Transparencer = Class.create();
Ee.Transparencer.prototype = {
initialize: function(a,b){
this.Tw=a;
this.setOption(b);
this.As = null;
if(this.So >=0) this.setTimeout("this.run()",this.So);
},
setOption: function(b){
if(this.As) this.stop();
if(!b) return;
this.Hh = (new Number(b.from)||100);
if(b.from!=null){
Ke(this.Tw,b.from);
}
this.Dy = (new Number(b.to)||0);
this.Dg = (b.func||Ee.emptyFunction);
this.So = (b.interval||0);
this.Zs = Math.floor(15/(b.speed||2)/((NTUserAgent.type==4 || NTUserAgent.type==2)?1.5:1.5));
},
run: function(){
this.Tw.style.cursor="default";
this.Hh += (this.Dy - this.Hh)/this.Zs
Ke(this.Tw,this.Hh);
if(Math.abs(this.Dy-this.Hh)<0.5){
Ke(this.Tw,this.Dy);
this.stop();
return this.Dg();
}
this.As = this.setTimeout("this.run()",10);
},
stop: function(){
clearTimeout(this.As);
this.As = null;
}
};
Ee.Object = function(){};
Ee.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 - Ee.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 - Ee.S(e.target,"top");
}else{
return e.target.y ? e.layerY - e.target.y : e.layerY;
}
},
copy: function(a){
var Bq = document.createElement(a.tagName);
a.parentNode.appendChild(Bq);
for(var i in a.style){
try{Bq.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]);
Bq.appendChild(copyObject);
}
if(a.innerHTML) Bq.innerHTML = a.innerHTML;
return Bq;
},
W: function(a){return a.offsetWidth;},
H: function(a){return a.offsetHeight;}
}
Ee.Object.Util = {
createPng: function(url,b){
return Yh(url,b);
},
setAlpha: function(a,b){
Ke(a,b);
},
removeElement: function(a){
Im(a);
Ap(a);
},
windowSize: function(){
var Zj, Cm;
if (window.innerHeight && window.scrollMaxY) { 
Zj = document.body.scrollWidth;
Cm = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ 
Zj = document.body.scrollWidth;
Cm = document.body.scrollHeight;
} else { 
Zj = document.body.offsetWidth;
Cm = document.body.offsetHeight;
}
var Jb, Qy, $Lg$, $mI$;
if (self.innerHeight) { 
Jb = self.innerWidth;
Qy = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { 
Jb = document.documentElement.clientWidth;
Qy = document.documentElement.clientHeight;
} else if (document.body) { 
Jb = document.body.clientWidth;
Qy = document.body.clientHeight;
}
if(Cm < Qy){
mI = Qy;
} else { 
mI = Cm;
}
if(Zj < Jb){ 
Lg = Jb;
} else {
Lg = Zj;
}
return {windowWidth:Jb, windowHeight:Qy, pageWidth:Lg, pageHeight:mI};
},
scroll: function(){
if(NTUserAgent.type==1){
return document.body.scrollTop
}else{
return pageYOffset;
}
}
}
Ee.Object.DragDrop = Class.create();
Ee.Object.DragDrop.prototype = Object.extend(new Ee.Object, {
initialize: function(a,b){
this.Tw = a;
this.Tw.style.position="absolute";
this.Xn = (b.trigger || this.Tw);
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.Fs = b && b.clone;
var rR = this.Xn.setCapture?this.Xn:window;
this.Ni = {x:0, y:0};
NTEvent.add(this.Xn, "mousedown", this.startDrag.bind(this));
NTEvent.add(rR, "mouseup",this.stopDrag.bind(this));
NTEvent.add(rR, "mousemove", this.move.bind(this));
this.Sc = (b.ondrag || function(){});
this.Xw = (b.onmove || function(){});
this.Do = (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.Xn){
Ee.C(e);
return false;
}
if(this.Xn.setCapture) this.Gx = this.Xn.setCapture();
this.Bi ={x:(e.clientX - this.X(e)), y:(e.clientY - this.Y(e))};
this.Ug ={x:Ee.S(this.Tw, "left"), y:NTAgis.S(this.Tw, "top")};
this.Bs ={x:this.X(e), y:this.Y(e)};
this.Bw = true;
this.Ni = {x:0, y:0};
this.Xn.style.cursor = "move";
Ee.C(e);
if(this.Fs){
this.Wc = this.copy(this.Tw);
this.Wc.style.zIndex=this.Tw.style.zIndex-1;
Ke(this.Tw, "-50");
}
this.Sc(this.Ug);
},
move: function(e){
var Ed = this.Tw.style;
if(!this.Bw){
NTAgis.C(e);
return;
}
var x,y;
x=e.clientX + this.Ug.x - this.Bs.x - this.Bi.x;
y=e.clientY + this.Ug.y - this.Bs.y - this.Bi.y;
if(this.minPos.x >= x){
Ed.left = Ee.P(this.minPos.x);
this.Ni.x = this.minPos.x-this.Ug.x;
}else if(this.maxPos.x < x){
Ed.left = Ee.P(this.maxPos.x);
this.Ni.x = this.maxPos.x-this.Ug.x;
}else{
Ed.left = Ee.P(x);
this.Ni.x = x-this.Ug.x;
}
if(this.minPos.y > y){
Ed.top = Ee.P(this.minPos.y);
this.Ni.y = this.minPos.y-this.Ug.y;
}else if(this.maxPos.y < y){
Ed.top = Ee.P(this.maxPos.y);
this.Ni.y = this.maxPos.y-this.Ug.y;
}else{
Ed.top = Ee.P(y);
this.Ni.y = y-this.Ug.y;
}
this.Xw({pos:{x:x,y:y}, moved:this.Ni});
},
stopDrag: function(e){
if(e.button!=0&&e.button!=1||this.Bw==false){
Ee.C(e);
return false;
}
this.Bs = null;
this.Bw = false;
if(this.Xn.releaseCapture)this.Xn.releaseCapture(this.Gx);
if(this.Wc){
Ap(this.Wc);
Ke(this.Tw, "+50");
}
if(this.Ni.x == 0 && this.Ni.y == 0){
return false;
}
this.Xn.style.cursor = "default";
this.Ug = {x:Ee.S(this.Xn,"left"),y:Ee.S(this.Xn, "top")};
this.Do({x:Ee.S(this.Tw, "left"), y:NTAgis.S(this.Tw, "top")});
return {x:-this.Ni.x,y:-this.Ni.y};
}
});
Ee.Object.Button = Class.create();
Ee.Object.Button.prototype = Object.extend(new Ee.Object,{
initialize: function(a,b){
this.Tw = a;
if(b && b.image){
this.Eh = b.image;
this.Tw = Yh(this.Eh, {src: this.Tw, width: this.Tw.offsetWidth, height:this.Tw.offsetHeight});
}
this.Kd = (b.ratio||1.5);
this.Fq = {startx:this.W(a), starty:this.H(a), endx: Math.floor(this.W(a)*this.Kd), endy: Math.floor(this.H(a)*this.Kd), func:this.openAlt.bind(this)};
this.Af = {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 = Ee.P(this.Tw.offsetTop + Math.floor(this.H(a)*this.Kd));
this.alt.style.left = Ee.P(this.Tw.offsetLeft);
this.alt.style.border = "1px #AAA solid";
this.alt.style.backgroundColor="#EEE";
this.alt.style.padding = "2px";
this.alt.style.display = "none";
this.Tw.parentNode.appendChild(this.alt);
}
this.hY = new Ee.Resizer(this.Tw,{interval:-1});
if(b && b.click) this.Jm = b.click;
NTEvent.add(this.Tw, "mouseover", this.scaleup.bind(this));
NTEvent.add(this.Tw, "mouseout" , this.scaledown.bind(this));
NTEvent.add(this.Tw, "click", this.click.bind(this));
},
scaleup: function(e){
e.target.style.cursor="pointer";
this.hY.setOption(this.Fq);
this.hY.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.hY.setOption(this.Af);
this.hY.run();
},
click: function(e){
(this.Jm || Ee.emptyFunction)();
}
});
Rr('NTAgis', Ee);
Ro(Ee.Resizer);
Ro(Ee.Mover);
Ro(Ee.Transparencer);
})();
