// avoid conflict with other libraries
jQuery.noConflict();
jQuery(function() {					   
	// initialize a news component, and grab HTML response
	jQuery.ajax({    
    	url: '/newcar/companycar/widget/news/news.cfc',    
    	method: 'POST',    
    	data: {
			method: 'getWidget',
			returnFormat: 'plain',
			numClk: 1,
			strServer: window.location.hostname
		},    
    	success: function(data) {
			$('#newsContent').html(data);
			
			var newsHeight = $('#newsContent .tabNews').height();			
			
			$('#newsContent .tab').each(function(){
				var thisHeight = $(this).height();
				if (thisHeight > newsHeight) newsHeight = thisHeight;
			});
			
			$('#newsContent .tabNews').height(newsHeight*1.1);			
		},    
    	error: function(x,t,e) {
			$('#newsContent').html('The news feed could not be loaded');
		}    
    });
	
	// click handler for news tabs
	$('.tabMenuItem').live('click',function(){
		// get menu item value
		var thisItem = $(this).html();
		var thisClass = thisItem.replace(/[^0-9a-zA-Z]/gi,'');
		
		$('.tab').hide();
		$('#tab'+thisClass).show();
		
		$('.tabMenuItem').removeClass('tabCurr');
		$('.tabMenuItem:contains("'+thisItem+'")').addClass('tabCurr');
	});
});
