function popup(which) {
	mywindow = window.open(which, "mywindow");
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init == true) with (navigator) {
		if ((appName == "Netscape") && (parseInt(appVersion) == 4)) {
			document.MM_pgW = innerWidth; document.MM_pgH = innerHeight; onresize = MM_reloadPage;
		} 
	}
	else if (innerWidth != document.MM_pgW || innerHeight != document.MM_pgH) location.reload();
}

function MM_openBrWindow(theURL, winName, features) { //v2.0
	window.open(theURL, winName, features);
}

function MM_jumpMenu(targ, selObj, restore) { //v3.0
	eval(targ + ".location='" + selObj.options[selObj.selectedIndex].value + "'");
	if (restore) selObj.selectedIndex = 0;
}

function MM_showHideLayers() { //v6.0
	var i, p, v, obj, args = MM_showHideLayers.arguments;
	for (i = 0; i < (args.length - 2); i += 3) if ((obj = MM_findObj(args[i])) != null) {
		v = args[i + 2];
		if (obj.style) { obj = obj.style; v = (v == 'show') ? 'visible' : (v == 'hide') ? 'hidden' : v; }
		obj.visibility = v;
	}
}

function MM_preloadImages() { //v3.0
	var d = document; if (d.images) {
		if (!d.MM_p) d.MM_p = new Array();
		var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
			if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
	}
}

function MM_swapImgRestore() { //v3.0
	var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_findObj(n, d) { //v4.01
	var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
		d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
	}
	if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
	for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
	if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
		if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}

function MM_goToURL() { //v3.0
	var i, args = MM_goToURL.arguments; document.MM_returnValue = false;
	for (i = 0; i < (args.length - 1); i += 2) eval(args[i] + ".location='" + args[i + 1] + "'");
}

function isSecure() {
	return location.protocol == 'https:';

}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for (var i = 0; i < ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0) == ' ') c = c.substring(1, c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
	}
	return null;
}


function getElementByID_Master(e) {
	//    alert('ge-' + e.toString());

	var ret = null;

	ret = MM_findObj(e);
	if (ret)
		return ret;

	ret = MM_findObj("ContentPlaceHolder1_" + e);
	if (ret)
		return ret;

	ret = MM_findObj("ContentPlaceHolder1$" + e);
	if (ret)
		return ret;

	//alert('ctl00_ContentPlaceHolder1_' + e.toString());
	ret = MM_findObj("ctl00_ContentPlaceHolder1_" + e);
	if (ret)
		return ret;

	//alert('ctl00$ContentPlaceHolder1$' + e.toString());
	ret = MM_findObj("ctl00$ContentPlaceHolder1$" + e);
	if (ret)
		return ret;



	/*
	//alert('ctl00_ContentPlaceHolder1_' + e.toString());
	ret = document.getElementsByName('ctl00_ContentPlaceHolder1_' + e.toString());
	if (ret != null)
	return ret;

	//alert('ctl00$ContentPlaceHolder1$' + e.toString());
	ret = document.getElementsByName('ctl00$ContentPlaceHolder1$' + e.toString());
	if (ret != null)
	return ret;
	*/

	//if (ret)
	//alert(e.toString());

	return ret;
}

function popup_extra(theURL, winName, features) { //v2.0
	var pw;
	pw = window.open(theURL, winName, features);
	pw.focus();
}

function zeropad(i) {
	if (i == 0)
		return 0;

	if (i < 9)
		return "0" + i;

	return i;
}

function popup_win_params(w, p) {
	var pw;
	pw = window.open(w, 'Popup', p);
	pw.focus();
}

function popup_win(w) {
	var pw;
	pw = window.open(w, 'Popup', 'height=275,width=475,toolbar=no,resizable=no,scrollbars=no');
	pw.focus();
}

function popup_fitguide(w, height, width) {
	var pw;
	var paramstring = "height=" + height + ",width=" + width + ",toolbar=no,resizable=no,scrollbars=no";
	pw = window.open(w, 'FitGuide', paramstring);
	pw.focus();
}
function popup_sizechart(w) {
	var pw;
	pw = window.open(w, 'SizeChart', 'height=450,width=620,toolbar=no,resizable=no,scrollbars=yes');
	pw.focus();
}

function popup_sizechart2(w, height, width) {
	var pw;
	var paramstring = "height=" + height + ",width=" + width + ",toolbar=no,resizable=no,scrollbars=yes";
	pw = window.open(w, 'SizeChart', paramstring);
	pw.focus();
}

function popup_cantfindsizeandcolor(w, height, width) {
	var pw;
	var paramstring = "height=" + height + ",width=" + width + ",toolbar=no,resizable=no,scrollbars=yes";
	pw = window.open(w, 'CantFindSizeandColor', paramstring);
	pw.focus();
}

function popup_referafriend(w) {
	var pw;
	var colorid = 0;
	var colorname = "";
	colorid = color_ids[g_color];

	var pc = getElementByID_Master("ProductColors");
	if (pc != null)
		colorname = pc.options[pc.selectedIndex].text.toLowerCase();

	if (colorid != 0 && colorname != "")
		pw = window.open(w + "&colorid=" + colorid + "&colorname=" + colorname, 'ReferAFriend', 'height=425,width=450,toolbar=no,resizable=no,scrollbars=no');
	else
		pw = window.open(w, 'ReferAFriend', 'height=425,width=450,toolbar=no,resizable=no,scrollbars=no');

	pw.focus();
}

function popup_shareproduct(w, height, width) {
	var pw;
	var paramstring = "height=" + height + ",width=" + width + ",toolbar=no,resizable=no,scrollbars=yes";
	pw = window.open(w, 'ShareBookmarkProduct', paramstring);
	pw.focus();
}

function FacebookShare(productid) {
	FacebookShareURL(location.hostname + "/pd/cl/" + color_ids[g_color] + "/p/" + productid + ".html");

}

function FacebookShareURL(url) {
	window.open("http://www.facebook.com/sharer.php?u=" + url);
}

function getElementsByClassName(className, tag, elm) {
	var Class = new RegExp("(^|\\s)" + className + "(\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all) ? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for (var i = 0; i < length; i++) {
		current = elements[i];
		if (Class.test(current.className)) {
			returnElements.push(current);
		}
	}
	return returnElements;
}

function addCls(elm, className) {
	var currentClass = elm.className;
	if (!new RegExp(("(^|\\s)" + className + "(\\s|$)"), "i").test(currentClass)) {
		elm.className = currentClass + ((currentClass.length > 0) ? " " : "") + className;
	}
	return elm.className;
}

function remCls(elm, className) {
	var classToRemove = new RegExp(("(^|\\s)" + className + "(\\s|$)"), "i");
	elm.className = elm.className.replace(classToRemove, "").replace(/^\s+|\s+$/g, "");
	return elm.className;
}

function toggleElem(id, show) {
	if (show == "1") {
		if (document.layers) {
			document.layers[id].visibility = "show";
		} else if (document.all) {
			document.all[id].style.visibility = "visible";
		} else if (document.getElementById) {
			getElementByID_Master(id).style.visibility = "visible";
		}
	} else if (show == "0") {
		if (document.layers) {
			document.layers[id].visibility = "hide";
		} else if (document.all) {
			document.all[id].style.visibility = "hidden";
		} else if (document.getElementById) {
			getElementByID_Master(id).style.visibility = "hidden";
		}
	}
}

function setElem(id, val) {
	if (getElementByID_Master(id))
		getElementByID_Master(id).innerHTML = val;
	try { getElementByID_Master(id).className = "" }
	catch (err) { }
}

function reload_sizes() {
	if (size_count == 0)
		return;

	var ps = getElementByID_Master("ProductSizes");
	if (ps == null)
		return;

	var curr_value = ps.options[ps.selectedIndex].value;
	var curr_index = 0;

	ps.length = 0;
	ps.options[0] = new Option("Select " + g_sizealias, "-1");
	curr_index++;


	for (var i = 1; i <= size_count; i++) {
		if (g_color == 0 || aSCSA[g_color][i] == true || g_showwhenoos == 1) {
			ps.options[curr_index] = new Option(size_names[i], size_ids[i]);
			if (curr_value == size_ids[i])
				ps.selectedIndex = curr_index;

			curr_index++;
		}
	}
	if (ps.length == 2 && (getElementByID_Master("DisableOneSizeSelection") == null || (getElementByID_Master("DisableOneSizeSelection") != null && getElementByID_Master("DisableOneSizeSelection").value != 1))) {
		ps.selectedIndex = 1;
	}
}

function reload_colors() {
	if (color_count == 0)
		return;

	var ps = getElementByID_Master("ProductColors");
	if (ps == null)
		return;

	var curr_value = ps.options[ps.selectedIndex].value;
	var curr_index = 0;

	ps.length = 0;
	ps.options[0] = new Option("Select Color", "-1");
	curr_index++;

	for (var i = 1; i <= color_count; i++) {
		if (g_size == 0 || aSCSA[i][g_size] == true || g_showwhenoos == 1) {
			ps.options[curr_index] = new Option(color_names[i], color_ids[i]);
			if (curr_value == color_ids[i])
				ps.selectedIndex = curr_index;

			curr_index++;
		}
	}
	if (ps.length == 2) {
		ps.selectedIndex = 1;
	}
}

function change_upc() {
	var upc = getElementByID_Master("upc_text");
	if (upc == null)
		return;

	if (aUPC[g_color] == null) {
		upc.innerHTML = '';
		return;
	}

	var val = aUPC[g_color][g_size];
	if (val == null || val == '') {
		upc.innerHTML = '';
		return;
	}

	upc.innerHTML = 'UPC: ' + val;
}

function HideElem(id) {
	var e = getElementByID_Master(id);
	if (e != null) {
		e.style.display = "none";
	}
}

function ShowElem(id) {
	var e = getElementByID_Master(id);
	if (e != null) {
		e.style.display = "inline";
	}
}

function reset_unitcost(uc, flag) {
	if (g_unitcost == '$0.00' || g_mincost != g_maxcost) {
		if (g_mincost == g_maxcost || flag == 1) {
			if (g_previouscost == '$0.00')
				uc.innerHTML = g_maxcost;
			else
				uc.innerHTML = g_unitcost;
		}
		else
			uc.innerHTML = g_mincost + ' - ' + g_maxcost;
	}
	else {
		uc.innerHTML = g_unitcost;
	}
}

