﻿
var nowid = "index";
var gnflg = "gn_01";

var spdUp;
var spdDw;
var val;
var static_val;
var swc = true;

if(navigator.userAgent.indexOf("Opera") != -1){
    spdUp = 0.1;
    spdDw = 0.1;
    static_val = 1;
    val = 1;
}else if(navigator.userAgent.indexOf("MSIE") != -1){
    spdUp = 10;
    spdDw = 10;
    static_val = 100;
    val = 100;
}else if(navigator.userAgent.indexOf("Firefox") != -1){
    spdUp = 0.1;
    spdDw = 0.1;
    static_val = 1;
    val = 1;
}else if(navigator.userAgent.indexOf("Netscape") != -1){
    spdUp = 0.1;
    spdDw = 0.1;
    static_val = 1;
    val = 1;
}else if(navigator.userAgent.indexOf("Safari") != -1){
    spdUp = 0.1;
    spdDw = 0.1;
    static_val = 1;
    val = 1;
}else{
    spdUp = 0.1;
    spdDw = 0.1;
    static_val = 1;
    val = 1;
}


function headerOver(id){
    document.getElementById(id).src="images/"+id+"_onm.jpg";
}
function headerOut(id){
    document.getElementById(id).src="images/"+id+"_off.jpg";
    if(id==gnflg){
        document.getElementById(id).src="images/"+gnflg+"_on.jpg";
    }
}

function onc(gn,id){

    for(i=1;i<=6;i++){
        if("gn_0"+i==gn){
            document.getElementById("gn_0"+i).src = "images/"+"gn_0"+i+"_on.jpg"
            gnflg = "gn_0"+i;
        }else{
            document.getElementById("gn_0"+i).src = "images/"+"gn_0"+i+"_off.jpg"
        }
    }

    if(val < 0 && swc){
        setOpacity(nowid,static_val);
//        document.getElementById(nowid).style.opacity = 1;
        document.getElementById(nowid).style.display="none";
        setOpacity(id,0);
//        document.getElementById(id).style.opacity = 0;
        document.getElementById(id).style.display="";
        val = 0;
        swc = false;
        setTimeout("onc('" + gn + "','" + id + "')",50);
    }else if(swc){
       val -= spdDw;
       setOpacity(nowid,val);
//       document.getElementById(nowid).style.opacity = val;
       setTimeout("onc('" + gn + "','" + id + "')",50);
    }else if(val > static_val && !swc){
        setOpacity(id,static_val);
//        document.getElementById(id).style.opacity = 1;
        swc = true;
        val = static_val;
        nowid = id;
        document.getElementById("if_"+id).src="if_"+id+".html";
    }else{
        val += spdUp;
        setOpacity(id,val);
//        document.getElementById(id).style.opacity = val;
        setTimeout("onc('" + gn + "','" + id + "')",20);
    }
}

function setOpacity(id,num) {

    var num;

    if(navigator.userAgent.indexOf("Opera") != -1){
        document.getElementById(id).style.opacity = num;
    }else if(navigator.userAgent.indexOf("MSIE") != -1){
        document.getElementById(id).style.filter = 'alpha(opacity=' + num + ')';
    }else if(navigator.userAgent.indexOf("Firefox") != -1){
        document.getElementById(id).style.opacity = num;
    }else if(navigator.userAgent.indexOf("Netscape") != -1){
        document.getElementById(id).style.opacity = num;
    }else if(navigator.userAgent.indexOf("Safari") != -1){
        document.getElementById(id).style.opacity = num;
    }else{
        document.getElementById(id).style.opacity = num;
    }

}


var w=1
var h=1

if (document.getElementById || document.all)
document.write("<div style='visibility: hidden; position: absolute; z-index: 99;' id='trailimageid'><img src='images/loading.gif' id='ttimg' /></div>")

function gettrailobj()
{
	if (document.getElementById) return document.getElementById("trailimageid").style
	else if (document.all) return document.all.trailimagid.style
}

function truebody()
{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function hidetrail()
{
	document.onmousemove=""
	//document.getElementById('ttimg').src='img/s.gif'
	gettrailobj().visibility="hidden"
	gettrailobj().left=-1000
	gettrailobj().top=0
}


function showtrail(width,height,file)
{
	if(navigator.userAgent.toLowerCase().indexOf('opera') == -1)
	{
		w=width
		h=height
		
		gettrailobj().visibility="visible"
		gettrailobj().width=w+"px"
		gettrailobj().w=w;
		gettrailobj().height=h+"px"
		document.getElementById('ttimg').src=file
		document.onmousemove=followmouse

	}
}


function followmouse(e)
{

	if(navigator.userAgent.toLowerCase().indexOf('opera') == -1)
	{
		
		var xcoord=0
		var ycoord=20

		if (typeof e != "undefined")
		{
			xcoord+=e.pageX
			ycoord+=e.pageY
		}
		else if (typeof window.event !="undefined")
		{
			xcoord+=truebody().scrollLeft+event.clientX
			ycoord+=truebody().scrollTop+event.clientY
		}

		var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
		var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
		//alert(xcoord+w+3+" - "+docwidth+" "+ w +)
		//if (xcoord+w+3>docwidth)
		//xcoord=xcoord-w-(20*2)
		if((docwidth-xcoord)<250) xcoord -=250
		

		if (ycoord-truebody().scrollTop+h>truebody().clientHeight)
		ycoord=ycoord-h-20;
		
		gettrailobj().left = xcoord + "px"
		gettrailobj().top  = ycoord + "px"

	}

}