

$(window).load(function(){
	
	
	max=0;
	var divs=new Array("#static","#leftcol","#lastcolumn");
	
	for (i=0;i<3;i++)		
		if ( (h=$(divs[i]).height())>max) max=h;
	if ((h=$(".singlecat").height())>max) max=h;
	
	$('.column').each(function (){
	
	if  ((h=this.clientHeight)>max) max=h;
	//alert(h);
	});
	
	if ((h=$("#toppage .shortpost").height()+$("#toppage .readmore").height()+51)> max) max=h;
	if ((h=$("#bottompage .shortpost").height()+$("#toppage .readmore").height()+51)> max) max=h;
	
	
	//alert('max'+max);	
	for (i=0;i<3;i++)		$(divs[i]).css('height',max);
	
	$(".singlecat").height(max);
	
	$('.column').each(function (){$(this).css('height',max)});
	
	resize=function(){
		wid=$(this).attr('width');
		rate=374/wid;
		$(this).attr('width',374);
		hei=$(this).attr('height');
		hei=Math.round(hei*rate);
		$(this).attr('height',hei);
		
	};
	
	$('object').each(resize);
	$('embed').each(resize);
	$('iframe').each(resize);
	
	
	$('.shortpost img').attr('style','');
	
	
	
	
	
	slideUp=function(event) {
		  event.preventDefault();
		  eee=$(this);
		  eee.parent().parent().animate({height:'300px'},1500)
		    eee.parent().parent().children('.readmore').animate({height:'1.4em'},1500);
		  if (eee.parent().parent().attr('id')=='bottompage') 
			$('#toppage').animate({height:'300px'},1500);
		 // else
			//$('#bottompage').animate({height:'300px'},1500);
		  eee.css('display','none');
		  eee.parent().children('.more').css('display','inline');
		  return false;
		}
		
	slideDown=function(event) {
		  event.preventDefault();
		  eee=$(this);
		  target=max-12+'px';
		  target2=max-12-eee.parent().parent().children('h2').height()-eee.parent().parent().children('.shortpost').height()-30;
		
		  eee.parent().parent().animate({height:target},1500);
		  eee.parent().parent().children('.readmore').animate({height:target2},1500);
		  if (eee.parent().parent().attr('id')=='bottompage') 
			$('#toppage').animate({height:'0px'},1500);
		 //else
			//$('#bottompage').animate({height:'0px'},1500);
		  eee.css('display','none');
		  eee.parent().children('.less').css('display','inline');
		  return false;
		}
	
	


	$('.readmore a.more').click(slideDown);
	$('.readmore a.less').click(slideUp);
	$('#container.frontpage  .readmore a.more').unbind();
	
	$('.firlevel li span').click(function () { 
	  $('.seclevel').slideUp('slow');
	  $(this).parent().children().slideDown('slow'); 
    });
	
	
	
	
	
	
	
	$('.seclevelitem').children('a').click(function(event){
	event.preventDefault();
	$('.seclevelitem ul').slideUp('slow');
	$(this).parent().children('ul').slideDown('slow'); 
	}); 

	
})