function change_costspans() {
	var lpl = getElementByID_Master("legacy_price_layout");
	if (lpl == null)
		return;

	var csr = getElementByID_Master("costspan_regular");
	if (csr == null)
		return;

	var css = getElementByID_Master("costspan_sale");
	if (css == null)
		return;

	var uc = getElementByID_Master("UnitCostSpan");
	if (uc == null)
		return;

	var pc = getElementByID_Master("PreviousCostSpan");
	if (pc == null)
		return;

	var csr_uc = getElementByID_Master("costspan_regular_uc");
	if (csr_uc == null)
		return;

	var css_uc = getElementByID_Master("costspan_sale_uc");
	if (css_uc == null)
		return;

	var css_pc = getElementByID_Master("costspan_sale_pc");
	if (css_pc == null)
		return;

	if (pc.innerHTML == '') {
		csr.style.display = "block";
		css.style.display = "none";
		csr_uc.innerHTML = uc.innerHTML;
	} else {
		csr.style.display = "none";
		css.style.display = "block";
		css_uc.innerHTML = uc.innerHTML;
		css_pc.innerHTML = pc.innerHTML;
	}

	lpl.style.display = "none";
	HideElem("PreviousCost");
	HideElem("PreviousCostCustom");
	HideElem("PreviousCostCustom2");
}

function change_unitcost() {
	var uc = getElementByID_Master("UnitCostSpan");
	var ucv2 = getElementByID_Master("RegularPrice2LB");
	var ps = getElementByID_Master("ProductColors");
	var curr_value = 0;

	if (ps != null) {
		curr_value = ps.selectedIndex;
	}

	HideElem("RegularPrice2LB");

	if (uc == null)
		return;

	if (aSKUUnitCost[g_color] == null) {
		reset_unitcost(uc, 0);
		return;
	}

	var val = aSKUUnitCost[g_color][g_size];
	if (val == null || val == '') {
		reset_unitcost(uc, 1);
		return;
	}

	if (ucv2 != null) {
		if (val == g_unitcost)
			HideElem("RegularPrice2LB");
		else if (val == aSKUUnitCost[curr_value][0] && aSKUPreviousCost[curr_value][1] == '') {
			HideElem("RegularPrice2LB");
		}
		else
			ShowElem("RegularPrice2LB");
	}

	uc.innerHTML = val;
}

function reset_unitcost_col(productid, uc) {
	if (eval("g_unitcost_" + productid) == '$0.00') {
		if (eval("g_mincost_" + productid) == eval("g_maxcost_" + productid))
			uc.innerHTML = eval("g_maxcost_" + productid);
		else
			uc.innerHTML = eval("g_mincost_" + productid);
	}
	else {
		uc.innerHTML = eval("g_unitcost_" + productid);
	}
}

function change_unitcost_col(productid, i) {
	//alert(productid + " " + i);
	var uc = getElementByID_Master("UnitCostSpan_" + productid);
	//alert(uc);
	if (uc == null)
		return;

	//alert(eval("aSKUUnitCost_" + productid + "[" + "g_color_" + productid + "]"));
	if (eval("aSKUUnitCost_" + productid + "[" + "g_color_" + productid + "]") == null) {
		//alert('reset1');
		reset_unitcost_col(productid, uc);
		return;
	}

	var val = eval("aSKUUnitCost_" + productid + "[" + "g_color_" + productid + "]" + "[" + "g_size_" + productid + "]");
	if (val == null || val == '') {
		//alert(val + ' :reset2' + " aSKUUnitCost_" + productid + "[" + "g_color_" + productid + "]" + "[" + "g_size_" + productid + "]" + ' g_color: ' + eval("g_color_" + productid) + ' g_size: ' + eval("g_size_" + productid));
		reset_unitcost_col(productid, uc);
		return;
	}

	uc.innerHTML = val;
}

function reset_previouscost_col(productid, pc) {
	if (eval("g_previouscost_" + productid) == '$0.00') {

		pc.innerHTML = '';
	}
	else {
		pc.innerHTML = eval("g_previouscost_" + productid);
	}
}

function reset_previouscost(pc) {
	if (g_previouscost == '$0.00') {
		HideElem("PreviousCost");
		HideElem("PreviousCostCustom");
		HideElem("PreviousCostCustom2");

		pc.innerHTML = '';
	}
	else {
		pc.innerHTML = g_previouscost;

		if (g_previouscost == g_unitcost) {
			HideElem("PreviousCostCustom");
			HideElem("PreviousCostCustom2");
		}
		else {
			ShowElem("PreviousCost");
			ShowElem("PreviousCostCustom");
			ShowElem("PreviousCostCustom2");
		}
	}
}

function change_previouscost() {
	var pc = getElementByID_Master("PreviousCostSpan");
	if (pc == null)
		return;

	if (aSKUPreviousCost[g_color] == null) {
		reset_previouscost(pc);
		return;
	}

	var val = aSKUPreviousCost[g_color][g_size];
	if (val == null || val == '') {
		reset_previouscost(pc);
		return;
	}

	ShowElem("PreviousCost");
	ShowElem("PreviousCostCustom");
	ShowElem("PreviousCostCustom2");

	pc.innerHTML = val;
}

function change_previouscost_col(productid, i) {
	//alert(productid + " " + i);
	var pc = getElementByID_Master("PreviousCostSpan_" + productid);
	//alert(uc);
	if (pc == null)
		return;

	//alert(eval("aSKUUnitCost_" + productid + "[" + "g_color_" + productid + "]"));
	if (eval("aSKUPreviousCost_" + productid + "[" + "g_color_" + productid + "]") == null) {
		//alert('reset1');
		reset_previouscost_col(productid, pc);
		return;
	}

	var val = eval("aSKUPreviousCost_" + productid + "[" + "g_color_" + productid + "]" + "[" + "g_size_" + productid + "]");
	if (val == null || val == '') {
		//alert(val + ' :reset2' + " aSKUUnitCost_" + productid + "[" + "g_color_" + productid + "]" + "[" + "g_size_" + productid + "]" + ' g_color: ' + eval("g_color_" + productid) + ' g_size: ' + eval("g_size_" + productid));
		reset_previouscost_col(productid, pc);
		return;
	}

	pc.innerHTML = val;
}


function zoom_show(width, height) {
	//    alert('zoom_show');
	var rzg = getElementByID_Master("RealZoomGraphic");
	if (rzg != null)
		rzg.style.visibility = "visible";

	//alert(width + " " + height);
	zoom_zoomimagewid = width;
	zoom_zoomimagehei = height;

	Zoom_ReInitialize();
}

function zoom_hide() {
	//    alert('zoom_hide');
	var rzt = getElementByID_Master("realZOOMBG");
	if (rzt != null)
		rzt.style.visibility = "hidden";

	var rzg = getElementByID_Master("RealZoomGraphic");
	if (rzg != null)
		rzg.style.visibility = "hidden";

	zoom_zoomimagewid = 0;
	zoom_zoomimagehei = 0;

	Zoom_DeInitialize();
}

function zoom_show_if_loaded(width, height) {
	if (width > 0)
		zoom_show(width, height);
}

function get_product_image() {
	var x = document.images['ProductImage'];
	if (x == null)
		x = document.images['ProductImage2'];
	if (x == null)
		x = document.images['ContentPlaceHolder1_ProductImage'];
	if (x == null)
		x = document.images['ContentPlaceHolder1_ProductImage2'];
	if (x == null)
		x = document.images['ctl00_ContentPlaceHolder1_ProductImage'];
	if (x == null)
		x = document.images['ctl00_ContentPlaceHolder1_ProductImage2'];

	return x;
}

function change_zoom_realzoom(img, regpath, detailpath) {
	// Get the OnClick text from ProductImageHL
	var pih = getElementByID_Master("ProductImageHL");
	if (pih != null) {
		var f = pih.getAttribute('OnClick').toString();
		if (f.indexOf('anonymous') != -1) {
			f = f.substr(23, f.length - 24);
		}
		zoom_zoomclickfuncs += f;
	}

	zoom_mainimageurl = regpath + img;
	zoom_zoomimageurl = detailpath + img.replace(".jpg", "_z.jpg");

	//    alert(zoom_mainimageurl + " " + zoom_zoomimageurl);
	//    alert(loadzoom);

	//    var zmi = new Image();
	//    zmi.onerror = zoom_image_missing;
	//    zmi.src = zoom_mainimageurl;

	// Temporarily removed "Safari" Agent checker for testing - Richard 05-22-08

	/*
	if (navigator.userAgent.indexOf("Safari") != -1)
	{
	zoom_hide();
	var zzi = new Image();
	zzi.src = zoom_zoomimageurl;
	window.setTimeout("zoom_show_if_loaded(" + zzi.width + ", " + zzi.height + ")", 2000);
	}
	else
	{
	*/
	var zzi = new Image();
	zzi.onerror = zoom_hide;
	zzi.onload = function () { zoom_show(zzi.width, zzi.height); };
	zzi.src = zoom_zoomimageurl;
	//   }
}

function change_zoom_magiczoom(img, regpath, detailpath) {
	// Get the OnClick text from ProductImageHL
	var pih = getElementByID_Master("ProductImageHL");
	if (pih == null)
		return;

	MagicZoom_stopZooms();
	pih.href = detailpath + img.replace(".jpg", "_z.jpg");
	setTimeout('MagicZoom_findZooms()', 100);
}

function change_zoom(img, regpath, detailpath) {
	//zoom_hide();
	var mir = getElementByID_Master("RealZoomH");
	if (mir != null) {
		change_zoom_realzoom(img, regpath, detailpath);
		return;
	}

	var mz = getElementByID_Master("MagicZoomHidden");
	if (mz != null) {
		change_zoom_magiczoom(img, regpath, detailpath);
		return;
	}
}

function set_color(i) {
	g_color = i;
	try {
		get_product_image().src = "/store/productimages/regular/" + aColor[i];
	}
	catch (err) {
	}
	setElem("Message", "");
	if (g_size_priority == 0)
		reload_sizes();
	change_upc();
	change_unitcost();
	change_previouscost();
	change_costspans();
	change_extragroup();
}

function change_color(i) {
	set_color(i);
	change_zoom(aColor[i], "/store/productimages/regular/", "/store/productimages/details/");

	try {
		setElem("AddToCartMessage", "");

		if (g_isvproductid == 1)
			change_vpid_elements(i - 1);
	}
	catch (err) { }
}

function change_vpid_elements(i) {
	var modelname = getElementByID_Master("ModelNameLB");
	var description = getElementByID_Master("TD1_DescriptionLB");
	var mfgsku = getElementByID_Master("MFGSKUL");
	var breadcrumb = getElementByID_Master("modelname");

	if (modelname != null)
		modelname.innerHTML = aModelName[i];

	if (description != null)
		description.innerHTML = aDescription[i];

	if (mfgsku != null)
		mfgsku.innerHTML = aMfgSku[i];

	if (breadcrumb != null)
		breadcrumb.innerHTML = aModelName[i];
}

