$(document).ready(function(){
	overlabels();
	
	$('.forgotPW').click(function(){
		ColdFusion.Window.show('forgotPWWindow');
		return false;
	});		
	
	$('.clubsign').click(function(){
		if($('#clubsignform').css('display') == 'none'){
			$('#clubsignform').slideDown();
			$('#clubsignin').animate({'marginTop':'100px'});
		}else{
			$('#clubsignform').slideUp();
			$('#clubsignin').animate({'marginTop':'169px'});			
		}
		return false;
	});
	
	$('.red').click(function(){
		//slide up
		$('.aDistributors').slideUp();
		$('.aRetailers').slideUp();
		$('.aBrokers').slideUp();
		
		//show current
		$('.'+$(this).parent().attr('id')).slideToggle();
		//$(this).parent().toggleClass('selected');
		return false;
	});
	
	var megaConfig = {
		interval: 100,
		sensitivity: 4,
		over: addMega,
		timeout: 100,
		out: removeMega
	}
	
	$("li.mega").hoverIntent(megaConfig);
	
	$('.openwindow').click(function(){
		link = $(this).attr('href');
		window.open (link,"mywindow","location=1,status=1,scrollbars=1,width=500,height=500");		
		return false;
	});

});

function addMega(){
  $(this).addClass("hovering");
  }

function removeMega(){
  $(this).removeClass("hovering");
  }

function overlabels(){
	
	$('form.overlabels label').click(function(){
		$(this).hide();
		$(this).siblings().focus();
	});
	$('form.overlabels .input').blur(function(){
		if($(this).val().length == 0){
			$(this).siblings().show();
		}
	});	
	
	$('form.overlabels .input').focus(function(){
		$(this).prev().hide();
	});	
}
