function close_popup()
{
	if(document.getElementById('popup')!=null)
	{
		document.getElementById('popup').style.display='none';
	}
	else
	{
		this.location.href="http://www.earlnewton.de/index.php";
	}
}
function open_popup(bild,x,y,w,h,key,pfad,liste)
{
	listearr = liste.split("|");
	anz = listearr.length;
	maxkey = anz -1;
	nextkey = key +1;
	if(nextkey > maxkey)
	{
		nextkey = 0;
	}
	
	nextbild = listearr[nextkey];
	teile = nextbild.split("#");
	nextimg = pfad+"/"+ teile[0];
	wnext=teile[1];
	hnext=teile[2];
	
	if(x=='center')
	{
		x=(document.body.offsetWidth-w)/2;
	}
	if(y=='center')
	{
		y=(570-h)/2;
	}


	
	document.getElementById('popup').style.left=x+'px';
	
	document.getElementById('popup').style.top=y+'px';
	document.getElementById('popup').style.height=h+'px';
	document.getElementById('popup').style.width=w+'px';
	document.getElementById('popupbild').innerHTML='<img src="'+bild+'" alt="copyright earl newton - Photography Fashion Glamour Nude Art" onclick="open_popup(\''+nextimg+'\',\'center\',\'center\','+wnext+','+hnext+','+nextkey+',\''+pfad+'\',\''+liste+'\')">';
	document.getElementById('popup').style.display='block';
	xleft=w-17;
	document.getElementById('schliessx').style.left=xleft+'px';
	
}
function showlayer()
{
	document.getElementById('schliessx').style.display='block';
	document.getElementById('clicktipp').style.display='block';
}
function hidelayer()
{
	document.getElementById('schliessx').style.display='none';
	document.getElementById('clicktipp').style.display='none';
}
function openguestbookform()
{
	document.getElementById('guestbookform').style.display='block';
	document.getElementById('newentry').innerHTML='&nbsp;';
}

$(function(){
	//Get our elements for faster access and set overlay width
	var div = $('div.sc_menu'),
		ul = $('ul.sc_menu'),
		ulPadding = 15;

	//Get menu width
	var divWidth = div.width();

	//Remove scrollbars
	div.css({overflow: 'hidden'});

	//Find last image container
	var lastLi = ul.find('li:last-child');

	//When user move mouse over menu
	div.mousemove(function(e){
		//As images are loaded ul width increases,
		//so we recalculate it each time
		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;
		var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
		div.scrollLeft(left);
	});
});
