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="120"><span id="page_result"><span id="pl_pages_txt">' + pl_label['PAGES'] + '</span></span></td>' + 
			'<td class="pl_menu_sep"></td>' + 
			'<td><ul id="pl_pagenav"><li>&nbsp;</li></ul></td>' + 
			'<td width="140" id="pl_viewbuttons">' + 
			'<a href="javascript:void(0)" title="small"><img title="'+pl_label['SMALL']+'" alt="'+pl_label['SMALL']+'" src="'+pl.pl_imgpath+'az_pl_button_small.gif" border="0" align="middle"></a> ' + 
			'<a href="javascript:void(0)" title="med"><img title="'+pl_label['MEDIUM']+'" alt="'+pl_label['MEDIUM']+'" src="'+pl.pl_imgpath+'az_pl_button_med.gif" border="0" align="middle"></a> ' + 
			'<a href="javascript:void(0)" title="large"><img title="'+pl_label['LARGE']+'" alt="'+pl_label['LARGE']+'" src="'+pl.pl_imgpath+'az_pl_button_large.gif" border="0" align="middle"></a>' + 
			'</td>' + 
			'<td class="pl_menu_right">&nbsp;</td>' +
		  '</tr>' +
		'</table>';
	return _html;
}

function showPLcontent(pl_data){
	var _html = '';
	var col = 0;
	
	switch(pl.view){
		case "large":
			_html += '<div id="pl_large">' + cornerBox('open');
			_html += '<table class="pl_large_data" border="0" cellspacing="0" cellpadding="0" width="100%"><tr>';
			$(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 > 22 ? data['title'].substr(0,22)+'...' : data['title'];
				pdesc = data['desc'].length > 400 ? data['desc'].substr(0,400)+'...' : data['desc'];
				_pbox = '<table width="370px" border="0" cellpadding="0" cellspacing="0"><tr>' + 
	    				 '<td width="36%" align="center" valign="middle" style="padding-top:10px;">' + 
					  	 '<img src="'+imgpath+'" border="0" ' + imgDimension + ' alt="' + data['title'] + '">' + 
						 '<div class="cart_wrapper">' + 
						 '<div id="err'+data['id']+'" class="pl_errorbox"><img src="'+pl.loading1+'" alt="" border="0" width="16" height="16"></div>' + 
						 '<div id="cart'+data['id']+'" class="pl_cart">' + (data['cart']>0 ? '(' + data['cart'] + ') ' + pl_label['IN_CART'] : '') +'</div>' + 
						 '</div>' + 
						 '</td>' + 
						 '<td width="60%" valign="top">' + 
		  				 '<table width="100%" border="0" cellpadding="2" cellspacing="2"><tr>' + 
			  			 '<th colspan="2" align="left">' + 
			    		 '<span class="pl_title">' + data['title'] + '</span>' + 
						 '</th>' + 
						 '</tr><tr>' + 
						 '<td colspan="2">' + 
						 '<p class="pl_desc">' + pdesc + '</p>' + 
						 (data['attribute'] ? '<form id="az_pl_form'+data['id']+'" name="pl_cart_quantity" method="post">' + 
						 '<div class="pl_attribute">' + data['attribute'] + '</div></form>' : '') + 
						 '</td>' + 
						 '</tr><tr height="40">' + 
						 '<td class="pl_text">' + 
						 '</td><td class="pl_buttons">' + 
						 '<table align="right" border="0" cellspacing="0" cellpadding="0"><tr>' + 
				         '<td><a href="' + (pl.xmlsrc) + '&task=viewinfo&pid='+data['id']+'" rel="facebox">' + 
						 pl_azButton(pl_label['MORE_INFO'], '') + '</a></td>' + 
						 '<td class="pl_button_sep">&nbsp;</td>' + 
				         '</tr></table>' + 						 
						 '</td></tr>' + 
					     '</table></td>' + 
						 '</tr></table>';
				_html += '<td valign="top">' + _pbox + '</td>';
				if(((i+1)%view[pl.view][1]) == 0 && i < (pl_data.length-1)){
					_html += '</tr></table>' + cornerBox('') + '<table class="pl_large_data" border="0" cellspacing="0" cellpadding="0" width="100%"><tr>';
				}
			});
			if(pl_data.length < 1) _html += '<td class="pl_large_data"><p style="padding:4px 0 4px 0;">' + pl_label['NO_RECORDS_FOUND'] + '</p></td>';
			_html += '</tr></table>' + cornerBox('close') + '</div>';
		break;
		case "med":
			_html += '<div id="pl_med">' + cornerBox('open');
			_html += '<table class="pl_med_data" border="0" cellspacing="0" cellpadding="0" width="100%"><tr>';
			_html += '<td>'+pl_sep(9, 1)+'</td>';
			$(pl_data).each(function(i, data){
				imgpath = pl.imgpath + data['image'];
				imgpath_lrg = pl.imgpath + data['imagelrg'];
				imgDimension = (view[pl.view][2] ? 'width="'+view[pl.view][2]+'" ' : '') + (view[pl.view][3] ? 'height="'+view[pl.view][3]+'" ' : '');
				ptitle = data['title'].length > 22 ? data['title'].substr(0,22)+'...' : data['title'];
				
				_pbox = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' + 
						'<tr><td align="center" colspan="2" style="padding-bottom:4px;">' + 
						'<div class="pl_title"><span title="'+data['title']+'">' + data['title'] + '</span></div>' + 
				        '<a href="' + pl.xmlsrc + '&task=viewinfo&pid='+data['id']+'" rel="facebox" title="' + data['title'] + '">' + 
				        '<img src="'+imgpath+'" border="0" ' + imgDimension + ' alt="' + data['title'] + '"></a>' + 
						'</td></tr>' + 
						'<tr>' + 
						'<td height="30"><div class="pl_price">' + '</div></td>' + 
						'</tr>' + 
						'<tr><td colspan="2" style="height:20px;" valign="bottom">' + 
						'<table align="center" border="0" cellspacing="0" cellpadding="0"><tr>' + 
						'<td class="pl_buttons" width="40">' + 
						( data['attr_status'] > 0 ? '<a href="'+pl.xmlsrc+'&task=viewinfo&pid='+data['id']+'" rel="facebox" title="'+pl_label['ADD_TO_CART']+'">' : '<a href="javascript:void(0)" title="' + data['id'] + '" class="addtocart">' ) + 
						  '<img title="' + pl_label['ADD_TO_CART'] + '" src="'+pl.pl_imgpath+'az_pl_addtocart.gif" alt="' + pl_label['ADD_TO_CART'] + '" height="11" border="0"></a>' + 
						'&nbsp;&nbsp;' + 
						'<a href="' + imgpath_lrg + '" title="' + pl_label['ZOOM'] + '" rel="facebox">' + 
						  '<img src="'+pl.pl_imgpath+'az_pl_zoom.gif" height="11" border="0" alt=""></a>' + 
						'</td>' + 
				        '<td align="right">' + ( data['attr_status'] > 0 ? '<a href="'+pl.xmlsrc+'&task=viewinfo&pid='+data['id']+'" rel="facebox" title="'+pl_label['ADD_TO_CART']+'">' : '<a href="javascript:void(0)" title="' + data['id'] + '" class="addtocart">' ) + '<img title="' + pl_label['ADD_TO_CART'] + '" src="'+pl.pl_imgpath+'az_pl_cart.png" width="27" border="0" alt="' + pl_label['ADD_TO_CART'] + '"></a>&nbsp;' + 
						'<a href="' + pl.xmlsrc + '&task=viewinfo&pid='+data['id']+'" rel="facebox" title="'+pl_label['MORE_INFO']+'"><img src="'+pl.pl_imgpath+'az_pl_moreinfo.png" width="27" border="0" alt=""></a></td>' + 
				        '</tr></table>' + 
						'</td></tr>' + 
						'<tr><td align="right" height="20" style="padding:0 2px 2px 0;">' + 
						'<div class="cart_wrapper">' + 
						  '<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" alt=""></div>' + 
						'</div>' + 
						'</td></tr>' + 
						'</table>';
				_html += '<td width="33%" valign="top">' + _pbox + '</td>';
				col ++;
				if(((i+1)%view[pl.view][1])==0 && i < (pl_data.length-1)){
					_html += '<td>'+pl_sep(9, 1)+'</td></tr></table>' + cornerBox('') + '<table class="pl_med_data" border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td>'+pl_sep(9, 1)+'</td>';
					col = 0;
				}else{
					if(((i+1)%view[pl.view][1])!=0) _html += '<td class="pl_ver_sep"><img src="'+pl.pl_imgpath+'spacer.gif" border="0" width="1" height="1" alt=""></td>';
				}
			});
			if(pl_data.length < 1) _html += '<td class="pl_med_data"><p style="padding:4px 0 4px 0;">' + pl_label['NO_RECORDS_FOUND'] + '</p></td>';
			if(col < view[pl.view][1]) _html += '<td colspan="' + (view[pl.view][1]-col) + '">&nbsp;</td>';
			_html += '<td>'+pl_sep(9, 1)+'</td></tr></table>' + cornerBox('close') + '</div>';
		break;
		case "small":
			_html += '<div id="pl_small">' + cornerBox('open');
			_html += '<table class="pl_small_data" border="0" cellspacing="0" cellpadding="0" width="100%"><tr>';
			_html += '<td>'+pl_sep(9, 1)+'</td>';
			$(pl_data).each(function(i, data){
				imgpath = pl.imgpath + data['image'];
				imgpath_lrg = pl.imgpath + data['imagelrg'];
				imgDimension = (view[pl.view][2] ? 'width="'+view[pl.view][2]+'" ' : '') + (view[pl.view][3] ? 'height="'+view[pl.view][3]+'" ' : '');
				ptitle = data['title'].length > 20 ? data['title'].substr(0,20)+'...' : data['title'];
				
				_pbox = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' + 
						'<tr><td align="center" colspan="2" style="padding-bottom:4px;">' + 
						'<div class="pl_title"><span title="'+data['title']+'">' + data['title'] + '</span></div>' + 
				        '<a href="' + pl.xmlsrc + '&task=viewinfo&pid='+data['id']+'" rel="facebox" title="' + pl_label['DETAILS'] + '">' + 
				        '<img src="'+imgpath+'" border="0" ' + imgDimension + ' alt="' + data['title'] + '"></a>' + 
						'</td></tr>' + 
						'<tr>' + 
						'<td class="pl_buttons">' + 
						( data['attr_status'] > 0 ? '<a href="'+pl.xmlsrc+'&task=viewinfo&pid='+data['id']+'" rel="facebox" title="'+pl_label['MORE_INFO']+'">' : '<a href="javascript:void(0)" title="'+data['id']+'" class="addtocart">' ) + 
						  '<img title="' + pl_label['ADD_TO_CART'] + '" src="'+pl.pl_imgpath+'az_pl_addtocart.gif" alt="" height="11" border="0"></a>' + 
						'&nbsp;&nbsp;' + 
						'<a href="' + imgpath_lrg + '" title="' + pl_label['ZOOM'] + '" rel="facebox">' + 
						  '<img src="'+pl.pl_imgpath+'az_pl_zoom.gif" height="11" border="0" alt=""></a>' + 
						'</td>' + 
						'<td align="right">' + 
						'<div class="cart_wrapper">' + 
						  '<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" alt=""></div>' + 
						'</div>' + 
						'</td>' + 
						'</tr>' + 
						'<tr><td colspan="2" style="padding-bottom:4px;" height="36">' + 
						'<div class="pl_price">' + '</div>' + 
						'</td></tr>' + 
				        '</table>';
				_html += '<td width="25%" valign="top">' + _pbox + '</td>';
				col ++;
				if(((i+1)%view[pl.view][1])==0 && i < (pl_data.length-1)){
					_html += '<td>'+pl_sep(9, 1)+'</td></tr></table>' + cornerBox('') + '<table class="pl_small_data" border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td>'+pl_sep(9, 1)+'</td>';
					col = 0;
				}else{
					if(((i+1)%view[pl.view][1])!=0) {
						_html += '<td class="pl_ver_sep"><img src="'+pl.pl_imgpath+'spacer.gif" border="0" width="1" height="1" alt=""></td>';
					}
				}
			});
			if(pl_data.length < 1) _html += '<td class="pl_small_data"><p style="padding:4px 0 4px 0;">' + pl_label['NO_RECORDS_FOUND'] + '</p></td>';
			if(col < view[pl.view][1]) _html += '<td colspan="' + (view[pl.view][1]-col) + '">&nbsp;</td>';
			_html += '<td>'+pl_sep(9, 1)+'</td></tr></table>' + cornerBox('close') + '</div>';
		break;
	}		
	$("#pl_content").html(_html);
	
	pl_fixHeight();
		
	$(".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){
			var id = $("form#az_pl_form"+this.title).serialize() ? '&' + $("form#az_pl_form"+this.title).serialize()+'&pid='+this.title : ''
			addtocart(this.title, id);
		}
		$(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 pl_fixHeight() {
	var maxH = 0;
	var maxH2 = 0;
	var prev = 0;
	
	$('.pl_med_data .pl_title, .pl_small_data .pl_title').each(function(i){
		if(parseInt($(this).outerHeight()) > maxH) {
			maxH = $(this).outerHeight();
			for(var x=prev; x <= i; x++){
				$('.pl_title:eq(' + x + ')').height(maxH);
			}
			if((i+1)%view[pl.view][1] == 0){
				maxH = 0;
				prev = i+1;
			}
		}else{
			$('.pl_title:eq(' + i + ')').height(maxH);
			if((i+1)%view[pl.view][1] == 0){
				maxH = 0;
				prev = i+1;
			}
		}
	});
	
	prev = 0;
	$('.pl_med_data .pl_price').each(function(i){
		if(parseInt($(this).outerHeight()) > maxH2) {
			maxH2 = $(this).outerHeight();
			for(var x=prev; x <= i; x++){
				$('.pl_price:eq(' + x + ')').height(maxH2);
			}
			if((i+1)%view[pl.view][1] == 0){
				maxH2 = 0;
				prev = i+1;
			}
		}else{
			$('.pl_price:eq(' + i + ')').height(maxH2);
			if((i+1)%view[pl.view][1] == 0){
				maxH2 = 0;
				prev = i+1;
			}
		}
	});
}

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 cornerBox(tag) {
	if(tag=='open'){
		return '<div class="pl_pbox_L"><div class="pl_pbox_R"><div class="pl_pbox_topC"><div class="pl_pbox_footerC"><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></div></div></div></div>';
	}else{
		return '</div></div></div></div></div></div></div></div><div class="pl_pbox_L"><div class="pl_pbox_R"><div class="pl_pbox_topC"><div class="pl_pbox_footerC"><div class="pl_pbox_topL"><div class="pl_pbox_footerL"><div class="pl_pbox_topR"><div class="pl_pbox_footerR">';
	}
}

function pl_sep(w, h) {
	return '<td><img src="'+pl.pl_imgpath+'spacer.gif" border="0" width="'+w+'" height="'+h+'" alt=""></td>';	
}

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="">';
}
