// Autofucus the first input/file field in the page.
$(function (e){
	if ( $("input[type=text], input[type=file], textarea") ){ 
  var firstInput = $("input[type=text], input[type=file], textarea")[0];
  if(firstInput){
    firstInput.focus();
		}
  }
});

$(function (){
  // a click on the logo collapses all sections
  $("#logo")
    .css({cursor: "pointer"})
    .hover(
      function (){
      var animationDelay = 800;

      setTimeout(function (){
        $("#logo")
          .animate({"opacity":0.1}, animationDelay)
          .animate({"opacity":1.0}, animationDelay);
        }, 1000);
      }, function(){}
    );

  // translucent objects
  var transparency = "0.66";
  var translucent_objects = "#nav-bar-flags img";

  var full_opacity =
    function (event, obj){
      obj = obj ? obj : this;
      $(obj).animate({opacity: 0.99}); // not 1.0 because at least Opera 9.2 has a bug with it
    };

  var half_opacity =
    function (event, obj){
      obj = obj ? obj : this;
      $(obj).animate({opacity: 0.5});
    };

  $(translucent_objects).css({opacity: transparency});
  $(translucent_objects).hover(full_opacity, half_opacity);


  // effects for footer
  // translucent objects
  var transparency_footer = "0.7";
  var translucent_objects_footer = "#footer #links, #footer #contact";

  half_opacity =
    function (event, obj){
      obj = obj ? obj : this;
      $(obj).animate({opacity: 0.7});
    };

  // translucent objects, hover functionality
  $(translucent_objects_footer).css({opacity: transparency_footer});
  $(translucent_objects_footer).hover(full_opacity, half_opacity);


});
