var ebay = {
	start_reorder:function( id, button )
	{
		if( $('me_pick_reorder_flag_' + id ).innerHTML == 0 )
		{ 
			Sortable.create('me_add_edit_' + id );
			$('me_pick_reorder_flag_' + id ).innerHTML = 1;
			button.value = 'Stop Reorder';
		}else{
			Sortable.destroy('me_add_edit_' + id );
			$('me_pick_reorder_flag_' + id ).innerHTML = 0;
			button.value = 'Start Reorder';
		}
	}
}
function doModuleAjaxInsertEbay(div_id, base_path, plug_name, func_name, hm, pod_plug_id, modul_params, pod_id)
{
	var last_item_num_e_c = $('div_last_item_num_e_c_' + pod_plug_id).innerHTML;
	var url  = base_path + 'dashboard/call/'+ plug_name + '/' + func_name + '/' + hm + '/' + pod_plug_id + '/' + modul_params + '/' + last_item_num_e_c + '/' + pod_id;
	new Ajax.Updater(div_id, url, { insertion: Insertion.Bottom } );
	$('div_last_item_num_e_c_' + pod_plug_id ).innerHTML = parseInt(last_item_num_e_c, 10);
}
function VerifyEbayTextareaTmp( id, base_path_ft, pod_id)
{
		var last_item_num_e_li = $('last_item_num_e_li_'+id).innerHTML;
		var last_item_num_e_li_ret = parseInt(last_item_num_e_li, 10);
		var pattern = /[^ 0-9\n\r]/i;
		var textvalue = $('ebay_txta_'+id).value;
		if( !textvalue ) {
			window.alert('The form is empty');
			return false;
		}
		if( pattern.test( textvalue ) )
		{
			window.alert('Please check your spelling');
			return false;
		}
		$('ebay_txta_'+id).value='';
		//textvalue += ' ';
		//var ptrnm=/([0-9]+)[ \n\r]/g;
		//var item_id="";
		var items = textvalue.split(' ');
		var items_str = textvalue.split(' ').join('_').split("\n").join("_");
		/*
		while ((item_id_arr = ptrnm.exec(textvalue)) != null)
		{
		  item_id += item_id_arr[1]+'_';
		  last_item_num_e_li_ret++;
		}
		if( !item_id )
		{
			window.alert('Please enter a valid item number');
			return false;
		}*/
		var target = 'me_add_edit_' + id;
		doModuleAjaxInsertEbay( target, base_path_ft, 'ebay', 'addEbayItemsTxt', items_str, id, last_item_num_e_li, pod_id);
		$('last_item_num_e_li_'+id).innerHTML = items.length - 1;
		return true;
}
