$(function() {

	//target blank replacement for html strict
	$('a[rel*=external]').click(function(){window.open(this.href);return false;});

	//image carrousel
    $('#bannerContainer').cycle({fx:'fade'});
    
    //header menu
    $('ul.topnav li').hoverIntent({over: makeTall,out: makeShort});
    
    $("#subNav").css("width", $("#subNav ul:first").width() + "px");

    /*function makeTall(){
    	$(this).find('a').first().addClass('hoverMenu').css('color','#ffffff');
    	$(this).find("ul.subnav").slideDown('fast').show();
    }
    
    function makeShort(){
    	$(this).find('a').removeClass('hoverMenu').css('color','#000');
    	$(this).find("ul.subnav").slideUp('fast');
    }*/
    
    function makeTall()
    {
    	$(this).addClass('hoverLine').find('ul.subnav').slideDown('fast');
    }
    
    function makeShort()
    {
    	$(this).removeClass('hoverLine').find('ul.subnav').slideUp('fast');
    }
    
     if ($('#tweetsWidget').length != 0)
     {
   	/* http://tweet.seaofclouds.com/ */
	$("#tweetsWidget").tweet({
			username: "optines",
            count: 5,
             avatar_size: 32,
            loading_text: "loading tweets…"
    });
   }
     
   
	// largest height()
	var maxHeight1 = 0;
	var maxHeight2 = 0;
	var maxHeight3 = 0;
	
	
	/*$(".startTitle").each(function(){
	      if ($(this).height() > maxHeight1) {
	            maxHeight1 = $(this).height();
	      }
	});
	$(".startExtraTitle").each(function(){
	      if ($(this).height() > maxHeight2) {
	            maxHeight2 = $(this).height();
	      }
	});*/
	$(".startTitleHolder").each(function(){
	      if ($(this).height() > maxHeight1) {
	            maxHeight1 = $(this).height();
	      }
	});
	$(".startIntro").each(function(){
	      if ($(this).height() > maxHeight3) {
	            maxHeight3 = $(this).height();
	      }
	});
	$(".newsArchive").each(function(){
	
	    var currentTallest = 0;
		$(this).children().each(function(i){
			if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
			
		});
		$(this).height(currentTallest + 30); 
	});
	// set height of all elements with class of project to maxHeight.
	$(".startTitleHolder").height(maxHeight1);
	/*$(".startExtraTitle").height(maxHeight2);*/
	$(".startIntro").height(maxHeight3);
	
	$('#blogPost').click(function() {
  $('#blogForm').slideToggle('slow', function() {
    // Animation complete.
  });
});

});
