$(document).ready(function(){

// Mast Nav
	
	// Parent LI Hover
	

	// Nav Dropdowns
	$("#mast-nav li").hoverIntent(function(){
		$(this).children("a").css({'border-left-color':'#317d15','border-right-color':'#317d15'});
		$(this).find("ul.subnav").slideDown('fast').show();
	},function(){
		$(this).children("a").css({'border-left-color':'#225278','border-right-color':'#113b6e'});
		$(this).find("ul.subnav").slideUp('fast');
	});


	$("#mast-nav :first-child a").css("border-left","none");
	$("#mast-nav :last-child a").css("border-right","none");

	// Last button's drop down
	$("ul.topnav :last-child ul.subnav").css("left","-107px");
	
	
	
// Promotional images & H1
	$("h1 + img").prev().css("margin-bottom", "-2px").css("z-index", "2").css("position", "relative").css("text-shadow", "none");
	
	// This is to allow the same treatment for promo images wrapped in a link.
	// Wrapping the H1 and img in the same <a> causes a text-decoration bug in IE8
	$("h1 + a").prev().css("margin-bottom", "-2px").css("z-index", "2").css("position", "relative").css("text-shadow", "none");
		
// External Links
	$("a[href^='http']").attr('target','_blank');

// Form OnFocus for submit button			
	
	$('.input-text').focus(function() {
		$(this).css('background-position','0 -35px')							  
	});
	$('.input-text').blur(function() {
		$(this).css('background-position','0 0')							  
	});				
	
	$('.input-textarea textarea').focus(function() {
		$(this).parent().css('background-position','0 -100px')							  
	});
	$('.input-textarea textarea').blur(function() {
		$(this).parent().css('background-position','0 0')							  
	});	
	
	$('#submit').focus(function() {
		$(this).css('background-position','0 -50px')							  
	});	
	$('#submit').blur(function() {
		$(this).css('background-position','0 0')							  
	});
	
	$('#submit').hover(function() {
		$(this).css('background-position','0 -50px')							  
	}, function() {
		$(this).css('background-position','0 0')		
	});

	

// Testing toggle stuff for Andrew
	$("div.faqs dl dd").hide();
	$("div.faqs dt a").click(function() {
		$(this).parent().parent().find("dd").slideDown(500);
	});
	$("div.faqs dd a").click(function() {
		$(this).parent().parent().slideUp(500);
	});

});

//<![CDATA[
	// Demo NyroModal
	$(function() {
		$.nyroModalSettings({
			debug: false,
			processHandler: function(settings) {
				var url = settings.url;
				if (url && url.indexOf('http://www.youtube.com/watch?v=') == 0) {
					$.nyroModalSettings({
						type: 'swf',
						height: 355,
						width: 425,
						url: url.replace(new RegExp("watch\\?v=", "i"), 'v/')
					});
				}
				// Embedded YouTube
				if (url && url.indexOf('http://www.youtube.com/v') == 0) {
					$.nyroModalSettings({
						type: 'swf',
						height: 478,
						width: 590,
						url: url.replace(new RegExp("\\?v=", "i"), 'v/')
					});
				}
			},
			endShowContent: function(elts, settings) {
				$('.resizeLink', elts.contentWrapper).click(function(e) {
					e.preventDefault();
					$.nyroModalSettings({
						width: Math.random()*1000,
						height: Math.random()*1000
					});
					return false;
				});
				$('.bgLink', elts.contentWrapper).click(function(e) {
					e.preventDefault();
					$.nyroModalSettings({
						bgColor: '#'+parseInt(255*Math.random()).toString(16)+parseInt(255*Math.random()).toString(16)+parseInt(255*Math.random()).toString(16)
					});
					return false;
				});
			}
		});
		
		
	});
	
	$(function() {
		$('.nyroModalWide').nyroModal({width: '600'});
	});





