var gProdNames = [];
var gProdCodes = [];
var gProdLinks = [];
var gProdPrices = [];

var gProdNames_1 = [];
var gProdCodes_1 = [];
var gProdLinks_1 = [];
var gProdPrices_1 = [];

var gProdNames_2 = [];
var gProdCodes_2 = [];
var gProdLinks_2 = [];
var gProdPrices_2 = [];

var gProdNames_3 = [];
var gProdCodes_3 = [];
var gProdLinks_3 = [];
var gProdPrices_3 = [];

var gProdCodes_altImages = [];
var searchClicked = "0";
var hasAltImages ="0";

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );

  if( results == null )
    return "";
  else
    return results[1];
}
function getBaseProductCode2Dashes( myString )
{
	var mySplitArray = myString.split("/");
	var myBaseCode = mySplitArray[mySplitArray.length-1];
	
	var myBaseCodeArray = myBaseCode.split("-");
	
	myBaseCode = ""; 
	myBaseCode+= myBaseCodeArray[0] + "-";
	myBaseCode+= myBaseCodeArray[1] + "-";
	myBaseCode+= myBaseCodeArray[2];
	
	return (myBaseCode);
}
function getBaseProductCode( myString )
{
	var mySplitArray = myString.split("/");
	var myBaseCode = mySplitArray[mySplitArray.length-1];
	
	var myBaseCodeArray = myBaseCode.split("-");
	
	myBaseCode = ""; 
	myBaseCode+= myBaseCodeArray[0] + "-";
	myBaseCode+= myBaseCodeArray[1] + "-";
	myBaseCode+= myBaseCodeArray[2] + "-";
	myBaseCode+= myBaseCodeArray[3];

	return (myBaseCode);
}
function getBaseProductCodeAltImage( myString )
{
	var mySplitArray = myString.split("/");
	var myBaseCode = mySplitArray[mySplitArray.length-1];
	
	var myBaseCodeArray = myBaseCode.split("-");
	
	myBaseCode = ""; 
	myBaseCode+= myBaseCodeArray[0] + "-";
	myBaseCode+= myBaseCodeArray[1] + "-";
	myBaseCode+= myBaseCodeArray[2] + "-";
	myBaseCode+= myBaseCodeArray[3] + "-";
	myBaseCode+= myBaseCodeArray[4];
	
	return (myBaseCode);
}
function change_this(item,type) {
	
	var item;
	var type;
	var itemValue = item.value;
	var category = document.thisForm.CatCode.value;
	var parent_category = document.thisForm.Parent_Code.value;
	var sku = document.thisForm.sku.value;

	//PUT DATA IN HIDDEN FIELD FOR LATER
	if (type == "SIZE") { document.thisForm.SIZE.value = itemValue; }
	if (type == "COLOR") { document.thisForm.COLOR.value = itemValue; }
	if (type == "FLAVOR") { document.thisForm.FLAVOR.value = itemValue; }
	if (type == "SCENT") { document.thisForm.SCENT.value = itemValue; }
	if (type == "DESIGN") { document.thisForm.DESIGN.value = itemValue; }
	if (type == "TIME") { document.thisForm.TIME.value = itemValue; }

	//GET CURRENT ATTR VALUE
	if (type == "SIZE") { var size = itemValue; }
	if (type == "COLOR") { var color = itemValue; }
	if (type == "FLAVOR") { var flavor = itemValue; }
	if (type == "SCENT") { var scent = itemValue; }
	if (type == "DESIGN") { var design = itemValue; }
	if (type == "TIME") { var time = itemValue; }

	//GET PRODUCT ATTRIBUTE COUNT
 	total = document.thisForm.Product_Attribute_Count.value;

 	//FIND OUT WHAT THE NAMES OF THE ATTRS ARE
 	for (i=1; i<=total; i++) {
  		attrName = eval("document.thisForm.A" + i + ".value");
 		if (attrName != type) {
 			if (attrName == "SIZE") { var size = document.thisForm.SIZE.value; }
 			if (attrName == "COLOR") { var color = document.thisForm.COLOR.value; }
 			if (attrName == "FLAVOR") { var flavor = document.thisForm.FLAVOR.value; }
 			if (attrName == "SCENT") { var scent = document.thisForm.SCENT.value; }
 			if (attrName == "DESIGN") { var scent = document.thisForm.DESIGN.value; }
 			if (attrName == "TIME") { var scent = document.thisForm.TIME.value; }
 		}
 	}

	//CATEGORY SPECIFIC
	if (category == "HOUS-LIGH" || category == "GARD-DECS" || category == "GARD-OUTF" || category == "GARD-CONT" || category == "GARD-GEAR" || category == "HOUS-FIEL" || category == "GIFS-GARD" || category == "GIFS-HBAS" || category == "SALE-ONSA" || category == "HOUS-LIBR" || category == "SALE-GARD" || category == "SALE-HOUS") {
		if (!color) { color = "001"; }
		if (!size) { size = "001"; }
		var newProduct = category + '-' + sku + '-' + color + size;
		var newProductShort = color + size + sku;
        } else 	if (category == "WELL-GARD" || category == "WELL-AROM") {
		if (!color) { color = "001"; }
		if (!scent) { scent = "001"; }
		var newProduct = category + '-' + sku + '-' + color + scent;
		var newProductShort = color + scent + sku;
        } else 	if (category == "WELL-BATH") {
		if (!color) { color = "001"; }
		if (!scent) { scent = "001"; }
		var newProduct = category + '-' + sku + '-' + color + scent;
		var newProductShort = color + scent + sku;
        } else 	if (category == "WELL-SKIN" || category == "GARD-WILD" || category == "SEAS-TREE" || category == "SEAS-NEST") {
		if (!size) { size = "001"; }
		if (!color) { color = "001"; }
		var newProduct = category + '-' + sku + '-' + size + color;
		var newProductShort = size + color + sku;
        } else 	if (category == "HOUS-FURN") {
		if (!color) { color = "001"; }
		if (!design) { design = "001"; }
		var newProduct = category + '-' + sku + '-' + design + color;
		var newProductShort = design + color  + sku;
        } else 	if (category == "SEAS-PANT") {
		if (!flavor) { flavor = "001"; }
		if (!size) { size = "001"; }
		var newProduct = category + '-' + sku + '-' + flavor + size;
		var newProductShort = flavor + size  + sku;
        } else 	if (category == "GIFS-HOST") {
		if (!design) { design = "001"; }
		if (!scent) { scent = "001"; }
		var newProduct = category + '-' + sku + '-' + design + scent;
		var newProductShort = design + scent  + sku;
        } else 	if (category == "SEAS-ENTE") {
		if (!design) { design = "001"; }
		if (!size) { size = "001"; }
		var newProduct = category + '-' + sku + '-' + design + size;
		var newProductShort = design + size  + sku;
        } else 	if (category == "SEAS-HDEC") {
		if (!design) { design = "001"; }
		if (!size) { size = "001"; }
		var newProduct = category + '-' + sku + '-' + size + design;
		var newProductShort = size + design  + sku;
        } else 	if (category == "WORK") {
		if (!time) { time = "001"; }
		if (!size) { size = "001"; }
		var newProduct = category + '-' + sku + '-' + size + time;
		var newProductShort = size + time  + sku;
        }
	
	
	// UPDATE IMG
	var myNewImgSrc = "/bin-images-products/"+newProduct+"-stndrd-m.jpg";
	$("#prod_detail_page_medium_img").attr("src",myNewImgSrc);
	var cursor = "pointer";
	$("#prod_detail_page_medium_img").css("cursor",cursor);
	
	
	prod_detail_page_load_alt_imgs(newProduct);
	
	// UPDATE FORM PRODUCT CODE
	document.thisForm.Product_Code.value = newProduct;
	
	// UPDATE CODE
	$("#code").html( newProduct );
	
	// UPDATE PRICE
	$("#prod_detail_page_price").html( eval("document.thisForm.F" + newProductShort + ".value") );
	
	// UPDATE SURCHARGE
	$("#surcharge").html( eval("document.thisForm.F" + newProductShort + "surcharge.value") );
	
	// UPDATE TITLE
	$("#title").html( eval("document.thisForm.F" + newProductShort + "title.value") );
	
	// UPDATE DESCRIPTION
	$("#prod_detail_page_description").html( eval("document.thisForm.F" + newProductShort + "descrip.value") );

}


