var mxpos = 0;
var mypos = 0;

var b_title;
var b_studio;
var b_movie_size;
var b_play_time;
var b_actresses;
var b_actors;
var b_url_download;
var b_url_information;

function getMousePos(e) {
	if (document.body) {
		var evnt = e;
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;

		if (document.documentElement.scrollTop) {
			var scrollT = document.documentElement.scrollTop;
		} else {
			var scrollT = document.body.scrollTop;
		}
		mxpos = e.clientX;
		mypos = e.clientY+scrollT;
	}
}
document.onmousemove = getMousePos;

/* bubbles */
var pp = null; // active popup

var hidetimer = null;
var showtimer = null;

function bubble_over(el, title, studio, movie_size, play_time, actresses, actors, url_download, url_information) {
	b_title = title;
	b_studio = studio;
	b_movie_size = movie_size;
	b_play_time = play_time;
	b_actresses = actresses;
	b_actors = actors;
	b_url_download = url_download;
	b_url_information = url_information;

	clearTimeout(showtimer);
	showtimer = window.setTimeout(function () { bubble_show(el); }, 150);
}

function bubble_on() {
    clearTimeout(showtimer);
    clearTimeout(hidetimer);
}

function bubble_out(el) {
	b_title = b_studio = b_movie_size = b_play_time = b_actresses = b_actors = b_url_download = b_url_information = '';
	clearTimeout(showtimer);
	if (pp != null)
		hidetimer = window.setTimeout(function() { bubble_hide(); }, 150);
}

function bubble_show(el) {
	var app = null;
	var im = null;
	var d = el.getElementsByTagName('span');
	var i = 0;
	var id = 0;
	var input;

	var s = "";

	while (i<d.length) { 
		if (d.item(i).className && 
			(d.item(i).className == "popup off" || d.item(i).className == "kregion off" ) ) {
			app = d.item(i);
		} else
		if (d.item(i).className && d.item(i).className == "img") {
			im = d.item(i)
		}
		i++; 
	}

	if (app != null) {
		if (pp != null && pp != app) { b_hide(); }

		if (pp == null || app != pp) {
			app.style.left = (mxpos - 20) + "px";
			app.style.top = (mypos + 10) + "px";
		}
		app.onmouseover = function() {
			clearTimeout(hidetimer);
		}
		app.onmouseout = function() {
			hidetimer = window.setTimeout(function() { bubble_hide(); }, 150);
		}
		app.style.visibility='visible';
		pp=app;
	}
	
	input = '<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" style=\"FONT-SIZE: 10px; VERTICAL-ALIGN: top; COLOR: #5f0113; FONT-FAMILY: Tahoma; line-height: 12px;\">';
	input += '<tr><td colspan=\"2\" align=\"center\" style=\"background-image: url(../../img/bg_title.gif); background-repeat: repeat-x; font-weight: bold; font-family: Verdana; font-size: 12px;color: #6F1C08; \">';
	input += b_title;
	input +='</td></tr>';
	if(b_studio !='')
		{
		input +='<tr bgcolor=\"#FBF2E9\"><td>Studio:</td>';
		input +='<td>'+b_studio+'</td></tr>';
		}
	if(b_movie_size !='')
		{
		input +='<tr bgcolor=\"#FBF2E9\"><td>Movie&nbsp;Size:</td>';
		input +='<td>'+b_movie_size+' MB</td></tr>';
		}
	if(b_play_time !='')
		{
		input +='<tr bgcolor=\"#FBF2E9\"><td>Play&nbsp;Time:</td>';
		input +='<td>'+b_play_time+'</td></tr>';
		}
	if(b_actresses !='')
		{
		input +='<tr bgcolor=\"#FBF2E9\"><td valign=\"top\">Actresses:</td>';
		input +='<td valign=\"top\">'+b_actresses+'</td></tr>';
		}
	if(b_actors !='')
		{
		input +='<tr bgcolor=\"#FBF2E9\"><td valign=\"top\">Actors:</td>';
		input +='<td valign=\"top\">'+b_actors+'</td></tr>';
		}
		
		input +='<tr bgcolor=\"#FBF2E9\"><td colspan=\"2\" style=\"border-bottom: 1px solid #FFFFFF;\"><img src=\"../../img/1x1.gif\" width=\"2\" height=\"2\" border=\"0\"></td></tr>';
		
	if(b_url_download !='')
		{
		input +='<tr><td align=\"right\" style=\"padding-top: 16px;\"><img src=\"../../img/download2.gif\" width=\"20\" height=\"20\" border=\"0\"></td>';
		input +='<td style=\"padding-top: 16px;\"><a href=\"'+b_url_download+'\" class=\"movie\">DOWNLOAD</a></td></tr>';
		}
		input +='<tr><td align=\"right\"><img src=\"../../img/info.gif\" width=\"20\" height=\"20\" border=\"0\"></td>';
		input +='<td><a href=\"'+b_url_information+'\" class=\"movie\">INFORMATION</a></td></tr>';
	input += '</table>';
	
	
	app.innerHTML = input;
	return true;
}

function bubble_hide() {
	if (pp != null) {
		pp.style.visibility = "hidden";
		pp = null;
	}
}


