var what
var delay = 1 											// speed of growing low = faster, high = slower
var pixels = 80											// pixels to grow
var pixelsShrink = 20								// pixels to shrink
var offset_X = 10   								  // distance of popup from mouse (neg = left, pos = right)
var offset_Y = 10    							  // distance of popup from mouse (neg = above, pos = below)
var startDelay = 0  								// delay to wait on mouseover
var screenX = screen.width 					// The width 0f the screen
var screenY = screen.availHeight 					// The height 0f the screen
var curDelay = 950
//alert (screenY)
function grow(divId,text, fHeight){
	curDelay ++;
	if ((what == "grow") && (curDelay > startDelay)) {
		var change = false
		theheight=document.getElementById(divId).offsetHeight;
		if(theheight<fHeight){
			if (fHeight-theheight > pixels){
				document.getElementById(divId).style.height=theheight+pixels+'px';
				document.getElementById(divId).innerHTML = unescape(text)
			}
			else {
				document.getElementById(divId).style.height= fHeight + 'px';
				divTop = document.getElementById(divId).style.top
				divTop=divTop.replace(/px/g," ")
				//alert(screenY - divTop - fHeight)
				if (fHeight > screenY - divTop - 130) { 
					document.getElementById(divId).style.top = screenY - fHeight - 160 + 'px'
				}
				//alert(document.getElementById(divId).style.top)
				curDelay = 0
			}
		}
	}
}
function shrink(divId){
	if (what == "shrink"){
		theheight=document.getElementById(divId).offsetHeight;
		if (theheight >= pixels){
			document.getElementById(divId).style.height = theheight - pixelsShrink +'px';
		}
		else {
			document.getElementById(divId).style.height = "0px"
			document.getElementById(divId).style.left = "-100px"
			document.getElementById(divId).style.visibility = "hidden"
		}
	}
}
function startGr(divId){
	
	if (document.getElementById(divId).style.visibility != "visible") {
		what = "grow"
		shrinkAll()
		text = escape(document.getElementById(divId).innerHTML)
		fHeight = document.getElementById(divId).offsetHeight
		
		fWidth	= document.getElementById(divId).offsetWidth
		if (fWidth + mouseX + offset_X > screenX  ){
			document.getElementById(divId).style.left = screenX - fWidth - 50 +'px'
			//alert("wrong");
			//alert(fWidth + mouseX + offset_X);
		}
		else {
			document.getElementById(divId).style.left = mouseX +  offset_X +'px'
			//alert(fWidth + mouseX + offset_X);
		}
		orMouseY = mouseY + offset_Y
		//document.getElementById(divId).style.left = mouseX +  offset_X +'px'
		document.getElementById(divId).style.top = mouseY + offset_Y +'px'
		document.getElementById(divId).innerHTML = ""
		document.getElementById(divId).style.height = "0px"
		document.getElementById(divId).style.visibility = "visible"
		growInt = setInterval("grow('"+divId+"','" + text+ "'," + fHeight+")",delay);
	}
	else {
		startSh(divId)
	}
}
function startSh(divId){
	what = "shrink"
	shrinkInt = setInterval("shrink('"+divId+"')",delay);
}

function shrinkAll(){
	var num = document.getElementsByTagName('div').length;
	for (i=0;i<=num;i++){
		var curDiv_id = "song_" + i 
  	if (document.getElementById(curDiv_id)){
  		document.getElementById(curDiv_id).style.visibility = "hidden"
  	}
  }  
}

var mouseX, mouseY;

function getMousePos(e){
	if (!e)
		var e = window.event||window.Event;
	
	if('undefined'!=typeof e.pageX){
		mouseX = e.pageX;
		mouseY = e.pageY;
	} else {
		mouseX = e.clientX + document.body.scrollLeft;
		mouseY = e.clientY + document.body.scrollTop;
	}
}

// You need to tell Mozilla to start listening:

if(window.Event && document.captureEvents) {
 	document.captureEvents(Event.MOUSEMOVE);
}
// Then assign the mouse handler

document.onmousemove = getMousePos;