function prod_list_page_cat_insp_pan1_click() {
	$("#prod_list_page_cat_insp_pan1").click(function() {
		$(this).unbind('click');
		prod_detail_page_insp_load_products($("#prod_list_page_cat_insp_pan1"),"INSP-PAN1");	
//alert('unload1');
		prod_detail_page_insp_unload_products($("#prod_list_page_cat_insp_pan2"),"INSP-PAN2");
		prod_detail_page_insp_unload_products($("#prod_list_page_cat_insp_pan3"),"INSP-PAN3");
	});
}
function prod_list_page_cat_insp_pan2_click(){
	$("#prod_list_page_cat_insp_pan2").click(function() {
		$(this).unbind('click');
		prod_detail_page_insp_load_products($("#prod_list_page_cat_insp_pan2"),"INSP-PAN2");
//alert('unload2');
		prod_detail_page_insp_unload_products($("#prod_list_page_cat_insp_pan1"),"INSP-PAN1");
		prod_detail_page_insp_unload_products($("#prod_list_page_cat_insp_pan3"),"INSP-PAN3");
	});
}
function prod_list_page_cat_insp_pan3_click(){
	$("#prod_list_page_cat_insp_pan3").click(function() {
		$(this).unbind('click');
		prod_detail_page_insp_load_products($("#prod_list_page_cat_insp_pan3"),"INSP-PAN3");
//alert('unload3');
		prod_detail_page_insp_unload_products($("#prod_list_page_cat_insp_pan2"),"INSP-PAN2");
		prod_detail_page_insp_unload_products($("#prod_list_page_cat_insp_pan1"),"INSP-PAN1");
	});	
}
function ajax_load_srch_product_list( myTotalProducts, myCurrentPage, myTotalPages, myContext, mySearchValue, mySortValue )
{
	var myOffset = 0;
	
	for (var i=0; i<myTotalPages; i++)
	{
		
		var myProductListLoadUrl = "http://shopterrain.com/merchant.mvc?Screen=SRCH_1004_AJAX&Store_Code=ST&sort=" +mySortValue+ "&Search="+mySearchValue+"&offset="+ myOffset;
	
		$.ajax({
			url: myProductListLoadUrl,
			async: false,
			success: function(data) {
				$("#"+myContext+"_dict_helper_hidden").html(data);
				var myCount = $("#"+myContext+"_dict_helper_hidden").children().size();
				$("#"+myContext+"_dict_helper_hidden").html("");
				$("#"+myContext+"_dict_hidden").append(data);
				
				myOffset+=myCount;
			}
		});
	}
	
	loadProdListArrayAndFilterToUniqueCodes( $("#"+myContext+"_dict_hidden").children() );
	
}
function drawTable_srch_product_list( myContext )
{
	var myProductsPerPage = 32;
	var myProductsOffset = 0;
	var myProductsWide = 4;
	var myProductsTableId = 0;
	var myListAll = 0;
	var myShowRank = false;
	var myScreen = "SRCH_1004";
	var mySearch = gup("Search");
	var mySort = gup("sort");

	if (gup("myoffset").length>0) {
		myProductsOffset = parseInt(gup("myoffset"));
	}
	
	var myOutput = "";

	myOutput+= '<img src="/bin-images/headers/header_search1.gif" border="0"><p><br>';

//myOutput += '<p>Our search function is currently under repair. Please check back soon, and thanks for your patience.';
	myOutput+= '<form method="get" name="searchForm" action="http://shopterrain.com/merchant.mvc?"><input type="hidden" name="Store_Code" value="ST"><input type="hidden" name="Screen" value="SRCH_1004"><table border="0" width=750 cellpadding=0 cellspacing=0><tr><td align="left" valign="top"><input type="text" name="Search" value="'+mySearch+'" style="width: 125px;top:0px;border: 1px solid #999999;">&nbsp;&nbsp;<select name="sort" style="width: 125px;top:0px;border: 1px solid #999999;"><option value="" selected>Change Sorting</option>';
	myOutput+= '<option value="name.asc"';
	if (mySort == "name.asc") { myOutput+= " SELECTED "; }
	myOutput+= '>Name A-Z</option>';
	
	myOutput+= '<option value="name.desc"';
	if (mySort == "name.desc") { myOutput+= " SELECTED "; }
	myOutput+= '>Name Z-A</option>';
	
	myOutput+= '<option value="price.asc"';
	if (mySort == "price.asc") { myOutput+= " SELECTED "; }
	myOutput+= '>Price (lowest first)</option>';
	
	myOutput+= '<option value="price.desc"';
	if (mySort == "price.desc") { myOutput+= " SELECTED "; }
	myOutput+= '>Price (highest first)</option>';
	
	myOutput+= '</select>&nbsp;&nbsp;<input type="image" align="absmiddle" src="/bin-images/searchbtn.gif" value="Search"></td><td align="right" valign="top">';
	myOutput+= drawProductsTablePaginationSearch( myProductsOffset, myProductsPerPage, myListAll, myScreen, mySearch );
	myOutput+='</td></tr></table></form>';
	myOutput+= drawProductsTable( myProductsOffset, myProductsPerPage, myShowRank, myProductsWide, myProductsTableId);	
	myOutput+= drawProductsTablePaginationFooter( myProductsOffset, myProductsPerPage, myListAll, myScreen, mySearch );	
		
	$("#"+myContext+"_display").html(myOutput);
	$("#"+myContext+"_display").css("visibility","visible");
}

function prod_detail_page_insp_unload_products( myElement, myCatCode )
{
	if (myCatCode == "INSP-PAN2") {
		newHTML = "<div style=\"position:relative;top:0px;overflow-x:hidden;\" id=\"prod_list_page_cat_insp_pan2\"><img src=\"/bin-images/cat_inspideas_pan2.jpg\" border=\"0\"></div><div id=\"ctgy_product_list_insp_gmom_dict_hidden\" class=\"hiddenAndNoSize\"></div>";
		$("#prod_list_page_cat_insp_pan2").html(newHTML);
		$("#prod_list_page_cat_insp_pan2").css("visibility","visible");
		prod_list_page_cat_insp_pan2_click();
	}

	if (myCatCode == "INSP-PAN3") {
		newHTML = "<div style=\"position:relative;top:0px;overflow-x:hidden;\" id=\"prod_list_page_cat_insp_pan3\"><img src=\"/bin-images/cat_inspideas_pan3.jpg\" border=\"0\"></div><div id=\"ctgy_product_list_insp_rtrv_dict_hidden\" class=\"hiddenAndNoSize\"></div>";
		$("#prod_list_page_cat_insp_pan3").html(newHTML);
		$("#prod_list_page_cat_insp_pan3").css("visibility","visible");
		prod_list_page_cat_insp_pan3_click();
	}
	if (myCatCode == "INSP-PAN1") {
		newHTML = "<div style=\"position:relative;top:0px;overflow-x:hidden;\" id=\"prod_list_page_cat_insp_pan1\"><img src=\"/bin-images/cat_inspideas_pan1.jpg\" border=\"0\"></div><div id=\"ctgy_product_list_insp_gard_dict_hidden\" class=\"hiddenAndNoSize\"></div>";
		$("#prod_list_page_cat_insp_pan1").html(newHTML);
		$("#prod_list_page_cat_insp_pan1").css("visibility","visible");
		prod_list_page_cat_insp_pan1_click();
	}
}

