
	function searchforOrderDetails(o_id, o_user_id, o_name, o_date, o_status, o_paypal_status, o_paypal_amount)
	{
		
		//$('ajaxResult').innerHTML = '';
		active = true;
		var myAjax = new Ajax.Request(
			'/ajax/orders/search_for_orders/index.php?orderid='+o_id, 
			{
				method: 'get', 
				parameters: '', 
				onComplete: function(response) {
					myResult = eval('(' + response.responseText + ')');
					active = false;
					drawResults(myResult, $('ajaxResult'), o_id, o_user_id, o_name, o_date, o_status, o_paypal_status, o_paypal_amount);
				}
			});
		

	}

	function drawResults(myResult, contain, o_id, o_user_id, o_name, o_date, o_status, o_paypal_status, o_paypal_amount) {
	table =     '<div style="clear:both;"><br /></div>';
	table +=     '<h3 class="orderdet">Order Details: Purchase no. ' + o_id + '</h3>';
	table +=    '<p class="con1">';
	table +=    (o_name) ? 'Name: <strong>' + o_name + '</strong> <a href="/customers/?action=view&shopping_user_id=' + o_user_id +'">[view customer]</a> | ' : '';
	table +=    '<a href="/customers/?action=view&shopping_user_id=' + o_user_id +'&purchase_id=' + o_id + '">[view full order details]</a></p>';
	table +=    (o_date) ? '<p class="con1">Date: ' + o_date + '</p>' : '';
	table +=    (o_status || o_paypal_status || o_paypal_amount) ? '<p class="con1">Status: ' + o_status + ' - ' + o_paypal_status + ' - ' + o_paypal_amount + '</p>' : '';
	table += 	'<table cellpadding="2" cellspacing="1" border="0" width="100%">';
    table += 	'<tr class="usertr">';
	table += 	'<td>product</td>';
	table += 	'<td>reference</td>';
	table += 	'<td>quantity</td>';
	table += 	'<td>price</td>';
	table += 	'<td>sold</td>';
	table += 	'</tr>';
	
	alt = 'usertd1';
	for(i = 0; i < myResult['orders'].length; i++) {
		sold_msg = (myResult['orders'][i].sold==1) ? 'Yes' : 'No';
		table +=		'<tr class="'+alt+'">' +
						'<td><a href="/products/edit/?product_id=' + myResult['orders'][i].id 	+ '">' + myResult['orders'][i].product 	+ '</a></td>' +
						'<td>' + myResult['orders'][i].reference 	+ '</td>' +
						'<td>' + myResult['orders'][i].quantity	+ '</td>' +
						'<td>' + myResult['orders'][i].price 	+ '</td>' +
						'<td>' + sold_msg + '</td>' +
						'</tr>';
		(alt == 'usertd1')
			?	alt = 'usertd2'
			:	alt = 'usertd1';
	}
	
	table += '</table>';
	contain.innerHTML = table;
	}
	
	
	var myGlobalHandlers = {
		onCreate: function(){
			Element.show('systemWorking');
		},

		onComplete: function() {
			if(Ajax.activeRequestCount == 0){
				Element.hide('systemWorking');
			}
		}
	};

	Ajax.Responders.register(myGlobalHandlers);
	
	
	function close_all_layers (obj) {
    var lay = document.getElementById(obj);
    var dis = lay.style.display;
    lay.style.display = (dis == 'none') ? 'block' : 'none';
	}
