var $j = jQuery.noConflict();
$j(document).ready(function($)
                    	    
{    

function smartPort() { 
/*  $j("#pblock").css({ 'width' : "100%"});*/
//  $j("#pblock").css({ 'width' : "auto"});
/*  $j("#pblock").css({ 'width' : ($j("#pblock").width()-130) });*/
}
function smartColumns() { 
 var colFixed,colNum,colWrap,elem;
//  $j("#pblock").css({ 'width' : "100%"});

  colWrap = $j("body").width()-130; 
  colNum = Math.floor(colWrap / 260); 
if (colNum>8)
	colNum=8;
  colFixed = Math.floor(colWrap / colNum);

  $j("#pblock").css({ 'width' : colWrap});
  $j("#portfolio").css({ 'width' :   colWrap }); 
  $j(".portfolioelem").css({ 'width' : colFixed}); 
for (i=0;i<$j(".portfolioelem").size();i++)
	{
	elem = $j(".portfolioelem").get(i);
	if (i>=colNum)
		{
//		elem.style.display="none";
//		alert(i);
		}
	else
		elem.style.display="block";
	}
//alert($j(".portfolioelem").size());
}

smartColumns(); 

$j(window).resize(function () { 
  smartPort();
  smartColumns();
});

$j('#darr').click(function () {
	if ($j(this).text()=='d')  {
		$j('#portfolio').animate({height:'480px'},1000);
		$j(this).text('u');
		$j(this).css('background-position','center top');
	
		$j(this).css('border-top','0');
		$j(this).css('border-bottom','1px solid #aaa');
	} else {
		$j('#portfolio').animate({height:'240px'},1000);
		$j(this).text('d');
		$j(this).css('background-position','center bottom');
		$j(this).css('border-bottom','0');
		$j(this).css('border-top','1px solid #aaa');
	}
	return false;
	
});

});

