// handles things in the new search form

// we're namespacing this to make sure things don't conflict with other things
var PvaSearch = PvaSearch ? PvaSearch : {
	tabListing: Array('street_add','parcel_id','owner','legal','sales'),
	tabPrefix: 'tab_',
	buttonPrefix: 'sn_',
	highLightSuffix: '_02',
	noHighlightSuffix: '_01',
	inactiveSuffix: '_ia',
	activeSuffix: '_on',
	imagesLocation: '/images/',
	imageSuffix: '.gif',
  
	highlightTab : function(source) {
		if (source.getAttribute('pvaunavailable') == '1') {
			source.src = this.imagesLocation + this.buttonPrefix + "advancedonly" + this.imageSuffix;
		} else {
			source.src = this.imagesLocation + this.buttonPrefix + source.id + this.highLightSuffix + this.imageSuffix;
		}
	},
	
	unhighlightTab : function(source) {
		// if pvaunavailable is set, this is a tab that is not available without a subscription.
		if (source.getAttribute('pvaunavailable') == '1') {
			source.src = this.imagesLocation + this.buttonPrefix + source.id + this.inactiveSuffix + this.imageSuffix;		
		} else {
			// check to see if this one is the current one.
			// we've created a special attribute on the img tag named 'pvacurrent' that holds a 1 or 0 for this purpose.
			source.src = this.imagesLocation + this.buttonPrefix + source.id + ((source.getAttribute('pvacurrent') == '1') ? this.activeSuffix : this.noHighlightSuffix) + this.imageSuffix;
		}
	},
	
	showTab : function(source) {
		// go through all the tabs.
		totalTabs = this.tabListing.length;
		for (i=0; i < totalTabs; i++) {
			// first cleanup the tabs themselves.
			currentItem = $(this.tabListing[i]);
			currentItem.src = this.imagesLocation + this.buttonPrefix + this.tabListing[i] + ((currentItem.getAttribute('pvaactive') == '1') ? this.noHighlightSuffix : this.inactiveSuffix) + this.imageSuffix;
			currentItem.setAttribute('pvacurrent','0');
			
			// now hide the content areas.
			$(this.tabPrefix + this.tabListing[i]).hide();
			
		}
		
		// show this one.
		source.src = this.imagesLocation + this.buttonPrefix + source.id + this.activeSuffix + this.imageSuffix
		source.setAttribute('pvacurrent','1');
		$(this.tabPrefix + source.id).show();
	}
}
