/*---------------------------Coordinates---------------------------------------*/
function align()
{
	viewWidth = $(window).width();	
	viewHeight = $(window).height();
}

/*-----------------------------Initialize----------------------------------*/
function initView()
{
	$('.portfolio-preview-image').fadeTo(0, 0.8);	
}

function initScroll()
{
	$('#loading').fadeOut(500, function()
	{
		$('#content').show(0);
		$('#content').animate({ 'margin-top' : 20 }, 1000, function()
		{
				loadHashContent();
		});		
	});
}

/*-----------------------------Portfolio----------------------------------*/
function initContent($index, $id, $parent, $holder, $details)
{
	var $target = $parent;
	var $targetOffset = $($target).offset().top;
	var $num = $holder.find('img').length;
	
	urlHash = '/' + portfolioArray[$index] + '/';
	document.title = 'Philleep Florence - ' + titleArray[$index];
	window.location.hash = urlHash;
	
	if($num == 0)
	{
		$('html, body').animate({scrollTop : $targetOffset}, 600, function(){
			loadContent($parent, $index, $holder, $details, $targetOffset);
		});
	}
	else
	{		
		$('html, body').animate({scrollTop : $targetOffset}, 600);
		$details.slideToggle(800);
	}	
}

function scrollContent($parent)
{
	var $target = $parent;
	var $targetOffset = $($target).offset().top;
	$('html, body').animate({scrollTop : $targetOffset}, 600);
}

function rotateImages($num, $index, $class, $numClass)
{
	if($num > 0)
	{
		if($index < $num - 1)
		{
			$index++;			
		}
		else if($index == $num - 1)
		{
			$index = 0;
		}
		
		$numClass.text($index + 1 + ' - ' + $num);
		var $image = '#' + $($class.get($index)).attr('id');
		var $swipe = $($class.parent().find('.portfolio-swipe'));
		$image = $($image);
		$height = $image.height();
		
		$swipe.css({ 'height' : $height, 'display' : 'block', 'width' : 0, 'margin-left' : 0 });
		
		$swipe.animate({ 'width' : 985 }, 800, 'easeOutExpo', function()
		{
			$class.hide();
			$image.show();
			$swipe.animate({ 'margin-left' : 985, 'width' : 0 }, 800, 'easeOutExpo');
		});		
	}
}

