

jQuery(document).ready(function(){   
	
	jQuery('div.get_portfolio_list').each(function(i){
		getByRequests(this, 'show_portfolios');
	});
});

//Call AJAX to populate Portfolios:
function getByRequests(htmlTarget, requestFor){
	//Disable until the request is being processed:
	jQuery(htmlTarget).html('<div style="padding:100px 0; text-align:center"><img src="../wp-content/plugins/wp-portfolio/ajax-loader.gif" alt="LOADING...." />');
	
	//Do not enable until anything is selected:
	if( requestFor=='show_portfolios' ){
		jQuery.ajax({
		   type: "POST",
		   url: '../wp-content/plugins/wp-portfolio/ajax.php',
		   data: 'requestFor='+requestFor,
		   success: function(msg){
			   //Enable as the request is processed:
				jQuery(htmlTarget).html(msg)//.removeAttr('disabled');
				
				//unbind thickbox events:
				jQuery('.thickbox').each(function() {
					jQuery(this).unbind('click');
				});
				
				//rebind thickbox events:
				tb_init('a.thickbox, area.thickbox, input.thickbox');
		   }
		});
	}
}
