// Last updated 2010-02-05


function show_baynote_guide(pagetype,listsize)
{
	baynote_tag.server = "http://usmattress-www.baynote.net";
	baynote_tag.customerId = "usmattress";
	baynote_tag.code = "www";
	baynote_tag.type = "guide";
	baynote_tag.format = "results2"

	if(pagetype == "home")
	{
		baynote_tag.guide = "Home";
		baynote_tag.listSize = 3;
	}
	else if(pagetype == "HomeHoriz")
	{
		baynote_tag.guide = "HomeHoriz";
		baynote_tag.listSize = 4;
	}
	else if(pagetype == "home-custom")
	{
		baynote_tag.guide = "MostPopular";
		baynote_tag.attrFilter = "PriceFlag:true|RecommendFlag:true";
		baynote_tag.listSize = 3;
	}
	else if(pagetype == "Section")
	{
		baynote_tag.guide = "Section";
		baynote_tag.listSize = 5;
	}
	else if(pagetype == "default")
	{
		var showguide = baynote_checkShowGuide();
		if(showguide)
		{
			baynote_tag.guide = "AutoGuide";
			baynote_tag.listSize = 5;
		}
	}
	else if(pagetype == "threeProducts")
	{
		var showguide = baynote_checkShowGuide();
		if(showguide)
		{
			baynote_tag.guide = "AutoGuide";
			baynote_tag.listSize = 3;
		}
	}

	if(listsize != null && listsize > 0) { baynote_tag.listSize = listsize;}

	if(baynote_tag.guide != "" && baynote_tag.listSize > 0)
		baynote_tag.show();
	else
		baynote_tag.noshow();
}

function baynote_checkOrderForm()
{
	var has_orderform = false;
	var form_tags = document.getElementsByTagName("form");
	for (var i=0; i<form_tags.length; i++)
	{
		var form_obj = form_tags[i];
		var form_method = form_tags[i].method;
		var form_action = form_tags[i].action;
		if(form_action.indexOf("http://order.store.yahoo.net/cgi-bin/wg-order?us-mattress+") == 0)
		{
			has_orderform = true;
			break;
		}
	}
	return has_orderform;
}

function baynote_checkShowGuide()
{
	var showguide = true;
	var page_url = window.location.href;
	if(page_url.indexOf("?") > 0) { page_url = page_url.substring(0,page_url.indexOf("?")); }
	if(page_url.indexOf("http://us-mattress.com/") == 0) { page_url = page_url.replace(/http:\/\/us\-mattress\.com\//,"http://www.us-mattress.com/"); }
	else if(page_url.indexOf("http://usmattress.com/") == 0) { page_url = page_url.replace(/http:\/\/usmattress\.com\//,"http://www.usmattress.com/"); }

	if(page_url == "http://www.us-mattress.com/") { showguide = false; }
	else if(page_url == "http://www.us-mattress.com/index.html") { showguide = false; }
	else if(page_url == "http://www.us-mattress.com/homepagetest.html") { showguide = false; }
	else if(page_url == "http://www.usmattress.com/") { showguide = false; }
	else if(page_url == "http://www.usmattress.com/index.html") { showguide = false; }
	else if(page_url == "http://www.usmattress.com/homepagetest.html") { showguide = false; }
	else if(page_url.match(/^http:\/\/us\-f[\d]\-edit\.store\.yahoo\.com\/RT\/NEWEDIT\.us\-mattress\/[^\/]+\/index\.html$/)) { showguide = false; }
	else if(page_url.match(/^http:\/\/us\-f[\d]\-edit\.store\.yahoo\.com\/RT\/NEWEDIT\.us\-mattress\/[^\/]+\/homepagetest\.html$/)) { showguide = false; }

	return showguide;
}

