var show = 1;
function e(id) { return document.getElementById(id); }
function crossfade(num)
{
  hide = show;
  show = Math.round(Math.random()*num);
  $('#b'+show).fadeIn('slow');
  $('#b'+hide).fadeOut('slow');
}

function rotatequote(last)
{
  $('#quotetext').fadeOut('normal',function()
  {
    $('#quotetext').load("/testimonial/&ajax=true&last="+last);
    $('#quotetext').fadeIn();
  });
}

$(document).ready(function()
{
  var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
  if(IE6) return;
  $('#menu li').not('.active').hover
  (
    function()
    {
      $(this).find('.left').css('background-image','url(/img/left.png)');
      $(this).find('a').css('background-image','url(/img/menu.png)');
      $(this).find('.right').css('background-image','url(/img/right.png)');
      $(this).find('.wrap').animate({height:'80px'});
    },
    function()
    {
      $(this).children('.wrap').animate({height:'40px'},function()
      {
        $(this).find('.left').css('backgroundImage','none');
        $(this).find('a').css('background-image','none');
        $(this).find('.right').css('background-image','none');
      });
    }
  );
});

function validate(data,jqform,options)
{
  res = true;
  $('.alert').removeClass('alert');
  $('.alertmsg').remove();

  $('.validate').each(function()
  {
    label = $('#label_'+$(this).attr('id'));
    if(!$(this).val())
    {
      if(msg = $(this).attr('notnull'))
      {
        label.addClass('alert');
        $(this).before('<div class="alertmsg">'+msg+'</div>');
        res = false;
      }
    }
  });

  if(window.custom_validate) res = custom_validate();
  if(res) $("input[type='submit']").not('.nodisable').attr('disabled',true);
  return res;
}

function capture_submit(form,ajax)
{
  if(!ajax) $('#'+form).submit(function() { return validate(false,false,false); });
  else
  $('#'+form).submit(function()
  {
    if(window.completed) $(this).ajaxSubmit({ target: '#response', beforeSubmit: validate, success: completed });
    else
    $(this).ajaxSubmit({ target: '#response', beforeSubmit: validate });

    return false;
  });
}
