$(function() {
  $('.nyroModal').nyroModal();
});

var photoArray = new Array("1.jpg","2.jpg","3.jpg","header.jpg");
var currentPhoto = 0;
var divElementMain;
var divElementLeft;
var divElementRight;


/* HEADERPHOTO */
function setPhoto()
{
	divElementMain = document.getElementById('headerPhoto');
	
	currentPhoto = Math.floor( Math.random() * photoArray.length );
	
	divElementMain.style.backgroundImage = "url('../photoAlbumHeader/" + photoArray[currentPhoto] + "')";
}

function showPhoto(direction)
{	
	if (direction == -1)
	{
		if ((currentPhoto - 1) < 0)
			currentPhoto = ( photoArray.length - 1 );
		else
			currentPhoto -= 1;
			
		divElementMain.style.backgroundImage = "url('../photoAlbumHeader/" + photoArray[currentPhoto] + "')";	
	}		
	else if (direction == 1)
	{
		if((currentPhoto + 1) >= photoArray.length)
			currentPhoto = 0;
		else
			currentPhoto += 1;
			
		divElementMain.style.backgroundImage = "url('../photoAlbumHeader/" + photoArray[currentPhoto] + "')";		
	}
}

/* STICKY STICKY MENUBAR! */
var _pos;
var _height = 0;
var _el = document.getElementById('menuBar');
var _topValue = 0;

// calculate _el y-position in pixels
_height = getPosition(_el);

function SetMenuBar()
{
  if (navigator.appName == "Microsoft Internet Explorer")
    _pos = document.body.scrollTop;
  else
    _pos = window.pageYOffset;   

  // set _el style
  if( _pos >= (_height+10))
  {
    _el.style.position = "fixed";
    _el.style.top = "-10px";
  }
  else
  {
    _el.style.position = "";
    _el.style.top = "";
  }
}
function getPosition(_obj)
{  
  while(_obj)
  {
    _topValue += _obj.offsetTop;
    _obj = _obj.offsetParent;
  }  
  return _topValue;
}
/*	ACTIONS	*/
window.onscroll = SetMenuBar;
window.onload = setPhoto;
