function showPLmenu(){
	var _html = 
		'<table class="pl_menu" width="100%" border="0" cellpadding="0" cellspacing="0">' + 
		  '<tr>' + 
		    '<td class="pl_menu_left">&nbsp;</td>' + 
			'<td width="54" class="pl_viewText">&nbsp;&nbsp;View:</td>' + 
			'<td width="46"><a href="javascript:void(0);" class="pl_viewbuttons" title="grid">' + 
			'  <img src="'+pl.pl_imgpath+'az_pl_grid.gif" border="0" /></a></td>' + 
			'<td width="42" class="pl_viewText">Grid</td>' + 
			'<td class="pl_menu_sep"></td>' + 
			'<td width="48"><a href="javascript:void(0);" class="pl_viewbuttons" title="list">' + 
			'  <img src="'+pl.pl_imgpath+'az_pl_list.gif" border="0" /></a></td>' + 
			'<td width="30" class="pl_viewText">List</td>' + 
			'<td width="180">Sort by: ' + 
			'<select id="pl_sort" name="sort_by" size="1">' + getSortValue() + '</select>&nbsp;&nbsp;&nbsp;' + 
			'<a id="pl_sortdir" href="javascript:void(0);" title="'+pl.sort_dir+'">' + 
			'  <img src="'+pl.pl_imgpath+pl.sort_dir+'.gif" border="0" /></a>' + 
			'</td>' + 
			'<td width="150">Results per page: ' + 
			'<select id="pl_result" name="pl_result" size="1">' + getPerPageValue() + '</select>' + 
			'</td>' + 
			'<td width="160" id="pl_pagenav">&nbsp;</td>' + 
			'<td class="pl_menu_right">&nbsp;</td>' + 
		  '</tr>' + 
		'</table>';
	return _html;
}

function showPLcontent(pl_data){
	var _html = '';
	var _pbox = '';
	
	switch(pl.view){
		case "list":
			_html += '<table id="pl_list" align="center" border="0" cellspacing="1" cellpadding="2">';
			if(pl_data.length > 0){
				_html += '<tr>' + 
						   '<th align="center">&nbsp;</th>' + 
						   '<th align="left">&nbsp;Product Name&nbsp;</th>' + 
						   '<th align="center">&nbsp;Price&nbsp;</th>' + 
						   '<th align="center">&nbsp;Add to Cart&nbsp;</th>' + 
						 '</tr>';
			}else{
				_html += '<tr class="pl_list_data"><td><p>No records found...</p></td></tr>';
			}
			$(pl_data).each(function(i, data){
				imgpath = pl.imgpath + data['image'];
				imgDimension = (view[pl.view][1] ? 'width="'+view[pl.view][1]+'" ' : '') + (view[pl.view][2] ? 'height="'+view[pl.view][2]+'" ' : '');
				
				_html += '<tr class="pl_list_data">' + 
				         '<td align="center">' + 
                  data['link'] + 
						   '<img src="'+imgpath+'" border="0" ' + imgDimension + ' /></a>' + 
						 '</td>' + 
				         '<td class="pl_title">' + 
						 '<div><a href="'+pl.xmlsrc+'?task=viewinfo&'+pl.params+'&pid='+data['id']+'" rel="facebox" title="View Details">' + 
						 data['title'] + '</a></div>' + 
//						 '<div id="cart'+data['id']+'" class="pl_cart">' + (data['cart']>0 ? '(' + data['cart'] + ') in cart' : '') +'</div>' + 
//						 '<div id="err'+data['id']+'" class="pl_errorbox"><img src="'+pl.loading1+'" border="0" width="16" /></div>' + 
						 '</td>' + 
				         '<td class="pl_price">' + getPrice(data['price'], data['sprice']) + '</td>' + 
						 '<td align="center" class="pl_buttons"><a href="'+pl.xmlsrc+'?task=viewinfo&'+pl.params+'&pid='+data['id']+'" rel="facebox" title="View Details">' + 
						 pl_azButton('add to cart', '') + '</a></td>' + 
				         '</tr>';
			});
			_html += '</table>';
		break;
		
		case "grid":
			_html += '<table id="pl_grid" align="center" border="0" cellspacing="0" cellpadding="0"><tr>';
			$(pl_data).each(function(i, data){
				imgpath = pl.imgpath + data['image'];
				imgDimension = (view[pl.view][1] ? 'width="'+view[pl.view][1]+'" ' : '') + (view[pl.view][2] ? 'height="'+view[pl.view][2]+'" ' : '');
				ptitle = data['title'].length > 12 ? data['title'].substr(0,100)+'' : data['title'];
				
				_pbox = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>' + 
				         '<td valign="top" align="center">' + 
				         '<div class="pl_title"><a href="'+pl.xmlsrc+'?task=viewinfo&'+pl.params+'&pid='+data['id']+'" rel="facebox" title="View Details">' + ptitle + '</a></div>' + 
				         //'<a href="' + imgpath + '" rel="facebox" title="View Details">' + 
				         data['link']+
				         '<img src="'+imgpath+'" border="0" ' + imgDimension + ' />' + 
				         '</a>' + 
//						 '<div id="cart'+data['id']+'" class="pl_cart">' + (data['cart']>0 ? '(' + data['cart'] + ') in cart' : '') +'</div>' + 
//						 '<div id="err'+data['id']+'" class="pl_errorbox"><img src="'+pl.loading1+'" border="0" width="16" /></div>' + 
				         '</td>' + 
				         '<td valign="top">' + 
				         '<div class="pl_price">' + getPrice(data['price'], data['sprice']) + '</div>' + 
				         '<p class="pl_desc">' + data['desc'] + '</p>' + 
				         '<table class="pl_buttons" align="center" border="0" cellspacing="0" cellpadding="0"><tr>' + 
				         '<td>'+data['link']+
						 pl_azButton('Product Details', '2') + '</a></td>' + 
						 '<td class="pl_button_sep"></td>' + 
				         '<td><a href="'+pl.xmlsrc+'?task=viewinfo&'+pl.params+'&pid='+data['id']+'" rel="facebox" title="View Details">' + 
						 pl_azButton('add to cart', '') + '</a></td>' + 
				         '</tr></table>' + 
				         '</td>' + 
				         '</tr></table>';
				_html += '<td class="pl_grid_data">' + pl_productBox(_pbox) + '</td>';
				if(((i+1)%view[pl.view][0])==0 && i < (pl_data.length-1)){
					_html += '</tr><tr><td class="pl_hor_sep" colspan="'+(view[pl.view][0]+1)+'"><img src="'+pl.pl_imgpath+'spacer.gif" border="0" width="1" height="1" /></td></tr><tr>';
				}else{
					_html += '<td class="pl_ver_sep"><img src="'+pl.pl_imgpath+'spacer.gif" border="0" width="1" height="1" /></td>';
				}
			});
			if(pl_data.length < 1) _html += '<td><p>No records found...</p></td>';
			_html += '</tr></table>';
		break;
	}
		
	$("#pl_content").html(_html);
		
	$("div.pl_prod, div.pl_prod_small").mouseover(function(){
		$(this).toggleClass("pl_prod_hover");
	}).mouseout(function(){
		$(this).toggleClass("pl_prod_hover");
	});
	
	$("a.addtocart").click(function(){
		if($(".pl_errorbox").is(":animated")==false){
			addtocart(this.title);
		}
	});
	
	jQuery('a[rel*=facebox]').facebox();
	$('#facebox').bgiframe();
}

