/*
====================================================

  http://www.GlobalWebCart.com - Version 2

  Copyright 2008 Internet Specialty Services, LLC.

  ANY UN-AUTHORIZED USE OR DISTRIBUTION OF THIS
  FILE OR IT'S CONTENTS IS STRICTLY PROHIBITED

====================================================
*/

var MPP_ID = 0;
var SBF_ID = 0;

//alert(location.protocol+'//'+location.hostname+'/');



function SortByForm(tSBF,tDtxt) {
	SBF_ID=SBF_ID+1;

	if (tSBF!='') {SortByFields=tSBF;}
	if (tDtxt=='') {tDtxt='Default';}

	var tLnk = MainDomain.toLowerCase() + '/';
	var ts = String(document.location).toLowerCase();

	document.write('<form method="post" action="'+ location.href +'" name="ProductSort_'+SBF_ID+'">');
	document.write('<select name="SortBy_'+SBF_ID+'" id="SortBy_'+SBF_ID+'" onchange="document.ListSettings.SortBy.value=this.value;document.ListSettings.submit();">');
	document.write('<option value="disp_a">'+tDtxt);


	if (SortByFields.indexOf("|T|") != -1) {
		document.write('<option value="title_a">Title, A to Z<option value="title_d">Title, Z to A');
		}

	if (SortByFields.indexOf("|PR|") != -1) {
		document.write('<option value="price_a">Price, Low to High<option value="price_d">Price, High to Low');
		}

	if (SortByFields.indexOf("|M|") != -1 && ts.indexOf(tLnk+"m/") < 1) {
		document.write('<option value="brand_a">Manufacturer, A to Z<option value="brand_d">Manufacturer, Z to A');
		}

	if (SortByFields.indexOf("|P|") != -1 && ts.indexOf(tLnk+"p/") < 1) {
		document.write('<option value="type_a">Product Type, A to Z<option value="type_d">Product Type, Z to A');
		}

	if (SortByFields.indexOf("|R|") != -1) {
		document.write('<option value="rev_a">Rating, Low to High<option value="rev_d">Rating, High to Low');
		}

	document.write('</select>');
	document.write('<input type="submit" name="Go" value="Go" id="SortByGoBtn">');
	document.write('</form>');
	//} catch(err) {alert('SortByForm');}

}



function UpdateListSettings() {
	if (document.ListSettings != undefined) {
		if (document.ProductSort_1 != undefined) {
			if (document.ProductSort_1.SortBy_1 != undefined && document.ListSettings.SortBy != undefined) {
				document.ProductSort_1.SortBy_1.value = document.ListSettings.SortBy.value;
				}
			}
		if (document.ProductSort_2 != undefined) {
			if (document.ProductSort_2.SortBy_2 != undefined && document.ListSettings.SortBy != undefined) {
				document.ProductSort_2.SortBy_2.value = document.ListSettings.SortBy.value;
				}
			}

		if (document.ProductMaxPerPage_1 != undefined) {
			if (document.ProductMaxPerPage_1.MaxPerPage_1 != undefined && document.ListSettings.MaxPerPage != undefined) {
				document.ProductMaxPerPage_1.MaxPerPage_1.value = document.ListSettings.MaxPerPage.value;
				}
			}
		if (document.ProductMaxPerPage_2 != undefined) {
			if (document.ProductMaxPerPage_2.MaxPerPage_2 != undefined && document.ListSettings.MaxPerPage != undefined) {
				document.ProductMaxPerPage_2.MaxPerPage_2.value = document.ListSettings.MaxPerPage.value;
				}
			}
		}
}





function MaxPerPage(i,m) {
	var i2 = i;
	if (i>100) {i=100;}

	//try {
	if (i>m) {
		MPP_ID=MPP_ID+1;

		document.write('<form method="post" action="'+ location.href +'" name="ProductMaxPerPage_'+MPP_ID+'">');
		document.write('<select name="MaxPerPage_'+MPP_ID+'" id="MaxPerPage_'+MPP_ID+'" onchange="document.ListSettings.MaxPerPage.value=this.value;document.ListSettings.action=GetUrlStr(location.href);document.ListSettings.submit();">');
		var t=0;
		while (t<i) {
			t=t+m;
			if (t>i || t==i) {
				if (i==i2) {
					document.write('<option value="'+i+'">View all '+i);
					}
				}
			else {
				document.write('<option value="'+t+'">'+t+' per page');
				}
			}
		document.write('</select>');
		document.write('</form>');
		}

	//} catch(err) {alert('MaxPerPage');}
}






function GetOlDiv(pid) {
	return overlib(document.getElementById('GetOlDiv_'+pid).innerHTML);
}


function PL_Thumb(pid,oValue) {
	if (oValue.indexOf('_') != -1) {
		var sc = oValue.split('_');
		oValue = sc[1];
		}

//alert(oValue);

	document.images['pltImg_'+pid].src = iUrl + oValue;
}






function PagingGo(tO) {
	var ts = tO.getAttribute("rel");
	var tID = tO.value;
	if (Left(ts,2)=='s/') {
		ts = ts.replace(/_PG_/,tID);
		}
	else {
		if (tID==1) {
			ts = ts.replace(/_PG/, "");
			}
		else {
			ts = ts.replace(/_PG/, "_"+tID);
			}
		}
	document.location = HTTP+ts;
}



function CopyPagingHtml() {
	var tpg1 = document.getElementById("Paging");
	var tpg2 = document.getElementById("Paging2");
	var tpgt = document.getElementById("PagingTop");
	var tpgb = document.getElementById("PagingBottom");
	var tpg = document.getElementById("tPaging");

	if (tpg) {
		if (tpg1) {tpg1.innerHTML = tpg.innerHTML;}
		if (tpg2) {tpg2.innerHTML = tpg.innerHTML;}
		if (tpgt) {tpgt.innerHTML = tpg.innerHTML;}
		if (tpgb) {tpgb.innerHTML = tpg.innerHTML;}
		tpg.style.display='none';
		}
	hidePG('Paging');
	hidePG('Paging2');
	hidePG('PagingTop');
	hidePG('PagingBottom');
	hidePG('tPaging');
}

function hidePG(tID) {
	if (gH(tID).length==0) {hideID(tID);}
}
