

$(document).ready(function() {
    enable_cycle = true;                // Enable/Disable the Slideshow Cycle
    slide_animation_time = 260;         // Base time (t) to use on Slides
    slide_transition_duration = 8;      // Seconds for each slide

    initialize();
    hover_events();
	init_forms();
});

function featured_cycle_init(enabled) {
	if ( $('#featured').length == 0 ) {return false;}
    if (!enabled) {$('#featured .meta a.left').css('right','30px');return false;}
    
	cycle_enabled = true;
	$('#featured .meta .trigger').run_cycle('#featured .meta .pause', '#featured .separators .pause', '#featured .progress .bar', slide_transition_duration );
}

function initialize() {
    // Get the Theme
    theme = $('meta[name=gateway-color]').attr('content');

	// Internet Explorer 6 Fixes
	if (IE6) {
		DD_belatedPNG.fix(".png, ul.check li");
		$('ul#navigation li').dropdown();
	}
    
	// Alternating Colors for menu items
	$("ul#navigation li").find("ul:first").children("li").children("a:even").addClass('alt');

	// Add ID's to portfolio items
	var counter = 1; $('#portfolio .thumbs .thumb').each(function() {$(this).attr('id', 'thumb-' + counter);counter += 1;});
	$('#back-to-top').top_animation('easeInOutExpo', 800);

	// Setup Hover Elements
	if (!IE) {
		$('#featured .separators .pause').css({'visibility':'visible', 'display':'block'});
		$('#portfolio .wrap .thumbs .thumb .hover a img.top, #portfolio .wrap .thumbs .thumb .hover .heading, #featured .separators .pause').css('opacity','0');
	}

	// Prettyphoto Configuration
	$("a[rel^='lightbox']").prettyPhoto({
		animationSpeed: 'normal',
		padding: 40,
		opacity: 0.40,
		showTitle: true,
		allowresize: true,
		counter_separator_label: '/',
		theme: 'light_square',
		hideflash: false,
		modal: false,
		changepicturecallback: function(){},
		callback: function(){}
	});

    // Support for target="_blank"
    $('a[rel=_blank]').attr('target','_blank');

}

function hover_events() {
	$.fn.toggleThumb = function(animList, duration) {
		var id = $(this).attr('id');
		var selector = '#' + id + ' img.top, #' + id + ' .heading';
		$(selector).stop().animate(animList, duration);
	}

	$.fn.toggleThumbIE = function(show) {
		var id = $(this).attr('id');
		var selector = '#' + id + ' img.top, #' + id + ' .heading';
		if (show) {$(selector).show()} else {$(selector).hide()}
	}

	// Dropdown Menu
	$('ul#navigation li').hover(function() {
		$(this).find('ul:first').css({visibility: 'visible',display: 'none'}).slideDown(400,'easeOutQuart');
	}, function() {
		$(this).find('ul:first').css({visibility: 'hidden'});
	});

}
