$(function() {

/*
	$('.trigger').qtip({
	  // content: 'test'
	});
*/

	$('.tab-left-mid .content').masonry({
		itemSelector:		'.act_type_div'
	});
	
	$('.tab-left-mid .content').masonry({
		itemSelector:		'.news_item'
	});
	
	var maxheight = 0;
	
	$('.tab-in').each(function() {
		if($(this).height() > maxheight) maxheight = $(this).height();
	});
	
	if(maxheight < 230) maxheight = 230;
	
	$('.tab-in').each(function() {
		$(this).height(maxheight);
	});
	
	
	$('#tab_contact').click(function() {
		$('#tab_details').removeClass('act');
		$('#table_details').hide();
		$('#table_contact').show();
		$(this).addClass('act');
	});
	
	$('#tab_details').click(function() {
		$('#tab_contact').removeClass('act');
		$('#table_details').show();
		$('#table_contact').hide();
		$(this).addClass('act');
	});

	$('#contact-btn').click(function() {
		
		if(	$('#contact-message').val().length< 2 | $('#contact-phone').val().length < 2 | $('#contact-email').val().length < 2) {
				$('#all_fields_dialog').dialog({
					modal: true,
					buttons: {
						Okee: function() {
							$(this).dialog('close');
						}
					}
				});
				return false;
		}
			
		$.ajax({	type:	'POST',
							url: 	'/ajax/contact', 
							data: {	
							name: $('#contact-name').val(),
							message:	$('#contact-message').val(),
							phone: 		$('#contact-phone').val(),
							email: 		$('#contact-email').val(),
							newsletter: $('#contact-newsletter').attr('checked')
					},
								
				success: function(data) {
							$('#contact-return').html(data);
						}
		}); 
	}); 

});

/*
function playVid(obj, yt_id, w)
{
	if(w==undefined) w = 400;
	
	hideYT();
	$('#foto').fadeOut();
	$('img[rel|="'+yt_id+'"]').attr('src', '/img/btn-play-act.png');
	$('#youtube').flash({ swf:'http://www.youtube.com/v/'+yt_id+'?enablejsapi=1&version=3&playerapiid=ytplayer&autoplay=1',height:400,width: w});		
	$("#youtube").show();
}
*/

function playVid(obj, yt_id, w)
{
	if(w==undefined) w = 400;
	
	hideYT();
	$('#foto').fadeOut();
	$('img[rel|="'+yt_id+'"]').attr('src', '/img/btn-play-act.png');

	$('#youtube').html('<iframe class="youtube-player" type="text/html" width="'+w+'" height="400" src="http://www.youtube.com/embed/'+yt_id+'/?&autoplay=1" frameborder="0"></iframe>');
	$("#youtube").show();
	
}
