function Item_search( q ) {
	var str = this.no +' ' +this.original_numbers +' ' +this.description +' ' +this.comment;
	var rexp = new RegExp( q, 'gi' );
	if( str.search( rexp ) != -1 )
		return true;
	else
		return false;
}
function Item_show_cart( bg, cnt ) {
	return '<tr valign="top">' +
		'<td' +bg +'>' +this.bought +'</td>' +
		'<td' +bg +'><a href="javascript:zoom(' +cnt +')">' +this.description.substring(0,15) +'..</a></td>' +
		'<td' +bg +' nowrap="nowrap" style="text-align:right">kr. ' +this.price +'</td></tr>';
}
function Item_show_manual( cnt ) {
	var html = '<td style="padding-right:10px">' +this.manual_index +'</td>';
	html += '<td style="cursor:pointer; padding-right:10px" onclick="zoom(\'' +cnt +'\')">' +this.no +': ' +this.description +'<br />';
	if( this.comment != '' )
		html += this.comment +'<br />';
	html += 'kr. ' +this.price +',00</td>';

	html += '<td nowrap="nowrap" style="padding-right:10px">' +
			'<table border="0" cellpadding="0" cellspacing="0"><tr>' +
			'<td rowspan="2"><input name="f' +this.no +'" value="1" maxlength="2" /></td>';
	html += '<td><img src="objects/decrease.gif" border="0" onclick="decrease(\'' +this.no +'\')" /></td></tr>' +
		'<tr><td><img src="objects/increase.gif" border="0" onclick="increase(\'' +this.no +'\')" /></td></tr>' +
		'</table></td>' +
		'<td style="padding-bottom:1px">' +
		'<img src="objects/cart-empty.gif" onclick="buy(' +cnt +',this)" /></td>';
	return html;
}
function Item_show_group( cnt ) {
	var html = '<td style="padding-right:10px; height:65px">';
	if( this.image != '' )
		html += '<img style="cursor:pointer" src="myparts/images/small/' +this.image +'" border="0" onclick="zoom(\'' +cnt +'\')" />';
 	html += '</td>' +
		'<td valign="top" style="cursor:pointer; padding-right:10px" onclick="zoom(\'' +cnt +'\')">' +this.no +': ' +this.description +'<br />';
	if( this.manual_text != '' )
		html += this.manual_text +'<br />';
	html += 'kr. ' +this.price +',00</td>' +
		'<td nowrap="nowrap" style="padding-right:10px">' +
			'<table border="0" cellpadding="0" cellspacing="0"><tr>' +
			'<td rowspan="2">';
	if( this.bought == 0 )
		html += '<input name="f' +this.no +'" value="1" maxlength="2" />';
	else
		html += '<input name="f' +this.no +'" value="' +this.bought +'" maxlength="2" />';
	html += '</td><td><img src="objects/decrease.gif" border="0" onclick="decrease(\'' +this.no +'\')" /></td></tr>' +
			'<tr><td><img src="objects/increase.gif" border="0" onclick="increase(\'' +this.no +'\')" /></td></tr>' +
			'</table></td>' +
		'<td style="padding-bottom:1px">';
	if( this.bought == 0 )
		html += '<img src="objects/cart-empty.gif" onclick="buy(' +cnt +',this)" /></td>';
	else
		html += '<img src="objects/cart-full.gif" onclick="buy(' +cnt +',this)" /></td>';
	return html;
}
function Item_show_checkout( cnt, subtotal ) {
	var html = '<tr valign="middle"><td nowrap="nowrap" style="padding-top:2px">';
	html += '<table border="0" cellpadding="0" cellspacing="0"><tr style="padding:0px"><td rowspan="2" style="padding-right:0px">' +
		'<input name="f' +this.no +'" value="' +this.bought +'" maxlength="3" style="width:30px" onblur="doUpdate(this,' +cnt +')" />' +
		'</td><td><img src="objects/decrease.gif" border="0" onclick="decrease(\'' +cnt +'\')" /></td></tr>' +
		'<tr style="padding:0px"><td><img src="objects/increase.gif" border="0" onclick="increase(\'' +cnt +'\')" /></td></tr>' +
		'</table></td>';

	html += '<td>' +this.no +'</td>' +
		'<td><a onclick="zoom(' +cnt +')" style="cursor:pointer">' +this.description +'</a></td>' +
		'<td align="right" nowrap="nowrap">kr. ' +this.price +',00</td>' +
		'<td align="right" nowrap="nowrap">kr. ' +subtotal +',00</td>' +
		'</tr>';
	return html;
}

function Item_buy( amount ) {
	this.bought = amount;
	return this;
}
function Item_decrease() {
	this.bought--;
}
function Item_increase() {
	this.bought++;
}
function Item_update( amount ) {
	this.bought = amount;
}
function Item( no, group_web, group, manual, manual_index, manual_text, oem, oem_no, description, image, price ) {
	this.no = no;
	this.group_web = group_web
	this.group = group;
	this.manual = manual;
	this.manual_index = manual_index;
	this.manual_text = manual_text;
	this.oem = oem;
	this.oem_no = oem_no;
	this.description = description;
	this.image = image;
	this.price = price;
	this.bought = 0;

	this.zoom = Item_zoom;
	this.show_cart = Item_show_cart;
	this.show_group = Item_show_group;
	this.show_manual = Item_show_manual;
	this.show_checkout = Item_show_checkout;
	this.buy = Item_buy;
	this.decrease = Item_decrease;
	this.increase = Item_increase;
	this.update = Item_update;
	this.search = Item_search;
}
function Item_zoom() {
	var a = this.no +';' +this.group +';' +this.oem +';' +this.oem_no +';' +this.manual +';' +this.manual_index +';' +this.manual_text +';' +this.image +';' +this.description +';' +this.price;
	window.open( 'zoom.htm?' +escape(a), 'zoom', 'height=300,width=500,top=100,left=100,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no', true );
}
