/*
 * for inline thickbox implementation
 */
function change_tb_href()
{
  var qString = $("a.thickbox").attr('rel');
  $("a.thickbox").attr('href', '#TB_inline?' + qString);
}

/*
 * auto submit form that has class of "auto" when any select is changed
 */
function form_auto_submit()
{
  $('form.auto select').change(function(){
    // added this to null second select if first is changed
    if (this.id == 'f1') {
      $('select#f2').attr('selectedIndex',0);
    }
    var $form = $(this).parents('form');
    $form.submit();
  });
}

function drop_nav()
{
//  $('#nav ul ul').attr('style','display:none');
//  $('#nav ul ul').parent().hoverIntent({
//    over:function(){
//      $(this).children('ul').slideToggle(100);
//    },
//    timeout: 500,
//    out:function(){
//      $(this).children('ul').slideToggle(100);
//    }
//  });
}

function enewsValidation() {
	$('form#e-news').submit(function(){
		var fVal = $(this).children('input#email').val();
		if (fVal == '') {
			alert('Please enter an Email Address');
			$(this).children('input#email').focus();
			return false;
		}

		if (! (/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(fVal)) ) {
			alert('Invalid Email Address');
			$(this).children('input#email').focus();
			return false;
		}

	});
}

/* onDocumentReady Call */
$(function(){
  if ($('a.thickbox').hasClass('inline')) {
      change_tb_href();
  }
	$('a.external').attr('target','_blank');

//  if (typeof(hoverIntent) != 'undefined') {
//    drop_nav();
//  }

  form_auto_submit();
  drop_nav();

	enewsValidation();
});

