var $j = jQuery.noConflict();
$j(document).ready(function($){
	
	/* !run plugins ============================== */
	$("#phone").mask("(999) 999-9999",{placeholder:" "});
	$("#fax").mask("(999) 999-9999",{placeholder:" "});
	
/*
	$('#newsletter').submit(function(){
		if($('input[name=checkSend]', this).val() != '111')	return false;
		
		$('<span class="loading"></span>').appendTo(this);
		$(this).html('<p>Thank you for signing up for our newsletter.</p>');
		return false;
	});
*/
	$('#newsletter-email').clearInput({defaultVal: 'Enter your email address'});
	$('#search input[type=text]').clearInput({defaultVal: 'Search'});

	/* !rfq form ============================== */
	if($j("#product-number").val()){
		$j("div.custom").hide();
	};	
	
	$j("p.customize a").click(function(){
		$j("div.custom").slideDown("fast");
	});
	
	$j("#linevoltage").change(function(){
		if($j(this).val()=='Other'){
			$j("#othervoltage").slideDown('fast');
		}else{
			$j("#othervoltage").slideUp('fast').val("");
		}

	});
	
	
	$("#agencyother").click(function(){
		if($(this).attr('checked')==true){
			$("#agencyval").slideDown('fast');
		}else{
			$("#agencyval").slideUp('fast');
		}
	});
	$("#leadlengthother").click(function(){
		if($(this).attr('checked')==true){
			$("#leadlengthval").slideDown('fast');
		}else{
			$("#leadlengthval").slideUp('fast');
		}
	});
		
	$('#primary-nav li').hover(function(){
		$(this).addClass('hover').children('ul').show();	
	}, function(){
		$(this).removeClass('hover').children('ul').hide();	
	});
});

	(function($){  
		$.fn.clearInput = function(options) {  
			settings = jQuery.extend({
				defaultVal: 'Search'
			}, options);
			
			return this.each(function() {
				if($(this).val() == '')
				{
					$(this).val(settings.defaultVal);
				}
				$(this).focus(function(){
					if($(this).val() == settings.defaultVal)
					{
						$(this).val('');
					}
				});
				$(this).blur(function(){
					if($(this).val() == '')
					{
						$(this).val(settings.defaultVal);
					}
				});
			});  
		};  
	})(jQuery); 