function prod_detail_page_insp_load_products( myElement, myCatCode )
{
	var myProductListLoadUrl = "http://shopterrain.com/merchant.mvc?Screen=CTGY_1004_AJAX&Store_Code="+gup("Store_Code")+"&Category_Code="+myCatCode;

	var myArrayId = 0;

	if (myCatCode.toLowerCase().indexOf("pan1")>-1) { myArrayId=1;}
	else if(myCatCode.toLowerCase().indexOf("pan2")>-1) { myArrayId=2;}
	else if (myCatCode.toLowerCase().indexOf("pan3")>-1) { myArrayId=3;}
	
	$.get(myProductListLoadUrl, function(data) {
		
		var myDict = "#ctgy_product_list_"+myCatCode.toLowerCase().replace("-","_")+"_dict_hidden";
		$(myDict).html(data);
		loadProdListArrayAndFilterToUniqueCodes( $(myDict).children(), myArrayId );
		
		
		var myProductsOffset = 0;
		var myProductsPerPage = 100;
		var myShowRank = false;
		var myProductsWide = 1;
		
		var myOutput = "";
		
		myOutput+= drawProductsTableInsp( myProductsOffset, myProductsPerPage, myShowRank, myProductsWide, myArrayId, myCatCode );
		
		myDict = "#prod_list_page_cat_"+myCatCode.toLowerCase().replace("-","_");
		$(myDict).html(myOutput);
		
		
	});
}
function prod_detail_page_insp()
{	
	var myOutput = "";
	myOutput += "<div style=\"position:relative;\">";
		myOutput += "<div style=\"position:absolute;left:0px;top:0px;overflow-x:hidden;\" id=\"prod_list_page_cat_insp_pan1\"><img src=\"/bin-images/cat_inspideas_pan1.jpg\" border=\"0\"></div>";
		myOutput += "<div style=\"position:absolute;left:246px;top:0px;width:15px;\"></div>";
		myOutput += "<div style=\"position:absolute;left:261px;top:0px;overflow-x:hidden;\" id=\"prod_list_page_cat_insp_pan2\"><img src=\"/bin-images/cat_inspideas_pan2.jpg\" border=\"0\"></div>";
		myOutput += "<div style=\"position:absolute;left:507px;top:0px;width:15px;\"></div>";
		myOutput += "<div style=\"position:absolute;left:522px;top:0px;overflow-x:hidden;\" id=\"prod_list_page_cat_insp_pan3\"><img src=\"/bin-images/cat_inspideas_pan3.jpg\" border=\"0\"></div>";
	myOutput += "</div>";
	
	myOutput += "<div id=\"ctgy_product_list_insp_pan1_dict_hidden\" class=\"hiddenAndNoSize\"></div>";
	myOutput += "<div id=\"ctgy_product_list_insp_pan2_dict_hidden\" class=\"hiddenAndNoSize\"></div>";
	myOutput += "<div id=\"ctgy_product_list_insp_pan3_dict_hidden\" class=\"hiddenAndNoSize\"></div>";
	
	
	
	$("#ctgy_product_list_display").html(myOutput);
	$("#ctgy_product_list_display").css("visibility","visible");
	
	
	prod_list_page_cat_insp_pan1_click();
	prod_list_page_cat_insp_pan2_click();
	prod_list_page_cat_insp_pan3_click();

}
function prod_detail_page_dialog_preview_update_img( myDirection )
{

	var myModifier = 0;
	if (myDirection == "next") {
		myModifer = 1;
	}
	else if (myDirection == "previous") {
		myModifer = -1;
	}
	var myImg = $("#prod_detail_page_large_img");
	var myImgSrc = $(myImg).attr("src");

	var myBaseProductCode = "";
	if (myImgSrc.indexOf("-alt")>-1) {
		myBaseProductCode = getBaseProductCodeAltImage( myImgSrc);
	} else {
		myBaseProductCode = getBaseProductCode( myImgSrc);
	}

	var myBasePath = myImgSrc.substring(0,myImgSrc.indexOf(myBaseProductCode));
	
	var myFoundIndex = -1;
	for (var i = 0; i < gProdCodes_altImages.length; i++)
	{
		if (getBaseProductCodeAltImage(gProdCodes_altImages[i])==myBaseProductCode) {
			myFoundIndex = i; break;
		}
	}
	
	
	if ((myFoundIndex + myModifer) <= (gProdCodes_altImages.length - 1)) {
		myFoundIndex = myFoundIndex + myModifer;
		if (myFoundIndex == "-2") {
			myFoundIndex = gProdCodes_altImages.length - 1;
		}
	} else {
		myFoundIndex = -1;
	}	
		
	var myProposedImgSrc = "";

	if (gProdCodes_altImages[myFoundIndex]!=undefined) {
		myProposedImgSrc = myBasePath+(gProdCodes_altImages[myFoundIndex]).replace("-t.jpg","-l.jpg");
	} else {
		if (gProdCodes_altImages.length > '0') {
			myProposedImgSrc = myBasePath + (getBaseProductCode(gProdCodes_altImages[0]))+"-stndrd-l.jpg";
		} else {
			myProposedImgSrc = myBasePath + (getBaseProductCode(myImgSrc))+"-stndrd-l.jpg";
		}
	}
	
	// APPLY NEW IMAGE
	$(myImg).fadeOut('slow', function () {
		$(myImg).attr("src", myProposedImgSrc);
		$(myImg).fadeIn('slow');
	});
	
}
function prod_detail_page_load_alt_imgs( myBaseProdCode )
{	
//alert('load alt imgs');
	$("#prod_detail_page_alt_imgs").html("");

	var myAltImgs = new Array();
	for (var i = 0; i<10; i++) {
		myAltImgs[i] = myBaseProdCode + "-alt0" + (i + 1) + "-s-t.jpg";
	}
	
	var myUrl_01 = "http://shopterrain.com/bin-images-products/" + myAltImgs[0];
	var myUrl_02 = "http://shopterrain.com/bin-images-products/" + myAltImgs[1];
	var myUrl_03 = "http://shopterrain.com/bin-images-products/" + myAltImgs[2];
	var myUrl_04 = "http://shopterrain.com/bin-images-products/" + myAltImgs[3];
	var myUrl_05 = "http://shopterrain.com/bin-images-products/" + myAltImgs[4];
	var myUrl_06 = "http://shopterrain.com/bin-images-products/" + myAltImgs[5];
	var myUrl_07 = "http://shopterrain.com/bin-images-products/" + myAltImgs[6];
	var myUrl_08 = "http://shopterrain.com/bin-images-products/" + myAltImgs[7];
	var myUrl_09 = "http://shopterrain.com/bin-images-products/" + myAltImgs[8];
	var myUrl_10 = "http://shopterrain.com/bin-images-products/" + myAltImgs[9];


	$.ajax({ url: myUrl_01, type: 'GET', complete: function(transport) { if(transport.status == 200) { prod_detail_page_load_alt_img(myUrl_01); prod_detail_page_save_alt_img(0,myUrl_01); var hasAltImages = "1";} } });
	$.ajax({ url: myUrl_02, type: 'GET', complete: function(transport) { if(transport.status == 200) { prod_detail_page_load_alt_img(myUrl_02); prod_detail_page_save_alt_img(1,myUrl_02);} } });
	$.ajax({ url: myUrl_03, type: 'GET', complete: function(transport) { if(transport.status == 200) { prod_detail_page_load_alt_img(myUrl_03); prod_detail_page_save_alt_img(2,myUrl_03);} } });
	$.ajax({ url: myUrl_04, type: 'GET', complete: function(transport) { if(transport.status == 200) { prod_detail_page_load_alt_img(myUrl_04); prod_detail_page_save_alt_img(3,myUrl_04);} } });
	$.ajax({ url: myUrl_05, type: 'GET', complete: function(transport) { if(transport.status == 200) { prod_detail_page_load_alt_img(myUrl_05); prod_detail_page_save_alt_img(4,myUrl_05);} } });	
	$.ajax({ url: myUrl_06, type: 'GET', complete: function(transport) { if(transport.status == 200) { prod_detail_page_load_alt_img(myUrl_06); prod_detail_page_save_alt_img(5,myUrl_06);} } });	
	$.ajax({ url: myUrl_07, type: 'GET', complete: function(transport) { if(transport.status == 200) { prod_detail_page_load_alt_img(myUrl_07); prod_detail_page_save_alt_img(6,myUrl_07);} } });	
	$.ajax({ url: myUrl_08, type: 'GET', complete: function(transport) { if(transport.status == 200) { prod_detail_page_load_alt_img(myUrl_08); prod_detail_page_save_alt_img(7,myUrl_08);} } });	
	$.ajax({ url: myUrl_09, type: 'GET', complete: function(transport) { if(transport.status == 200) { prod_detail_page_load_alt_img(myUrl_09); prod_detail_page_save_alt_img(8,myUrl_09);} } });	
	$.ajax({ url: myUrl_10, type: 'GET', complete: function(transport) { if(transport.status == 200) { prod_detail_page_load_alt_img(myUrl_10); prod_detail_page_save_alt_img(9,myUrl_10);} } });	
	
}
function prod_detail_page_save_alt_img(myIndex, myUrl)
{
//alert('save alt imgs');

	var mySplitUrl = myUrl.split("/");
	var myFileName = mySplitUrl[mySplitUrl.length-1];

	gProdCodes_altImages[myIndex] = myFileName;
}
function prod_detail_page_load_alt_img(myUrl)
{
//alert('load alt img - single');
	var hasAltImages = "1";

	var myAltId = myUrl.substring(myUrl.indexOf("-alt")+4,myUrl.indexOf("-alt")+6);
	var myId = "prod_detail_page_alt_img_" + myAltId;

	var myHTML = "<div style=\"width:210px;\"><img id=\""+myId+"\" src=\""+myUrl+"\" onmouseover=\"this.style.cursor='pointer';\"></div>";
		myHTML+= "<div style=\"width:210px;height:10px;\"></div>"
	
	$("#prod_detail_page_alt_imgs").append(myHTML);
	
	$("#"+myId).click(function(){
			var myImgSrc = $(this).attr("src");
			myImgSrc = myImgSrc.replace("-t.jpg","-m.jpg");

//			$("#prod_detail_page_medium_img").fadeOut('slow', function () {
//alert('changing main image ' + myId);	
//comment out below two lines if you don't want to change med image
//				$("#prod_detail_page_medium_img").attr("src", myImgSrc);
//				$("#prod_detail_page_medium_img").fadeIn('slow');
//			});
dialog_modal_large_preview(myImgSrc, 'altImage');


	});
}
function prod_detail_page_setupPreviousNextLinks( myProdCode )
{
//alert('set up links');
	var myIndex = getIndexFrom_gProdCodes(myProdCode);
	
	var myPrevLink = "";
	var myNextLink = "";
	
	if ((myIndex+1)>=0 && (myIndex+1)<gProdCodes.length)
	{
		myNextLink = "http://shopterrain.com/merchant.mvc?Screen=PROD&Store_Code="+gup("Store_Code")+"&Product_Code="+gProdCodes[myIndex+1]+"&Category_Code="+gup("Category_Code");
		if (gup("mySearch").length > 0) {
			myNextLink = "http://shopterrain.com/merchant.mvc?Screen=PROD&Store_Code="+gup("Store_Code")+"&Product_Code="+gProdCodes[myIndex+1];
			myNextLink+= "&mySearch="+gup("mySearch");
			myNextLink+= "&mySearchTtlPrds="+gup("mySearchTtlPrds");
			myNextLink+= "&mySearchCrrntPg="+gup("mySearchCrrntPg");
			myNextLink+= "&mySearchTtlPgs="+gup("mySearchTtlPgs");
		}
		$("#prod_detail_page_next").click(function() {
			window.location = myNextLink;
		});
	} else{
		$("#prod_detail_page_next").html("");
	}
	if ((myIndex-1)>=0 && (myIndex-1)<gProdCodes.length)
	{
		myPrevLink = "http://shopterrain.com/merchant.mvc?Screen=PROD&Store_Code="+gup("Store_Code")+"&Product_Code="+gProdCodes[myIndex-1]+"&Category_Code="+gup("Category_Code");
		if (gup("mySearch").length > 0) {
			myPrevLink = "http://shopterrain.com/merchant.mvc?Screen=PROD&Store_Code="+gup("Store_Code")+"&Product_Code="+gProdCodes[myIndex-1];
			myPrevLink+= "&mySearch="+gup("mySearch");
			myPrevLink+= "&mySearchTtlPrds="+gup("mySearchTtlPrds");
			myPrevLink+= "&mySearchCrrntPg="+gup("mySearchCrrntPg");
			myPrevLink+= "&mySearchTtlPgs="+gup("mySearchTtlPgs");
		}
		$("#prod_detail_page_previous").click(function() {
			window.location = myPrevLink;
		});
	} else {
		$("#prod_detail_page_previous").html("");
	}
	
	// BEGIN UPDATE RANK DISPLAY ON PAGE
	if (gup("Category_Code").length > 0) {
		var myRankAsText = "00000" + (myIndex+1).toString();
	    myRankAsText = myRankAsText.substring(myRankAsText.length-3,myRankAsText.length);
		$("#prod_detail_page_rank").html(myRankAsText);
	}
	
}
function loadProdListArrayAndFilterToUniqueCodes( myKids, myId )
{
	var myUniqCntr = 0;
	var myUniqueProductStringList = "";
	
	if (myId==undefined) { myId = 0;}
		
		
	// BUILD ARRAY OF EXCLUDABLE PRODUCT CODES
	var excludeProdCodes = [];
	var ePC_counter = 0;
	$(".prod_list_attr_item_exclude_me").each(function() {
		
		var myCodeSuffix = $(this).text();
		var myParentCode = $(this).parent();
			myParentCode = $(myParentCode).parent();
			myParentCode = $(myParentCode).children();
			myParentCode = $(myParentCode).get(1);
			myParentCode = $(myParentCode).text();
			
		var itemCodeToExclude = getBaseProductCode2Dashes(myParentCode) + "-" + myCodeSuffix;

		excludeProdCodes[ePC_counter] = itemCodeToExclude;
		ePC_counter++;
	});
	
	// REMOVE PRODUCT CODES THAT ARE IN THE EXCLUDE LIST ARRAY
	for (var d = 0; d < myKids.length; d++) {
		var myProdCode = $($(myKids[d]).children().get(1)).text();

		for (var m=0; m<excludeProdCodes.length; m++) {
			if (myProdCode.indexOf(excludeProdCodes[m])==0) {
				$(myKids[d]).html("");
				continue;
			}
		}
	}	
		

	// POPULATE PRODUCT ARRAY
	for (var i = 0; i < myKids.length; i++) {
		
		var myProdCode = $($(myKids[i]).children().get(1)).text();	
		
		var myUniqueProdCodeArray = myProdCode.split("-");
		
		if (myUniqueProdCodeArray.length >= 3) {
			var myUniqCode = myUniqueProdCodeArray[0] + "-" + myUniqueProdCodeArray[1] + "-" + myUniqueProdCodeArray[2];

			if (myUniqueProductStringList.indexOf(myUniqCode) == -1) {
				
				var myProdName = $($(myKids[i]).children().get(0)).html();
				var myHREF = $($(myKids[i]).children().get(2)).html();
				var myPrice = $($(myKids[i]).children().get(4)).html();
				if (myPrice) {
					priceArray = myPrice.split(".");
					if (priceArray[1] == "00") {
						myPrice = priceArray[0];
					} 
				} else {
					myPrice = "";
				}
				
				if (gup("Search").length > 0) {
					myHREF += "&mySearch=" + gup("Search")
					myHREF += "&mySearchTtlPrds=" + $($("#srch_ctgy_product_list_info").children().get(0)).text();
					myHREF += "&mySearchCrrntPg=" + $($("#srch_ctgy_product_list_info").children().get(1)).text();
					myHREF += "&mySearchTtlPgs=" + $($("#srch_ctgy_product_list_info").children().get(2)).text();
				}

				if (myId == 0) {

					gProdNames[myUniqCntr] = myProdName;
					gProdCodes[myUniqCntr] = myProdCode;
					gProdLinks[myUniqCntr] = myHREF;
					gProdPrices[myUniqCntr] = myPrice;
				}
				else 

					if (myId >= 1) {
						eval("gProdNames_" + myId + "[myUniqCntr] = myProdName");
						eval("gProdCodes_" + myId + "[myUniqCntr] = myProdCode");
						eval("gProdLinks_" + myId + "[myUniqCntr] = myHREF");
						eval("gProdPrices_" + myId + "[myUniqCntr] = myPrice");
					}
				
				
				myUniqueProductStringList += myUniqCode + ";";
				myUniqCntr++;
			} // end if
			
		} // end if
	} // end for i

}

