$(document).ready(function(){
// Copyright (c) 2011 42 Answers Creative Internet Studio. All rights reserved.
// No reproduction or republication without exclusive written permission from owner.
// http://42answers.com/


  $.fn.extend({
    clickOutside: function(handler, exceptions) {
      var $this = this;
      $("body").bind("click", function(event) {
        if (exceptions && $.inArray(event.target, exceptions) > -1) {
          return;
        } else if ($.contains($this[0], event.target)) {
          return;
        } else {
          handler(event, $this);
        }
      });
      return this;
    }
  });


  $("a[href*='http://']:not([href*='"+location.hostname+"']),[href*='https://']:not([href*='"+location.hostname+"'])")
      .addClass("external")
      .attr("target","_blank");

  $("a[href*='.pdf']")
      .addClass("file")
      .addClass("pdf")
      .attr("target","_blank");

  $("a[href*='.xls'],[href*='.xlsx'][href*='.csv']")
      .addClass("file")
      .addClass("xls")
      .attr("target","_blank");

  $("a[href*='.doc'],[href*='.docx']")
      .addClass("file")
      .addClass("doc")
      .attr("target","_blank");

  $("a[href*='.ppt'],[href*='.pptx']")
      .addClass("file")
      .addClass("ppt")
      .attr("target","_blank");

// Menu/submenu  -  Show submenu TuneIn
  $("#menu-menu-header > li").mouseover(
    function() {
      $("#menu-menu-header ul").hide();
      $(this).find("ul").show();

      $("#menu-menu-header li").removeClass("active");
      $(this).addClass("active");

      return false;
    }
  );


/*
 $("#headerMenuSites input#s").bind("click", function(){
      $("#headerMenuSites input#s").animate({
        width: "150px",
        color: "#c4d0d3"
      }, 400, 'swing', function(){
        if($("#headerMenuSites input#s").val() == "Zoeken..."){
          $("#headerMenuSites input#s").val("")
        }
        $(this).css({
          color: "#000000"
        })
        return false;
      });
  });

  $("#headerMenuSites input#s").clickOutside(function(event, obj) {
      $("#headerMenuSites input#s").animate({
        width: "80px"
      }, 400, 'swing');
  });
*/

  $("#headerMenuSites input#s").live("click", function(){
    if($("#headerMenuSites input#s").val() == "Zoeken..."){
      $(this).blur();
      $("#headerMenuSites input#s").animate({
        width: "150px",
        color: "#c4d0d3"
      }, 400, 'easeOutQuad', function(){
        $("#headerMenuSites input#s").val("")
        $(this).css({
          color: "#000000"
        })
        return false;
      });
      $(this).focus();
    } else {
      $(this).blur();
      $("#headerMenuSites input#s").animate({
        width: "150px"
      }, 400, 'easeOutQuad', function(){
        return false;
      });
      $(this).focus();
    }
  });


  $("#headerMenuSites").clickOutside(function(event, obj) {
      $("#headerMenuSites input#s").animate({
        width: "80px"
      }, 400, 'easeOutQuad', function(){
      if($("#headerMenuSites input#s").val() == ""){
        $("#headerMenuSites input#s").val("Zoeken...")
      }
      $(this).css({
        color: "#000000"
      });
      return false;
    });
    $(this).focus();
  });


  $("#headerMenuTabs .tab a").bind("click", function(){
    $(".form").hide();
    $(this).next().show();
    return false;
  });

  $("#headerMenuTabs").clickOutside(function(event, obj) {
    $(".form").hide();
  });

  $("a.colorbox").colorbox();


});