function change_extrabutton(hyperlinkname, imgname, elementindex) {
	//    alert(g_color + " " + hyperlinkname + " " + imgname + " " + elementindex);
	if (g_useextragroup_colors == 0)
		return;

	var e_img = getElementByID_Master(imgname);
	if (e_img == null)
		return;

	var e_hl = getElementByID_Master(hyperlinkname);
	if (e_hl == null)
		return;

	try {
		if (aExtraGroupColors[g_color] == null || aExtraGroupColors[g_color][elementindex] == null) {
			e_hl.style.visibility = "hidden";
			e_img.src = '';
			return;
		}

		e_hl.style.visibility = "visible";
		e_img.src = aExtraGroupColors[g_color][elementindex];
	}
	catch (err) {
	}
}

function change_extragroup() {
	change_extrabutton("ExtraMediaButton1", "ExtraMediaButton1_img", 1);
	change_extrabutton("ExtraMediaButton2", "ExtraMediaButton2_img", 2);
	change_extrabutton("ExtraMediaButton3", "ExtraMediaButton3_img", 3);
	change_extrabutton("ExtraMediaButton4", "ExtraMediaButton4_img", 4);
	change_extrabutton("ExtraMediaButton5", "ExtraMediaButton5_img", 5);
	change_extrabutton("ExtraMediaButton6", "ExtraMediaButton6_img", 6);
}

function change_stockalert() {
	var stockLevelAlert = getElementByID_Master("StockLevelAlert");
	if (stockLevelAlert == null)
		return;

	if (aSCSA[g_color][g_size] == false || g_size == 0) {
		stockLevelAlert.style.visibility = "hidden";
		g_size = 0;
		return;
	}

	var stockLevel3OrLess = getElementByID_Master("StockLevel3OrLess");
	var stockLevel2OrLess = getElementByID_Master("StockLevel2OrLess");
	var AdjustLowStockMsg = getElementByID_Master("AdjustLowStockMsg");

	if (stockLevel3OrLess != null && aStockLevels[g_color][g_size] < 4) {
		setElem("StockLevel3OrLess", aStockLevels[g_color][g_size]);
		stockLevelAlert.style.visibility = "visible";
	}
	else if (stockLevel2OrLess != null && aStockLevels[g_color][g_size] < 3) {
		setElem("StockLevel2OrLess", aStockLevels[g_color][g_size]);
		stockLevelAlert.style.visibility = "visible";
	}
	else if (AdjustLowStockMsg != null) {
		AdjustLowStockMsg.innerHTML = "";
		checkAdjustableStockLevel(aStockLevels[g_color][g_size]);
	}
	else {
		stockLevelAlert.style.visibility = "hidden";
	}
}

function change_size(i) {
	g_size = i;
	setElem("Message", "");
	if (g_size_priority == 1)
		reload_colors();
	change_upc();
	change_unitcost();
	change_previouscost();
	change_costspans();

	try {
		setElem("AddToCartMessage", "");
	}
	catch (err) { }
}

function change_extra(i) {
	document.images['theimage'].src = aExtra[i];
}

function change_extra2(i) {
	//    alert('change_extra2(' + i + ')');
	if (color_count > 1) {
		set_color(getElementByID_Master("ProductColors").selectedIndex);
	}
	try {
		get_product_image().src = aExtra[i];
	}
	catch (err) {
	}
	change_zoom(aExtra[i], "", "");
}

function change_extra3(i) {
	if (g_useextragroup_colors == 0)
		return;

	if (aExtraGroupColors[g_color] == null || aExtraGroupColors[g_color][i + 1] == null)
		return;

	var img = aExtraGroupColors[g_color][i + 1];
	img = img.replace("_t.jpg", ".jpg");
	try {
		get_product_image().src = img;
	}
	catch (err) {
	}
	change_zoom(img, "", "");

	var educontent = getElementByID_Master("EduHidden");

	if (educontent != null) {
		try {
			$("#ContentPlaceHolder1_ProductImage").removeAttr('width')
			$("#ContentPlaceHolder1_ProductImage").removeAttr('height');
			$('.jcarousel-text').fadeIn('slow', function () {
				$('.jcarousel-text').html(aExtraGroupText[g_color][i + 1]);
			});
		}
		catch (err) { }
	}

	var quicklookzoom = getElementByID_Master("ZoomImage");

	if (quicklookzoom != null) {
		try {
			quicklookzoom.href = img.replace(".jpg", "_z.jpg");
		}
		catch (err) { }
	}
}

function Contains(s) {
	if (s.indexOf(s) >= 0) {
		return 1;
	}

	return 0;
}

function change_and_select_color(i, cid, qtycid) {
	if (Contains("ProductColors")) {
		var pc = getElementByID_Master("ProductColors");
		if (pc != null) {
			pc.selectedIndex = i;
		}
		change_color(i);
		window.status = '';
	}
	else {
		try {
			getElementByID_Master(cid).selectedIndex = i;
			// 	if(getElementByID_Master(qtycid)!= null && getElementByID_Master(qtycid).value=='')
			//	    getElementByID_Master(qtycid).value = '1'; 
		}
		catch (err) { }
	}
}

function set_selection(id, val) {
	getElementByID_Master(id).selectedIndex = val;
}

function show_color(i) {
	try {
		get_product_image().src = "/store/productimages/regular/" + aColor[i];
	}
	catch (err) {
	}
}

function swatch_mouse_out(i) {
	window.status = '';
	if (g_color != i)
		MM_swapImgRestore();
	show_color(g_color);
	window.status = '';
}

function swatch_mouse_over(i, color_name, over_img_name) {
	window.status = '';
	MM_swapImage(color_name, '', over_img_name, 1);
	show_color(i);
	window.status = color_name;
}

function swatch_click(i, color_name, img_name) {
	window.status = '';
	MM_swapImage(g_swatch_name, '', g_swatch_img, 1);
	change_and_select_color(i);
	g_swatch_name = color_name;
	g_swatch_img = img_name;
	window.status = color_name;
}

function size_swatch_click(i, size_name) {
	window.status = '';
	set_selection("ProductSizes", i);
	set_size_swatch(i);
	change_size(i);
	window.status = size_name;
}

function set_size_swatch(i) {
	for (var i = 0; i < size_count; i++) {
		var j = i + 1;
		var sw = getElementByID_Master("SizeSwatch_" + j);
		if (sw == null)
			continue;

		if (g_size == j)
			sw.className = "sizebox active";
		else
			sw.className = "sizebox a";
	}
}

function NoChangeAll(nochangename, updatename) {
	var ml = document.forms[0];
	var len = ml.elements.length;

	for (var i = 0; i < len; i++) {
		var e = ml.elements[i];
		if (e.value == nochangename) {
			e.checked = true;
		}
		if (e.value == updatename) {
			e.checked = false;
		}
	}
}

function UpdateAll(nochangename, updatename) {
	var ml = document.forms[0];
	var len = ml.elements.length;

	for (var i = 0; i < len; i++) {
		var e = ml.elements[i];
		if (e.value == nochangename) {
			e.checked = false;
		}
		if (e.value == updatename) {
			e.checked = true;
		}
	}
}

function DefaultButton(btnID, event) {
	btn = getElementByID_Master(btnID);
	if (document.all) {
		if (event.keyCode == 13) {
			event.returnValue = false;
			event.cancelBubble = true;
			btn.click();
		}
	}
	else if (document.getElementById) {
		if (event.which == 13) {
			event.returnValue = false;
			event.cancelBubble = true;
			btn.click();
			btn.focus();
		}
	}
	else if (document.layers) {
		if (event.which == 13) {
			event.returnValue = false;
			event.cancelBubble = true;
			btn.focus();
			btn.click();
		}
	}
}

function findObj(n, d) {
	var p, i, x;

	if (!d)
		d = document;

	if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
		d = parent.frames[n.substring(p + 1)].document;
		n = n.substring(0, p);
	}

	if (!(x = d[n]) && d.all)
		x = d.all[n];

	for (i = 0; !x && i < d.forms.length; i++)
		x = d.forms[i][n];

	for (i = 0; !x && d.layers && i < d.layers.length; i++)
		x = findObj(n, d.layers[i].document);

	if (!x && d.getElementById)
		x = d.getElementById(n);

	return x;
}

function change_img(imgid, img) {
	var i = getElementByID_Master(imgid);
	if (i == null)
		return;

	i.src = eval(img + ".src");
}

function change_master_img(img) {
	change_img("master_img", img);
}

function change_master_text(txt) {
	var i = getElementByID_Master("master_text");
	if (i == null)
		return;

	i.innerHTML = txt;
}

function change_master_text2(txt, txtid) {
	var i = getElementByID_Master(txtid);
	if (i == null)
		return;

	i.innerHTML = txt;
}

function change_master_link(link) {
	var i = getElementByID_Master("master_link");
	if (i == null)
		return;

	i.href = link;
}

function change_master_link2(link, linkid) {
	var i = getElementByID_Master(linkid);
	if (i == null)
		return;

	i.href = link;
}

function change_master_price(txt) {
	var i = getElementByID_Master("master_price");
	if (i == null)
		return;

	/// FOR QL COLOR SPLIT UPDATES ///
	while (txt.toLowerCase().indexOf('<a ') != -1) {
		txt = txt.replace('<a ', '<');
		txt = txt.replace('<A ', '<');
		txt = txt.replace('</a>', '</>');
		txt = txt.replace('</A>', '</>');
	}

	i.innerHTML = txt;
}

function change_master_price2(txt, txtid) {
	var i = getElementByID_Master(txtid);
	if (i == null)
		return;

	i.innerHTML = txt;
}

function change_master_mfgsku(txt) {
	var i = getElementByID_Master("master_mfgsku");
	if (i == null)
		return;

	i.innerHTML = txt;
}

function change_master_morecolors(txt) {
	var i = getElementByID_Master("master_colors");
	if (i == null)
		return;

	i.innerHTML = txt;
}

function change_master_new(txt) {
	var i = getElementByID_Master("master_newtxt");
	if (i == null)
		return;

	i.innerHTML = txt;
}

function lightup(imageobject, opacity) {
	var obj = getElementByID_Master(imageobject);

	if (navigator.userAgent.indexOf("Safari") != -1)
		obj.style.opacity = opacity / 100;
	else if ((navigator.appName.indexOf("Netscape") != -1 && parseInt(navigator.appVersion) >= 5))
		obj.style.MozOpacity = opacity / 100;
	else if ((navigator.appName.indexOf("Microsoft") != -1 && parseInt(navigator.appVersion) >= 4))
		obj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + opacity + ");";
}

function set_master_img(img) {
	var i = getElementByID_Master("master_img");
	if (i == null)
		return;

	i.src = img;
}

