
$(document).ready(function() {  

	var windowHeight = $(window).height();
	
	if (windowHeight < 760) { $("body").addClass("small"); }

	$("#contact-panel").css({display: "block", height: "0", overflow: "hidden"});
	$("#connect-strip div.connect, #sharing div.share, #sharing div.tweet, #contact").css("display", "block");
	$('#contactForm img, #contactSuccess').hide();
        $('#contactForm img').css('margin', '27px 0 0 15px');
	
	$("#contact, #f-contact, #closecontact, .fightContact").click(function(){						 
		if($("#contact-panel").height() < 10) {
		$("header div#hinner").append("<div id='efade'></div>");
		$("#efade").css("opacity","0").animate({opacity: "0.4"}, 600);
		$("#contact-panel").animate({height: "400px"}, 500);
		$("header").animate({top: "400px"}, 500);
		} else {
		$("#contact-panel").animate({height: "0"}, 500);
		$("header").animate({top: "0"}, 500);
		$("#efade").animate({opacity: "0"}, 600, function(){ $(this).remove(); });
		}
		return false;
	});
	
  // Show connect info
  $("#connect").css("display","block");
  $("div#connect-info").hide();
  $("#connect-strip").height($("div.connect").height());
  $("#connect").click(function(){
	  connectOpen = 1;

          if ($('html').hasClass('ie6') || $('html').hasClass('ie7') || $('html').hasClass('ie8')) {
            $(this).hide(0, function(){
              $("#connect-strip").animate({height: $("div#connect-info").height() }); 
              $("div#connect-info").fadeIn('slow'); 
            }); 
          } else {
            $(this).fadeOut("fast", function(){ 
              $("#connect-strip").animate({height: $("div#connect-info").height() }); 
              $("div#connect-info").fadeIn('slow'); 
            }); 
          }

	  $('html, body').animate({scrollTop : $(document).height()}, 900);
	  return false;
  });
  $("#connect-close").click(function(){
	connectOpen = 0;

        if ($('html').hasClass('ie6') || $('html').hasClass('ie7') || $('html').hasClass('ie8')) {
          $("div#connect-info").fadeOut("fast", function() { $("#connect-strip").animate({height: $("div#connect").height() }); $("div#connect").show(); }); return false;
        } else {
          $("div#connect-info").fadeOut("fast", function() { $("#connect-strip").animate({height: $("div#connect").height() }); $("div#connect").fadeTo('slow', 0.8); }); return false;
        }

  });
	

	$('ul li.services').hoverIntent(function(){
		$(this).parent().find("ul").slideDown(200);
	}, function(){
		$(this).parent().find("ul").fadeOut(200);
	});
	
	if(!$.browser.msie) {
		$('a.btn-red, a.btn-purple').hover(function(){
			$(this).stop().fadeTo("fast",0.8);
		}, function(){
			$(this).stop().fadeTo("fast",1);
		});
	}
	
//	$('iframe').each(function(){
//		var url = $(this).attr("src");
//		$(this).attr("src",url+"&wmode=transparent");
//	});
	
	$("div.comment-text").each(function(){
		$(this).append("<div class='speech-l'></div><div class='speech-2'></div>");
	});
	$("div.avatar").each(function(){
		$(this).append("<span></span>");
	});
	
	$("footer p a:first").click(function(){
		$('html, body').animate({scrollTop : 0}, 900);
		return false;
	});

  // Ajax contact form
  $("#signupForm").submit(function() {
    $("#signupForm div.loading").show();

    var dataStr = $("#signupForm").serialize();
    $.ajax({ type: "POST", url: "../includes/newsletter.php", data: dataStr, success: function(response){
        $('#signupForm div.loading').hide();
        if (response == 'success') {
          $('#signupForm').hide();
          $('#signupFormSuccess').fadeIn();
        } else {
          alert(response);
        }
      }
    });
    return false;
  });

  $("a[data-type='cbnewsletter']").colorbox({
    iframe:true,
    innerWidth:'800px',
    height:'600px',
    maxHeight:'100%'
  });

  $('body.postid-3139').append('<img src="/images/fight-the-good-fight-bg.jpg" id="aliFrazier" alt="Fight the Good Fight" />');

});