function getIndexFrom_gProdCodes( myPCode )
{
	var myReturnValue = -1;
	for (var i=0; i<gProdCodes.length; i++)
	{
		if (gProdCodes[i]==myPCode) {
			myReturnValue = i;
			break;
		}
	}
	
	return (myReturnValue);
}

function drawProductsTable( myProductsOffset, myProductsPerPage, myShowRank, myProductsWide, myProductsTableId )
{
var myCategory_Code = gup("Category_Code");
var myScreen = gup("Screen");
if (myScreen == "SRCH_1004") {
	myCategory_Code = "SEARCH";
}
	//////////////////////////////////////////////////////////////////////////////
	// DRAW TABLE
	//////////////////////////////////////////////////////////////////////////////
	var myOutput = "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
	
	var myTotalWide = myProductsWide;
	var myTotalWideCntr = 0;
	var myRankCount = myProductsOffset;
	var myRowCounter = 0;
	
	var myCntr = 0;
	
	var myMaxRecords = 0;
	
	var myProdNames = "";
	var myProdCodes = "";
	var myProdLinks = "";
	var myProdPrices = "";
	
	if (myProductsTableId == undefined) {
		myProductsTableId=0;
	}
	if (myProductsTableId>=1)
	{
		myProdNames = "gProdNames_"+myProductsTableId;
		myProdCodes = "gProdCodes_"+myProductsTableId;
		myProdLinks = "gProdLinks_"+myProductsTableId;
		myProdPrices = "gProdPrices_"+myProductsTableId;
	}
	else
	{
		myProdNames = "gProdNames";
		myProdCodes = "gProdCodes";
		myProdLinks = "gProdLinks";
		myProdPrices = "gProdPrices";
	}

	//get total rows
	totalRows = "";
	totalProducts = eval(myProdNames+".length");
	totalRows = Math.ceil(totalProducts/4);

	for (var i=myProductsOffset; i<eval(myProdNames+".length"); i++)
	{
		myRankCount++;
		myTotalWideCntr++;
		myCntr++;
		
		if (myTotalWideCntr==1) { myOutput+="<tr>"; myRowCounter++;}
		myOutput+="<td style=\"width: 178px;height: 188px;\">";
	
		
		var myRankAsText = "00000" + myRankCount.toString();
		    myRankAsText = myRankAsText.substring(myRankAsText.length-3,myRankAsText.length);
		
		var productPrice = eval(myProdPrices+"[i]");
		
		nameLower = eval(myProdNames+"[i]");
		myOutput+="<div style=\"position: relative;width: 178px;height: 206px;\">";
			myOutput+="<div style=\"position: absolute;left: 0px;top: 0px;width: 178px;height: 178px;\">";
			myOutput+="<a href=\""+eval(myProdLinks+"[i]")+"\">";
			myOutput+="<img src=\"/bin-images-products/"+eval(myProdCodes+"[i]")+"-stndrd-t.jpg\" border=\"0\" style=\"width: 178px; height: 178px;\">";
			myOutput+="</a>";
			myOutput+="</div>";
			myOutput+="<div style=\"position: absolute;left: 0px;top: 178px;width: 178px;height: 28px;\"><img src=\"/bin-images/bg_paper/paper_thumbnail_bottom.jpg\" border=\"0\"></div>";
			myOutput+="<div style=\"position: absolute; top: 183px;width: 173px;height: 10px; text-align: right; \">";
			myOutput+="<table cellpadding=0 cellspacing=0 width=135 align=right style=\"line-height:90%; text-align: right;\"><tr><td><span class=\"prod_list_page_prodname\">";
			myOutput+= nameLower.toLowerCase();
			myOutput+= "</span></td></tr></table>";
			myOutput+="</span></div>";
			
			if (myShowRank==true) {
				myOutput+="<div style=\"position: absolute;left: 5px;top: 183px;width: 173px;height: 10px;text-align: left;\"><span class=\"prod_list_page_rank\">";
				myOutput+=myRankAsText;
				myOutput+="</span></div>";
			} else {
				myOutput+="<div style=\"position: absolute;left: 5px;top: 183px;width: 173px;height: 10px;text-align: left;\"><span class=\"prod_list_page_prodprice\">";
				myOutput+=productPrice;
				myOutput+="</span></div>";
			}
			
		myOutput+="</div>";
		
		myOutput+="</td>";
		
		if (myTotalWideCntr<myTotalWide) {
			myOutput+="<td style=\"width: 15px;height: 188px;\"><div style=\"width: 15px;height: 188px;\"></div></td>";

			if ((i+1) == totalProducts) {
				if (totalRows <= '2' && myRowCounter == totalRows && myProductsOffset==0) {
					myOutput+="</tr>"; 				
					myOutput+="<tr><td colspan=\""+((myTotalWide*2)-1)+"\" style=\"height:15px;\"><div style=\"height:15px;\"></div></td></tr>";			
					myOutput+="<tr><td colspan=\""+((myTotalWide*2)-1)+"\"><div style=\"position: relative;width: 757px;height: 175px;\"><img src=\"/bin-images-categories/"+ myCategory_Code+".jpg\" border=\"0\" style=\"width: 757px; height: 175px;\"></div></td></tr>";			
					myOutput+="<tr><td colspan=\""+((myTotalWide*2)-1)+"\" style=\"height:15px;\"><div style=\"height:15px;\"></div></td></tr>";					
				}
			}
		}
	
		if (myTotalWideCntr==myTotalWide)
		{
			myOutput+="</tr>"; 
			myTotalWideCntr=0;

			myOutput+="<tr><td colspan=\""+((myTotalWide*2)-1)+"\" style=\"height:15px;\"><div style=\"height:15px;\"></div></td></tr>";
			if ((myRowCounter==2 && myProductsOffset==0) || (totalRows <= '2' && myRowCounter == totalRows && myProductsOffset==0)) {
				//alert('second case ' + totalRows);
				myOutput+="<tr><td colspan=\""+((myTotalWide*2)-1)+"\"><div style=\"position: relative;width: 757px;height: 175px;\"><img src=\"/bin-images-categories/"+ myCategory_Code+".jpg\" border=\"0\" style=\"width: 757px; height: 175px;\"></div></td></tr>";	
				myOutput+="<tr><td colspan=\""+((myTotalWide*2)-1)+"\" style=\"height:15px;\"><div style=\"height:15px;\"></div></td></tr>";					
			}	
		}
		
		if (myCntr==myProductsPerPage) { break; }
	}
	
	myOutput+="</table>";
	if(totalProducts == "0") {
		myOutput="<span class=\"prod_detail_page_description\">We're sorry, no products matched your search criteria.  Please use the search field above to try again.</span><p><br>";
	}
	return (myOutput);
}

