var _path = '/';

function showhide(id)
{

	element = document.getElementById(id).style.display;
	if (element == 'none')
	{
		document.getElementById(id).style.display = 'block';
	}
	else
	{
		document.getElementById(id).style.display = 'none';
	}
}

function addFav(prod_id)
{
	LoadIntoElement( '/users.php?do=addfav&p='+prod_id,'hiddenblock','this is a secret message :)' );
	var imgfav = document.getElementById('addfav_img');
	imgfav.innerHTML = '<a href="#" onclick="removeFav('+prod_id+')" title="Remove Product from Favourites"><img src="/images/products_removefavorite.gif" alt="Remove from Favorites" /></a>';
}

function removeFav(prod_id)
{
	LoadIntoElement( '/users.php?do=removefav&p='+prod_id,'hiddenblock','this is a secret message :)' );
	var imgfav = document.getElementById('addfav_img');
	imgfav.innerHTML = '<a href="#" onclick="addFav('+prod_id+')" title="Add Product Into Favourites"><img src="/images/products_addfavorite.gif" alt="Add into Favorite" /></a>';
}

function sortComments(pid,type,sort)
{
	LoadIntoElement( '/get.comments.php?type='+type+'&pid='+pid+'&sort='+sort,'showcomments','<strong>Sorting</strong>' );
}

function selImage(url,desc,name)
{
	document.getElementById('mainimage').src=url;
	document.getElementById('mainimage_link').target=image;
	document.getElementById('mainimage_link').href=image_link;	
	document.getElementById('mainimage_desc').style.display = 'block';
	document.getElementById('mainimage_desc').innerHTML = '<em>'+desc+'</em>';


	if (name != '')
	{
		document.getElementById('mainimage_user').innerHTML = 'Picture submitted by <a href="/users/'+name+'/">'+name+'</a>';
	}
	else
	{
		document.getElementById('mainimage_user').innerHTml = '';
	}
}

function showTip(e, text, l) {
	initTips();
	if (!e) var e = window.event;
	if (!obj) var obj = (e.target) ? e.target : e.srcElement;
	p_container.innerHTML = text;
	xPos = findPosX(obj) + obj.offsetWidth;
	yPos = findPosY(obj) + obj.offsetHeight + 2;
	if (xPos + p_container.offsetWidth > document.body.clientWidth) xPos = document.body.clientWidth - p_container.offsetWidth - 2;
	p_container.style.left = xPos + 'px';
	p_container.style.top = yPos + 'px';
	p_container.style.visibility = 'visible';
	if (!obj) return;
	obj.onmouseout = destroyTip;
}
function destroyTip(e) {
	if (!e) var e = window.event;
	if (!obj) var obj = (e.target) ? e.target : e.srcElement;
	p_container.style.visibility = 'hidden';
	p_container.innerHTML = '';
	if (!obj) return;
	obj.onmouseout = null;
}
function initTips() {
	p_container = document.createElement('div');
	p_container.className = 'tooltip';
	if (!p_container) return;
	p_container.style.visibility = 'hidden';
	p_container.style.zIndex = '100';
	p_container.style.position = 'absolute';
	document.body.appendChild(p_container);
}


function hlite(what)
{
	what.style.border = '1px solid #E6C7E8';
}

function hno(what)
{
	what.style.border = '1px solid #fff';
}

function go(what)
{
	window.location = what.firstChild.href;
}