var timer;

$.fn.delay = function(time, callback){
    jQuery.fx.step.delay = function(){};
    return this.animate({delay:1}, time, callback);
};

function whitepapers() {
	$("a#skip").bind("click", function(e){
		timer = window.setInterval(countdown, 1000);
	});
	$('div.half').equalHeight();
	
	
	if(false) {//!$.browser.msie){
		var loginNav = $("div#topHeadline div");
		
		$("a[href$=login]").unbind("click").click(function(e) {
			$("div#login").load("/whitepapers/login/ajax", function(){
				window.scrollTo(0,0);
				loginNav.fadeOut(300);
				$(this).fadeIn(300);
			});
			return false;
		});
		
		
		$('div#login form').live('submit', function(e) {
			// we want to store the values from the form input box, then send via ajax below
			var email     = $('input#user_email').attr('value');
			$('p#welcomeMsg, p#errorMsg').remove();
	 
	 		$.ajax({
				type: "POST",
				url: "/whitepapers/login/ajax",
				data: { user_email: email },
				dataType: "json",
				success: function(user){
					if (user.success == "yes")
					{
						$("div#login form").append("<p id='welcomeMsg'>"+ user.welcome +"</p>").find('p#welcomeMsg').fadeIn(400).delay(1000, function(){
							$("div#login form").parent().fadeOut(300);
						});
						$('.loggedOut').slideUp(300, function(){
							$('.loggedIn').slideDown(300);
						});
					}
					else
					{
						$("div#login form").append("<p id='errorMsg'>"+ user.error +"</p>").find('p#errorMsg').fadeIn(400);
					}
				}
			});
			return false;
		});
	}
	
	$('form#register dd').addClass('clearfix');
	
	$("div#list > ul > li").hover(function(){
		$('div.cover', this).stop().animate({top:'104px'},{queue:false,duration:160});
	},function(){
		$('div.cover', this).stop().animate({top:'129px'},{queue:false,duration:160});
	});
	
	$("div#file_info div.boxgrid").css({left:'-1px',marginBottom:'10px'}).find("div.cover").css({top:'104px'});
}

function countdown() {
	window.clearInterval(timer);
	location.href = 'http://rtcrm.com/whitepapers/register/success';
}

function doDownload() {
	
}