
	//File Name		: utilities.js
    //Description	: For common function.
    //Author		:
    //Version		: 1.0
    //Create Date 	: 10/25/2007 (MM/DD/YYYY)
    //Last Modified 	: 
	//Copyright		:

// JavaScript Document
function addToFavorites() { 
	pageName = window.document.title;
	urlAddress = window.location;
	if (window.external) { 
		window.external.AddFavorite(urlAddress,pageName) 
	} 
	else { 
		alert("Sorry! Your browser doesn't support this function."); 
	} 
}



function showbullets()
{
	window.setTimeout("document.getElementById('1').style.visibility='visible'; opacity('1', 0, 100, 550);", 1000);
	window.setTimeout("document.getElementById('2').style.visibility='visible'; opacity('2', 0, 100, 550);", 3000);
	window.setTimeout("document.getElementById('3').style.visibility='visible'; opacity('3', 0, 100, 550);", 5000);
	window.setTimeout("document.getElementById('4').style.visibility='visible'; opacity('4', 0, 100, 550);", 7000);
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}
function enableTooltips(id){
	var links,h;
	if(!document.getElementById || !document.getElementsByTagName) {
		return;
	}
	AddCss();
	
	h=document.createElement("span");
	h.id="btc";
	h.setAttribute("id","btc");
	h.style.position="absolute";
	
	document.getElementsByTagName("body")[0].appendChild(h);
	
	if(id==null) {
		links=document.getElementsByTagName("a");
	}
	else { 
		links=document.getElementById(id).getElementsByTagName("a");
	}
	
	for(var i=0; i<links.length; i++){
		var lk = links[i];
		if (lk.getAttribute("id") == "glossary") { 
			Prepare(links[i]);
		}
	}
}

function Prepare(el){
	var tooltip,t,b,s,l;
	t=el.getAttribute("title");
	if(t==null || t.length==0) {
		t="link:";
	}
	el.removeAttribute("title");
	tooltip=CreateEl("span","tooltip");
	s=CreateEl("span","top");
	s.appendChild(document.createTextNode(t));
	tooltip.appendChild(s);
	b=CreateEl("b","bottom");
	l=el.getAttribute("href");
	if(l.length>30) {
		l=l.substr(0,27)+"...";
	}
	b.appendChild(document.createTextNode(""));
	tooltip.appendChild(b);
	setOpacity(tooltip);
	el.tooltip=tooltip;
	el.onmouseover=showTooltip;
	el.onmouseout=hideTooltip;
	el.onmousemove=Locate;
}

function showTooltip(e){
	document.getElementById("btc").appendChild(this.tooltip);
	Locate(e);
}

function hideTooltip(e){
	var d=document.getElementById("btc");
	if(d.childNodes.length>0) {
		d.removeChild(d.firstChild);
	}
}

function setOpacity(el){
	el.style.filter="alpha(opacity:95)";
	el.style.KHTMLOpacity="0.95";
	el.style.MozOpacity="0.95";
	el.style.opacity="0.95";
}

function CreateEl(t,c){
	var x=document.createElement(t);
	x.className=c;
	x.style.display="block";
	return(x);
}

function AddCss(){
	var l=CreateEl("link");
	l.setAttribute("type","text/css");
	l.setAttribute("rel","stylesheet");
	l.setAttribute("href","/css/bt.css");
	l.setAttribute("media","screen");
	document.getElementsByTagName("head")[0].appendChild(l);
}

