jQuery(document).ready(function(){
	
//--------------------------------------------------------------------------------------------
//Page scroll functions
//-------------------------------------------------------------------------------------------- 
jQuery.localScroll({duration:800});
//--------------------------------------------------------------------------------------------
//Portfolio hover functions
//-------------------------------------------------------------------------------------------- 
	jQuery("#work 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/esr/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'	:	'elastic',
		'transitionOut'	:	'fade',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayColor' : '#fff',
		'overlayOpacity' : '0.8',
		'padding' : 10,
		'showCloseButton'	: true,
		'titlePosition' 		: 'outside',
		'titleFormat'		: formatTitle

	});
	
	jQuery("a.visit").fancybox({
		'transitionIn'	:	'fade',
		'transitionOut'	:	'fade',
		'speedIn'		:	200, 
		'speedOut'		:	200, 
	'width'				: '95%',
		'height'			: '85%',
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titleShow' : false,
		'type'				: 'iframe',
		'showCloseButton'	: true

	});
//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'	: true,
			'titleShow' : 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,
			'width'		: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),
			'type'			: 'swf',
			'showCloseButton'	: true,
				'titleShow' : 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/esr/_j/fancybox/closelabel.gif" style="display:none;" /></a></span>' + (title && title.length ? '<b>' + title + '</b>' : '' ) + '</div>';
	}

}); //end d