function outfit_left() {
	g_outfitindex--;
	if (g_outfitindex <= 0)
		g_outfitindex = g_numoutfits - 1;

	reload_outfits(g_outfitindex);
}

function outfit_right() {
	g_outfitindex++;
	if (g_outfitindex == g_numoutfits)
		g_outfitindex = 1;

	reload_outfits(g_outfitindex);
}

function reload_outfits(current_outfit) {
	var outfit_changer = current_outfit;

	for (var i = 1; i <= g_maxdisplaythumbscollection; i++) {
		var img = getElementByID_Master("OutfitThumbRPT_ctl" + zeropad(i) + "_OutfitNavImage");
		var imghl = getElementByID_Master("OutfitThumbRPT_ctl" + zeropad(i) + "_OutfitNavImageHL");
		if (img != null)
			img.src = "/store/productimages/thumbs/" + aOutfitThumb[outfit_changer];

		if (imghl != null)
			imghl.href = aOutfitThumbHL[outfit_changer];

		outfit_changer++;
		if (outfit_changer == g_numoutfits)
			outfit_changer = 0;
	}
}

function change_color_col_img(imgctlname, productid, i) {
	var img = getElementByID_Master(imgctlname);
	if (img == null)
		return;

	var imgpath = "/store/productimages/regular/" + eval("aColors_" + productid + "[i]");
	img.src = imgpath;
}

function change_color_col(imgctlname, productid, i) {
	this["g_color_" + productid] = i;

	change_color_col_img(imgctlname, productid, i);
	change_unitcost_col(productid, i);
	change_previouscost_col(productid, i);
}

function change_size_col(productid, i, qtycid, sizecid) {
	//    alert(eval("g_color_" + productid));

	this["g_size_" + productid] = i;

	change_unitcost_col(productid, i);
	change_previouscost_col(productid, i);

	if (getElementByID_Master(qtycid) != null && getElementByID_Master(qtycid).value == '')
		getElementByID_Master(qtycid).value = '1';

	var ps = getElementByID_Master(sizecid);

	if (ps == null)
		return;

	var curr_value = ps.options[ps.selectedIndex].value;

	if (curr_value == '-1')
		getElementByID_Master(qtycid).value = '';
}

function GetQueryStringVar(name) {
	var regexS = "[\\?&]" + name + "=([^&#]*)";
	var regex = new RegExp(regexS);
	var tmpURL = window.location.href;
	var results = regex.exec(tmpURL);
	if (results == null)
		return "";
	else
		return results[1];
}

function toggle_RPTFullDivItem(i) {
	var div = getElementByID_Master("ProductRPTFull_ctl" + zeropad(i) + "_RPTFullDiv");
	if (div.style.visibility == "hidden")
		div.style.visibility = "visible";
	else
		div.style.visibility = "hidden";
}

function unset_checkbox(i, j) {
	var rb_ip = getElementByID_Master("ProductRPTFull_ctl" + zeropad(i) + "_PM1_PetiteRB");
	var rb_jp = getElementByID_Master("ProductRPTFull_ctl" + zeropad(j) + "_PM1_PetiteRB");

	if (rb_ip.checked == true) {
		rb_jp.checked = true;
	}
	else {
		rb_jp.checked = false;
	}

	var rb_im = getElementByID_Master("ProductRPTFull_ctl" + zeropad(i) + "_PM1_MissyRB");
	var rb_jm = getElementByID_Master("ProductRPTFull_ctl" + zeropad(j) + "_PM1_MissyRB");

	if (rb_im.checked == true) {
		rb_jm.checked = true;
	}
	else {
		rb_jm.checked = false;
	}
}

function toggle_RPTFullDiv(rb, i, j) {
	unset_checkbox(i, j);

	toggle_RPTFullDivItem(i);
	toggle_RPTFullDivItem(j);

	return false;
}

function get_DIVVisibilityStates() {
	var s = "";

	for (var i = 0; i < 10; i++) {
		var div = getElementByID_Master("ProductRPTFull_ctl" + zeropad(i) + "_RPTFullDiv");
		if (div == null)
			continue;

		if (div.style.visibility == "hidden")
			s += "h";
		else
			s += "v";
	}

	return s;
}


function AttributePoster() {
	var a = "";

	var ProductSizesV = getElementByID_Master("ProductSizesV");
	if (ProductSizesV != null)
		ValidatorEnable(ProductSizesV, false);
	var ProductColorsV = getElementByID_Master("ProductColorsV");
	if (ProductColorsV != null)
		ValidatorEnable(ProductColorsV, false);

	// Get the selected values from the nav and send to the productslist page
	for (var i = 0; i < aAttributes.length; i++) {
		var c = getElementByID_Master(aAttributes[i]);
		if (c == null)
			continue;

		a += c.value;

		if (i + 1 < aAttributes.length)
			a += ",";
	}

	var vals = "";

	if (a.length > 0)
		vals += "&a=" + a;

	// See if there's a size option
	var s = getElementByID_Master(AttributeSizeNameDDL.id);
	if (s != null && s.length > 0)
		vals += "&sn=" + s.value;

	location.href = "/store/productslist.aspx?categoryid=" + AttributeSearchCategoryID + vals;
}

// function change image
function chgimg(imgfield, newimg) {
	if (document.images) {
		document[imgfield].src = eval(newimg + ".src")
	}
}

function openWin(url, name, height, width) {
	remote = window.open(url, name, 'height=' + height + ',width=' + width + ',titlebar=0,channelmode=0,screenX=10,left=10,screenY=10,top=10,hotkeys=0,dependent=1,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0');
	remote.focus();
	if (remote.opener == null) remote.opener = window;
	// remote.opener.name = 'opener';
}

function openbranchby_branchnamevar() {
	if (typeof (branchname) != 'undefined') {
		openBranchByName(branchname);
	}
}

function doSort(val) {
	filterorsort("sort", val);
}

function doSizeFilter(val) {
	filterorsort("sizef", val);
}

function doColorFilter(val) {
	filterorsort("colorf", val);
}

function doFitFilter(val) {
	filterorsort("fitf", val);
}

function doRiseFilter(val) {
	filterorsort("risef", val);
}

function doWashFilter(val) {
	filterorsort("washf", val);
}

function doSupportFilter(val) {
	filterorsort("supportf", val);
}

function doSportFilter(val) {
	filterorsort("sportf", val);
}

function doPriceFilter(min, max) {
	filterorsort2("minf", min, "maxf", max);
}


function addsingleparam(param, value, searchstring, categoryid, parentcolorid) {
	var newsearchstring = "";

	if (value == "viewall")
		newsearchstring = "?categoryid=" + categoryid + "&page=0";
	else if (searchstring == "" && parentcolorid == "")
		newsearchstring = "?categoryid=" + categoryid + "&" + param + "=" + (gup(param) == "" ? value : gup(param));
	else if (searchstring == "" && parentcolorid != "")
		newsearchstring = "?categoryid=" + categoryid + "&" + param + "=" + (gup(param) == "" ? value : gup(param)) + "&parentcolorid=" + parentcolorid;
	else
		newsearchstring = searchstring.replace("&" + param + "=" + gup(param), "") + "&" + param + "=" + (gup(param) == "" ? value : gup(param).replace(gup(param), value));

	if (value == "")
		newsearchstring = newsearchstring.replace("&" + param + "=", "")

	return newsearchstring;
}

function addparam(param, value, base, searchstring, categoryid, parentcolorid) {
	var baseurl = "";
	var newsearchstring = addsingleparam(param, value, searchstring, categoryid, parentcolorid);

	baseurl = base + newsearchstring;

	return baseurl;
}

function filterorsort(ctrlname, ctrlvalue) {
	var categoryid = getElementByID_Master("categoryidhidden").value;
	var parentcolorid = 0;
	try {
		parentcolorid = getElementByID_Master("parentcoloridhidden").value;
	}
	catch (err) { }

	var page = window.location.href;
	var base = "";

	if (page.indexOf("productslist2") > 0) {
		base = "/store/productslist2.aspx";
	} else if (page.indexOf("productslist3") > 0) {
		base = "/store/productslist2.aspx";
	} else if (page.indexOf("productslist4") > 0) {
		base = "/store/productslist4.aspx";
	} else {
		base = "/store/productslist.aspx";
	}
	var searchstring = window.location.search;
	var baseurl = addparam(ctrlname, ctrlvalue, base, searchstring, categoryid, parentcolorid);

	window.location.href = baseurl;
}

function filterorsort2(ctrlname, ctrlvalue, ctrlname2, ctrlvalue2) {
	var categoryid = getElementByID_Master("categoryidhidden").value;
	var base = "/store/productslist.aspx";
	var searchstring = window.location.search;
	var newsearchstring = addsingleparam(ctrlname, ctrlvalue, searchstring, categoryid);
	var baseurl = addparam(ctrlname2, ctrlvalue2, base, newsearchstring, categoryid);

	window.location.href = baseurl;
}

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 popup_productemailsignup(w) {
	var pw;
	pw = window.open(w, 'ProductEmailSignup', 'height=508,width=541,toolbar=no,resizable=yes,scrollbars=yes');
	pw.focus();
}

function autoclose_popup(timebeforeclosing) {
	closeMe(timebeforeclosing)
}

function closeMe(timebeforeclosing) {
	t = null;
	t = setTimeout("self.close()", timebeforeclosing);
}

function OutfitListPageLoad() {
	var firstthumb = findObj("OutfitImagesDL_OutfitNavImage");
	if (firstthumb == null)
		firstthumb = findObj("OutfitImagesDL_ctl00_OutfitNavImage");
	if (firstthumb == null)
		return;

	var oc = firstthumb.getAttribute("onmouseover");
	if (oc == null)
		return;

	//    alert(oc);

	var ocs = oc.toString();

	if (ocs.indexOf('anonymous') != -1) {
		ocs = ocs.substr(23, ocs.length - 24);
	}

	//    alert(ocs);

	eval(ocs);
}


function ProductsListPageLoad() {
	var firstthumb = getElementByID_Master("ContentPlaceHolder1_MyList_ThumbnailImage_0");

	if (firstthumb == null)
		firstthumb = getElementByID_Master("MyList_ctl00_ThumbnailImage");
	if (firstthumb == null)
		return;
	var oc = firstthumb.getAttribute("onmouseover");
	if (oc == null)
		return;

	var ocs = oc.toString();

	if (ocs.indexOf('anonymous') != -1) {
		ocs = ocs.substr(23, ocs.length - 24);
	}

	// STRIP EXTRA IE CODE
	if (ocs.indexOf('function onmouseover()') != -1) {
		ocs = ocs.replace('function onmouseover()', '');
	}
	if (ocs.indexOf('{') != -1) {
		ocs = ocs.replace('{', '');
	}
	if (ocs.indexOf('}') != -1) {
		ocs = ocs.replace('}', '');
	}

	eval(ocs);

}

