$(document).ready(function() {


	// Example Cufon
	//Cufon.replace('h2', { fontFamily: 'Perpetua' });	

	// Cycle class "cycle"
	$('.cycle').cycle({
		delay: 8000,
		timeout: 8000,
		speed: 1000,
		fx: 'fade'
	});

  	/*  simulate an a tag on product div */
	$('.directory_category').click(function() {
	     window.location=$(this).find("a").attr("href");
	     return false;
	});	
	
	// allows validating 
	$('.new_window').attr('target', '_blank');
	
	/* menu below */
	$("ul.topnav > li a:first-child").hover(function() {
	$(this).parent().find("ul.subnav").slideDown(100).show();
	$(this).parent().hover(function() {
	}, function() {
	$(this).parent().find("ul.subnav").slideUp(300);
	});
	}).hover(function() {
		$(this).addClass("subhover");
	}, function() {
		$(this).removeClass("subhover");
	});
    
	$('.columnize').columnize({
		columns: 4
	})
	
	$('a.lightbox').fancybox({
		'type' 			: 	'image',
		'transitionIn'	:	'fade',
		'transitionOut'	:	'fade',
		'titlePosition' : 	'over'
	});
	
	$(".iframe").fancybox({
		'width'				: '75%',
		'height'			: '90%',
        'autoScale'     	: false,
        'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'				: 'iframe'
	});

	$("#new_record").bind("submit", function() {
	
		if($("#name").val().length < 1 || $("#name").val() == "Your Name" || $("#email_address").val() == "Your Email Address" || $("#email_address").val().length < 1) {
		    $("#subscribe_error").css('visibility','visible');	    
		    return false;
		}
		
	    $("#subscribe_error").css('visibility','hidden');	    
		$.fancybox.showActivity();
	
		$.ajax({
			type		: "POST",
			cache		: false,
			url			: "subscribe.php",
			data		: $(this).serializeArray(),
			success: function(data) {
				$.fancybox(data);
			}
		});
		
		return false;

	});
	
	$('.coming_soon').click(function() {
		alert("Coming Soon");
		return false;
	});	 


    // Initialize Galleria
	$('#galleria').galleria({
	    lightbox: true
	});
	
	// Grab the weather
	//$('#weather').weatherfeed(['ASXX0019']);
    	
	// fix mailto spam bot filter
	$('a').each(function() {
		var url = $(this).attr('href');
		url = url.replace('###', '@');
		var text = $(this).html();
		text = text.replace('###', '@');		
		$(this).attr('href', url);
		$(this).html(text);
	}); 
        
});
