Shadowbox.loadSkin('classic', '../js/src/skin');
Shadowbox.loadLanguage('en', '../js/src/lang');
Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'qt', 'swf', 'wmp'], '../js/src/player');

$(document).ready(function(){
						   
	h = $('#wrapper').height()+12;
	$('#media-expo').css('height',h);
						   
	$('#media-expo #info').load("mediaexpo/2009/index.html");
	
	s = 14;
	
	updateText = setInterval(
		function(){
			$('a#skip').text('To skip this ad, click here, or wait '+s+' seconds.');
			s--;
		}, 1000);
	
	$('#skip')
		.click(
			function(){
				$('#media-expo')
					.hide();
					clearInterval(updateText);
				return false;
			}
		);
	$('#media-expo')
		.animate({
				opacity: 1
			}, 15000, function()
				{
					$(this).hide();
					clearInterval(updateText);
				});
	
	$('a#media-expo-link')
		.click(
			function(){
				$('a#skip').text('Click here to close ad.');
				$('#media-expo').show();
				
				return false;
			}
		);
	
	$('.gbutton').hover(
		function(){
			$(this)
				.children()
				.fadeIn()
				.animate({bottom: '75px'}, {queue: false});
		},
		function(){
			$(this)
				.children()
				.fadeOut()
				.animate({bottom: '70px'}, {queue: false});
		}
	);
	
	Shadowbox.init();
	
	$("a.media").media({width:935, height:525});

	$(".box").hover(
		function(over){
			$(this).css("border-top","#888 1px solid");
			$(this).css("border-left","#888 1px solid");
			$(this).css("border-right","#888 1px solid");
			$(this).css("border-bottom","#888 1px solid");
		},
					   
		function(out){
			$(this).css("border-top","#fff 1px solid");
			$(this).css("border-left","#fff 1px solid");
			$(this).css("border-right","#fff 1px solid");
			$(this).css("border-bottom","#ccc 1px solid");
		}
	);
	
	$(".equip").hover(
		function(over){
			$(this).css("background","#eee");
			$(this).css("color","#000");
		},
					   
		function(out){
			$(this).css("background","#fefefe");
			$(this).css("color","#333");
		}
	);
	
	$("#awards-list a").hover(
		function(over){
			$(this).animate({backgroundColor:"#fff"}, 500);
		},
					   
		function(out){
			$(this).animate({backgroundColor:"#ccc"}, 500);
		}
	);
	
	$("#awards-text").click(
		function(){
			var txt = $(this).text();
			
			if (txt !== "close awards list"){
				$("#awards-tab").animate({top:"80px"},1500);
				$("#awards-list").animate({top:"80px"},1500);
				$("#awards-text").animate({top:"466px"},1500);
				$("#awards-text").html("close awards list");
			} else {
				$("#awards-tab").animate({top:"-193px"},1500);
				$("#awards-list").animate({top:"-193px"},1500);
				$("#awards-text").animate({top:"193px"},1500);
				$("#awards-text").html("view awards won");
			}
		}
	);
	
	$('#topBannerProducts #slideShow').innerfade({ timeout: '6000', type: 'sequence', containerheight: '398px' });
	
	$("#name, #email, #verify-email, #message").defaultvalue("(required)", "(required)", "(required)", "Please type a short description of how we can help you.");
	
	$("input").focus(
		function(){
			$(this).animate({backgroundColor:"#fff", color:"#000"}, 500);
		}
	);
	
	$("#name, #email").blur(
		function(){
			var rText = $(this).val();
			
			if (rText == ""){
				$(this).animate({backgroundColor:"#BF0D1C", color:"#fff"}, 500);
			};
			
			if (rText !== ""){
				$(this).animate({backgroundColor:"#9EFF97", color:"#000"}, 500);
			};
		}
	);
	
	$("#verify-email").blur(
		function(){
			var e = $("#email").val();
			var ev = $("#verify-email").val();
			
			if (ev == ""){
				$(this).animate({backgroundColor:"#BF0D1C", color:"#fff"}, 500);
				$(this).defaultvalue("(required)");
			} else if (e == ev){
				$(this).animate({backgroundColor:"#9EFF97", color:"#000"}, 500);
			} else {
				$(this).animate({backgroundColor:"#BF0D1C", color:"#fff"}, 500);
				$(this).defaultvalue("emails must match");
			}
		}
	);
	
	$("#contactForm")
		.submit(
			function(){
				n = $("#name").val();
				e = $("#email").val();
				ev = $("#verify-email").val();
				comp = $('#company').val();
				phone = $('#phone').val();
				mess = $('#message').val();
				error = '';
				
				if (n == "(required)" || e == "(required)" || ev == "(required)"){
					error += 'Please fill in the required fields.<br />';
				} else if (e != ev){
					error += 'Please enter matching email address.';
				}
				
				if (error != ''){
					$('.alerts')
						.html(error)
						.fadeIn()
						.animate({
							opacity: 1
						}, 6000)
						.fadeOut();
				} else {
					$.ajax({
						   url: "contact-submit.cfm",
						   data: {name:n, company:comp, email:e, phone:phone, message:mess, sendrequest:'yes', important:''},
						   success: function(){
							   $('.alerts').html('Thank you for contacting Wright\'s Reprints.<br />We will be in touch shortly. <a href="index.cfm">(reset form)</a>').fadeIn();
						   }
						});
				}
				
				return false;
			}
		);
	
	var formStatus = $("#form-status").text();
	
	if (formStatus == "yes"){
		$("#successful").show();
		$("#form-content").hide();
	};
	
	$('h1.title')
		.click(
			function(){
				if ($(this).children('span').html() === '[+]'){
					$(this).next().slideDown();
					$(this).children('span').html('[-]');
				} else {
					$(this).next().slideUp();
					$(this).children('span').html('[+]');
				}
			}
		)
	if ($('#contactForm').length > 0){
		// $("#contactForm").validationAideEnable(null, {showInlineMessages:true, inlineShowSpeed:"fast"});
	}
});