function showPLmenu(){
	var _html = 
		'<table class="pl_menu" width="100%" border="0" cellpadding="0" cellspacing="0">' + 
		  '<tr>' + 
			'<td style="white-space:nowrap; padding:0 10px 0 2px;">&nbsp;&nbsp;' + 
			'<span id="page_result"><span id="pl_pages_txt">' + pl_label['PAGES'] + '</span></span></td>' + 
			'<td class="pl_menu_sep"></td>' + 
			'<td width="100%"><ul id="pl_pagenav"><li>&nbsp;</li></ul></td>' + 
		  '</tr>' +
		'</table>';
	return _html;
}

function showPLcontent(pl_data){
	var _html = '';
	var col = 0;
	
	switch(pl.view){
		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 > 22 ? data['title'].substr(0,22)+'...' : data['title'];
				pdesc = data['desc'].length > 120 ? data['desc'].substr(0,120)+'...' : data['desc'];
				reviews = data['reviews'] ? '<div class="reviewBox" style="width:140px; margin:0 0 6px 12px">' + data['reviews'] + '</div>' : '';
				
				_pbox = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' + 
				         '<tr><td valign="top">' + 
						 '<div class="pl_title">' + data['title'] + '</div>' + 
				         '<p class="pl_desc">' + pdesc + '</p>' + reviews + 
				         '</td>' + 
						 '<td valign="top" align="center" width="110">' + 
				         '<a href="'+pl.xmlsrc+'?task=viewinfo&'+pl.params+'&pid='+data['id']+'" rel="facebox" title="' + data['title'] + '">' + 
				         '<img src="'+imgpath+'" border="0" ' + imgDimension + ' class="borderedPic" alt="' + data['title'] + '">' + 
				         '</a>' + 
						 '<div style="margin-top:8px;"><a href="' + imgpath + '" title="' + pl_label['ZOOM'] + '" rel="facebox">' + 
						   '<img src="'+pl.pl_imgpath+'az_pl_zoom.gif" height="11" border="0" alt=""></a></div>' + 
						 '<div class="cart_wrapper">' + 
						 '<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" alt=""></div>' + 
						 '</div>' + 
				         '</td></tr>' + 
						 '<tr><td colspan="2">' + 
						 '<table class="pl_buttons" border="0" cellspacing="0" cellpadding="0"><tr>' + 
				         '<td><div class="pl_price">' + getPrice(data['price'], data['sprice']) + '</div></td>' + 
						 '<td class="pl_button_sep"></td>' + 
				         '<td>' + ( data['attribute'] > 0 ? '<a href="'+pl.xmlsrc+'?task=viewinfo&'+pl.params+'&pid='+data['id']+'" rel="facebox" title="' + data['title'] + '">' : '<a href="javascript:void(0)" title="' + data['id'] + '" class="addtocart">' ) + 
						 pl_azButton(pl_label['BUY'], '') + '</a></td>' + 
						 '<td width="10"></td><td><a href="product_info.php?products_id='+data['id']+'">' + pl_azButton(pl_label['MORE_INFO'], '') + '</a></td>' +
				         '</tr></table>' + 
						 '</td></tr>' + 
				         '</table>';
				_html += '<td class="pl_grid_data" height="100%">' + 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="3" /></td></tr><tr>';
				}else{
					if(((i+1)%pl.limit)!=0) _html += '<td class="pl_ver_sep"><img src="'+pl.pl_imgpath+'spacer.gif" border="0" width="6" 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);
		
	$(".pl_buttons img").mouseover(function(){
		$(this).css({"width": 12, "height": 12});
	}).mouseout(function(){
		$(this).css({"width": 11, "height": 11});
	});
	
	$("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 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 getPerPageValue(){
	var opt = "";
	$.each(display, function(key, value) {
		opt += '<option value="' + value + '"'+(pl.limit==value ? ' selected="selected"' : '' )+'>' + value + '</option>';
	});
	
	return opt;
}

function pl_azButton(alt, bnum) {
	var image_button = '<span class="az-template-button"><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></span>';
	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" style="display:inline-table; height:100%;">' + 
			'<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="6" height="1" /></td>' + 
			  '<td width="100%" class="pl_prodBoxC" height="100%">' + contents + '</td>' + 
			  '<td class="pl_prodBoxR"><img src="'+pl.pl_imgpath+'spacer.gif" border="0" width="7" height="1" /></td>' + 
			'</tr>' + 
			'<tr><td colspan="3">' + pl_productBoxBorder('pl_prodBoxFooter') + '</td></tr>' + 
			'</table>';
	return _html;
}

function cornerBox(tag) {
	if(tag=='open'){
		return '<div class="pl_pbox_topL"><div class="pl_pbox_footerL"><div class="pl_pbox_topR"><div class="pl_pbox_footerR">';
	}else if(tag=='close'){
		return '</div></div></div></div>';
	}else{
		return '</div></div></div></div><div class="pl_pbox_topL"><div class="pl_pbox_footerL"><div class="pl_pbox_topR"><div class="pl_pbox_footerR">';
	}
}

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" alt="">';
}