//Start PopOver Swatches
function os_moveemnt(id, x, y) {
	if (document.getElementById) {
		getElementByID_Master(id).style.left = x + 'px';
		getElementByID_Master(id).style.top = y + 'px';
	}
}
function os_showemnt(id) {
	if (document.getElementById) {
		if (getElementByID_Master(id)) {
			getElementByID_Master(id).style.visibility = 'visible';
		}
	}
}
function os_hideemnt(id) {
	if (document.getElementById) {
		if (getElementByID_Master(id)) {
			getElementByID_Master(id).style.visibility = 'hidden';
		}
	}
}
function swhtml(id, html) {
	if (document.getElementById) {
		if (getElementByID_Master(id)) {
			getElementByID_Master(id).innerHTML = html;
		}
	}
}
function os_swmvswh(index, swatchDiv, colorDesc, img) {
	os_strcont = getElementByID_Master("os_swcntr" + index);
	os_strbcont = getElementByID_Master("container");
	os_strconttop = os_strcont.offsetTop + os_strbcont.offsetTop;
	os_strcontleft = os_strcont.offsetLeft + os_strbcont.offsetLeft;
	os_strscontwidth = os_strcont.offsetWidth;
	os_strcontright = os_strcontleft + os_strscontwidth;

	os_strbox = getElementByID_Master("os_swbox");
	os_strboxtop = os_strbox.offsetTop;
	os_strboxleft = os_strbox.offsetLeft;
	os_strboxwidth = os_strbox.offsetWidth;
	os_strsboxheight = os_strbox.offsetHeight;

	os_strboxnewleft = os_strcontleft + (swatchDiv.offsetLeft + (swatchDiv.offsetWidth / 2)) - (os_strboxwidth / 2)
	os_strboxnewright = os_strboxnewleft + (os_strboxwidth)

	if ((os_strboxnewleft) < (os_strcontleft)) {
		sbPosLeft = os_strcontleft;
	} else if ((os_strboxnewright) > (os_strcontright)) {
		sbPosLeft = os_strcontright - os_strboxwidth - 4;
	} else {
		sbPosLeft = os_strboxnewleft;
	}
	imgTag = '<img src="' + img + '">';
	imgURL = '' + img;
	os_showsw(index);
	var IfrRef = getElementByID_Master('dvsh');
	IfrRef.style.width = os_strbox.offsetWidth;
	IfrRef.style.height = os_strbox.offsetHeight;
	IfrRef.style.top = os_strbox.style.top;
	IfrRef.style.left = os_strbox.style.left;
	IfrRef.style.zIndex = 999;

	os_moveemnt('dvsh', sbPosLeft, os_strconttop - os_strsboxheight - 1);
	os_moveemnt('os_swbox', sbPosLeft, os_strconttop - os_strsboxheight - 1);
	swhtml('os_swboxclrdsc', colorDesc);

	swhtml('os_swboximg', imgTag);
}

dispSwatch = false;
function os_swhdswh(index) {
	dispSwatch = false;
	setTimeout('os_dohideswatch()', 100);
}
function os_dohideswatch(index) {
	if (!dispSwatch) {
		var IfrRef = getElementByID_Master('dvsh');
		IfrRef.style.display = "none";
		os_hideemnt('os_swbox');
	}
}
function os_showsw(index) {
	dispSwatch = true;
	var IfrRef = getElementByID_Master('dvsh');
	IfrRef.style.display = "block";
	os_showemnt('os_swbox');
}

{
	document.write("<div class=\"os_swbox\" id=\"os_swbox\">");
	document.write("<div class=\"os_swboximg\" id=\"os_swboximg\"></div>");
	document.write("<div class=\"os_swboxtxt\">");
	document.write("<div class=\"os_swboxclrdsc\" id=\"os_swboxclrdsc\"></div>");
	document.write("<div class=\"os_swboxacn\" id=\"os_swboxacn\"></div>");
	document.write("</div>");
	document.write("</div>");
	document.write("<div class=\"dvsh\" id=\"dvsh\" src=\"javascript:false;\" scrolling=\"no\" style=\"position:absolute; top:0px; left:0px; display:none;\"></div>");
}
//End PopOver Swatches

//PopupHover - Collections Page

function getObj(objectId) {
	if (document.getElementById && getElementByID_Master(objectId)) {
		return getElementByID_Master(objectId).style;
	} else if (document.all && document.all(objectId)) {
		return document.all(objectId).style;
	} else if (document.layers && document.layers[objectId]) {
		return document.layers[objectId];
	} else {
		return false;
	}
}

function objvisibilityStatus(objectId, newVisibility) {
	// make sure the object exists
	var styleObject = getObj(objectId);
	if (styleObject) {
		styleObject.visibility = newVisibility;
		return true;
	} else {
		// if we cant find the object change visibility
		return false;
	}
}

function verifyPosition(objectId, x, y) {
	// check if object exists
	var styleObject = getObj(objectId);
	if (styleObject) {
		styleObject.left = x;
		styleObject.top = y;
		return true;
	} else {
		// we couldn't find the object, so we can't very well move it
		return false;
	}
}

// Variables used to determine where the popup opens
var xOffset = 40;
var yOffset = -5;

function openPopup(newObjID, eventObj) {
	if (eventObj) {
		hidePopup();
		eventObj.cancelBubble = true;
		var x = (eventObj.pageX) ? eventObj.pageX + xOffset : eventObj.x + xOffset + ((document.body.scrollLeft) ? document.body.scrollLeft : 0);
		var y = (eventObj.pageY) ? eventObj.pageY + yOffset : eventObj.y + yOffset + ((document.body.scrollTop) ? document.body.scrollTop : 0);
		verifyPosition(newObjID, x, y);
		// and make it visible
		if (objvisibilityStatus(newObjID, 'visible')) {
			// globally-accessible object
			window.currentlyVisiblePopup = newObjID;
			return true;
		} else {
			// popup couldnt be found
			return false;
		}
	} else {
		// no event found
		return false;
	}
}

function hidePopup() {
	// note: we've stored the currently-visible popup on the global object window.currentlyVisiblePopup
	if (window.currentlyVisiblePopup) {
		objvisibilityStatus(window.currentlyVisiblePopup, 'hidden');
		window.currentlyVisiblePopup = false;
	}
}

// initialize workarounds whenever the page loads
window.onload = initFixes;

// Hide popup if doc is clicked
document.onclick = hidePopup;

function initFixes() {
	if ((navigator.appVersion.indexOf('MSIE 5') != -1)
	&& (navigator.platform.indexOf('Mac') != -1)
	&& getObj('blankDiv')) { }
}


// End PopupHover - Collections Page


//Start Swatches with Selection Enabled


function DisplayDefault(id, DefaultSwatchText, tableName, strlblSwatch) {
	var swatchlabel = getElementByID_Master(strlblSwatch);
	swatchlabel.innerHTML = DefaultSwatchText;
}

function DisplayText(id, SwatchText, currTDValue, tableName, strlblSwatch) {
	var strSwatchText = SwatchText;
	var swatchlabel = getElementByID_Master(strlblSwatch);
	swatchlabel.innerHTML = SwatchText;
	toggleImgColor(id, currTDValue, tableName)
}

function toggleImgColor(id, currentTD, tableName) {
	var tdTag;
	tdTag = getElementByID_Master(tableName).getElementsByTagName('td');

	for (var counter = 0; counter < tdTag.length; counter++) {
		var imgTag = tdTag[counter].getElementsByTagName('img');

		if (imgTag != null) {
			var imgClass = imgTag.item(0).className;

			if (imgClass == 'SelectedImage') {
				imgTag.item(0).className = '';
			}
		}
	}
	if (currentTD == null)
		imgTag.item(0).className = '';
	else
		currentTD.className = 'SelectedImage';
}

function SetImgColor(cid, id, currentTD, tableName, DefaultSwatchText, strlblSwatch) {
	var swatchlabel = getElementByID_Master(strlblSwatch);
	swatchlabel.innerHTML = 'Selected Color: ' + DefaultSwatchText;

	var tdTag;
	tdTag = getElementByID_Master(tableName).getElementsByTagName('td');

	for (var counter = 0; counter < tdTag.length; counter++) {
		var imgTag = tdTag[counter].getElementsByTagName('img');

		if (imgTag != null) {
			var imgClass = imgTag.item(0).className;

			if (imgClass == 'SelectedImage') {
				imgTag.item(0).className = '';
			}
		}
	}
	currentTD.className = 'SelectedImage';

	try {
		getElementByID_Master(cid).selectedIndex = id + 1;
	}
	catch (err) { }
}

// End Swatches with Selection Enabled

function SwapS7Image(VignetteName, ProductID, Scene7RenderServer, ImageID, ProductColor, ImageIndex, CurrTD, tableName, FabricName, strlblSwatch, Scene7VignetteWidth, Scene7VignetteSharpness, Scene7VignetteResolution, SKUPrice) {
	try {
		var swatchlabel = getElementByID_Master(strlblSwatch);
		swatchlabel.innerHTML = 'Now Showing: ' + FabricName + " | Price: " + SKUPrice;
	}
	catch (err) { }
	try {
		getElementByID_Master("MainProductImage").src = Scene7RenderServer + ProductID + '?wid=' + Scene7VignetteWidth + '&obj=body&src=' + VignetteName + '&res=' + Scene7VignetteResolution + '&sharpen=' + Scene7VignetteSharpness + '&cache=off';
	}
	catch (err) { }
	try {
		for (var s = 0; s <= getElementByID_Master("ProductSizes").length; s = s + 1) {
			var ddl1value = getElementByID_Master("ProductSizes").options[s].value;

			if (ddl1value == ImageID) {
				getElementByID_Master("ProductSizes").selectedIndex = s;
				break;
			}
		}

		for (var i = 0; i <= getElementByID_Master("ProductColors").length; i = i + 1) {
			var ddlvalue = getElementByID_Master("ProductColors").options[i].value;

			if (ddlvalue == ProductColor) {
				getElementByID_Master("ProductColors").selectedIndex = i;
				break;
			}
		}
	}
	catch (err) { }
}

function swatch_swap_mouse_over(ImagePath, ImageID, SwatchCount, SwatchID, ThumbImageID, NavUrl) {
	getElementByID_Master(ImageID).src = ImagePath;
	UnSelectAllSwatches_Iterator(SwatchID);
	getElementByID_Master(SwatchID + "_" + SwatchCount).className = "main-prod-swatch-selected";

	getElementByID_Master(ThumbImageID).href = NavUrl;

	if (ImagePath != null)
		swap_previewimage(ImagePath);
}

