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;' + pl_label['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">' + pl_label['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">' + pl_label['LIST'] + '</td>' + 
			'<td width="180">' + pl_label['SORT'] + ' ' + 
			//'<select id="pl_sort" name="sort_by" size="1">' + getSortValue() + '</select>&nbsp;&nbsp;&nbsp;' + 
                        '<select class="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">' + pl_label['RESULT_PER_PAGE'] + ' ' + 
			//'<select id="pl_result" name="pl_result" size="1">' + getPerPageValue() + '</select>' + 
			//'</td>' + 
                        '<select class="pl_result" name="pl_result" size="1">' + getPerPageValue() + '</select>' + 
			'</td>' + 
			//'<td width="160" id="pl_pagenav">&nbsp;</td>' +
                         '<td width="160" class="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":
				$(pl_data).each(function(i, data){
				imgpath = pl.imgpath + data['image'];
				imgDimension = (view[pl.view][2] ? 'width="'+view[pl.view][2]+'" ' : '') + (view[pl.view][3] ? 'height="'+view[pl.view][3]+'" ' : '');
				ptitle = data['title'].length > 40 ? data['title'].substr(0,40)+'...' : data['title'];
				_html += '<div class="pl_large">' + 
    					 '<table width="98%" align="center" border="0" cellpadding="2" cellspacing="0"><tr>' + 
	    				 '<td width="38%" align="center" valign="middle">' + 
					  	 '<img src="'+imgpath+'" border="0" ' + imgDimension + ' />' + 
						 '</td>' + 
						 '<td width="62%" valign="top">' + 
		  				 '<table width="100%" border="0" cellpadding="2" cellspacing="2"><tr>' + 
			  			 '<th colspan="2" align="left">' + 
						 '<div id="err'+data['id']+'" class="pl_errorbox"><img src="'+pl.loading1+'" border="0" width="16" height="16"></div>' + 
						 '<div>' + 
						 '<div id="cart'+data['id']+'" class="pl_cart">' + (data['cart']>0 ? '(' + data['cart'] + ') ' + pl_label['IN_CART'] : '') +'</div>' + 
			    		 '<span class="pl_title">' + data['title'] + '</span>' + 
						 '</div>' + 
			  			 '</th>' + 
						 '</tr>' + 
						 '<tr>' + 
						 '<td colspan="2"><p class="pl_desc">' + data['desc'] + '</p></td>' + 
						 '</tr>' + 
						 '<tr height="40">' + 
						 '<td class="pl_text">' + 
						 '<span class="pl_price">' + getPrice(data['price'], data['sprice']) + '</span>' + 
						 '</td>' + 
						 '<td>' + 
						 '<table class="pl_buttons" align="right" border="0" cellspacing="0" cellpadding="0"><tr>' + 
				         '<td><a href="product_info.php?task=viewinfo&pid='+data['id']+'&products_id='+data['id']+'&'+pl.params+' title="'+pl_label['DETAILS']+'">' + 
						 pl_azButton(pl_label['MORE_INFO'], '') + '</a></td>' + 
						 '<td></td>' + 
				         '<td></td>' + 
				         '</tr></table>' + 
						 
						 '</td></tr>' + 
					     '</table></td>' + 
						 '</tr></table>' + 
						 '<p class="pl_sep_hor_large"></p>'+
					  	 '</div>';
				if(((i+1)%view[pl.view][1]) == 0 && i < (pl_data.length-1)){
					_html += '<div class="pl_sep_hor_large"></div>';
				}
			});
			if(pl_data.length < 1) _html += '<p>'+pl_label['NO_RECORDS_FOUND']+'</p>';
			_html += '<div class="clear"></div>';
		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'];
				imgpath_lrg = pl.imgpath + data['imagelrg'];
				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,12)+'...' : data['title'];
				pdesc = data['desc'].length > 200 ? data['desc'].substr(0,200)+'...' : data['desc'];
				
				_pbox = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>' + 
				         '<td valign="top" align="center" style="padding:0 4px 0 4px;">' + 
				         '<div class="pl_title">' + data['title'] + '</div>' + 
				         '<a href="' + imgpath_lrg + '" rel="facebox" title="' + pl_label['DETAILS'] + '">' + 
				         '<img src="'+imgpath+'" border="0" ' + imgDimension + ' />' + 
				         '</a>' + 
						 '<div id="cart'+data['id']+'" class="pl_cart">' + (data['cart']>0 ? '(' + data['cart'] + ') ' + pl_label['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">' + pdesc + '</p>' + 
				         '<table class="pl_buttons" align="center" border="0" cellspacing="0" cellpadding="0"><tr>' + 
				         '<td><a href="product_info.php?task=viewinfo&pid='+data['id']+'&products_id='+data['id']+'&'+pl.params+' title="'+pl_label['DETAILS']+'">' + 
						 pl_azButton(pl_label['MORE_INFO'], '2') + '</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{
					if(((i+1)%pl.limit)!=0 && i < (pl_data.length-1)) _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>' + pl_label['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, '');
		}
		$(this).blur();
	});
	
	jQuery('a[rel*=facebox]').facebox();
	$('#facebox').bgiframe();
}

function popAddtoCart(obj, pid) {
	var id = '&' + $("form#az_popForm").serialize()
	obj.blur()
	addtocart(pid, id)
}

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"' : '' )+'>'+pl_label['LATEST']+'</option>' + 
		   '<option value="name"'+(pl.sortby=="name" ? ' selected="selected"' : '' )+'>'+pl_label['NAME']+'</option>' + 
		   '<option value="price"'+(pl.sortby=="price" ? ' selected="selected"' : '' )+'>'+pl_label['PRICE']+'</option>' + 
		   '<option value="brand"'+(pl.sortby=="brand" ? ' selected="selected"' : '' )+'>'+pl_label['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">&nbsp;</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" />';
}
