jQuery(document).ready(function(){
	jQuery(".slider img").css("display", "none");
//--------------------------------------------------------------------------------------------
//Page scroll functions
//-------------------------------------------------------------------------------------------- 
jQuery.localScroll({duration:800});
//--------------------------------------------------------------------------------------------
//Portfolio hover functions
//-------------------------------------------------------------------------------------------- 
	jQuery("#portfolio li.thumb").hover(function() {
			jQuery(this).find('.moreinfo').stop()
					.animate({
									 opacity: '0.95'
									 }, 400);
			} , function() {
			jQuery(this).find('.moreinfo').stop()
					.animate({	
									 opacity: '0'
									 }, 400);
	});
//--------------------------------------------------------------------------------------------
//Input Labels and Validation
//-------------------------------------------------------------------------------------------- 
	jQuery("label.infield").inFieldLabels();
				jQuery("form").validate();	
//--------------------------------------------------------------------------------------------
//Contact Form
//-------------------------------------------------------------------------------------------- 
	jQuery("#contact-form").submit(function(){
				var str = jQuery(this).serialize();
				jQuery.ajax({
				   type: "POST",
				   url: "wp-content/themes/monolith/php/send.php",
				   data: str,
				   success: function(msg)
				   {
						jQuery("#formstatus").ajaxComplete(function(event, request, settings){
							if(msg == 'OK'){ // Message Sent? Show the 'Thank You' message and hide the form
								jQuery("#contact-form").slideUp("fast");
								result = '<div class="formstatusok">Your message has been sent. Thank you!</div>';
							}
							else{
								result = msg;
							}
							jQuery(this).html(result);
						});
					}
				
				 });
				return false;
	});
//--------------------------------------------------------------------------------------------
//Fancybox functions
//-------------------------------------------------------------------------------------------- 
jQuery("a.zoom").fancybox({
		'transitionIn'		:	'fade',
		'transitionOut'		:	'fade',
		'speedIn'			:	200, 
		'speedOut'			:	200, 
		'overlayColor' 		: '#000',
		'overlayOpacity' 	: '0.8',
		'padding' 			: 10,
		'showCloseButton'	: false,
		'titlePosition' 	: 'inside',
		'titleFormat'		: formatTitle

	});
//youtube fancybox
jQuery("a.y_zoom").click(function() {
	jQuery.fancybox({
			'padding'		: 10,
			'autoScale'		: false,
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade',
			'speedIn'		:	200, 
			'speedOut'		:	200, 
			'overlayColor' : '#000',
			'overlayOpacity' : '0.8',
			'title'			: this.title,
			'width'		: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'showCloseButton'	: false,
			'titlePosition' 		: 'inside',
			'titleFormat'		: formatTitle,
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
});

	return false;
});

//vimeo fancybox
jQuery("a.v_zoom").click(function() {
	jQuery.fancybox({
		'padding'			: 10,
		'autoScale'			: false,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'speedIn'			:	200, 
		'speedOut'			:	200, 
		'overlayColor'		: '#000',
		'overlayOpacity'	: '0.8',
		'title'				: this.title,
		'url'				: this.getAttribute('url'),
		'width'				: 680,
		'height'			: 495,
		'href'				: this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),
		'type'				: 'swf',
		'showCloseButton'	: false,
		'titlePosition' 	: 'inside',
		'titleFormat'		: formatTitle,
		'swf': {
			'wmode'				: 'transparent',
			'allowfullscreen'	: 'true'
		}
});

	return false;
});

//custom menu functions for fancybox
function formatTitle(title, currentArray, currentIndex, currentOpts) {
	// return '<div id="title"><span><a href="javascript:;" onclick="jQuery.fancybox.close();"><img src="wp-content/themes/monolith/js/fancybox/closelabel.gif" /></a></span>' + (title && title.length ? '<b>' + title + '</b>' : '' ) + 'Image ' + (currentIndex + 1) + ' of ' + currentArray.length + '</div>';

	var theUrl 		= currentOpts.orig.attr('url');
	var theTitle 	= '';
	
	theTitle += '<div id="title"><span><a href="javascript:;" onclick="jQuery.fancybox.close();"><img src="wp-content/themes/monolith/js/fancybox/closelabel.gif" /></a></span>';
	
	if ( title && title.length )
	{
		theTitle += '<b>' + title + '</b>';
	}
	
	if ( theUrl && theUrl.length )
	{
		theTitle += '<a href="' + theUrl + '" target="_blank">Visit this project</a> - ';
	}
	
	theTitle += 'Work ' + (currentIndex + 1) + ' of ' + currentArray.length;
	
	theTitle += '</div>';
	
	return theTitle;
}

function readUrl()
{
	
}
	
}); //end doc rdy

jQuery(document).ready(function($){
	$('div.moreinfo').each(function(){
		var link = $(this).find('a.zoom');
		if ( link.size() )
		{
			$(this).click(function(e){
				link.click();
				e.preventDefault();
			});
		}
	});
});

