// Custom fonts
Cufon.replace('#nav li A', {hover: true});
Cufon.replace('.panel h2');
Cufon.replace('#nav li A.activeLink', {
	color: '#c3ea24'
});

var find_in_array = function(str, arr)
{
	var pos = -1;
	for (var i=0; i < arr.length; i++) {
		if(arr[i] == str)
		{
			return i;			
		}
	};
	return pos;
}


var init_contact_form = function()
{
	$('#form-app_contact_form').live('submit', function(e)
	{
		var frm = $(this);
		e.preventDefault();
		$.ajax({
			type: 'POST',
			url: get_url() + 'blocks_contact/view',
			data: $(this).serialize(),
			success: function(resp)
			{
				frm.replaceWith(resp);
				var err_el = $('#form_result');	
				if (err_el) 
				{
					err_el.slideDown();
					err_el.css('display', 'block');
				}
			}
		});
	});
}


// Remove divider from last li
$(document).ready(function() {
	
	$('.newsletterSignup input[type=text]').each(function()
	{
		var el = $(this);
		var v = el.val();

		if (v.length > 0) 
		{
			el.bind('focus', function(e)
			{
				if (el.val() == v) 
				{
					el.val('');
				}
			});	
			el.bind('blur', function(e)
			{
				if (el.val().length == 0) 
				{
					el.val(v);
				}
			});			
		}
	});
	
	if ($('#form-app_contact_form').size() > 0) 
	{
		init_contact_form();
	};
	
	$("#nav ul li:last-child").addClass("last");
});

// Fading Banner -->
$(document).ready(function() {
	$('#bannerPhotos').cycle({
	fx: 'shuffle',
	delay: 2800
	/* speed: 1300,
	timeout: 3200 */
	})
});


/* Panel sliders */
$(document).ready(function()
{
	$('.slide').hide();	
	$('.panel').hover(function() {
		$(this).children('.slide').stop(true, true).fadeTo("fast", 1);
;
	}, function() {
		$(this).children('.slide').stop(true, true).fadeTo("slow", 0);
	});
});

// Make a nice striped effect on the table			
$(document).ready(function() {
	// Make a nice striped effect on the table
	$("#content table tbody tr:nth-child(odd)").addClass("color2");
});

/* Tooltips */
$(document).ready(function(){
	if ($(".item A").size() > 0) 
	{
		$(".item A").tipTip();
	};
	
});

/* Hover zoom icon */
$(document).ready(function()
{
	$('.zoomHover').css('display','none');
	   $('.photoGallery li, .item').hover(function() {
		  $('.zoomHover',this).stop(true, true).fadeTo("fast", 0.8);
		  }, function() { $('.zoomHover').fadeOut(500);
	});
}); 