function swatch_swap_mouse_out(ImagePath, ImageID, SwatchCount, SwatchID, ThumbImageID, NavUrl) {

	UnSelectAllSwatches_Iterator(SwatchID);
	getElementByID_Master(ImageID).src = ImagePath;
	getElementByID_Master(SwatchID + "_" + SwatchCount).className = "main-prod-swatch-selected";

	getElementByID_Master(ThumbImageID).href = NavUrl;

	if (ImagePath != null)
		swap_previewimage(ImagePath);
}

function isNumeric(value) {
	if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
	return true;
}

function swatch_swap_click(ImagePath, ImageID, SwatchCount, SwatchID, ThumbImageID, NavUrl) {

	if (isNumeric(ImageID)) {
		getElementByID_Master(ImageID.toString()).src = ImagePath;
	}
	else if (getElementByID_Master("EnableListSwatchClickHiddenWithQuickView") != null) {
		var imgid = SwatchID.replace('swatches', '');
		getElementByID_Master(imgid).src = ImagePath;

	}
	else {
		getElementByID_Master(ImageID).src = ImagePath;
	}

	/// FOR QL COLOR SPLIT UPDATES ///
	if (getElementByID_Master("EnableListSwatchClickHiddenWithQuickView") != null) {
		if (SwatchID.indexOf('-') != -1)
			var imgid = SwatchID.split('-')[0] + 'swatches';
		else
			var imgid = SwatchID;
		UnSelectAllSwatches_Iterator(imgid);
		getElementByID_Master(imgid + "_" + SwatchCount).className = "main-prod-swatch-selected";
	}
	else {
		UnSelectAllSwatches_Iterator(SwatchID);
		getElementByID_Master(SwatchID + "_" + SwatchCount).className = "main-prod-swatch-selected";
	}

	getElementByID_Master(ThumbImageID).href = NavUrl;

	if (ImagePath != null)
		swap_previewimage(ImagePath);
}

function swap_previewimage(ImagePath) {
	var s = ImagePath;
	var previewimage = getElementByID_Master('main');
	var path = s.replace("thumbs", "regular").replace("_thumb.jpg", ".jpg");

	if (previewimage != null)
		previewimage.src = path;
}

function swap_previewimage_mouseover(ImageID, index) {
	var id = ImageID.replace(/[^0-9]/g, '');

	/// FOR QL COLOR SPLIT UPDATES ///
	if (index) {
		id += '-' + index;
	}
	var thumbpath;

	thumbpath = getElementByID_Master(id).src;

	var pathReplace = ImageID.toString().indexOf("detail") > 0 ? "detail" : "regular";
	var path = thumbpath.replace("thumbs", pathReplace).replace("_thumb.jpg", ".jpg");
	var previewimage = getElementByID_Master('main');
	if (previewimage != null) {
		previewimage.src = path;
	}
}


function UnSelectAllSwatches_Iterator(elementId) {
	var i = 0;
	while (!isNull(getElementByID_Master(elementId + "_" + i))) {
		var elem = getElementByID_Master(elementId + "_" + i)
		if (elem.className == "main-prod-swatch-selected") {
			elem.className = "main-prod-swatch-unselected";
		}
		i++;
	}
}

function isNull(elem) {
	if (elem == null) return true;
	return false;
}

function OnRequestStart(ajaxPanel, eventArgs) {
	if (navigator.userAgent.indexOf("Firefox") != -1) {
		DisableControls();
	}
}

function OnResponseEnd(ajaxPanel, eventArgs) {
	if (navigator.userAgent.indexOf("Firefox") != -1) {
		EnableControls();
	}
	try {
		var CartItems;
		var CartTotal;
		var CartItemsHidden;
		var CartTotalHidden;

		HideCartItemsText = getElementByID_Master("ShoppingBag1$HideCartItemsText");
		if (HideCartItemsText == null)
			HideCartItemsText = getElementByID_Master("ctl00$ShoppingBag1$HideCartItemsText");
		CartItems = getElementByID_Master("Top1_ShoppingBag1_CartItemsLB");
		CartTotal = getElementByID_Master("Top1_ShoppingBag1_CartTotalLB");
		CartItemsCount = getElementByID_Master("ShoppingBag1_CartItemsCount");
		if (CartItemsCount == null)
			CartItemsCount = getElementByID_Master("ctl00_ShoppingBag1_CartItemsCount");
		CartItemsHidden = getElementByID_Master("CartItemsHidden");
		CartTotalHidden = getElementByID_Master("CartTotalHidden");
		CartItemsTopNav = getElementByID_Master("TopNav1_ShoppingBag1_CartItemsLB");
		if (CartItemsTopNav == null)
			CartItemsTopNav = getElementByID_Master("ctl00_TopNav1_ShoppingBag1_CartItemsLB");
		CartTotalTopNav = getElementByID_Master("TopNav1_ShoppingBag1_CartTotalLB");
		if (CartTotalTopNav == null)
			CartTotalTopNav = getElementByID_Master("ctl00_TopNav1_ShoppingBag1_CartTotalLB");
		CartItemsCountTopNav = getElementByID_Master("TopNav1_ShoppingBag1_CartItemsCount");
		if (CartItemsCountTopNav == null)
			CartItemsCountTopNav = getElementByID_Master("ctl00_TopNav1_ShoppingBag1_CartItemsCount");
		CartItemsCountTopNav2 = getElementByID_Master("TopNav1_ShoppingBag2_CartItemsCount");
		if (CartItemsCountTopNav2 == null)
			CartItemsCountTopNav2 = getElementByID_Master("ctl00_TopNav1_ShoppingBag2_CartItemsCount");
		CartItemsHidden2 = getElementByID_Master("ContentPlaceHolder1_CartItemsHidden");
		if (CartItemsHidden2 == null)
			CartItemsHidden2 = getElementByID_Master("ctl00_ContentPlaceHolder1_CartItemsHidden");
		CartTotalHidden2 = getElementByID_Master("ContentPlaceHolder1_CartTotalHidden");
		if (CartTotalHidden2 == null)
			CartTotalHidden2 = getElementByID_Master("ctl00_ContentPlaceHolder1_CartTotalHidden");

		//CartItems can remain null for clients like PAIG/SEVN/BTSY whose Top1 is null (line 1842)
		//consequently, bag value gets updated but bag item count does not
		//therefore, we would only want to re-init CartItems IF IT REMAINS NULL so I am changing line 1854 from != to ==
		if (CartItems == null) {
			if (CartItemsTopNav != null)
				CartItems = getElementByID_Master("ctl00_TopNav1_ShoppingBag1_CartItemsLB");
			else
				CartItems = getElementByID_Master("ctl00_ShoppingBag1_CartItemsLB");
		}

		if (CartItemsCountTopNav2 != null && (CartItemsHidden2.value != ""))
			CartItemsCountTopNav2.innerHTML = CartItemsHidden.value;

		if (CartTotalTopNav != null)
			CartTotal = getElementByID_Master("ctl00_TopNav1_ShoppingBag1_CartTotalLB");
		else
			CartTotal = getElementByID_Master("ctl00_ShoppingBag1_CartTotalLB");

		if (CartTotal != null)
			CartTotal.innerHTML = CartTotalHidden.value;

		if (CartItemsCount != null)
			CartItemsCount.innerHTML = CartItemsHidden.value;

		if (CartItemsCountTopNav != null)
			CartItemsCountTopNav.innerHTML = CartItemsHidden.value;

		if (CartItemsHidden.value == "1") {
			if (CartItems != null) {
				if (HideCartItemsText != null && HideCartItemsText.value == "1")
					CartItems.innerHTML = CartItemsHidden.value;
				else
					CartItems.innerHTML = CartItemsHidden.value + " Item";
			}
		}
		else {
			if (CartItems != null) {
				if (HideCartItemsText != null && HideCartItemsText.value == "1")
					CartItems.innerHTML = CartItemsHidden.value;
				else
					CartItems.innerHTML = CartItemsHidden.value + " Items";
			}
		}
		render_cart_header("CartItemsLBGet", "CartTotalLBGet");

		if (getElementByID_Master('ShoppingCartAjaxEnabled') != null) {
			trigger_cartajax();
		}
	}
	catch (err) { }
}
function UpdateContinueShoppingLink() {
	try {
		var continueShippingLink = getFirstElementByClassName("jsHlContinueshopping");
		if (continueShippingLink != null) {
			var hiddenField = getFirstElementByClassName("jsHdnContinueShoppingLink");
			if (hiddenField != null) {
				continueShippingLink.href = hiddenField.value;
			}
		}
	}
	catch (err) { }
}
function DisableControls() {
	for (var i = 0; i < document.forms[0].elements.length; i++) {
		var obj = document.forms[0].elements[i];

		if (document.forms[0].elements[i].name == "__VIEWSTATE")
			obj.disabled = true;
	}
}

function EnableControls() {
	for (var i = 0; i < document.forms[0].elements.length; i++) {
		var obj = document.forms[0].elements[i];
		obj.disabled = false;
	}
}

function addToFavorites(url, title) {
	var ua = navigator.userAgent.toLowerCase();
	var isSafari = ua.indexOf('webkit') != -1;
	var isMac = ua.indexOf('mac') != -1;
	var buttonStr = isMac ? 'Command/Cmd' : 'CTRL';

	if (window.sidebar) // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url, "")
	else if (window.external) // IE Favorite
		window.external.AddFavorite(url, title)
	else if (isSafari) // Safari
		alert('You need to press ' + buttonStr + ' + D to bookmark this page.');
	else // Others
		alert("Your browser doesn't support this function.");
}

function ToggleCheck(me, group) {
	var checked = me.checked;
	if (checked) for (var i = 1; i < arguments.length; i++) {
		var ck = document.getElementById(arguments[i]);
		if (ck) ck.checked = false;
	}
	me.checked = checked;
}

