1/////////////////////////////////////////////////////////////////////////////////////////////////////////////
2//
3//  ALTTXT V1.2
4//  BY: BRIAN GOSSELIN OF SCRIPTASYLUM.COM
5//  ADDED FADING EFFECT FOR IE4+ AND NS6+ ONLY AND OPTIMIZED THE CODE A BIT.
6//  SCRIPT FEATURED ON DYNAMIC DRIVE (http://www.dynamicdrive.com)
7
8
9var dofade=true;     // ENABLES FADE-IN EFFECT FOR IE4+ AND NS6 ONLY
10var center=true;     // 將漸出說明欄出現在滑鼠中間(true), 否則出現在滑鼠右邊(false)
11var centertext=false; // 說明文字以中間對準排列(true),否則文字靠左排列(false)
12
13
14////////////////////////////// 以下無需修改 //////////////////////////////////////
15
16var NS4 = (navigator.appName.indexOf("Netscape")>=0 && !document.getElementById)? true : false;
17var IE4 = (document.all && !document.getElementById)? true : false;
18var IE5 = (document.getElementById && document.all)? true : false;
19var NS6 = (document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? true: false;
20var W3C = (document.getElementById)? true : false;
21var w_y, w_x, navtxt, boxheight, boxwidth;
22var ishover=false;
23var isloaded=false;
24var ieop=0;
25var op_id=0;
26
27function getwindowdims(){
28w_y=(NS4||NS6||W3C)? window.innerHeight : (IE5||IE4)? document.body.clientHeight : 0;
29w_x=(NS4||NS6||W3C)? window.innerWidth : (IE5||IE4)? document.body.clientWidth : 0;
30}
31
32function getboxwidth(){
33if(NS4)boxwidth=(navtxt.document.width)? navtxt.document.width : navtxt.clip.width;
34if(IE5||IE4)boxwidth=(navtxt.style.pixelWidth)? navtxt.style.pixelWidth : navtxt.offsetWidth;
35if(NS6)boxwidth=(navtxt.style.width)? parseInt(navtxt.style.width) : parseInt(navtxt.offsetWidth);
36if(W3C)boxwidth=(navtxt.style.width)? parseInt(navtxt.style.width) : parseInt(navtxt.offsetWidth);
37}
38
39function getboxheight(){
40if(NS4)boxheight=(navtxt.document.height)? navtxt.document.height : navtxt.clip.height;
41if(IE4||IE5)boxheight=(navtxt.style.pixelHeight)? navtxt.style.pixelHeight : navtxt.offsetHeight;
42if(NS6)boxheight=parseInt(navtxt.offsetHeight);
43}
44
45function movenavtxt(x,y){
46if(NS4)navtxt.moveTo(x,y);
47if(W3C||IE4){
48navtxt.style.left=x+'px';
49navtxt.style.top=y+'px';
50}}
51
52function getpagescrolly(){
53if(NS4||NS6||W3C)return window.pageYOffset;
54if(IE5||IE4)return document.body.scrollTop;
55}
56
57function getpagescrollx(){
58if(NS4||NS6||W3C)return window.pageXOffset;
59if(IE5||IE4)return document.body.scrollLeft;
60}
61
62function writeindiv(text){
63if(NS4){
64navtxt.document.open();
65navtxt.document.write(text);
66navtxt.document.close();
67}
68if(W3C||IE4)navtxt.innerHTML=text;
69}
70
71//**** END UTILITY FUNCTIONS ****//
72
73function writetxt(text){
74if(isloaded){
75	if(text!=0){
76	ishover=true;
77	if(NS4)text='<div class="navtext">'+((centertext)?'<center>':'')+text+((centertext)?'</center>':'')+'</div>';
78	writeindiv(text);
79	getboxheight();
80		if((W3C || IE4) && dofade){
81			ieop=0;
82			incropacity();
83		}
84	}
85	else{
86	if(NS4)navtxt.visibility="hide";
87	if(IE4||W3C){
88		if(dofade)clearTimeout(op_id);
89		navtxt.style.visibility="hidden";
90	}
91	writeindiv('');
92	ishover=false;
93
94	}
95}
96}
97
98function incropacity(){
99if(ieop<=100){
100ieop+=10;
101if(IE4 || IE5)navtxt.style.filter="alpha(opacity="+ieop+")";
102if(NS6)navtxt.style.MozOpacity=ieop/100;
103op_id=setTimeout('incropacity()', 50);
104}}
105
106function moveobj(evt){
107if(isloaded && ishover){
108margin=(IE4||IE5)? 1 : 23;
109if(NS6)if(document.height+27-window.innerHeight<0)margin=15;
110if(NS4)if(document.height-window.innerHeight<0)margin=10;
111mx=(NS4||NS6)? evt.pageX : (IE5||IE4)? event.clientX : 0;
112my=(NS4||NS6)? evt.pageY : (IE5||IE4)? event.clientY : 0;
113if (NS4){
114	mx=evt.pageX;
115	my=evt.pageY;
116}
117else if (NS6){
118	mx=evt.clientX;
119	my=evt.clientY;
120}
121else if (IE5){
122	mx=event.clientX;
123	my=event.clientY;
124}
125else if (IE4){
126	mx=0;
127	my=0;
128}
129else if (navigator.appName.indexOf("Opera")>=0){ //Lock add 2009.07.02 for Opera;
130	mx=evt.clientX;
131	my=evt.clientY;
132}
133
134
135if(NS4){
136	mx-=getpagescrollx();
137	my-=getpagescrolly();
138}
139xoff=(center)? mx-boxwidth/2 : mx+5;
140yoff=(my+boxheight+10-getpagescrolly()+margin>=w_y)? -15-boxheight: 10; //10px lock modified.
141
142movenavtxt( Math.min(w_x-boxwidth-margin , Math.max(2,xoff))+getpagescrollx() , my+yoff+getpagescrolly());
143	if(NS4)navtxt.visibility="show";
144	if(W3C||IE4){
145		navtxt.style.visibility="visible";
146	}
147}
148}
149
150if(NS4)document.captureEvents(Event.MOUSEMOVE);
151document.onmousemove=moveobj;
152
153function load_alttxt_enviroment(){
154  navtxt=(NS4)? document.layers['navtxt'] : (IE4)? document.all['navtxt'] : (W3C)? document.getElementById('navtxt') : null;
155  getboxwidth();
156  getboxheight();
157  getwindowdims();
158  isloaded=true;
159  if((W3C || IE4) && centertext)navtxt.style.textAlign="center";
160  if(W3C)navtxt.style.padding='4px';
161  if(IE4 || IE5 && dofade)navtxt.style.filter="alpha(opacity=0)";
162}
163
164window.onload=function(){
165		load_alttxt_enviroment();
166}
167window.onresize=getwindowdims;
168
169
170