﻿var ie4=document.all;
var ns6=document.getElementById&&!document.all;

function getposOffset(what, offsettype){
    var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
    var parentEl=what.offsetParent;
    while (parentEl!=null){
        totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
        parentEl=parentEl.offsetParent;
    }
return totaloffset;
}

function showhide(obj, e, visible, hidden, tipwidth){
    if (ie4||ns6)
        dropmenuobj.style.left=dropmenuobj.style.top=-500
    if (tipwidth!=""){
        dropmenuobj.widthobj=dropmenuobj.style
        dropmenuobj.widthobj.width=tipwidth
    }
    if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
        obj.visibility=visible
    else if (e.type=="click")
        obj.visibility=hidden
}

function iecompattest(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge, vertical_offset){
    var edgeoffset=(whichedge=="rightedge")? parseInt("0px")*-1 : parseInt(vertical_offset)*-1
    if (whichedge=="rightedge"){
    var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
        dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
    if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
        edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
    }
    else{
    var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
        dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
    if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
        edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
    }
return edgeoffset
}

function fixedtooltip(menucontents, obj, e, tipwidth, tipTop){
	if(eval(checkwhere(e)) > 600) {
		tipTop = eval(tipTop) * -1;
		tipTop += "px";
		chgcontents =	"<div class='balloon-cslayer'>" +
						"	<div class='balloon'>" +
						"		<table>" +
						"		<tr><td class='tround-l'></td><td class='tround-c'></td><td class='tround-r'></td></tr>" +
						"		<tr>" +
						"			<td class='cround-l'><span><!--bullet--></span></td>" +
						"			<td class='cont-txt'><p>" + menucontents + "</p></td>" +
						"			<td class='cround-r'></td>" +
						"		</tr>" +
						"		<tr><td class='bround-l'></td><td class='bround-c'></td><td class='bround-r'></td></tr>" +
						"		</table>" +
						"	</div>" +
						"</div>";
	} else {
		tipTop = "5px"; 
		chgcontents =	"<div class='balloon-cslayer'>" +
						"	<div class='balloon-type02'>" +
						"		<table>" +
						"		<tr><td class='tround-l'></td><td class='tround-c'></td><td class='tround-r'></td></tr>" +
						"		<tr>" +
						"			<td class='cround-l'><span><!--bullet--></span></td>" +
						"			<td class='cont-txt'><p>" + menucontents + "</p></td>" +
						"			<td class='cround-r'></td>" +
						"		</tr>" +
						"		<tr><td class='bround-l'></td><td class='bround-c'></td><td class='bround-r'></td></tr>" +
						"		</table>" +
						"	</div>" +
						"</div>";
	}
	

    if (window.event) event.cancelBubble=true
    else if (e.stopPropagation) e.stopPropagation()
        clearhidetip()
        dropmenuobj=document.getElementById? document.getElementById("fixedtipdiv") : fixedtipdiv
        dropmenuobj.innerHTML=chgcontents

    if (ie4||ns6){
        showhide(dropmenuobj.style, e, "visible", "hidden", tipwidth)
        dropmenuobj.x=getposOffset(obj, "left")
        dropmenuobj.y=getposOffset(obj, "top")
        dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge", tipTop)+"px"
        dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge", tipTop)+obj.offsetHeight+"px"
    }
}

function hidetip(e){
    if (typeof dropmenuobj!="undefined"){
    if (ie4||ns6)
        dropmenuobj.style.visibility="hidden"
    }
}

function delayhidetip(){
    if (ie4||ns6)
        delayhide=setTimeout("hidetip()", 150)
}

function clearhidetip(){
    if (typeof delayhide!="undefined")
        clearTimeout(delayhide)
}



function checkwhere(e) {
	if (document.layers){
		yCoord = e.y;
	}
	else if (document.all){
		yCoord = event.clientY;
	}
	else if (document.getElementById){
		yCoord = e.clientY;
	}
	return yCoord; 
}