function getPerPageValue(){
	var opt = "";
	$.each(display, function(key, value) {
		opt += '<option value="' + value + '"'+(pl.limit==value ? ' selected="selected"' : '' )+'>' + value + '</option>';
	});
	
	return opt;
}

function getSortValue(){
	var opt = "";
	opt += '<option value="latest"'+(pl.sortby=="latest" ? ' selected="selected"' : '' )+'>Latest</option>' + 
		   '<option value="name"'+(pl.sortby=="name" ? ' selected="selected"' : '' )+'>Name</option>' + 
		   '<option value="price"'+(pl.sortby=="price" ? ' selected="selected"' : '' )+'>Price</option>' + 
		   '<option value="brand"'+(pl.sortby=="brand" ? ' selected="selected"' : '' )+'>Brand</option>';
	
	return opt;
}

function pl_azButton(alt, bnum) {
	var image_button = '<nobr><span class="az-button-left'+bnum+'" title="' + alt + '">&nbsp;</span><span class="az-button-middle'+bnum+'" title="' + alt + '">&nbsp;' + alt +'&nbsp;</span><span class="az-button-right'+bnum+'" title="' + alt + '">&nbsp;</span></nobr>';
	return image_button;
}

function pl_productBoxBorder(boxclass) {
	var _html = '<table width="100%" border="0" cellspacing="0" cellpadding="0" class="' + boxclass + '"><tr>' + 
			'<td class="' + boxclass + 'L"><img src="'+pl.pl_imgpath+'spacer.gif" border="0"></td>' + 
			'<td width="100%" class="' + boxclass + 'C"></td>' + 
			'<td class="' + boxclass + 'R"><img src="'+pl.pl_imgpath+'spacer.gif" border="0"></td>' + 
			'</tr></table>';
	return _html;
}

function pl_productBox(contents) {
	var _html = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' + 
			'<tr><td colspan="3">' + pl_productBoxBorder('pl_prodBoxHeader') + '</td></tr>' + 
			'<tr>' + 
			  '<td class="pl_prodBoxL"><img src="'+pl.pl_imgpath+'spacer.gif" border="0" width="1" height="1" /></td>' + 
			  '<td width="100%" class="pl_prodBoxC">' + contents + '</td>' + 
			  '<td class="pl_prodBoxR"><img src="'+pl.pl_imgpath+'spacer.gif" border="0" width="1" height="1" /></td>' + 
			'</tr>' + 
			'<tr><td colspan="3">' + pl_productBoxBorder('pl_prodBoxFooter') + '</td></tr>' + 
			'</table>';
	return _html;
}

function getPrice(price, sprice){
	if(!sprice == 0){
		price = '<s>' + price + '</s> ' + sprice;
	}
	return price;
}

function getLoading1(){
	return '<img src="'+pl.loading1+'" border="0" width="16" height="16" />';
}