/**
 * Click handler to set an accordian element active
 */
setActive = function(el){
	$$('.cat-list').each(function(el){ $(el).hide();});
	$(el).show();
}


/**
 * open a full view of a listing, by ID.
 */
function listingExpand(id){
	$('listing-full-'+id).show();
	$('listing-container-'+id).hide();
}

/**
 * Collapse a listing, by Id.
 */
function listingContract(id){
	$('listing-full-'+id).hide();
	$('listing-container-'+id).show();
}

/**
 * Initialize the page.
 */
document.observe("dom:loaded", function() {

	//collapse all listings.
//	$$('.listing-full').each(function(el){   el.hide();});


	//accordionize our category list
	$$('.cat-list').each(function(el){el.hide();} );
	$$('div.catListTab a').each(
		function(el,cycle){			
			el.observe('click',function(e){  setActive($(this.up().next())); });
		}
	);
	if (! (typeof(activeTab) == 'undefined')){
		setActive($('tab-'+activeTab).next());
	}
	if ((! (typeof(activeListings) == 'undefined')) && activeListings != ''){
		//alert(activeListings);
		activeListings.each(function(id){  listingExpand(id); });
	}
	if (self.document.location.hash.substring(1)){
		listingExpand(self.document.location.hash.substring(1));
	}

});

function popwin(wname,name,h,w) {
		//var t=((screen.height/2))
		//var l=((screen.width/2))
		t=10
		l=10
		var url = name
		window.name="pops";
		window.open(url,wname,'width='+w+',height='+h+',top='+t+',left='+l+',status=0,toolbar=1,resizable=1,scrollbars=1');
}
