// get mouse position
var mousex = 0; // mouse position x
var mousey = 0; // mouse position y
function getmouseposition(e)
{
	var xScrollLeft = 0, xScrollTop = 0;

	if (!e) var e = window.event;
	if (e.pageX || e.pageY)
	{
		mousex = e.pageX;
		mousey = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		// get scroll top and left only if body has been created
		if (document.body)
		{
			xScrollLeft = document.body.scrollLeft;
			xScrollTop = document.body.scrollTop;
		}
		mousex = e.clientX + xScrollLeft;
		mousey = e.clientY + xScrollTop;
	}
}
document.onmousemove = getmouseposition;


// when mouse over a thumbnail
function mouseOverThumb(thumbID, status)
{
	xThumb = document.getElementById(thumbID);
	if (status) xThumb.className = 'si_thumbnail_over';
	else xThumb.className = 'si_thumbnail';
}

// create a cookie
function createCookie(name, value, days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0; i < ca.length; i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name, "", -1);
}

function getSize(xSizeb)
{
	var xSize = 0+'b';

	xSizeb = parseInt(xSizeb);
	xSizekb = xSizeb / 1024;
	xSizemb = xSizekb / 1024;
	xSizegb = xSizemb / 1024;
	xSizetb = xSizegb / 1024;
	xSizepb = xSizetb / 1024;
	if (xSizeb > 1) xSize = Math.round(xSizeb,2)+'b';
	if (xSizekb > 1) xSize = Math.round(xSizekb,2)+'kb';
	if (xSizemb > 1) xSize = Math.round(xSizemb,2)+'mb';
	if (xSizegb > 1) xSize = Math.round(xSizegb,2)+'gb';
	if (xSizetb > 1) xSize = Math.round(xSizetb,2)+'tb';
	if (xSizepb > 1) xSize = Math.round(xSizepb,2)+'pb';
	return xSize;
}


// display quicktip
var showquicktip = '';
function quicktip(suffix_id)
{
		window.status = 'Hold your mouse over the question mark for help';
	icon = document.getElementById('i_qtip_'+suffix_id);
	tip = document.getElementById('qtip_'+suffix_id);

	args = quicktip.arguments; // get arguements

	if (args[1] !== 'hide' && (mousex > (tip.offsetLeft + tip.offsetWidth) || mousex < tip.offsetLeft || mousey > (tip.offsetTop + tip.offsetHeight) || mousey < tip.offsetTop))
	{
		// set up position
		client_x = (document.body.clientWidth + document.body.scrollLeft);
		client_y = (document.body.clientHeight + document.body.scrollTop);
		if ((icon.offsetLeft + icon.offsetWidth + tip.offsetWidth + 2) > client_x)
		{
			tipleft = (client_x - tip.offsetWidth)+'px';
			tiptop = (icon.offsetTop + icon.offsetHeight + 2)+'px';
		}
		else if ((icon.offsetTop + icon.offsetHeight + tip.offsetHeight) > client_y)
		{
			tipleft = (icon.offsetLeft + icon.offsetWidth + 2)+'px';
			tiptop = (client_y - tip.offsetHeight)+'px';
		}
		else
		{
			tipleft = (icon.offsetLeft + icon.offsetWidth + 2)+'px';
			tiptop = icon.offsetTop+'px';
		}

		// set position
		tip.style.top = tiptop;
		tip.style.left = tipleft;

		if (args[1] == 'click') tip.style.visibility = 'visible';
		else showquicktip = setTimeout("tip.style.visibility = 'visible'", 900);
	}
	else
	{
		// hide tip
		clearTimeout(showquicktip);
		tip.style.visibility = 'hidden';
		window.status = '';
	}
}