function drawProductsTableInsp( myProductsOffset, myProductsPerPage, myShowRank, myProductsWide, myProductsTableId )
{
var myCategory_Code = gup("Category_Code");
var myScreen = gup("Screen");
var imageName = "";

	if (myProductsTableId == "1") {
		imageName = "insp_pan1.gif";
	} else if (myProductsTableId == "2") {
		imageName = "insp_pan2.gif";
	} else if (myProductsTableId == "3") {
		imageName = "insp_pan3.gif";
	}

	//////////////////////////////////////////////////////////////////////////////
	// DRAW TABLE
	//////////////////////////////////////////////////////////////////////////////
	var myOutput = "<div style=\"align:center; text-align:center; background-image:url('/bin-images/bg_paper/InspIdeaspaperbkg.jpg');width:246px;\"><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=246>";
	myOutput += "<br><div style=\"align:center; text-align:center;\"><img src=\"/bin-images/"+imageName+"\"></div><p>";
	
	var myTotalWide = myProductsWide;
	var myTotalWideCntr = 0;
	var myRankCount = myProductsOffset;
	var myRowCounter = 0;
	
	var myCntr = 0;
	
	var myMaxRecords = 0;
	
	var myProdNames = "";
	var myProdCodes = "";
	var myProdLinks = "";
	var myProdPrices = "";
	
	if (myProductsTableId == undefined) {
		myProductsTableId=0;
	}
	if (myProductsTableId>=1)
	{
		myProdNames = "gProdNames_"+myProductsTableId;
		myProdCodes = "gProdCodes_"+myProductsTableId;
		myProdLinks = "gProdLinks_"+myProductsTableId;
		myProdPrices = "gProdPrices_"+myProductsTableId;
	}
	else
	{
		myProdNames = "gProdNames";
		myProdCodes = "gProdCodes";
		myProdLinks = "gProdLinks";
		myProdPrices = "gProdPrices";
	}

	//get total rows
	totalRows = "";
	totalProducts = eval(myProdNames+".length");
	totalRows = Math.ceil(totalProducts/1);

	for (var i=myProductsOffset; i<eval(myProdNames+".length"); i++)
	{
		myRankCount++;
		myTotalWideCntr++;
		myCntr++;
		
		if (myTotalWideCntr==1) { myOutput+="<tr>"; myRowCounter++;}
		myOutput+="<td style=\"width: 178px;height: 188px;\">";
	
		
		var myRankAsText = "00000" + myRankCount.toString();
		    myRankAsText = myRankAsText.substring(myRankAsText.length-3,myRankAsText.length);
		
		var productPrice = eval(myProdPrices+"[i]");
		
		nameLower = eval(myProdNames+"[i]");
		myOutput+="<div style=\"position: relative;width: 178px;height: 206px;\">";
			myOutput+="<div style=\"position: absolute;left: 34px;top: 0px;width: 178px;height: 178px;\">";
			myOutput+="<a href=\""+eval(myProdLinks+"[i]")+"\">";
			myOutput+="<img src=\"/bin-images-products/"+eval(myProdCodes+"[i]")+"-stndrd-t.jpg\" border=\"0\" style=\"width: 178px; height: 178px;\">";
			myOutput+="</a>";
			myOutput+="</div>";
			myOutput+="<div style=\"position: absolute;left: 34px;top: 178px;width: 178px;height: 28px;\"><img src=\"/bin-images/bg_paper/paper_thumbnail_bottom.jpg\" border=\"0\"></div>";
			myOutput+="<div style=\"position: absolute; left: 34px;top: 183px;width: 173px;height: 10px; text-align: right; \">";
			myOutput+="<table cellpadding=0 cellspacing=0 width=135 align=right style=\"line-height:90%; text-align: right;\"><tr><td><span class=\"prod_list_page_prodname\">";
			myOutput+= nameLower.toLowerCase();
			myOutput+= "</span></td></tr></table>";
			myOutput+="</div>";
			
			if (myShowRank==true) {
				myOutput+="<div style=\"position: absolute;left: 39px;top: 183px;width: 173px;height: 10px;text-align: left;\"><span class=\"prod_list_page_rank\">";
				myOutput+=myRankAsText;
				myOutput+="</span></div>";
			} else {
				myOutput+="<div style=\"position: absolute;left: 39px;top: 183px;width: 173px;height: 10px;text-align: left;\"><span class=\"prod_list_page_prodprice\">";
				myOutput+=productPrice;
				myOutput+="</span></div>";
			}
			
		myOutput+="</div>";
		
		myOutput+="</td>";
		
		if (myTotalWideCntr<myTotalWide) {
			myOutput+="<td style=\"width: 15px;height: 188px;\"><div style=\"width: 15px;height: 188px;\"></div></td>";

			if ((i+1) == totalProducts) {
				if (totalRows <= '2' && myRowCounter == totalRows && myProductsOffset==0) {
					myOutput+="</tr>"; 				
					myOutput+="<tr><td colspan=\""+((myTotalWide*2)-1)+"\" style=\"height:15px;\"><div style=\"height:15px;\"></div></td></tr>";			
					myOutput+="<tr><td colspan=\""+((myTotalWide*2)-1)+"\"><div style=\"position: relative;width: 757px;height: 175px;\"><img src=\"/bin-images-categories/"+ myCategory_Code+".jpg\" border=\"0\" style=\"width: 757px; height: 175px;\"></div></td></tr>";			
					myOutput+="<tr><td colspan=\""+((myTotalWide*2)-1)+"\" style=\"height:15px;\"><div style=\"height:15px;\"></div></td></tr>";					
				}
			}
		}
	
		if (myTotalWideCntr==myTotalWide)
		{
			myOutput+="</tr>"; 
			myTotalWideCntr=0;

			myOutput+="<tr><td colspan=\""+((myTotalWide*2)-1)+"\" style=\"height:15px;\"><div style=\"height:15px;\"></div></td></tr>";
		}
		
		if (myCntr==myProductsPerPage) { break; }
	}
	
	myOutput+="</table><br></div>";
	if(totalProducts == "0") {
		myOutput="<div style=\"align:center; text-align:center; background-image:url('/bin-images/bg_paper/InspIdeaspaperbkg.jpg');width:246px;\"><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=246><br><div style=\"align:center; text-align:center;\"><img src=\"/bin-images/"+imageName+"\"></div><p><span class=\"prod_detail_page_description\">We're sorry, no products matched your search criteria.  Please use the search field above to try again.</span><p><br>";
	}
	//alert(myOutput);
	return (myOutput);
}