function TrimString(inputString) {
	if (typeof inputString != "string") { return inputString; }
	var retValue = inputString;
	var ch = retValue.substring(0, 1);
	while (ch == " ") {
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	ch = retValue.substring(retValue.length - 1, retValue.length);
	while (ch == " ") {
		retValue = retValue.substring(0, retValue.length - 1);
		ch = retValue.substring(retValue.length - 1, retValue.length);
	}
	while (retValue.indexOf("  ") != -1) {
		retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ") + 1, retValue.length);
	}
	return retValue;
}

function SearchBarSetQuery(searchfield, storeUrl, btnId, searchfieldid) {
	if (false == ValidateSearch(searchfieldid)) {
		return false;
	}
	searchfield = TrimString(searchfield.toLowerCase());

	if (false == ValidateSearch(searchfieldid)) {
		return false;
	}
	else {
		document.MM_returnValue = false;
		window.location.href = storeUrl + CallEncode(searchfield);
	}
}

function CallEncode(text) {
	var encoded = encodeURIComponent(text);
	return encoded;
}

function ValidateSearch(textBoxId) {
	var textBox = document.getElementById(textBoxId);
	if (TrimString(textBox.value).length == 0) {
		alert('Please specify a search criteria');
		return false;
	}
	// Check for invalid characters, specifically, "<" and ">".
	if (TrimString(textBox.value).indexOf('<') > -1 || TrimString(textBox.value).indexOf('>') > -1) {
		alert('We\'re sorry, the search value entered is invalid. Please try again.');
		return false;
	}
	return true;
}
//*************Search Functions used on TRUE*************//

function SingleSelectCheckBox(regex, current) {
	re = new RegExp(regex);
	for (i = 0; i < document.forms[0].elements.length; i++) {
		elm = document.forms[0].elements[i];
		if (elm.type == 'checkbox') {

			if (re.test(elm.name)) {
				elm.checked = false;
			}
		}
	}
	current.checked = true;
}

function render_cart_header(items, total) {
	if (getElementByID_Master(total) == null || getElementByID_Master(items) == null)
		return;

	var xmlhttp = false;
	/*@cc_on@*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	@end@*/
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}

	try {
		if (topdomain) {
			var prot = "http://";
			if (isSecure())
				prot = "https://";
			//alert(prot + topdomain);
			xmlhttp.open("GET", prot + topdomain + "/store/os/shoppingcartcost.aspx", false);
			xmlhttp.send();
			var str = xmlhttp.responseText;
			xmlhttp.close;
			xmlhttp = false;
			var ary = str.split("|");
			if (ary.length > 1) {
				getElementByID_Master(total).innerHTML = ary[0];
				getElementByID_Master(items).innerHTML = ary[1];
			}
		}
	}
	catch (e) { }

	try {
		getElementByID_Master("CartLiteralSgl").style.display = "none";
		getElementByID_Master("CartLiteralPlural").style.display = "none";
		(getElementByID_Master("CartItemsLBGet").innerHTML == "1") ? getElementByID_Master("CartLiteralSgl").style.display = "inline" : getElementByID_Master("CartLiteralPlural").style.display = "inline";
	}
	catch (e) { }
}

function addEvent(obj, evType, fn, useCapture) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, useCapture);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent("on" + evType, fn);
		return r;
	}
}

function addEventToElement(element, evenType, functionToRun) {
	if (element.addEventListener) {
		element.addEventListener(evenType, functionToRun, false);
		EventCache.add(element, evenType, functionToRun);
	}
	else if (element.attachEvent) {
		element["e" + evenType + functionToRun] = functionToRun;
		element[evenType + functionToRun] = function () { element["e" + evenType + functionToRun](window.event); }
		element.attachEvent("on" + evenType, element[evenType + functionToRun]);
		EventCache.add(element, evenType, functionToRun);
	}
	else {
		element["on" + evenType] = element["e" + evenType + functionToRun];
	}
}

var EventCache = function () {
	var listEvents = [];
	return {
		listEvents: listEvents,
		add: function (node, sEventName, fHandler) {
			listEvents.push(arguments);
		},
		flush: function () {
			var i, item;
			for (i = listEvents.length - 1; i >= 0; i = i - 1) {
				item = listEvents[i];
				if (item[0].removeEventListener) {
					item[0].removeEventListener(item[1], item[2], item[3]);
				};
				if (item[1].substring(0, 2) != "on") {
					item[1] = "on" + item[1];
				};
				if (item[0].detachEvent) {
					item[0].detachEvent(item[1], item[2]);
				};
				item[0][item[1]] = null;
			};
		}
	};
} ();

function setNumericValuesOnlyOnElements(elementsClassName) {
	var elements = getElementsByClassName(elementsClassName);
	if (elements != null) {
		var numberOfElements = elements.length;
		if (numberOfElements > 0) {
			var element;
			for (var i = 0; i < numberOfElements; i++) {
				setNumericValuesOnlyOnElement(elements[i]);
			}
		}
	}
}

function setNumericValuesOnlyOnElement(element) {
	if (element != null) {
		addEventToElement(element, "keyup",
										function () { removeNoNumericValuesOnElement(element); });
	}
}

function removeNoNumericValuesOnElement(element) {
	if (element != null) {
		element.value = element.value.replace(/[^0-9]/g, "");
	}
}

function getFirstElementByClassName(className) {
	var elements = getElementsByClassName(className);
	if (elements != null) {
		if (elements.length > 0) {
			return elements[0];
		}
	}
	return null;
}
/* CHECKBOX START */
function createOneStopCheckBoxes() {
	var checkBoxes = getElementsByClassName("OneStopCheckBox");
	if (checkBoxes != null) {
		var numberOfCheckBoxes = checkBoxes.length;
		if (numberOfCheckBoxes > 0) {
			for (var i = 0; i < numberOfCheckBoxes; i++) {
				setOneStopCheckBox(checkBoxes[i]);
			}
		}
	}
}
function setOneStopCheckBox(checkbox) {
	if (checkbox.type == "checkbox") {
		var oneStopSpan = createOneStopElementSpan();
		if (checkbox.checked == true) {
			addCls(oneStopSpan, "OneStopCheckBoxChecked");
		}
		oneStopSpan.onclick = function () { changeCheckBoxStatus(checkbox, oneStopSpan); };
		checkbox.parentNode.appendChild(oneStopSpan);
	}
}
function createOneStopElementSpan() {
	var span = document.createElement("span");
	span.className = "OneStopElementSpan";
	return span;
}
function changeCheckBoxStatus(checkbox, span) {
	if (checkbox.checked == true) {
		remCls(span, "OneStopCheckBoxChecked");
		checkbox.checked = false;
	}
	else {
		addCls(span, "OneStopCheckBoxChecked");
		checkbox.checked = true;
	}
	fireCheckBoxChangeEvent(checkbox);
}
function fireCheckBoxChangeEvent(element) {
	if (element.onchange) {
		var fireOnThis = element;
		if (document.createEvent) {
			var evObj = document.createEvent('HTMLEvents');
			evObj.initEvent('change', true, false);
			fireOnThis.dispatchEvent(evObj);
		} else if (document.createEventObject) {
			var evObj = document.createEventObject();
			fireOnThis.fireEvent('change', evObj);
		}
	}
}

/* CHECKBOX END */
var topdomain = document.domain;

function SetOptOutShopper(chk) {
	if (chk.checked == 1) {
		//if (Get_Cookie('ShopperBagPersist')) alert(Get_Cookie('ShopperBagPersist'));

		Delete_Cookie('ShopperBagPersist', '/', '');
		//  (Get_Cookie('ShopperBagPersist')) ? alert(Get_Cookie('ShopperBagPersist')) :
		//  alert('it is gone');

		getElementByID_Master("IsShopperBagUnchecked").value = "0";
		//  alert(getElementByID_Master("IsShopperBagUnchecked").value);
	}

	else {
		Set_Cookie('ShopperBagPersist', '1', '7', '/', '', '');
		getElementByID_Master("IsShopperBagUnchecked").value = "1";
		//  (Get_Cookie('ShopperBagPersist')) ? alert(Get_Cookie('ShopperBagPersist')) :
		//  alert('it is added  ');  
	}
}

