﻿$(document).ready(function() {

	/****************************************************************************************************************

	View all work functionality

	*/

	$('#work > section > p > a').click(function(event) {

		event.preventDefault();

		$(this).toggleClass('open');

		if ($('#more_work').length == 0) {

			$('#work > section')

				.after(innerShiv('<section id="more_work"><div></div></section>', false));

				//var $holder = $('#more_work div');

			$('#more_work')

				.hide()

				.prepend('<h1>More Work</h1>')

				.slideDown('slow', function() {

					$('#more_work div')

						.css({

							'height': '0',

							'display': 'block'

						})

						.load('/main/work-pull', function() {

							var targHeight = $(this).children('ul').outerHeight() + 'px';

							$(this).animate({

								height: targHeight

							}, 1500, function() {

								$(this).removeAttr('style');

								//alert("ol outerHeight: " + $(this).find('ol').outerHeight() + "px, $this height: " + $(this).outerHeight() + "px");

							});

						});

					/*var $holder = $('#more_work div');

					$holder.css({

						'height': '0',

						'overflow': 'hidden'

					});

					$.get('/main/work-pull/', function(data) {

						$holder

							.html(innerShiv(data, false))

							.animate({

								height: $(this).children('ol').outerHeight() + 'px'

							}, 1500, function() {

								//$(this).removeAttr('style');

								alert("ol outerHeight: " + $(this).children('ol').outerHeight() + "px, $this height: " + $(this).outerHeight() + "px");

							});

						});*/

				});

		} else {

			$('#more_work').slideToggle('slow');

		}

	});

	
	
	/****************************************************************************************************************

	POP IN

	*/
	
	
	$("a.popin").prettyPopin({width: 870, height:600});
});
