var bn_window_param_start = "unb~usap~[";
var bn_window_param_end = "]~";
function bnCheckU(action)
{
	var page_url = window.location.href;
	if(page_url.indexOf("http://us-appliance.com/") == 0) { page_url = page_url.replace(/http:\/\/us\-appliance\.com\//,"http://www.us-appliance.com/"); }
	if(action == "setWU" && page_url.match(/^http:\/\/[^\/]+\.us-appliance\.com(:[\d]+)?\//)) { bnSetWU(); }
	else if (action == "getWU" && page_url.match(/^https?:\/\/([^\/]+\.)?store\.yahoo\.net(:[\d]+)?\//)) { bnGetWU(); }
}
function bnSetWU(bn_iter)
{
	var bn_iter_limit = 5;
	if(typeof(bn_iter) != 'undefined' && bn_iter > bn_iter_limit) { return; }
	var bn_u_val = bnGetCookie('bn_u');
	if(bn_u_val != null && bn_u_val != "") {
		window.name = bn_window_param_start + bn_u_val + bn_window_param_end;
	} else {
		if(typeof(bn_iter) != 'undefined' && bn_iter > 0)
			setTimeout("bnSetWU("+(bn_iter+1)+");",500);
		else
			setTimeout("bnSetWU("+1+");",500);
	}
}
function bnGetWU()
{
	var window_name = window.name;
	if(window_name != null && window_name != "" && window_name.indexOf(bn_window_param_start) == 0)
	{
		var start_idx = bn_window_param_start.length;
		var end_idx = window_name.indexOf(bn_window_param_end);
		if(end_idx > start_idx && end_idx < window_name.length)
		{
			bn_u_val = window_name.substring(start_idx, end_idx);
			if(bn_u_val != null && bn_u_val != "")
			{
				bnSetCookie('bn_u',bn_u_val,365*10);
				return;
			}
		}
	}
	bnSetCookie('bn_u',4,365*10);
}
function bnGetCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{ 
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length
				return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}
function bnSetCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays)
	document.cookie=c_name+ "=" +escape(value)+ ";path=/" +
		((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function bnDebug(msg)
{
	alert(msg);
}