function Get_Cookie(check_name) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split(';');
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for (i = 0; i < a_all_cookies.length; i++) {
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split('=');

		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if (cookie_name == check_name) {
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if (a_temp_cookie.length > 1) {
				cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if (!b_cookie_found) {
		return null;
	}
}

function Get_Cookie(name) {
	var start = document.cookie.indexOf(name + "=");
	var len = start + name.length + 1;
	if ((!start) && (name != document.cookie.substring(0, name.length))) {
		return null;
	}
	if (start == -1) return null;
	var end = document.cookie.indexOf(";", len);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(len, end));
}

function Delete_Cookie(name, path, domain) {
	if (Get_Cookie(name)) document.cookie = name + "=" + ((path) ? ";path=" + path : "") + ((domain) ? ";domain=" + domain : "") + ";expires=Mon, 01-Jan-1900 00:00:01 GMT";
}

function Set_Cookie(name, value, expires, path, domain, secure) {

	// set time, it's in milliseconds
	var today = new Date();
	today.setTime(today.getTime());

	/*
	if the expires variable is set, make the correct  
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if (expires) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date(today.getTime() + (expires));

	document.cookie = name + "=" + escape(value) +
	((expires) ? ";expires=" + expires_date.toGMTString() : "") +
	((path) ? ";path=" + path : "") +
	((domain) ? ";domain=" + domain : "") +
	((secure) ? ";secure" : "");
}

var gomez = {
	gs: new Date().getTime(),
	acctId: '547B67',
	pgId: '',
	grpId: ''
};

/*Gomez tag version: 5.1*/

var gomez = gomez ? gomez : {}; gomez.h3 = function (d, s) { for (var p in s) { d[p] = s[p]; } return d; }; gomez.h3(gomez, { b3: function (r) { if (r <= 0) return false; return Math.random() <= r && r; }, b0: function (n) { var c = document.cookie; var v = c.match(new RegExp(';[ ]*' + n + '=([^;]*)')); if (!v) v = c.match(new RegExp(n + '=([^;]*)')); if (v) return unescape(v[1]); return ''; }, c2: function (n, v, e, p, d, s) { try { var t = this, a = location.hostname; var c = n + '=' + escape(v) + (e ? ';expires=' + e.toGMTString() : '') + (p ? ';path=' + p : ';path=/') + (d ? ';domain=' + d : ';domain=' + a) + (s ? ';secure' : ''); document.cookie = c; } catch (e) { } }, z0: function (n) { var t = this; if (n) { var s = t.b0("__g_c"); if (!s) return ''; var v = s.match(new RegExp(n + ':([^\|]*)')); if (v) return unescape(v[1]); return ''; } else return ''; }, z1: function (n, m) { var t = this; if (n) { var s = t.b0("__g_c"); if (s) { if (s.indexOf(n + ':') != -1) s = s.replace(new RegExp('(' + n + ':[^\|]*)'), n + ':' + m); else s = s == ' ' ? n + ':' + m : s + '|' + n + ':' + m; t.c2("__g_c", s); } else t.c2("__g_c", n + ':' + m); }; } }); if (gomez.wrate) { gomez.i0 = gomez.z0('w'); if (gomez.i0) { gomez.runFlg = parseInt(gomez.i0) > 0 ? true : false; } else if (gomez.b3(parseFloat(gomez.wrate))) { gomez.runFlg = true; gomez.z1('w', 1); } else { gomez.runFlg = false; gomez.z1('w', 0); } } else if (gomez.wrate == undefined) { gomez.runFlg = true; gomez.z1('w', 1); } else { gomez.runFlg = false; gomez.z1('w', 0); }; if (gomez.runFlg) { gomez.h1 = function (v, d) { return v ? v : d }; gomez.gs = gomez.h1(gomez.gs, new Date().getTime()); gomez.acctId = gomez.h1(gomez.acctId, ''); gomez.pgId = gomez.h1(gomez.pgId, ''); gomez.grpId = gomez.h1(gomez.grpId, ''); gomez.E = function (c) { this.s = c; }; gomez.E.prototype = { g1: function (e) { var t = gomez, i = t.g6(e); if (i) i.e = t.b5(); } }; gomez.L = function (m) { this.a = m; }; gomez.L.prototype = { g2: function (m) { var t = gomez, n = t.b5(); var s = document.getElementsByTagName(m); var e = t.k; if (m == 'script') e = t.j; if (m == 'iframe') e = t.l; if (s) { var l = s.length; for (var i = 0; i < l; i++) { var u = s[i].src || s[i].href; if (u && !e[u]) { var r = new gomez.E(e); t.grm[u] = r; e[u] = new t.c7(u, n); if (t.gIE && m == 'script') t.e2(s[i], 'readystatechange', t.d2, false); else t.e2(s[i], 'load', r.g1, false); } } } } }; gomez.L.m = new Object; gomez.L.m['link'] = new gomez.L(); gomez.L.m['iframe'] = new gomez.L(); gomez.S = function () { var t = this, h = gomez.acctId + ".r.axf8.net"; t.x = location.protocol + '//' + h + '/mr/b.gif?'; t.y = location.protocol + '//' + h + '/mr/a.gif?'; }; gomez.h2 = function () { var t = this; t.gIE = false; t.f = new Object; t._h = 0; t.j = new Object; t.k = new Object; t.l = new Object; t.m = location.href; t.p = -1; t.q = -1; t.t = new Array; t.u = new Array; t._w = false; t.gSfr = /KHTML|WebKit/i.test(navigator.userAgent); t.gc = { 'n': 'c' }; t.grm = new Object; t.b; t.a = 0; t.d = false; t.x = false; t.s = new gomez.S; t._a = false; t.h6 = false; t.n1 = 0; }; gomez.h3(gomez, { h5: function (u) { try { var s = document.createElement('script'); s.src = u; s.type = 'text/javascript'; if (document.body) document.body.appendChild(s); else if (document.documentElement.getElementsByTagName('head')[0]) document.documentElement.getElementsByTagName('head')[0].appendChild(s); } catch (e) { } }, a9: function () { var t = gomez, i = t.z0('a'), g = t.b0('__g_u'), h = t.z0('h'); t.gc.h = t.z0('b'); if (h) t.n1 = parseInt(h); if (!t.gc.h) t.gc.h = 1; t.z1('b', parseInt(t.gc.h) + 1); if (i) { t.a = parseInt(i); if (t.a == 1) { t._w = true; } else if (t.a == 3) { t.x = true; t._w = true; }; t.d = true; t.gc.c = t.z0('c'); t.gc.d = t.z0('d'); t.gc.i = t.z0('e'); t.gc.j = t.z0('f'); if (t._w && !t._a) { t.h7(); t._a = true; }; } else { if (!t.gc.a) return; var s = 'v=1'; t.c2('__g_u', '1', new Date(t.gt() + 1000)); if (t.b0('__g_u') && g && g != '1' && g.indexOf('NaN') == -1 && g.indexOf('undefined') == -1) { s = 'v=0'; var r = g.split('_'); t.b2(parseInt(r[0]), parseInt(r[1]) + 1); if (r[4] && r[4] != '0' && t.gt() < parseInt(r[5]) && r[2] && r[2] != '0') { t.b1(parseFloat(r[2]), parseFloat(r[3]), parseFloat(r[4]), parseInt(r[5])); if (r[6]) t.n0(parseInt(r[6])); return; }; }; t.h6 = true; s = t.s.y + 'a=' + t.gc.a + '&' + s; if (t.gSfr) document.write("<scr" + "ipt src='" + s + "'" + "><\/scr" + "ipt>"); else t.h5(s); }; t.b = t.z0('g'); }, h7: function () { var t = gomez, u = t.tloc ? t.tloc : location.protocol + '//' + t.acctId + '.t.axf8.net/js/gtag5.1.js'; if (t.gSfr) document.write("<scr" + "ipt src='" + u + "'" + "><\/scr" + "ipt>"); else t.h5(u); }, n0: function (h) { var t = gomez, f = new Date(t.gt() + 946080000000), g = t.b0('__g_u'); t.n1 = h; t.z1('h', h); if (g && g != '1' && g.indexOf('NaN') == -1 && g.indexOf('undefined') == -1) { var r = g.split('_'); g = '' + r[0] + '_' + r[1] + '_' + r[2] + '_' + r[3] + '_' + r[4] + '_' + r[5] + '_' + h; t.c2('__g_u', g, f); }; }, b1: function (v, s, q, f) { var t = this; if (t._a) return; if (t.b3(v)) { t._w = true; t.a = 1; var p = parseFloat(s / v); if (t.b3(p)) { t.x = true; t.a = 3; }; }; t.d = true; t.z1('a', t.a); t.z1('e', v); t.z1('f', s); t.gc.i = v; t.gc.j = s; t.h4(v, s, q, f); if (t._w) { t.h7(); t._a = true; }; }, b2: function (v, s) { var t = this, f = new Date(t.gt() + 946080000000), g = '' + v + '_' + s; if (t._a) return; t.c2('__g_u', g, f); t.gc.c = v; t.gc.d = s; t.z1('c', v); t.z1('d', s); }, h4: function (o, p, q, d) { var t = this, f = new Date(t.gt() + 946080000000), g = t.b0('__g_u'); if (g && g != '1' && g.indexOf('NaN') == -1 && g.indexOf('undefined') == -1) { var r = g.split('_'), s; if (d) s = d; else if (q && q >= 0) s = new Date(t.gt() + parseInt(q * 86400000)).getTime(); else { q = 5; s = new Date(t.gt() + 432000000).getTime(); }; g = '' + r[0] + '_' + r[1] + '_' + o + '_' + p + '_' + q + '_' + s; t.c2('__g_u', g, f); }; }, gt: function () { return new Date().getTime() }, b5: function () { return new Date().getTime() - gomez.gs }, b6: function () { var t = gomez; t.p = t.b5(); }, f8: function () { var t = this; if (t.pollId1) clearInterval(t.pollId1); if (t.pollId2) clearInterval(t.pollId2); if (t.pollId3) clearInterval(t.pollId3); if (t.pollId4) clearInterval(t.pollId4); }, b7: function () { var t = gomez; t.f8(); t.q = t.b5(); }, c7: function (u, s) { var t = this; t.m = u; t.s = s; }, c8: function () { var t = gomez, n = t.b5(), l = document.images.length; if (l > t._h) { for (var i = t._h; i < l; ++i) { var u = document.images[i].src; if (u) { var r = new gomez.E(t.f); t.grm[u] = r; t.f[u] = new t.c7(u, n); t.e2(document.images[i], 'load', t.c4, false); t.e2(document.images[i], 'error', t.c5, false); t.e2(document.images[i], 'abort', t.c6, false); } } } t._h = l; }, c4: function (e) { var t = gomez, i = t.g6(e); if (i) i.e = t.b5(); }, c5: function (e) { var t = gomez, i = t.g6(e); if (i) { i.e = t.b5(); i.b = 1; } }, c6: function (e) { var t = gomez, i = t.g6(e); if (i) i.a = t.b5(); }, g6: function (e) { var t = gomez, e = window.event ? window.event : e, a = t.d8(e), i; if (t.grm[a.src || a.href] && t.grm[a.src || a.href].s) i = t.grm[a.src || a.href].s[a.src || a.href]; return i; }, d2: function () { var t = gomez; var e = window.event ? window.event : e, s = t.d8(e); if (s.readyState == 'loaded' || s.readyState == 'complete') { var o = t.j[s.src]; if (o) o.e = t.b5(); } }, setPair: function (name, value) { var t = this; t.t[t.t.length] = { 'n': 'p', 'a': name, 'b': value }; }, nameEvent: function (n) { var t = this; t.f6(n, 1); }, startInterval: function (n) { var t = this; t.f6(n, 2, 1); }, endInterval: function (n) { var t = this; t.f6(n, 2, 2); }, f6: function (n, p, b) { if (n && n.length > 20) n = n.substring(0, 20); var t = this, f = t.u; if (p == 3) { f[f.length] = { 'n': 'a', 'a': n, 'b': b, 'e': p, 'f': undefined }; } else { f[f.length] = { 'n': 'a', 'a': n, 'b': t.b5(), 'e': p, 'f': b }; } }, customValue: function (n, v) { var t = this; if (typeof (v) != 'number') { return; } t.f6(n, 3, v); }, d8: function (e) { if (gomez.gIE) return e.srcElement || {}; else return e.currentTarget || e.target || {}; }, e2: function (e, p, f, c) { var n = 'on' + p; if (e.addEventListener) e.addEventListener(p, f, c); else if (e.attachEvent) e.attachEvent(n, f); else { var x = e[n]; if (typeof e[n] != 'function') e[n] = f; else e[n] = function (a) { x(a); f(a); }; } }, i1: function () { var d = window.document, done = false, i2 = function () { if (!done) { done = true; gomez.b6(); gomez.a9(); } }; (function () { try { d.documentElement.doScroll('left'); } catch (e) { setTimeout(arguments.callee, 50); return; } i2(); })(); d.onreadystatechange = function () { if (d.readyState == 'complete') { d.onreadystatechange = null; i2(); } }; }, g7: function () { try { var t = gomez; t.gc.a = t.acctId; /*@cc_ont.gIE = true; @*/if (t.gIE) { t.i1(); window.attachEvent('onload', t.b7); } else if (window.addEventListener) { window.addEventListener('DOMContentLoaded', t.b6, false); window.addEventListener('load', t.b7, false); } else if (t.gSfr) { var m = setInterval(function () { if (/loaded|complete/.test(document.readyState)) { clearInterval(m); delete m; t.b6(); t.b7(); } }, 10); } else return; if (!t.jbo) { t.c8(); t.pollId1 = setInterval(t.c8, 10); gomez.L.m['link'].g2('link'); t.pollId3 = setInterval("gomez.L.m['link'].g2('link')", 10); gomez.L.m['iframe'].g2('iframe'); t.pollId4 = setInterval("gomez.L.m['iframe'].g2('iframe')", 10); } if (!t.gIE) t.a9(); } catch (e) { return; } } }); gomez.h2(); gomez.g7(); }

