function cp_add_row(id){
	id = jQuery('[name=maxcount]').val();
	if(!id){
		id=0;
	}
	str = '<tr id="cp_row_'+id+'">';
	str	+= '<td><input type="checkbox" checked="checked" name="cp_edit['+id+']" onclick="cp_edit_row('+id+')" /></td>';
	str	+= '<td><input type="checkbox" name="cp_delete['+id+']" onclick="cp_delete_row('+id+')" /></td>';
	str	+= '<td><input  type="hidden" name="cp_'+id+'[id]" value="'+id+'"/></td>';
	str += '<td><input  type="text" name="cp_'+id+'[name]" value=""/></td>';
	str	+= '<td><input type="text" size="6" name="cp_'+id+'[cats]" value=""/></td>';
	str	+= '<td><input type="text" size="3" name="cp_'+id+'[posts]" value=""/></td>';
	str	+= '<td><select name="cp_'+id+'[ordering]">';
	str += '<option value="0" selected="selected">Oldest First</option>';
	str += '<option value="1">Newest First</option>';
	str += '<option value="2">Specified Order</option>';	
	str += '</select></td>';
	str	+= '<td><input type="text" name="cp_'+id+'[IDs]" value=""/></td>';
	str	+= '<td><input type="text" disabled="disabled" size="35" name="cp_'+id+'[shortcode]" value=""/></td>';	
	str	+= '<td><select name="cp_'+id+'[readmore]">';
	str += '<option value="0" selected="selected">Full Article</option>';
	str += '<option value="1">Excerpt</option>';
	str += '<option value="2">Titles Only</option>';	
	str += '</select></td>';
	str	+= '</tr>';
	jQuery(str).insertAfter('tr:last');
	id=parseInt(id,10)+1;
	jQuery('[name=maxcount]').val(id);
}
function cp_edit_row(id){
	enable(id);
	setClass(id,'edit');
}

function cp_delete_row(id){
	setClass(id,'delete');
}

function enable(id){
	obj=jQuery('#cp_row_'+id+'>td>input[name!=cp_'+id+'\[shortcode\]]').removeAttr('disabled');
	obj=jQuery('#cp_row_'+id+'>td>select').removeAttr('disabled');	
}

function setClass(id,type){
	if(type=='edit'){
		jQuery('#'+id).toggleClass('cp-row-selected-edit');	
	}
	else if(type=='delete'){
		jQuery('#'+id).toggleClass('cp-row-selected-delete');			
	}
}
