$(document).ready(function() {
	if ($.browser.msie && $.browser.version < 7) return;
	$('.error').hide();
	$('.cover').stop().animate({top:'105px'},{duration:1600});
	$('a[rel*=colorbox]').colorbox();
	$('a[rel*=gallery]').colorbox({width:"750px", height:"80%",transition:'elastic'});
	$('a[rel*=colorBoxExt]').colorbox({width:"720px", height:"600px", iframe:true});
	$('a[rel*=contactForm]').colorbox({width:"750px", height:"80%", iframe:true});
	$('#contactLink').colorbox({href:"/contactform/contact.php"});
	$('a[rel*=accessibilityLink]').colorbox({width:"750px", height:"80%",href:"/accessibility.php div#minContent"});
	$('a[rel*=creditsLink]').colorbox({width:"750px", height:"80%",href:"/credits.php div#minContent"});
	$('a[rel*=rfpLink]').colorbox({width:"750px", height:"80%",href:"/rfp.php div#minContent"});
	$("#mainContent").codaSlider({
		firstPanelToLoad: 2,
		dynamicArrows: false,
		autoHeight: false
	});
	
	$('#smButtons li').removeClass('highlight').find('a').append('<span class="hover" />').each(function () {
		var $span = $('> span.hover', this).css('opacity', 0);
		$(this).hover(function () {
		    $span.stop().fadeTo(500, 1);
		}, function () {
			$span.stop().fadeTo(500, 0);
		});
	});	
	
	//Caption Sliding (Partially Hidden to Visible)
	$('.boxgrid.caption').hover(function(){
		$(".cover", this).stop().animate({top:'0px'},{duration:200});
	}, function() {
		$(".cover", this).stop().animate({top:'105px'},{duration:200});
	});	
	

	$(".required").blur(function() {
		var fieldLength;
		fieldLength = $(this).val().length;
		$(this).next(".error").empty().hide();
		if (fieldLength < 1) {
			$(this).next(".error").append("This is required").show();
		}
	});


	$('#contactForm').submit(function() {
		var imageOK = $('<img>').attr('src', '/images/accepted.png').attr('class', 'right');
		var name = $('#name').attr('value');
		var email = $('#email').attr('value');
		var comment = $('#comment').attr('value');
		var dataString = 'name='+ name + '&email=' + email + phone + '&phone' + '&comment=' + comment;
		//alert (dataString);return false;
		$("#contactFormWrap").attr('class', 'right col300 center nudged').html("<img src='/images/loading.gif')>");
		$.ajax({
			type: "POST",
			url: "/contactForm.php",
			data: dataString,	
			success: function() {
		        $('#contactFormWrap').attr('class', 'right col300 nudged').html("<div id='message'></div>");
		        $('#message').html("<h3>Contact Form Submitted!</h3>").append(imageOK).append("<p>We will be in touch soon.</p>");					
			}
		});
		return false;
    });
    

});