//***********************************************************************************
// Developed by Citricle Software Solutions - All Rights Reserved.
// This code is protected by the copyright law. 
// Contact: www.citricle.com 1-800-482-5195
//***********************************************************************************
$.jsonp({
			"url": "https://forms.netsuite.com/app/site/hosting/scriptlet.nl?script=17&deploy=1&compid=437148&h=1fd0752bbd78f7051962&jsoncallback=?",
			"success": function(data) {
				if(!data.noResults)	{
					var tableContent = "";
					tableContent += '<table width="100%" cellpadding="5" cellspacing="0">';
					$.each(data.items, function(i, item)	{
						switch(i % 3)	{
							case 0:
								//first column - includes <tr>
								tableContent += '<tr>';
								tableContent += '<td>' + printCell(item) + '</td>';
								break;
							case 1:
								//second column
								tableContent += '<td>' + printCell(item) + '</td>';
								break;
							case 2:
								//third column - includes </tr>
								tableContent += '<td>' + printCell(item) + '</td>';
								tableContent += '</tr>';
								break;
						}
					});
					tableContent += '</table>';
					$("#fragment-2").html(tableContent);
				}
			}			
		});
		var printCell = function(item)	{
			try {
				cellContent = "";
				cellContent += '<td width="33%">';
					cellContent += '<table cellpadding="0" cellspacing="0" width="100%">';
						cellContent += '<tr>';
							cellContent += '<td>';
								cellContent += '<table width="100%" cellpadding="0" cellspacing="0">';
									cellContent += '<tr>';
										cellContent += '<td width="10" height="10" nowrap class="listbox_top_left"><img src="/images/store/templates/common/spacer.gif" width="4" height="4"></td>';
										cellContent += '<td class="listbox_top_bg" height="10"><img src="/images/store/templates/common/spacer.gif" width="4" height="4"></td>';
										cellContent += '<td width="10" height="10" nowrap class="listbox_top_right"><img src="/images/store/templates/common/spacer.gif" width="4" height="4"></td>';
									cellContent += '</tr>';
								cellContent += '</table>';
							cellContent += '</td>';  	  	
						cellContent += '</tr>';
						cellContent += '<tr>';
							cellContent += '<td class="box">';
								cellContent += '<table width="100%" align="left" cellpadding="0" cellspacing="0" height="260">';
									cellContent += '<tr>';
										cellContent += '<td align="center">';
											cellContent += '<a href="' + item.itemURL + '"><img src="' + item.thumbnailURL + '" id="item' + item.internalId + '" border="0" rel="' + item.imageURL + '" class="itemimage" /></a>';
										cellContent += '</td>';
									cellContent += '</tr>';
									cellContent += '<tr>';
										cellContent += '<td height="40" class="smalltitle" style="padding-left: 20px;">';
															/*if(item.basePrice != item.onlinePrice)	{
																cellContent += '<span class="old_price">' + item.basePrice + '</span>&nbsp;&nbsp;<span class="sale_price">' + item.onlinePrice + '</span>';
															}
															else	{
																cellContent += '<span class="price">' + item.onlinePrice + '</span>';	
															}*/
															cellContent += '<span class="price">' + item.basePrice + '</span>';
															cellContent += '<br/>';
															cellContent += '<h2><a href="' + item.itemURL + '">' + unescape(item.caption) + '</a></h2>';
															cellContent += '<br/>';
															cellContent += 'Item Number: ' + item.itemID;
										cellContent += '</td>';
									cellContent += '</tr>';
									cellContent += '<tr>';
										cellContent += '<td class="smalltitle" style="padding-left: 20px;" height="30" valign="bottom">';
															if(item.isNew == "T")	{
																cellContent += '<img src="/site/new_design/images/new.jpg">&nbsp;&nbsp;';
															}
															if(item.isFreeShipping == "T")	{
																cellContent += '<img src="/site/new_design/images/free_shipping.jpg">&nbsp;&nbsp;';
															}
															/*if(item.basePrice != item.onlinePrice)	{
																cellContent += '<img src="/site/new_design/images/on_sale.jpg">&nbsp;&nbsp;';
															}*/
														cellContent += '&nbsp;';
										cellContent += '</td>';
									cellContent += '</tr>';
								cellContent += '</table>';
							cellContent += '</td>';
						cellContent += '</tr>';
						cellContent += '<tr>';
							cellContent += '<td>';
								cellContent += '<table width="100%" cellpadding="0" cellspacing="0">';
									cellContent += '<tr>';
										cellContent += '<td width="10" height="10" nowrap class="listbox_bottom_left"><img src="/images/store/templates/common/spacer.gif" width="4" height="4"></td>';
										cellContent += '<td class="listbox_bottom_bg" height="10"><img src="/images/store/templates/common/spacer.gif" width="4" height="4"></td>';
										cellContent += '<td width="10" height="10" nowrap class="listbox_bottom_right"><img src="/images/store/templates/common/spacer.gif" width="4" height="4"></td>';
									cellContent += '</tr>';
								cellContent += '</table>';
							cellContent += '</td>  ';     	  	
						cellContent += '</tr>';
					cellContent += '</table>';
				cellContent += '</td>';
				return cellContent;
			}
			catch(e) {
				return "";	
			}
		}