function drawProductsTablePaginationSearch( myProductsOffset, myProductsPerPage, myListAll, myScreen, mySearch )
{
	var myOutput = "";
	
	//////////////////////////////////////////////////////////////////////////////
	// FOOTER PAGINATION
	//////////////////////////////////////////////////////////////////////////////
	
	if (myListAll==0)
	{
		var pageTotal = parseInt( Math.ceil( (gProdNames.length/myProductsPerPage) ) );
		var myCatCode = $("#mvt_category_code").text();
		var myCurrentPageSet = 0;
		
		myOutput+="<div>";
		
		
		if((myProductsOffset-myProductsPerPage) >= 0) {
			myOutput+="<a href=\"http://shopterrain.com/merchant.mvc?Screen="+myScreen+"&Store_Code=ST";
			if (myScreen.indexOf("CTGY")==0) {
				myOutput+="&Category_Code="+myCatCode;
			}
			if (myScreen.indexOf("SRCH")==0) {
				myOutput+="&Search="+mySearch;
			}
			myOutput+="&sort=&myoffset=" + (myProductsOffset-myProductsPerPage)+"\" class=\"productPaginationFtr\"><</a>&nbsp";
			//myOutput+="|&nbsp";
		}
		
		for (var k=0; k<pageTotal; k++)
		{
			var myLinkyText = (k+1).toString();
			if (myProductsOffset==(k*myProductsPerPage)) { myCurrentPageSet=k; myLinkyText="<font color=red>"+myLinkyText+"</font>"; }
			
			var myLinky = "http://shopterrain.com/merchant.mvc?Screen="+myScreen+"&Store_Code=ST";
			if (myScreen.indexOf("CTGY")==0) {
				myLinky+="&Category_Code="+myCatCode;
			}
			if (myScreen.indexOf("SRCH")==0) {
				myLinky+="&Search="+mySearch;
			}
			myLinky+="&sort=&myoffset=" + (k*myProductsPerPage);
			myOutput+="<a href=\""+myLinky+"\" class=\"productPaginationFtr\">"+myLinkyText+"</a>&nbsp;";
			
			if ((k+1) < pageTotal) {
				myOutput += "|&nbsp;";
			}
		}
	
		//myOutput+="|&nbsp";
		// NEXT
		
		if((myProductsOffset+myProductsPerPage) <= gProdNames.length) {
			myOutput+="<a href=\"http://shopterrain.com/merchant.mvc?Screen="+myScreen+"&Store_Code=ST";
			if (myScreen.indexOf("CTGY")==0) {
				myOutput+="&Category_Code="+myCatCode;
			}
			if (myScreen.indexOf("SRCH")==0) {
				myOutput+="&Search="+mySearch;
			}
			myOutput+="&sort=&myoffset=" + (myProductsOffset+myProductsPerPage) +"\" class=\"productPaginationFtr\">></a>&nbsp";
			//myOutput+="|&nbsp";
		}
		// VIEW ALL
		//myOutput+="<a href=\"http://shopterrain.com/merchant.mvc?Screen="+myScreen+"&Store_Code=ST";
		//if (myScreen.indexOf("CTGY")==0) {
		//	myOutput+="&Category_Code="+myCatCode;
		//}
		//if (myScreen.indexOf("SRCH")==0) {
		//	myOutput+="&Search="+mySearch;
		//}
		//myOutput+="&sort=&mylist_all=1\" class=\"productPaginationFtr\">&nbsp;(View All)</a>";
		myOutput+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>";
	}
	//alert(myOutput);
	return (myOutput);
}

function drawProductsTablePaginationHeader( myProductsOffset, myProductsPerPage, myListAll, myScreen, mySearch )
{
	var myOutput = "";
	
	//////////////////////////////////////////////////////////////////////////////
	// FOOTER PAGINATION
	//////////////////////////////////////////////////////////////////////////////
	
	if (myListAll==0)
	{
		var pageTotal = parseInt( Math.ceil( (gProdNames.length/myProductsPerPage) ) );
		var myCatCode = $("#mvt_category_code").text();
		var myCurrentPageSet = 0;
		
		myOutput+="<div style=\"background-image: url('http://www.shopterrain.com/bin-images/bg_paper/paper_pagination.gif');background-repeat: no-repeat; height:44px; text-align: right; \"><img src='images/blank.gif' width=757 height=10><br>";
		
		
		if((myProductsOffset-myProductsPerPage) >= 0) {
			myOutput+="<a href=\"http://shopterrain.com/merchant.mvc?Screen="+myScreen+"&Store_Code=ST";
			if (myScreen.indexOf("CTGY")==0) {
				myOutput+="&Category_Code="+myCatCode;
			}
			if (myScreen.indexOf("SRCH")==0) {
				myOutput+="&Search="+mySearch;
			}
			myOutput+="&sort=&myoffset=" + (myProductsOffset-myProductsPerPage)+"\" class=\"productPaginationFtr\"><</a>&nbsp";
			//myOutput+="|&nbsp";
		}
		
		for (var k=0; k<pageTotal; k++)
		{
			var myLinkyText = (k+1).toString();
			if (myProductsOffset==(k*myProductsPerPage)) { myCurrentPageSet=k; myLinkyText="<font color=red>"+myLinkyText+"</font>"; }
			
			var myLinky = "http://shopterrain.com/merchant.mvc?Screen="+myScreen+"&Store_Code=ST";
			if (myScreen.indexOf("CTGY")==0) {
				myLinky+="&Category_Code="+myCatCode;
			}
			if (myScreen.indexOf("SRCH")==0) {
				myLinky+="&Search="+mySearch;
			}
			myLinky+="&sort=&myoffset=" + (k*myProductsPerPage);
			myOutput+="<a href=\""+myLinky+"\" class=\"productPaginationFtr\">"+myLinkyText+"</a>&nbsp;";
			
			if ((k+1) < pageTotal) {
				myOutput += "|&nbsp;";
			}
		}
	
		//myOutput+="|&nbsp";
		// NEXT
		
		if((myProductsOffset+myProductsPerPage) <= gProdNames.length) {
			myOutput+="<a href=\"http://shopterrain.com/merchant.mvc?Screen="+myScreen+"&Store_Code=ST";
			if (myScreen.indexOf("CTGY")==0) {
				myOutput+="&Category_Code="+myCatCode;
			}
			if (myScreen.indexOf("SRCH")==0) {
				myOutput+="&Search="+mySearch;
			}
			myOutput+="&sort=&myoffset=" + (myProductsOffset+myProductsPerPage) +"\" class=\"productPaginationFtr\">></a>&nbsp";
			//myOutput+="|&nbsp";
		}


if (myCatCode != "HOUS" && myCatCode != "GARD" && myCatCode != "WELL" && myCatCode != "ARTI" && myCatCode != "GIFS" && myCatCode != "SALE" && myCatCode != "SEAS") {
		// VIEW ALL
		myOutput+="<a href=\"http://shopterrain.com/merchant.mvc?Screen="+myScreen+"&Store_Code=ST";		
		if (myScreen.indexOf("CTGY")==0) {
			myOutput+="&Category_Code="+myCatCode;
		}
		if (myScreen.indexOf("SRCH")==0) {
			myOutput+="&Search="+mySearch;
		}
		myOutput+="&sort=&mylist_all=1\" class=\"productPaginationFtr\">&nbsp;View All</a>";
}

		// VIEW ALL
		//myOutput+="<a href=\"http://shopterrain.com/merchant.mvc?Screen="+myScreen+"&Store_Code=ST";
		//if (myScreen.indexOf("CTGY")==0) {
		//	myOutput+="&Category_Code="+myCatCode;
		//}
		//if (myScreen.indexOf("SRCH")==0) {
		//	myOutput+="&Search="+mySearch;
		//}
		//myOutput+="&sort=&mylist_all=1\" class=\"productPaginationFtr\">&nbsp;(View All)</a>";
		myOutput+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>";
	}
	//alert(myOutput);
	return (myOutput);
}

