$(document).ready(function() {
						   
	window.otherServicesThickbox = function() {
		var t = null;
		var a = 'environmentalserviceslbox.html?KeepThis=true&amp;TB_iframe=true&amp;height=280&amp;width=631';
		var g = false;
		tb_show(t,a,g);
	};
	
	
	$('#navigation ul.superfish').superfish({ 
		hoverClass:   'sfHover' 
		,delay:        800
		,animation:    {opacity:'show',height:'show'}
		,speed:        'normal'
		,autoArrows:   false
		,dropShadows:  false
		,onShow:       function(){ $(this).parent('li').addClass('sfHover'); }
        ,onHide:       function(){ $(this).parent('li').removeClass('sfHover'); }
	});
	
	
	$(document).oneTime(2000, function() {
		
		$('form object').each(function() {
			var object = $(this);
			object.removeAttr('name');					   
		});					 
	});
	
	$('#lightbox a').click(function(event) {
		
		event.preventDefault();
		
		if ($(this).attr("class").indexOf("close") == -1 && $(this).attr("class").indexOf("prev") == -1) {
			
			window.top.location = $(this).attr('href');		
		}
	});

	$('#lightbox .close').click(function() {
		self.parent.tb_remove();
	});
	
	$('div.lead-in div').each(function() {
		var $this = $(this),
			location = $this.find('a').attr('href');
			object = $this.find('object');
			
		object.click(function(event) {
							  
			window.location = location;					  
		});
		
									   
	}).click(function(event) {
		window.location = $(this).find('a').attr('href');
	}).hover(function(event) {
		$(this).css('cursor', 'pointer');	
	}, function(event) {
		$(this).css('cursor', 'auto');
	});
			
	$.validator.addMethod('dependsOn', function (value, el, params) {
		return !$(params.el).is(params.being) || $(el).is(':filled');
	}, 'This field is required.');

	$.validator.addClassRules({
		otherPropertyTypeDependent: {
			dependsOn: {
				el: '#other-property-type',
				being: ':checked'
			}
		},
		otherRelationshipDependent: {
			dependsOn: {
				el: '#other-relationship',
				being: ':checked'
			}
		}
	});
	
	// un-hide the other field on page load if the radio button is checked	
	$('form input[type=radio].other:checked').each(function() {										
		$(this).parent().next('.other-value').css('display', 'inline');
	});
	
	$('form input[type=radio][name=PropertyType]').click(function() {
		var radio = $(this);
		if (radio.val() == 'other') {
			radio.parent().parent().find('.other-value').css('display', 'inline');	
		} else {
			radio.parent().parent().find('.other-value').css('display', 'none');
			radio.parent().parent().find('label[for=other-property-type-value]').css('display', 'none');
		}
	});
	
	$('form input[type=radio][name=RelationshipToProperty]').click(function() {
		var radio = $(this);
		if (radio.val() == 'on') {
			radio.parent().parent().find('.other-value').css('display', 'inline');	
		} else {
			radio.parent().parent().find('.other-value').css('display', 'none');
			radio.parent().parent().find('label[for=other-relationship-value]').css('display', 'none');
		}
	});
	
	$('form input[type=radio][name=NeedMailedCopy]').click(function() {
		var radio = $(this);
		var fields = $('#extra-fields');
		if (radio.val() == 'Yes') {
			fields.show();
		} else {
			fields.hide();
		}
	});
}); 
