// script for dropdown menu
$('#jobseeker_menu_toggle').toggle(function(){

  $('.not_jobseeker_menu').slideDown();

},
function(){

  $('.not_jobseeker_menu').slideUp();

}
);


//------------------------------------

$('#postal_code').focus(function()
{
  var val = $(this).val();
  
  if (val=='Zip code of introduction...') $(this).val('').removeClass('faded');
});
$('#postal_code').blur(function()
{
  var val = $(this).val();
  
  if (val=='') $(this).val('Zip code of introduction...').addClass('faded');
});
 


 //------------------------------------
// change the current description in the right panel
function change_description(idx)
{
  $('.media_description_group DIV').hide();
  $('#description_'+idx).show();
  
  var offset = (idx-1) * 40 + 10;
  
  $('#description_arrow').css("margin-top",offset);
}



// create a custom method to force user to complete the fields
$.validator.addMethod("noDefault", 
                      function(value, element) {
                          if ($(element).hasClass('noDefault')) 
                          {
                            return true;
                          }
                          else 
                          {
                            return false;
                          }
                      }, 
                      "Required"
);


  // the form validation script
$("#step1").validate({
  rules: {
    identify: "required",
    seeking_job_title: {
      required: true,
      noDefault:true
    },
    intro_industry: "required",

    description: {
      required: true,
      minlength: 100,
      noDefault:true
    },


    
    postal_code: "required",
    postal_code: {
      required: true,
      minlength: 5,
      number:true
    }
  },
  messages: {
    seeking_job_title: {
      required: "Please fill this field",
      noDefault: "Please fill this field",
      minlength: "The title of the Ntroduction proposal must consist of at least 10 characters",
                              remote: jQuery.format("Please use a differnt title. '{0}' is already in use")
    },
  
    description: {
      required: "Please provide the description of Ntroduction you are seeking",
      noDefault: "Please provide the description of Ntroduction you are seeking",
      minlength: "Description must be at least 100 characters long"
    },
    postal_code: {
      required: "Please provide the postal code",
      minlength: "The postal code must be at least 5 characters long"
    }
  }
});
    
    
// TOOLTIP BEHAVIOUR

   

// first, for title
$('#seeking_job_title').focus(function()
{
  $('.tooltip_container').hide();
  $('.tooltip_container').filter('[rel=seeking_job_title]').fadeIn();
  $.timer(9000, function (timer) { $('.tooltip_container').filter('[rel=seeking_job_title]').hide();  ;timer.stop();});
});

$('#seeking_job_title').blur(function()
{
  $.timer(9000, function (timer) { $('.tooltip_container').filter('[rel=seeking_job_title]').hide();  ;timer.stop();});
});    

// second, for zipcode

$('#postal_code').focus(function()
{
  $('.tooltip_container').hide();
  $('.tooltip_container').filter('[rel=postal_code]').fadeIn();
  $.timer(9000, function (timer) { $('.tooltip_container').filter('[rel=postal_code]').hide();  ;timer.stop();});
});

$('#postal_code').blur(function()
{
  $.timer(9000, function (timer) { $('.tooltip_container').filter('[rel=postal_code]').hide();  ;timer.stop();});
});    

// then, for description
// beware the rel attribute, it's set only in homepage to avoid an empty tooltip
$('#description').not('[rel=notip]').focus(function()
{
  $('.tooltip_container').hide();
  $('.tooltip_container').filter('[rel=description]').fadeIn();
  $.timer(9000, function (timer) { $('.tooltip_container').filter('[rel=description]').hide();  ;timer.stop();});
});

$('#description').not('[rel=notip]').blur(function()
{
  //$('.tooltip_container').hide();
  $.timer(9000, function (timer) { $('.tooltip_container').filter('[rel=description]').hide();  ;timer.stop();});
});    


$('A.closetip').click(function()
{
   $('.tooltip_container').fadeOut();
});

