// JavaScript Document
function casestudyRollover(message) {
	$('#rollover-content p.default').hide();
	$('#rollover-content p.active').html(message).show();
}

function casestudyReset() {
	$('#rollover-content .active').hide();
	$('#rollover-content .default').show();
}

function popup() {
	window.open('popup.html', 'title', 'width=940, height=426, top=100, left=100');
	return false;
}

// on document ready
$(function(){ 
	// add basic corners to layout
	$('#analysis-form').corner('20px');
	$('a.button').corner('12px');
	
	//$('#navigation ul ul li:first-child').corner('top 7px');
	$('#navigation ul ul li:last-child').corner('bottom 5px');
	
	// tiered menu
	$('#navigation li').hoverIntent({ sensitivity: 3, interval: 100, over: function(){ $(this).children().fadeIn(200); }, timeout: 500, out: function(){ $(this).children().eq(1).fadeOut(100); }});
	
	// image rollover
	$('img[data-hover], input[type="image"][data-hover]').hover(function() { var currentImg = $(this).attr('src'); $(this).attr('src', $(this).attr('data-hover')); $(this).attr('data-hover', currentImg); }, function() { var currentImg = $(this).attr('src'); $(this).attr('src', $(this).attr('data-hover')); $(this).attr('data-hover', currentImg); });
		
	$('.show-video').click(function() {
		var left = (screen.width / 2) - (940 / 2);
		var top = (screen.height / 2) - (426 / 2);
	
		window.open('popup.html', 'title', 'width=940,height=426,left=' + left + ',top=' + top + ',directories=no,location=no,menubar=no,resizable=no,scrollbars=1,status=no,toolbar=no');
	
		return false;
	});
	
	// jQuery validation
	$('.af-form-wrapper').validate({
		rules: {
			name: "required",
			phone:  {
				required: true,
				phoneUS: true
			},
			email: {
				required: true,
				email: true
			}
		},
		errorPlacement: function(error, element) {
			error.insertAfter(element.parent().prev());
		}
	});
	
	// fancybox modal pop-ups
	$('a.lightbox').fancybox({
		autoScale: false,
		transitionIn: 'none',
		transitionOut: 'none',
		padding: 0, 
		width: 640, 
		height: 460,
		type: 'swf',
		showCloseButton: false,
		titleShow: false,
		swf: {
			wmode: 'transparent',
			allowfullscreen: 'true'
		}
	});
});
