    Cufon.replace('h2.frontTop, h3.frontNews, h1, h2', { fontFamily: 'HelvThinExp' });
    Cufon.replace('h1.frontBottom', { fontFamily: 'HelvUltraLight' });
    
$(document).ready(function(){
$(".varjo").dropShadow({left: -1, top: -1, blur: 1, opacity: 0.25});

$('textarea.text-area-special').autoResize({
    // On resize:
    onResize : function() {
        $(this).css({opacity:0.8});
    },
    // After resize:
    animateCallback : function() {
        $(this).css({opacity:1});
    },
    // Quite slow animation:
    animateDuration : 300,
    // More extra space:
    extraSpace : 20
});

  $('a#searchIcon').click(function(e){
    e.preventDefault();
    
    if($('form#searchBox').is(':visible')){
      $('form#searchBox').fadeOut(100);
    } else {
      $('form#searchBox').fadeIn(100);
    }
  });
  
  // checkbox handling
  $('form.defaultForm a.checkbox').click(function(e){
    e.preventDefault();
    
    var divId = $(this).attr("rel");
        
    if($('form.defaultForm  #'+divId).attr('checked')) {
      $(this).removeClass('selected');
      $('form.defaultForm #'+divId).attr('checked','');
    } else {
      $(this).addClass('selected');
      $('form.defaultForm #'+divId).attr('checked','checked');
    }
  });


  // checkbox handling for recruit
  $('form.defaultForm a.checkbox-special').click(function(f){
    f.preventDefault();    
    var inputId = $(this).parent().children('input').attr('id');
    
    if ($(this).attr('id') != '') {
      var linkId = $(this).attr('id');
      if($(this).parent().children('input').attr('checked')) {
        $(this).parent().parent().children('#'+inputId).addClass('hidden');
      }
      else {
        $(this).parent().parent().children('#'+inputId).removeClass('hidden');
      }
      
    }
    if($(this).parent().children('input').attr('checked')) {
      $(this).removeClass('selected');
      $(this).parent().children('input').attr('checked','');
    } else {
      $(this).addClass('selected');
      $(this).parent().children('input').attr('checked','checked');
    }    
  });
  
  
    // add new group  
  $('form.defaultForm a.addMore').click(function(f){
    f.preventDefault();
    
    var anchorValue = $(this).parent().children('.addMore').val();
    
      anchorValue++;
      $(this).parent().children('.addMore').val(anchorValue);
      $(this).parent().parent().children('.'+anchorValue).show('slow');

      
    if (anchorValue == 5) {        
      $(this).hide('slow');
      $(this).parent().children('.hideMore').show('slow');
      
      $(this).parent().children('.hideMore').click(function(f){
        f.preventDefault();
        $(this).hide('slow');
        $(this).parent().children('.addMore').show('slow');
          $(this).parent().children('.addMore').val(4);
          $(this).parent().parent().children('.5').css({display: "none"});

      }); 
    }
    // alert(anchorValue);    

    var inputId = $(this).parent().children('input').attr('id');
    
   
  });
  
  // radio button handling - custom
  $('form.defaultForm a.radio2').click(function(e){
    e.preventDefault();
    
    var divId = $(this).attr("rel");
    
    // if(!$('form.defaultForm  #'+divId).attr('checked')) {
      $('#specialButtons a.radio2').removeClass('selected');
      $(this).addClass('selected');
      $(this).parent().parent().parent().children('select').val($(this).attr('rel'));
      // $('form.defaultForm #'+divId).attr('checked','checked');
    // }
  });
  

  
  // radio button handling - survey

  $('.block a.radio2').click(function(e){
    e.preventDefault();
     var divId = $(this).attr("rel"); 
     var sectionId = $(this).parent().parent().parent().attr("class"); 
    
  //  alert('.block .'+sectionId+' a.radio2');
    // if(!$('form.defaultForm  #'+divId).attr('checked')) {
      $('.block .'+sectionId+' a.radio2').removeClass('selected');
      $('.block .'+sectionId+' input.survey_input').removeClass('checked');
      $(this).addClass('selected');

      $('.'+sectionId+' #'+divId).attr('checked','checked');
      

  });
  
  // radio button handling
  $('form.defaultForm a.radio').click(function(e){
    e.preventDefault();
    
    var divId = $(this).attr("rel");
    
    // if(!$('form.defaultForm  #'+divId).attr('checked')) {
      $(this).parent().children('a').removeClass('selected');
      $(this).addClass('selected');
      $(this).parent().children('select').val($(this).attr('rel'));
      // $('form.defaultForm #'+divId).attr('checked','checked');
    // }
  });
  
  // selectbox handling
  $('form.defaultForm a.fieldSelector').click(function(e){
    e.preventDefault();
    
    var divId = $(this).attr("rel");
    
    if($('form.defaultForm #'+divId).is(':visible')){
      $('form.defaultForm #'+divId).fadeOut(100);
    } else {
      $('form.defaultForm div.selectBox').fadeOut(100);
      $('form.defaultForm #'+divId).fadeIn(100);
    }
  });
  
  $('form.defaultForm div.selectBox a').click(function(e){
    e.preventDefault();
    
    var newTime = 'toivomasi mittarinlukuaika on <b>'+$(this).html()+'</b> (+/- puoli tuntia)';
    
    $(this).parent().parent().children('select').val($(this).attr('rel'));
    $(this).parent().parent().children('a.fieldSelector').html(newTime);
    $(this).parent().fadeOut(100);
  });

// We need to make some overridings for survey
    $('form.defaultForm .survey-choices div.selectBox a').click(function(e){
    e.preventDefault();
    
    var newTime = '<b>'+$(this).html()+'</b>';
    
    $(this).parent().parent().children('select').val($(this).attr('rel'));
    $(this).parent().parent().children('a.fieldSelector').html(newTime);
    $(this).parent().fadeOut(100);
  });
  
});
