// Javascript functions

function ViewPic(URL)
{
	var loading = document.getElementById('loading');
	var picture = document.getElementById('pic');
	
	if (document.images)
	{
		loading.innerHTML = 'Loading image... Please wait.';
		
		var image = new Image();
		image.src = URL;
			
		image.onload = function()
		{
			picture.src = URL;
			loading.innerHTML = 'Image ready.';
			
			window.location = '#view';
		}
	}
	else
	{
		return true; // An old browser is beign used.
	}
	return false;
}

function findPosX(object)
{
	var curleft = 0;
	var obj = document.getElementById(object);
	
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
	{
		curleft += obj.x;
	}
	return curleft;
}

function findPosY(object)
{
	var curtop = 0;
	var obj = document.getElementById(object);
	
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
	{
		curtop += obj.y;
	}
	return curtop;
}


	

function PropertyOptions()
{
	var Option = document.getElementById('options').style;
	
	Option.display = (Option.display == 'none' ? 'block' : 'none');
	return false;
}

function PrintProperty(id)
{
	window.open('printproperty.php?id='+ id, 'PrintProperty', 'width=850,left=100,toolbar=yes,scrollbars=yes,resizable=yes');
	return false;
}

function SendToFriend(id)
{
	window.open('sendtofriend.php?id='+ id, 'SendToFriend', 'width=600,height=220,top=300,left=350');
	return false;
}

function Select(field) 
{
	field.focus();
  	field.select();
}

function Picture(url)
{
	window.open('slideshow.php?image='+ url, 'Picture', 'width=700,height=550,top=80,left=250');
	return false;
}