function initPage() 
{

	var o = document.appFrames.mainContent();


	if(o)	
	{	 
		var oo = queryString(o.location.href);	
	}
	else
	{
		var o = document.appFrames.main();
		if(o)
		{
			var oo = queryString(o.location.href);
		}
	}


	if(oo)
	{
	    navbutton = oo.item("topNavButton").value;

	    if(navbutton)
	    {
	        navSwitch(navbutton);
	    }
	    else
	    {
	        ParentCode = oo.item("ParentCode").value;
	        if(ParentCode)
	        {
	        if(ParentCode == 'A')    { navSwitch(4);  }
    	        if(ParentCode == 'B')    { navSwitch(5);  }
    	        if(ParentCode == 'C')    { navSwitch(7);  }
		if(ParentCode == 'E')    { navSwitch(2);  }
    	        if(ParentCode == 'F')    { navSwitch(6);  } 
	        }
	        else
	        {
	        navSwitch(1);
	        }
	    }         
        }
}

// DO  NOT REMOVE
function resetDepartment() {};
function setActiveButton() {};

function clearSearchField(ref) {
	if(!window.searchCleared) {
		ref.value = '';
		window.searchCleared = true;
	}
}


function doSearch(oForm) {
	var o = document.getElementById("search");
	if(o) {
		if(o.value.trim() != "") {
			var oGo = document.getElementById("search-go");
			if(oGo) {
				var oGoSrc = oGo.getAttribute("src-go");
				if(oGoSrc) {
					oGo.src = oGoSrc;
				}
			}
			resetDepartment();
			if(checkUrl(oForm) && document.appFrames.mainContent()) {
				document.appFrames.mainContent().location.href = "/superstore/product/search.aspx?from=SEARCH&search=" + o.value.URLEncode2();
			}
		} else {
			alert("To search, type something into the search box and click 'Find'");
			o.focus();
		}
	}
	return false;
}

function completeSearch() {
	resetFindButton();
}

function startSearch() {
	var o = document.appFrames.mainContentLeft();
	if (o) {
		var oLis = o.document.getElementsByTagName("li");
		for (var i = 0; i < oLis.length; i++) {
			if (oLis[i].className == "department-selected") {
				oLis[i].className = "";
			}
		}
	}
}

function resetFindButton() {
	var o = document.appFrames.topNav();
	if(o) {
		var oGo = o.document.getElementById("search-go");
		if(oGo) {
			oGo.src = "/superstore/i/b/btnFind.gif";
		}
	}
}

function setActiveOffer(selectText) {
	setActiveButton("offersIdeas", selectText);
	window.focus();
}

function selectOffer(o) {
	var oOption = o.options[o.selectedIndex];
	if(oOption) {
		var sHref = oOption.value;
		
		if(sHref) {
			var sTarget = oOption.getAttribute("target");
			if(!sTarget) {
				sTarget = "mainContent";
			}

			o.blur();
			
			if(checkUrl(new urlData(document, sHref, sTarget))) {
				// the target frame currently exists...
				var oTarget = document.appFrames.locateFrame(sTarget);
				if(oTarget) {
					oTarget.location.href = sHref;
				}
			}
		}
	}
	setActiveButton(0, null, true);
}

function selectOption(o, id) {
	//setActiveButton(id);
	topNav(o);
	var oOption = o;
	if(oOption) {
		var sHref = oOption.href;
		if(sHref) {
			var sTarget = oOption.getAttribute("target");
			if(!sTarget) {
				sTarget = "mainContent";
			}

			if(checkUrl(new urlData(null, sHref, sTarget))) {
				// the target frame currently exists...
				var oTarget = document.appFrames.locateFrame(sTarget);
				if(oTarget) {
					oTarget.location.href = sHref;
				}
			}
		}
	}
	
	return false;
}
