/***********************************************************************Author:     Sander TiekstraCompany:    TiekstramediaURL:        http://www.tiekstramedia.nl***********************************************************************//* 19-08-2008 Henk Wijnholds (Concept7) 'Expanding textarea' toegevoegd *//* 19-08-2008 Rafaël L. Bekkema (Concept7) 'Toggle divs in form', 'Postit notes' en 'Adding upload inputs' toegevoegd *//* 20-08-2008 Henk Wijnholds (Concept7) 'DatePicker' toegevoegd */$(document).ready(function() {  /* Initiate  ------------------------------------------------------------------*/  // Check and initiate specials navigation  if ($('#specials-navigation').length > 0) initSpecialsNav()  // Check and initiate date picker  if ($('.calendar').length > 0) initDatePicker()  // Check and initiate post its  if ($('.postit').length > 0) initPostIt()  // Check and initiate another attachment  if ($('#anotherattachment').length > 0) initAnotherattachment()  // Initiate the positioning of rounded corner for IE6  if (jQuery.browser.msie && jQuery.browser.version == 6.0) {    $(window).load(function() { initCornerPositioningIE6() })  }  // Replace hr  replaceHr();  // Add .radio and .checkbox to hide custom borders  $("input[type='radio']").addClass("radio");  $("input[type='checkbox']").addClass("checkbox");  // Expanding textarea  if ($('textarea.expanding').length > 0) {    $.getScript("js/lib/jquery.autogrow.js;", function(){      $('textarea.expanding').autogrow();    });  }  /* Functions  ------------------------------------------------------------------*/  // Behaviour for specials navigation  function initSpecialsNav() {    $('#specials-navigation ul li').each(function() {      $(this).mouseover(function() {        $('#specials-navigation ul li.breadcrumb').removeClass('breadcrumb');        $('#specials-navigation ul li.last-child-breadcrumb').removeClass('last-child-breadcrumb');        if ($(this).hasClass('last-child')) {          $(this).addClass('last-child-breadcrumb');        }        $(this).addClass('breadcrumb');      });    });  }  // Replace hr  function replaceHr() {    $('hr').wrap('<div class="hr"></div>')  }  // Date Picker  function initDatePicker() {    $.getScript("js/lib/date.js", function(){      $.getScript("js/lib/jquery.datepicker.js", function(){        // IE6-div-ontop-of-select-fix        if ($.browser.msie && $.browser.version == 6.0 && $('select').length > 0) {          $.getScript("js/lib/jquery.bgiframe.js");        }        var today = new Date();        var currentYear = today.getFullYear();        $('.calendar')          .datePicker({            verticalOffset: '-5',            startDate: '01/01/' + (currentYear - 10),            endDate: '31/12/' + (currentYear + 10)          })          .bind(            'click',            function() {              $(this).dpDisplay();              this.blur();              return false;            }          )          .bind(            'dateSelected',            function(e, selectedDate, $td)            {              var day   = selectedDate.getDate();              var month = selectedDate.getMonth() + 1;              var year  = selectedDate.getFullYear();              $(this).parent().find('.day').val(day);              $(this).parent().find('.month').val(month);              $(this).parent().find('.year').val(year);            }          );        $('.dp-choose-date').html("<img src='../../static/menzis/menzis2008/assets/layout/icn.agenda.gif' />");        $('.day, .month, .year').change(function() {          var day     = $(this).parent().find('.day').val();          var month   = $(this).parent().find('.month').val();          var year    = $(this).parent().find('.year').val();          var calendar  = $(this).parent().find('.calendar');          // update input.calendar          calendar.val(day + '/' + month + '/' + year);          // update the selected date          var d = new Date(            year,            month-1,            day          );          calendar.dpSetSelected(d.asString());        });      });    });  };  // Postit notes  function initPostIt() {    $(".postit").after("<img src='../../static/menzis/menzis2008/assets/layout/icn.postit.gif' class='postit_icon' />");    $(".postit_icon").click(function () {      $(".postit:visible").hide();      $(this).parent("div").css("overflow","visible");      $(this).prevAll("input:text").css("background","#fff299")      $(this).prev().show();    });    $(".postit").click(function () {      $(this).parent("div").css("overflow","hidden");      $(this).prevAll("input:text").css("background","#fff")      $(this).hide();    });    $(".postit").append("<span class='postit_close'>Close</span>");  }    // Adding upload inputs  function initAnotherattachment(args) {      $('#anotherattachment').bind('click', function() {          var max_attachments = 5; // Maximaal aantal file input velden in bijbehorende ul          // Maak li met input en verwijder link en voeg deze toe aan ul          var ul = $(this).parent().children('ul');          var count = ul.children().length;          var name = 'bijlage_'+(count+1);          var li = $(document.createElement('li'));          var file = $(document.createElement('input'));          file.attr('type', 'file');          file.attr('name', name);          li.append(file);          var a = $(document.createElement('a'));          a.attr('href', 'javascript:;');          a.html('Verwijder');          li.append(a);          ul.append(li);          // Actie voor verwijder link          a.bind('click', function() {              if (li.parent().children().length == max_attachments) {                  li.parent().parent().children('.maxattachments').remove();                  $('#anotherattachment').show();              }              li.remove();          });          // Verberg toevoegen link en laat bericht zien dat maximum bereikt is          if (count+1 == max_attachments) {              var span = $(document.createElement('span'));              span.attr('class', 'maxattachments');              span.html('U heeft het maximaal aantal bijlages bereikt.');              $(this).parent().append(span);              $(this).hide();          }      });  }  // Fixing the Rounded Corners problem for IE6  function initCornerPositioningIE6() {    // bottom corners    $('.br, .bl').each(function(i) {      if ($(this).parent().hasClass('actie')) {} return;      var parentOuterHeight = $(this).parent().outerHeight();      if (parentOuterHeight % 2 == 1) {        var iMarginBottom = $(this).css('marginBottom').split("px")[0];        $(this).css({marginBottom: iMarginBottom - 1 });      };    });    // right corners    $('.tr, .br').each(function(i) {      if ($(this).parent().hasClass('actie')) return;      var parentOuterWidth = $(this).parent().outerWidth();      if (parentOuterWidth % 2 == 1) {        var iMarginRight = $(this).css('marginRight').split("px")[0];        $(this).css({marginRight: iMarginRight - 1, right: 0});      };    });  }});