function drawProductsTablePaginationFooter( myProductsOffset, myProductsPerPage, myListAll, myScreen, mySearch )
{
	var myOutput = "";
	
	//////////////////////////////////////////////////////////////////////////////
	// FOOTER PAGINATION
	//////////////////////////////////////////////////////////////////////////////
	
	if (myListAll==0)
	{
		var pageTotal = parseInt( Math.ceil( (gProdNames.length/myProductsPerPage) ) );
		var myCatCode = $("#mvt_category_code").text();
		var myCurrentPageSet = 0;
		
		myOutput+="<p style=\"background-image: url('http://www.shopterrain.com/bin-images/bg_paper/paper_pagination.gif');background-repeat: no-repeat; height:37px; text-align: right; \"><img src='images/blank.gif' width=757 height=10><br>";
		
		
		if((myProductsOffset-myProductsPerPage) >= 0) {
			myOutput+="<a href=\"http://shopterrain.com/merchant.mvc?Screen="+myScreen+"&Store_Code=ST";
			if (myScreen.indexOf("CTGY")==0) {
				myOutput+="&Category_Code="+myCatCode;
			}
			if (myScreen.indexOf("SRCH")==0) {
				myOutput+="&Search="+mySearch;
			}
			myOutput+="&sort=&myoffset=" + (myProductsOffset-myProductsPerPage)+"\" class=\"productPaginationFtr\"><</a>&nbsp";
			//myOutput+="|&nbsp";
		}
		
		for (var k=0; k<pageTotal; k++)
		{
			var myLinkyText = (k+1).toString();
			if (myProductsOffset==(k*myProductsPerPage)) { myCurrentPageSet=k; myLinkyText="<font color=red>"+myLinkyText+"</font>"; }
			
			var myLinky = "http://shopterrain.com/merchant.mvc?Screen="+myScreen+"&Store_Code=ST";
			if (myScreen.indexOf("CTGY")==0) {
				myLinky+="&Category_Code="+myCatCode;
			}
			if (myScreen.indexOf("SRCH")==0) {
				myLinky+="&Search="+mySearch;
			}
			myLinky+="&sort=&myoffset=" + (k*myProductsPerPage);
			myOutput+="<a href=\""+myLinky+"\" class=\"productPaginationFtr\">"+myLinkyText+"</a>&nbsp;";
			
			if ((k+1) < pageTotal) {
				myOutput += "|&nbsp;";
			}
		}
	
		//myOutput+="|&nbsp";
		// NEXT
		
		if((myProductsOffset+myProductsPerPage) <= gProdNames.length) {
			myOutput+="<a href=\"http://shopterrain.com/merchant.mvc?Screen="+myScreen+"&Store_Code=ST";
			if (myScreen.indexOf("CTGY")==0) {
				myOutput+="&Category_Code="+myCatCode;
			}
			if (myScreen.indexOf("SRCH")==0) {
				myOutput+="&Search="+mySearch;
			}
			myOutput+="&sort=&myoffset=" + (myProductsOffset+myProductsPerPage) +"\" class=\"productPaginationFtr\">></a>&nbsp";
			//myOutput+="|&nbsp";
		}

if (myCatCode != "HOUS" && myCatCode != "GARD" && myCatCode != "WELL" && myCatCode != "ARTI" && myCatCode != "GIFS" && myCatCode != "SALE" && myCatCode != "SEAS") {
		// VIEW ALL
		myOutput+="<a href=\"http://shopterrain.com/merchant.mvc?Screen="+myScreen+"&Store_Code=ST";		
		if (myScreen.indexOf("CTGY")==0) {
			myOutput+="&Category_Code="+myCatCode;
		}
		if (myScreen.indexOf("SRCH")==0) {
			myOutput+="&Search="+mySearch;
		}
		myOutput+="&sort=&mylist_all=1\" class=\"productPaginationFtr\">&nbsp;View All</a>";
}
		myOutput+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>";
	}
	return (myOutput);
}
function accordion( myActiveOption )
{
	$("#accordion").accordion({
		collapsible: true,
		active: myActiveOption,
		autoHeight: false,
		icons: false,
		event: false
	});
	
	$('#accordion_cat_garden').click(function(ev,ui) {
		ev.preventDefault();
		$("#accordion").accordion( "option", "active", 0 );
		searchClicked = "0";
		window.location = "http://shopterrain.com/merchant.mvc?Screen=CTGY_1004&Store_Code=ST&Category_Code=GARD";
	});

	$('#accordion_cat_househome').click(function(ev,ui) {
		ev.preventDefault();
		$("#accordion").accordion( "option", "active", 1 );
		searchClicked = "0";
		window.location = "http://shopterrain.com/merchant.mvc?Screen=CTGY_1004&Store_Code=ST&Category_Code=HOUS";
	});
	
	$('#accordion_cat_wellness').click(function(ev,ui) {
		ev.preventDefault();
		$("#accordion").accordion( "option", "active", 2 );
		searchClicked = "0";
		window.location = "http://shopterrain.com/merchant.mvc?Screen=CTGY_1004&Store_Code=ST&Category_Code=WELL";
	});
	
	$('#accordion_cat_vintage').click(function(ev,ui) {
		ev.preventDefault();
		$("#accordion").accordion( "option", "active", 3 );
		searchClicked = "0";
		window.location = "http://shopterrain.com/merchant.mvc?Screen=CTGY_1004&Store_Code=ST&Category_Code=ARTI";
	});
	
	$('#accordion_cat_seasons').click(function(ev,ui) {
		ev.preventDefault();
		$("#accordion").accordion( "option", "active", 4 );
		searchClicked = "0";
		window.location = "http://shopterrain.com/merchant.mvc?Screen=CTGY_1004&Store_Code=ST&Category_Code=SEAS";
	});
	
	$('#accordion_cat_gifts').click(function(ev,ui) {
		ev.preventDefault();
		$("#accordion").accordion( "option", "active", 5 );
		searchClicked = "0";
		window.location = "http://shopterrain.com/merchant.mvc?Screen=CTGY_1004&Store_Code=ST&Category_Code=GIFS";
	});
	
	$('#accordion_cat_sale').click(function(ev,ui) {
		ev.preventDefault();
		$("#accordion").accordion( "option", "active", 6 );
		searchClicked = "0";
		window.location = "http://shopterrain.com/merchant.mvc?Screen=CTGY_1004&Store_Code=ST&Category_Code=SALE";
	});
	
	$('#accordion_cat_dotdotdot').click(function(ev,ui) {
		ev.preventDefault();
		searchClicked = "0";
	});
	
	$('#accordion_cat_search').click(function(ev,ui) {
		ev.preventDefault();
		$("#accordion").accordion( "option", "active", 8 );
		document.getElementById('garden').src="/bin-images/sidebar/cat_garden_0.gif";
		document.getElementById('house').src="/bin-images/sidebar/cat_househome_0.gif";
		document.getElementById('wellness').src="/bin-images/sidebar/cat_wellness_0.gif";
		document.getElementById('vintage').src="/bin-images/sidebar/cat_vintage_0.gif";
		document.getElementById('seasons').src="/bin-images/sidebar/cat_seasons_0.gif";
		document.getElementById('gifts').src="/bin-images/sidebar/cat_gifts_0.gif";
		document.getElementById('sale').src="/bin-images/sidebar/cat_sale_0.gif";
		document.getElementById('search').src="/bin-images/sidebar/cat_search_0.gif";
		document.getElementById('inspiration').src="/bin-images/sidebar/cat_inspiration_0.gif";
		document.getElementById('giftcard').src="/bin-images/sidebar/cat_giftcard_0.gif";
		document.getElementById('search').src="/bin-images/sidebar/cat_search_1.gif";
		searchClicked = "1";
//		alert(searchClicked + ' searchnow');
	});
	
	$('#accordion_cat_inspiration').click(function(ev,ui) {
		ev.preventDefault();
		searchClicked = "0";
		window.location = "http://shopterrain.com/merchant.mvc?Screen=CTGY_1004&Store_Code=ST&Category_Code=INSP";
	});
	
	$('#accordion_cat_giftcard').click(function(ev,ui) {
		ev.preventDefault();
		searchClicked = "0";
		window.location = "http://shopterrain.com/merchant.mvc?Screen=CTGY_1004&Store_Code=ST&Category_Code=GIFS-GCAR";
	});

}




