Object.extend(Prototype.Browser, {
	IE6 : false /*@cc_on || @_jscript_version < 5.7 @*/,
	IE7 : false /*@cc_on || @_jscript_version == 5.7 @*/
});

if ( Object.isUndefined(Huntress) ) { var Huntress = {}; }

Object.extend(Huntress, {
	clearForms: function() {
		$$('input[type=text]', 'textarea').each(function(f) {
			$(f).observe('focus', function() {
				if ( $F(f) === $(f).defaultValue ) {
					$(f).value = '';
				}
			}).observe('blur', function() {
				if ( $F(f).blank() ) {
					$(f).value = $(f).defaultValue;
				}
			});
		});
		
		return this;
	},
		
	cancelForms: function() {		
		var cancel = $$('form .cancel', '#cancel');
		cancel.invoke('observe', 'click', function(event) {
			event.stop();
			this.up('form').reset();
		});
		
		return this;
	},
	
	fixBoxes: function() {
		if ( $('boxes') && $('boxes').down('.wrapper') ) {
			var boxes = $('boxes').select('.wrapper');
			boxes.each(function(box, i) {
				$(box).setStyle({ marginLeft: '4px' });
				if ( i == 0 ) { $(box).setStyle({ marginLeft: 0 }); }
			});
		}
		
		return this;
	},
	
	getOfficeAddress: function() {
		var text = '<div id="googlemap_info" style="font-size: 0.7em;">';
		if ( $('main_text') && $('main_text').down('div.vx_text') ) {
			text += $('main_text').down('div.vx_text').innerHTML.replace(/<h([1-9])>/, '<h$1 style="font-weight:normal;">');
		}
		text += '</div>';
		
		return text;
	},
	
	officeDropdown: function() {
		if ( $('office') && $('office').tagName.toUpperCase() == 'SELECT' ) {
			$('office').observe('change', function(event) {
				window.location.href = '../offices-' + $F(this) + '.asp';
			});
		}
	}
});

document.observe('dom:loaded', function() {
	Huntress.clearForms();
	Huntress.cancelForms();
	Huntress.officeDropdown();
});
