

var Home = {

	ART_VOLUME: 1,
	ART_DEALS: 2,
	elements: [ 'toptraded_volume', 'toptraded_deals' ],
	container: "mostTraded",
	data_url: "/infostock/ar/ahome",
	action_element: false,

	UpdateMostTraded: function( transport )
	{
		var c = document.getElementById( this.container );
		if( !c )
		{
			Loading.hide( -1 );
			return false;
		}
		Loading.hide( -1 );
		c.innerHTML = transport.responseText;
		this.action_element.style.color = "#1e4280";
		this.action_element = false;
	},

	ChangeMostTraded: function( el )
	{
		var p = false;
		if( !el )
			return;

		for( i = 0; i < this.elements.length; i++ )
		{
			p = document.getElementById( this.elements[i] )
			if( !p )
				continue;
			//p.style.fontWeight = "normal";
			p.style.color = "#7aa3cc";
		}

		this.action_element = el;

		// Loader Active ?
		var c = document.getElementById( this.container );
		if( !c )
			return;
		Loading.show( c );

		var stype = this.ART_VOLUME;
		if( el.id == "toptraded_deals" )
			stype = this.ART_DEALS;

		new Ajax.Request( this.data_url, { method: 'get', onSuccess: function( transport ) { Home.UpdateMostTraded( transport ); }, parameters: $H( {type: stype} ) } );
	}
}
