// JavaScript Document
$(document).ready(function(){
	newshead_closed = '/media/pic/right-header-closed.png';
	newshead_opend = '/media/pic/right-header-open.png';
    news_selector = '.news-head:not(.always-open)';
    text_selector =  '.news-head:not(.always-open) + .text';
    bottom_selector = '.news-head:not(.always-open) ~ .bottom';
    left_height = $('#content-left').height()
	$(text_selector).css('display', 'none');
	$(bottom_selector).css('display', 'none');
	$(news_selector).css('background-image', 'url(' + newshead_closed + ')');
	$(news_selector).css('cursor', 'pointer');

   	$(news_selector).click(function(){
		if ( $(this).css('background-image').match(newshead_opend)) {
			$(this).next().slideUp('normal', function(){
				$(this).prev().css('background-image', 'url(' + newshead_closed + ')');
                h = $('#content-right').height()
                if (h+110 > left_height){
                    $('#content-left').height($('#content-right').height() + 110);
                } else {
                    $('#conten-left').height(left_height);
                }
			});
			$(this).next().next().slideUp('normal');
		} else {
			$(this).css('background-image', 'url(' + newshead_opend + ')');
			$(this).next().slideDown('normal', function(){
                h = $('#content-right').height()
                if (h+110 > $('#content-left').height()){
                    $('#content-left').height($('#content-right').height() + 110);
                }
            });
			$(this).next().next().slideDown('normal');
		}
	});
 });