function dialog_modal_large_preview(newImageSrc,type)
{
	var myModalWidth = 980;
	$("#dialog-modal-large-preview").dialog({ 
		draggable: false,
		width: myModalWidth,
		height: 730,
		modal: true,
		autoOpen: false,
		resizable: false,
		title: ' ',
		open: function(){
		 	$(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar-close").remove();
			
			//$("#dialog-modal-large-preview-name").html($("#ctgy_product_detail_dict_hidden div div").html());
			var myPreviewName = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='/bin-images/previous_next/detail2.gif' border=0 align=absmiddle>&nbsp;<span class='prod_popup_name'>" + $("#ctgy_product_detail_dict_hidden div div").html() + "</span>";
			$("#dialog-modal-large-preview-name").html(myPreviewName);
			if (type == "altImage") {
				var myImgSrc = newImageSrc;
				myImgSrc = myImgSrc.replace("-m.jpg","-l.jpg");				
			} else {
				var myImgSrc = $("#prod_detail_page_medium_img").attr("src");
				myImgSrc = myImgSrc.replace("-m.jpg","-l.jpg");				
			}
			var myImgTag = "<img id=\"prod_detail_page_large_img\" src=\""+myImgSrc+"\" align=\"center\">";
			$("#dialog-modal-large-preview-img").html(myImgTag);

		}
	});
	
	var diff = $(window).width()  /  2-myModalWidth  /  2;
	var x = parseInt(0 + diff);
	var y = 0 - parseInt(($(document).scrollTop()));
	
	$("#dialog-modal-large-preview").dialog('option', 'position', [x,y]);
	//$("#dialog-modal-large-preview").dialog( "option", "dialogClass", 'prod_detail_page_preview_dialog_position' );
	
	$('.ui-dialog-titlebar').remove();
	$("#dialog-modal-large-preview").dialog("open");
}

$(document).ready(function() {
	var myAccordionLoaded = 0;
	
	
	
	
	$("#mvt_category_code").each(function(){
		var myCatCode = $(this).html();
		var origCatCode = myCatCode;

		if (myCatCode.indexOf("-")!=-1) {
			myCatCode = myCatCode.substring(0, myCatCode.indexOf("-"));
		}
		myCatCode = myCatCode.toLowerCase();

		var myIdToActive = -1;
		if (myCatCode == "gard") { myIdToActive = 0; }
		else if (myCatCode == "hous") { myIdToActive = 1; }
		else if (myCatCode == "well") { myIdToActive = 2; }
		else if (myCatCode == "arti") { myIdToActive = 3; }
		else if (myCatCode == "seas") { myIdToActive = 4; }
		else if (myCatCode == "gifs") { myIdToActive = 5; }
		else if (myCatCode == "sale") { myIdToActive = 6; }
		
		if (myIdToActive>-1)
		{
			myAccordionLoaded++;

if (origCatCode == 'GIFS-GCAR') {
	myIdToActive = "9";
}

			accordion(myIdToActive);

			var myFound = $("#accordion").find("h3 div a img");
			if (myFound.length>0)
			{
				var myImgSrc = $(myFound[myIdToActive]).attr("src");
				myImgSrc = myImgSrc.replace("_0.gif","_1.gif");
				$(myFound[myIdToActive]).attr("src", myImgSrc);
			}
			
		}	
	})
	
	if (myAccordionLoaded==0) {
		accordion(false);
	}
	
	$("#ctgy_product_list_dict_hidden").each(function(){
	
	
		//http://shopterrain.com/merchant.mvc?Screen=CTGY_1004&Store_Code=ST&Category_Code=INSP
		
		if (gup("Category_Code")=="INSP")
		{
			prod_detail_page_insp();
			return (false);
		}
		
		//////////////////////////////////////////////////////////////////////////////
		// FILTER LIST TO UNIQUE PRODUCT CODES
		//////////////////////////////////////////////////////////////////////////////
		
		var myProductsPerPage = 32;
		var myProductsOffset = 0;
		var myProductsWide = 4;
		var myProductsTableId = 0;
		var myListAll = 0;
		var myShowRank = false;
		var myScreen = "CTGY_1004";
		var mySearch = "";
		
		if (gup("myoffset").length>0) {
			myProductsOffset = parseInt(gup("myoffset"));
		}
		
		if (gup("mylist_all").length>0) {
			myListAll = parseInt(gup("mylist_all"));
			myProductsPerPage = 0;
			myProductsOffset = 0;
		}

		loadProdListArrayAndFilterToUniqueCodes( $(this).children() );
		
		
		var myOutput = "";
		myOutput+= drawProductsTablePaginationHeader( myProductsOffset, myProductsPerPage, myListAll, myScreen, mySearch );
		myOutput+= drawProductsTable( myProductsOffset, myProductsPerPage, myShowRank, myProductsWide, myProductsTableId);	
		myOutput+= drawProductsTablePaginationFooter( myProductsOffset, myProductsPerPage, myListAll, myScreen, mySearch );
		
		
		$("#ctgy_product_list_display").html(myOutput);
		$("#ctgy_product_list_display").css("visibility","visible");
	})
	

	//////////////////////////////////////////////////////////////////////////////
	// CATEGORY PRODUCT DETAIL DICT
	//////////////////////////////////////////////////////////////////////////////
	
	$("#ctgy_product_detail_dict_hidden").each(function(){
		
		var myCategory_Code = gup("Category_Code");
		
		var myKids = $(this).children();
		var myOutput = "";
		
		var myProdName 		= $($(myKids[0]).children().get(0)).html();
		var myProdCode 		= $($(myKids[0]).children().get(1)).html();
		var myDescription 	= $($(myKids[0]).children().get(2)).html();
		var myPrice 		= $($(myKids[0]).children().get(3)).html();
		
		myOutput+="<div style=\"position:relative;left:0px;top:0px;width: 535px;\">";
			myOutput+="<div style=\"width: 535px;\"><img id=\"prod_detail_page_medium_img\" src=\"/bin-images-products/"+myProdCode+"-stndrd-m.jpg\" border=\"0\" style=\"width: 535px; height: 535px;\"></div>";
			myOutput+="<div style=\"width: 535px;height: 10px;\">&nbsp;</div>";
			myOutput+="<div style=\"width: 535px;height: 20px;\" id=\"prod_detail_page_rank\" class=\"prod_detail_page_rank\"></div>";
			myOutput+="<div style=\"width: 535px;height: 10px;\">&nbsp;</div>";
			myOutput+="<div style=\"width: 535px;\" class=\"prod_detail_page_prodname\">"+myProdName+"</div>";
			myOutput+="<div style=\"width: 535px;height: 10px;\">&nbsp;</div>";
			myOutput+="<div style=\"width: 535px;\" id=\"prod_detail_page_description\" class=\"prod_detail_page_description\">"+myDescription+"</div>";
			myOutput+="<div style=\"width: 535px;height: 10px;\">&nbsp;</div>";
			myOutput+="<div style=\"width: 535px;\" id=\"prod_detail_page_price\" class=\"prod_detail_page_price\">"+myPrice+"</div>";
			myOutput+="<div style=\"width: 535px;height: 10px;\">&nbsp;</div>";
			myOutput+="<div style=\"width: 535px;\">" + $("#ctgy_product_detail_addtocart").html() + "</div>";
		myOutput+="</div>";	
		
		// REMOVE ORIGINAL COPIED FORM
		$("#ctgy_product_detail_addtocart").html("");
		
		$("#ctgy_product_detail_display").html(myOutput);
		$("#ctgy_product_detail_display").css("visibility","visible");
		
		
		$("#prod_detail_page_medium_img").click(function() {
			dialog_modal_large_preview();
		});
		
		if (gup("myDialog")=="1"){
			dialog_modal_large_preview();
		}
		
		$("#dialog-modal-large-preview-close").click(function() {
			$("#dialog-modal-large-preview").dialog('close');
		});
		
		prod_detail_page_load_alt_imgs(myProdCode);
		
		$("#dialog-modal-large-preview-next").click(function() {
			prod_detail_page_dialog_preview_update_img("next");
		});
		$("#dialog-modal-large-preview-previous").click(function() {
			prod_detail_page_dialog_preview_update_img("previous");
		});
		
		//////////////////////////////////////////////////////////////////////////////
		// LOAD PRODUCT LIST FOR (PREVIOUS/NEXT) LINKS
		//////////////////////////////////////////////////////////////////////////////
		
		
		
		if (gup("mySearch").length>0)
		{	
			var myTotalProducts = gup("mySearchTtlPrds");
			var myCurrentPage = gup("mySearchCrrntPg");
			var myTotalPages = gup("mySearchTtlPgs");
			var myContext = "ctgy_product_list";
			var mySearchValue = gup("mySearch");
//alert('here');			
			ajax_load_srch_product_list(  myTotalProducts, myCurrentPage, myTotalPages, myContext, mySearchValue  );
			prod_detail_page_setupPreviousNextLinks( myProdCode );
		}
		else
		{
			var myProductListLoadUrl = "http://shopterrain.com/merchant.mvc?Screen=CTGY_1004_AJAX&Store_Code="+gup("Store_Code")+"&Category_Code="+gup("Category_Code");
			
			$.get(myProductListLoadUrl, function(data) {
				$("#ctgy_product_list_dict_hidden").html(data);
				
				loadProdListArrayAndFilterToUniqueCodes( $("#ctgy_product_list_dict_hidden").children() );
				
				prod_detail_page_setupPreviousNextLinks( myProdCode );
				
			});
		}

	})
	
	
	
	
	
	

//	$("div[id$=product_image_thumbnail]").each(function(){
//	var myImgSrc = $(this).find("a").html() + "";
//	
//	myImgSrc = myImgSrc+"-stndrd-t.jpg";
//	myImgSrc = "<img src=\"/bin-images-products/"+myImgSrc+"\" border=\"\">";
//	
//	alert("test");
//	
//	$(this).find("a").html(myImgSrc);
//	
//	$(this).css("visibility","visible");
//	
//	
//})

$('#accordion h3 div a').mouseover(function(ev) {
	if ($(ev.target).attr("src")!=undefined) {
	if ($(ev.target).attr("src")!="undefined")
	{
		if ($(ev.target).attr("src").indexOf("dotdotdot")==-1)
		{
			$(ev.target).attr("src", $(ev.target).attr("src").replace("_0.gif","_1.gif"));
		}
	}}
	
}).mouseout(function(ev){
//alert(searchClicked + ' is searchclicked');
	if (categoryCode) {
		if (categoryCode == 'GIFS-GCAR') {
			catCode = 'GIFTCARD';
		} else {
			catCode = categoryCode.substr(0,4);
		}
	} else {
		catCode = 'home';
	}

	if ($(ev.target).attr("src")!=undefined) {
		var cat = $(ev.target).attr("src");
	} else {
		var cat = 'home';
	}
	var catgard = cat.match("gard");
	var cathous = cat.match("househome");
	var catwell = cat.match("wellness");
	var catarti = cat.match("vintage");
	var catseas = cat.match("seasons");
	var catgifs = cat.match("gifts");
	var catsale = cat.match("sale");
	var catgiftcard = cat.match("giftcard");
	var catinsp = cat.match("insp");
	var catsearch = cat.match("search");
//alert(searchClicked + ' and ' + catsearch);

	if ($(ev.target).attr("src")!=undefined) {
	if ($(ev.target).attr("src")!="undefined")
	{
		if ($(ev.target).attr("src").indexOf("dotdotdot")==-1)
		{
			if ((searchClicked == "1" && catsearch == "search") || (catCode == "INSP" && catinsp != null) || (catCode == "GIFTCARD" && catgiftcard != null) || (catCode == "GARD" && catgard != null) || (catCode == "HOUS" && cathous != null) || (catCode == "WELL" && catwell != null) || (catCode == "ARTI" && catarti != null) || (catCode == "SEAS" && catseas != null) || (catCode == "GIFS" && catgifs != null) || (catCode == "SALE" && catsale != null)) {
			} else {
				$(ev.target).attr("src", $(ev.target).attr("src").replace("_1.gif","_0.gif"));
			}
		}
	}}
});


$('#secondarymenu div a').mouseover(function(ev) {
	
	var myImgSrc = $(ev.target).attr("src");
	if (myImgSrc.indexOf("dotdotdot")!=-1) { return (false);}
	myImgSrc = myImgSrc.replace("_0.gif","_1.gif");

	
	
	$(ev.target).attr("src", myImgSrc);
	
}).mouseout(function(ev){

	var myImgSrc = $(ev.target).attr("src");
	if (myImgSrc.indexOf("dotdotdot")!=-1) { return (false);}
	myImgSrc = myImgSrc.replace("_0.gif","_1.gif");
	
	myImgSrc = myImgSrc.replace("_1.gif","_0.gif");
	$(ev.target).attr("src", myImgSrc);

if (screenName == "BASK") {
	document.getElementById('basket').src="/bin-images/sidebar/cat_basket_1.gif";
}
if (screenName == "LOGN") {
	document.getElementById('myaccount').src="/bin-images/sidebar/cat_myterrain_1.gif";
}
}); 

$("#srch_ctgy_product_list_info").each(function(){
	
	var myTotalProducts = $($(this).children().get(0)).text();
	var myCurrentPage = $($(this).children().get(1)).text();
	var myTotalPages = $($(this).children().get(2)).text();
	var myContext = "srch_product_list";
	var mySearchValue = gup("Search");
	var mySortValue = gup("sort");

	ajax_load_srch_product_list(  myTotalProducts, myCurrentPage, myTotalPages, myContext, mySearchValue,mySortValue  );

	drawTable_srch_product_list( myContext );
	
});
	

}) // $(document).ready(function() {