(function($) {
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(!$.support.opacity)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(!$.support.opacity)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeTo = function(speed,to,callback) {
		return this.animate({opacity: to}, speed, function() {
			if (to == 1 && jQuery.browser.msie)
				this.style.removeAttribute('filter');
			if (jQuery.isFunction(callback))
				callback();
		});
	};
})(jQuery);
$(function() {
 function show() {
	var menu = $(this);
	menu.find("div.sublinks").css('display','block');
	menu.addClass('activeParent');
 }
 function hide() { 
	var menu = $(this);
	menu.find("div.sublinks").css('display','none');
	menu.removeClass('activeParent');
 }
 $("#nav td.hasSublinks a").parent().hoverIntent({  
        sensitivity: 10,
        interval: 0,
        over: show,
        timeout: 200,
        out: hide
 });
  
 $('#newsList a.toggle').click(function() {
	obj = $(this).parent();
  	$(this).nextAll('ul').slideToggle('fast', function() {
		if($(this).is(":visible")) obj.addClass('active'); else obj.removeClass('active');
  	});
 });
 //$("#contactForm .req").css('position','absolute');
 $("#contactForm").submit(function() {
	var ret=true;	 
	 $("#contactForm .req").each(function (i) {
        if($(this).val()=="") {
		  ret = false;
		  $(this).css('position','static');
		  var errLbl = $(this).parent().prev();
		  if(errLbl.hasClass('errorLabel')) {
			  errLbl.slideDown('fast');
			  $(this).keyup(function() {
				  if($(this).val()!="") {
					errLbl.slideUp('fast'); 
				  	$(this).unbind('keyup');
				  }
				});
		  } else {
			w = parseInt($(this).width())-5;
		  	$(this).parent().before("<div class='errorLabel' style='width:"+w+"px'>required</div>");
			errLbl = $(this).parent().prev();
		  	$(this).keyup(function() {
			  if($(this).val()!="") {
				  errLbl.slideUp('fast'); 
			  	  $(this).unbind('keyup');
			  }
			});
		  }

        }
      });
  return ret;
});

});
