//Show the show layer, hide the hide layer
function swap(show, hide){
   document.getElementById(show).style.display='';
   document.getElementById(hide).style.display='none';
}

function ensureElementIsVisible(elem)
{
    var startPoint = document.documentElement.scrollTop;
    var endPoint = startPoint + document.documentElement.clientHeight;

    if (startPoint > elem.offsetTop || endPoint < elem.offsetTop)
    {
        elem.scrollIntoView();    
    }
}


function ensureElementIsVisibleVertically(elem) {
    var startPoint = document.documentElement.scrollTop;
    var endPoint = startPoint + document.documentElement.clientHeight;

    if (startPoint > elem.offsetTop || endPoint < elem.offsetTop) {
        document.documentElement.scrollTop = elem.offsetTop;
    }
}

function fixIe6DropdownProblemOnPopupDivsShow(elem)
{
    if (isIE6OrLess()) {
        var element = document.getElementsByTagName('select');
        for (var i = 0; i < element.length; i++) 
        {
            element[i].style.visibility = "hidden";
        }
    }
}

function fixIe6DropdownProblemOnPopupDivsHide(elem)
{
    if (isIE6OrLess()) {
        var element = document.getElementsByTagName('select');
        for (var i = 0; i < element.length; i++) {
            element[i].style.visibility = "visible";
        }
    }
}

function fixIe6DropdownProblemOnPopupDivsShowHover(elem) {
    if (isIE6OrLess()) {
        var theiFrame = document.getElementById("myiFrame");

        if (theiFrame == null)
        {                                
            //create the iframe
            theiFrame=document.createElement('iFrame');
            theiFrame.id="myiFrame";
            theiFrame.style.filter='alpha(opacity=0)';
            theiFrame.style.position='absolute';
            theiFrame.style.zIndex=999998; //iFrame will be just below the theDiv
            document.body.appendChild(theiFrame);                        
        }
        
        //set the position of the iframe and display it
        theiFrame.style.top= elem.offsetTop; //one less than the value given for theDiv
        theiFrame.style.left=elem.offsetLeft; //one less than the value given for theDiv
        theiFrame.style.height = (elem.offsetHeight + 45) + 'px';
        
        if (elem.offsetWidth > 100)
        {
            theiFrame.style.width = (elem.offsetWidth - 100) + 'px';
        }
        
        theiFrame.style.display='block';

    }
}
function fixIe6DropdownProblemOnPopupDivsHideHover(elem) {
    if (isIE6OrLess()) {
        var theiFrame = document.getElementById('myiFrame');

        if (theiFrame != null)
        {              
            theiFrame.style.display='none';
        }
    }
}


function showHideDiscount(toShowId,txtUpdateId){
    var showHideRow = document.getElementById(toShowId);
    var txtToUpdate = document.getElementById(txtUpdateId);
    if(showHideRow.style.display==""){
        showHideRow.style.display = "none";
        txtToUpdate.innerHTML = "<span>Show Discount Tools</span>";
    }else{
        showHideRow.style.display = "";
        txtToUpdate.innerHTML = "<span>Hide Discount Tools</span>";
    }
}

var _valueControl = null;
var _textControl = null;
var _modalExtender = null;

function showColorPicker(valueControlId, textControlId, modalExtenderId)
{
    _valueControl = document.getElementById(valueControlId);
    _textControl = document.getElementById(textControlId);
    _modalExtender = $find(modalExtenderId);
    
    _modalExtender.show();
}

function hideColorPicker()
{
    _modalExtender.hide();
}


function selectColor(colorId, colorText)
{
    if (_modalExtender != null)
    {
        _textControl.value = colorText;
        _valueControl.value = colorId;
        _modalExtender.hide();
    }
}


function showModalExtender(modalExtenderId)
{
    if (_modalExtender != null)
    {
        hideModalExtender();
    }
    
    _modalExtender = $find(modalExtenderId);    
    _modalExtender.show();
}

function hideModalExtender()
{
    if (_modalExtender != null)
    {
        _modalExtender.hide();
        _modalExtender = null;
    }
}

function hideColorPicker()
{
    hideModalExtender();
}

/*Go through all validators and invoke their validation*/
function Validate()
{
    return Validate('');
}

/*Go through all page validators witin a validation group and validate*/
function Validate(validationGroup)
{
    /*Show validators if they have been hidden*/
    ChangeValidatorVisibility(true, validationGroup);
    
    var returnValue = true;
    var validator;

    for (var i = 0; i < Page_Validators.length; i++)
    {
        validator = Page_Validators[i];
        
        if(validationGroup == ''
            || validator.getAttribute('validationGroup') == validationGroup)
        {
            ValidatorValidate(validator);

            if (!validator.isvalid)
            {
                returnValue = false;
            }
        }
    }
    
    return returnValue;
}

/*Show or hide validators of a specific validation group*/
function ChangeValidatorVisibility(visible, validationGroup)
{
    var validator;
    
    for (var i = 0; i < Page_Validators.length; i++)
    {
        validator = Page_Validators[i];
        
        if(validationGroup == '' 
            || validator.getAttribute('validationGroup') == validationGroup)
        {
            validator.style.display = visible ? 'inline' : 'none';
        }
    }
}

function getDocumentHeight()
{
    var returnValue = 0;

    if(typeof(window.innerHeight) == 'number') 
    {
        //Non-IE
        returnValue = window.innerHeight;
    } 
    else if(document.documentElement && (document.documentElement.clientHeight)) 
    {
        //IE 6+ in 'standards compliant mode'
        returnValue = document.documentElement.clientHeight;
    } 
    else if(document.body && (document.body.clientHeight) ) 
    {
        //IE 4 compatible
        returnValue = document.body.clientHeight;
    }

    return returnValue;
}

function getDocumentWidth()
{
    var returnValue = 0;

    if(typeof(window.innerWidth) == 'number') 
    {
        //Non-IE
        returnValue = window.innerWidth;
    } 
    else if(document.documentElement && (document.documentElement.clientWidth)) 
    {
        //IE 6+ in 'standards compliant mode'
        returnValue = document.documentElement.clientWidth;
    } 
    else if(document.body && (document.body.clientWidth) ) 
    {
        //IE 4 compatible
        returnValue = document.body.clientWidth;
    }

    return returnValue;
}

/*Make sure the given element fits within the screen dimensions*/
function ensureElementCanFitInScreen(elementId, heightPadding)
{
    var element = document.getElementById(elementId);
    
    if(element != null)
    {
        var currentHeight = getDocumentHeight();
        
        if(currentHeight < element.style.height || element.style.height == '')
        {
            element.style.height = currentHeight - heightPadding + 'px';
        }
        
        var a = 9;
    }
}

/*Function that toggles the sample in-cart status*/
function toggleVisibility(elementIdToHide, elementIdToShow)
{
    var elementToHide = getElement(elementIdToHide);
    var elementToShow = getElement(elementIdToShow);
    
    elementToHide.style.display = 'none';
    elementToShow.style.display = 'inline';
}

function showImage(path, title)
{
//debugger;
    //window.open(path, 'window', 'menubar=no,status=no,scrollbars=yes,resizable=yes,height=720,width=750', false);
    // 20090819 - wll - make it so users can have multiple windows open
    window.open(path, '_blank', 'menubar=no,status=no,scrollbars=yes,resizable=yes,height=720,width=750', false);
}

function VerifyValue(value)
{
    if (value == null) 
    {
        location.reload(true);
        return false;
    }
    else
    {
        return true;
    }
}

function ShowInformation(divId, obj)
{   
    var divinformation = document.getElementById(divId);        
    divinformation.style.visibility = "visible";
    fixIe6DropdownProblemOnPopupDivsShow(divinformation);  
}

function HideInformation(divId)
{
    var divinformation = document.getElementById(divId);
    divinformation.style.visibility = "hidden";    
    fixIe6DropdownProblemOnPopupDivsHide(divinformation);
}


function ShowInformationHover(divId, obj) {
    var divinformation = document.getElementById(divId);
    divinformation.style.visibility = "visible";
    fixIe6DropdownProblemOnPopupDivsShowHover(divinformation);
}

function HideInformationHover(divId) {
    var divinformation = document.getElementById(divId);
    divinformation.style.visibility = "hidden";
    fixIe6DropdownProblemOnPopupDivsHideHover(divinformation);
}


// Utility functions
function moveDivToTarget(whichTriggerString, whichDivString, xOffset, yOffset){
	var whichTrigger = document.getElementById(whichTriggerString);
	var whichDiv = document.getElementById(whichDivString);
	
	whichDiv.style.top=Top(whichTrigger) + yOffset - 127 + "px";
	whichDiv.style.left=Left(whichTrigger)+ xOffset - 429 + "px";
	
	window.currentlyVisiblePopup = whichTrigger;
	window.currentdiv = whichDiv;
}

function getElement(id)
{
    return document.getElementById(id);
}

function Left(elem){	
	var x=0;
	var oElem=elem;
	while(elem){
		 if ((elem.currentStyle)&& (!isNaN(parseInt(elem.currentStyle.borderLeftWidth)))&&(x!=0))
		 	x+=parseInt(elem.currentStyle.borderLeftWidth);
		 x+=elem.offsetLeft;
		 elem=elem.offsetParent;
	  } 
	return x;
}

function Top(elem){
	 var x=0;
	 if(!elem)return;
	 var oElem=elem;
	 while(elem){		
	 	 if ((elem.currentStyle)&& (!isNaN(parseInt(elem.currentStyle.borderTopWidth)))&&(x!=0))
		 	x+=parseInt(elem.currentStyle.borderTopWidth); 
			x+=elem.offsetTop;
	        elem=elem.offsetParent;
			
 	 }
 	 return x;
}

function mergeArrays(array1, array2)
{
    var returnValue = [];
    
    for(var i = 0; i < array1.length; i++)
    {
        returnValue.push(array1[i]);
    }
    
    for(var i = 0; i < array2.length; i++)
    {
        returnValue.push(array2[i]);
    }
    
    return returnValue;
}

function sbGetElementsByName(tag, name) {
     
     var elem = document.getElementsByTagName(tag);
     var arr = new Array();
     for(i = 0,iarr = 0; i < elem.length; i++) {
          att = elem[i].getAttribute("name");
          if(att == name) {
               arr[iarr] = elem[i];
               iarr++;
          }
     }
     return arr;
}


function clickArea(tagName, className, hoverClass) {
	var els = document.getElementsByTagName(tagName);
	for (var i = 0; i < els.length; i++) if (els[i].className.indexOf(className)>=0) {
		els[i].onmouseover=function() {
			this.className+=" " + hoverClass;
			window.status = this.getElementsByTagName("a")[0].href;
			return true;
		}
		els[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" " + hoverClass + "\\b"), "");
			window.status = "";
			return true;
		}
		els[i].onclick = function () {location.href = this.getElementsByTagName("a")[0].href}
   }
}
function getStyle(oElm, strCssRule){
	var strValue = "";
	if(document.defaultView && document.defaultView.getComputedStyle){
		strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
	}
	else if(oElm.currentStyle){
		strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
			return p1.toUpperCase();
		});
		strValue = oElm.currentStyle[strCssRule];
	}
	return strValue;
}

function findPos(obj) {
	var curleft = curtop = 0;
	
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}


function initSlider()
{
    positionSlider();
}

var initSliderHeight = 400; 
			        

function isIE6OrLess()
{
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
        var ieversion=new Number(RegExp.$1) 
        if (ieversion <=6) return true;
    }
  
     return false;
}

function positionSlider()
{
    var slider = document.getElementById("slider");
    var matte = document.getElementById("purchasePaneMatte");    
    
    if (isIE6OrLess())
    {
        var divPic = document.getElementById("divFullScreenLoadingPic");
                    
        if (divPic != null)
        {
            divPic.style.top = document.documentElement.scrollTop + 150;
            divPic.style.position = "absolute";
        }
    }

	if (slider != null)
	{
	   var documentTotalHeight = document.body.clientHeight;
	   var windowHeight = getDocumentHeight();
	   	   
       var mattePos = findPos(matte);

	    if( window.XMLHttpRequest ) { // IE 6 doesn't implement position fixed nicely...
		    if (document.documentElement.scrollTop > 150 || self.pageYOffset > 150) {
		        if (!isIE6OrLess())
		        {
		            if (mattePos[0] < 650)
		            {
		                //alert("self.pageXOffset: " + self.pageXOffset);
		                var iLeftPos = 0;
		                if (self.pageXOffset > 0)
		                {
		                    iLeftPos = self.pageXOffset;
		                }
		                else
		                {
		                    iLeftPos = document.documentElement.scrollLeft;
		                }
			            slider.style.position = 'fixed'; 
			            slider.style.top = '-40px';// (document.documentElement.scrollTop - 40) + "px"; //(mattePos[1] - 40) + 'px';
			            slider.style.left = (mattePos[0] - iLeftPos) + 'px';
			        }
			        else
			        {
			            slider.style.position = 'fixed'; 
			            slider.style.top = '-40px';
			            slider.style.left = mattePos[0] + 'px';
                    }
//			        //slider.scrollLeft = 15;//mattePos[0] + 'px';
			        //window.status = "Pos: " + mattePos[0] + ", scrollLeft: " + self.pageXOffset;
			    }
			    else
			    {
			        slider.style.position = 'absolute'; 
			        slider.style.top = (document.documentElement.scrollTop - 40) + 'px';
			        slider.style.left = (getDocumentWidth() - 170) + 'px';
	                slider.style.height = windowHeight;   
	                
	                var slider2 = document.getElementById("sliderInternal");
	                
	                if (slider2 != null)
	                {
	                    slider2.style.height = windowHeight;
	                    slider2.style.overflow = "hidden";
	                }   
			    }
			    
		    } else {
		        if (!isIE6OrLess())
		        {
			        slider.style.position = 'absolute'; 
			        slider.style.top = (mattePos[1] - 40) + 'px';
			        slider.style.left = mattePos[0] + 'px';
			    }
			    else
			    {
			        slider.style.position = 'absolute'; 
			        slider.style.top = '125px';
			        slider.style.left = (getDocumentWidth() - 170) + 'px';			    
			    }   
		    }
	    
	        if (isIE6OrLess())
	        {
                var theiFrame = document.getElementById("slideriFrame");

                if (theiFrame == null)
                {                                
                    //create the iframe
                    theiFrame=document.createElement('iFrame');
                    theiFrame.id="slideriFrame";
                    theiFrame.style.filter='alpha(opacity=0)';
                    theiFrame.style.position='absolute';
                    theiFrame.style.zIndex=8001; //iFrame will be just below the theDiv
                    document.body.appendChild(theiFrame);                        
                }
                
                //set the position of the iframe and display it
                theiFrame.style.top= slider.offsetTop; //one less than the value given for theDiv
                theiFrame.style.left=slider.offsetLeft; //one less than the value given for theDiv
                theiFrame.style.height = (slider.offsetHeight + 45) + 'px';
                
                if (slider.offsetWidth > 100)
                {
                    theiFrame.style.width = (slider.offsetWidth - 100) + 'px';
                }
                
                theiFrame.style.display='block';
            }
	    
	    }
	}
}

window.onload = function() {
	initSlider();
}
window.onscroll = function() {
	positionSlider();
}

window.onresize = function() {
	positionSlider();
}

function jumpToNextField(fromElement, targetElementId){
    if(fromElement.value.length == fromElement.maxLength){
        document.getElementById(targetElementId).focus();
    }
}


function setFocus(ele)
{
    if (ele != null)
    {
        for (var i = 0; i < 900; i++)
        {              
            ele.focus();
        }
    }

}
function incrementCartCount() {
    var ele = document.getElementById(currentCartItemCountId);
    var newValue = getCurrentCartCount() + 1;
    ele.innerHTML = "Cart (" + newValue + ")";
}
function getCurrentCartCount() {
    var ele = document.getElementById(currentCartItemCountId);
    var currentValue = ele.innerHTML;
    var newValue;
    
    if(currentValue != "Cart"){
        currentValue = currentValue.replace("Cart ","");
        currentValue = currentValue.replace("(","");
        currentValue = currentValue.replace(")","");
        currentValue = currentValue.replace(",","");
        newValue = parseInt(currentValue);    
    }else{
        newValue = 0;
    }
    return newValue;
}
function decrementCartCount() {
    var ele = document.getElementById(currentCartItemCountId);
    var newValue = getCurrentCartCount() - 1;
    if(newValue > 0)
        ele.innerHTML = "Cart (" + newValue + ")";
    else
        ele.innerHTML = "Cart";
}

    function addEvent(obj, evType, fn)
    {
         if (obj == null) return;
         if (obj.addEventListener)
         {
            // DO NOT SET PARAM 3 TO TRUE - THIS WILL BREAK SAFARI SUPPORT
		      obj.addEventListener(evType, fn, false);
		 }
		 else if (obj.attachEvent)
		 { 
              obj.attachEvent('on'+evType, fn);
	     }
    }
    
//    // removeEvent
//    function removeEvent(obj,type,fn)
//    {
//        if (obj == null) return;
//        if( obj.removeEventListener)
//        { 
//            obj.removeEventListener(type,fn,false);
//        }
//        else if(obj.detachEvent)
//        {
//            obj.detachEvent("on"+type,fn);
//            //obj.detachEvent("on"+type , obj[type+fn]);
////            obj[type+fn]=null;
////            obj["e"+type+fn]=null;
//        }
//    }

            

sfHover = function() {
    var mainNav = document.getElementById("mainNav");
    
    if (mainNav != null)
    {
	    var sfEls = mainNav.getElementsByTagName("LI");
	    for (var i=0; i<sfEls.length; i++) {
		    sfEls[i].onmouseover=function() {
			    this.className+=" sfhover";
		    }
		    sfEls[i].onmouseout=function() {
			    this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}

if (window.attachEvent) window.attachEvent("onload", sfHover);

// handle keypress submit - browser agnostic
// catch the keypress on a textbox, if the keystroke is the (enter) then call __doPostback to do
// a manual postback using that control
function submitOnEnterPress(ev, buttonId) {
    var enterkeyCode = 13;    // 13 is for (enter)
    
    if (window.event)  // ie
    {
        if (ev.keyCode == enterkeyCode) {
            callClick(buttonId);
            return false;
        }
    }
    else if (ev.which)  // all other
    {
        if (ev.keyCode == enterkeyCode) {
            {
                callClick(buttonId);
                return false;
            }
        }
    }
}

    function clearInnerHtmlForElement(elementId) {
        var elem = document.getElementById(elementId);
        try {
            elem.innerText = "";        // ie
            elem.innerHTML = "";        // firefox, safari
        }
        catch (e)
    { /* do nothing */ }
    }

    function navGoto(navList) {
        selecteditem = navList.selectedIndex;
        newurl = navList.options[selecteditem].value;
        if (newurl.length != 0) {
            location.href = newurl;
        }
    }

    /* handle message from Steve */
    function ROV_LaunchVideo() {
        arguments.callee.done = true;

        delete_cookie('ROV_Visitor');
        delete_cookie('ROV_Blocked');

        //var script = document.createElement('script');
        //script.type = 'text/javascript';
        //script.src = script.src = 'http://manager.rovion.com/include1.aspx?AffID=' + affID + '&PageID=' + pageID;
        //script.src = "try{playThisVideoNow('20090720105820HkkseIhqksW');}catch(e){}";        
        // <script type='text/javascript' src='http://objectservers.com/link/2009011998b772de08d680fe7'></script>
        //document.getElementsByTagName('head')[0].appendChild(script);
        
        try {
            playThisVideoNow('20090720105820HkkseIhqksW');
        } catch(e){}        
        
    }

    function delete_cookie(cookie_name) {
        var cookie_date = new Date();  // current date & time
        cookie_date.setTime(cookie_date.getTime() - 1);
        document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
    }

    function toggleDiv(divId) {
        var elem = document.getElementById(divId);
        if (elem.style.visibility == 'hidden')   // div is currently hidden
        {
            elem.style.visibility = 'visible';
        }
        else    // div is visible
        {
            elem.style.visibility = 'hidden';
        }
    }

    function callClick(buttonName) {

        var element = document.getElementById(buttonName);

        if (element != null) {
            if (element.dispatchEvent) {

                var e = document.createEvent("MouseEvents");
                e.initEvent("click", true, true);

                element.dispatchEvent(e);
            }
            else {
                element.click();
            }
        }
    }

/*Runs when the selected search productdropdown changes*/
function OnProductTypeChange(element, borderList, callback) {
    /*The border dropdown only needs to be shown when wallpaper is selected from the product drop down list*/
    // Constants.WALLPAPER_AND_BORDER_PRODUCT_DROPDOWN_ID = 3
    // Constants.BORDER_PRODUCT_DROPDOWN_ID = 5
    if(element.value == 3 || element.value == 5){
        borderList.style.display = 'inline';
    } else {
        borderList.style.display = 'none';
        borderList.selectedIndex = 0;
    }
}

// ******************************************************************************************
// ******************************************************************************************
// ******************************************************************************************
//          these items are for the dynamic menus
// ******************************************************************************************
// ******************************************************************************************
// ******************************************************************************************



var aryActiveMenus;
var dmTimeoutID;
var dmShowAfterThisTimeoutID;
var sCurrentMenuID = "";
var sDelayedMenuID = "";
function showHoverMenuDelayed(sMenuNameID) {

    //return;

    hideAllHoverMenus();
    
    sCurrentMenuID = sMenuNameID;
    clearDMTimeout();
    
    if (sDelayedMenuID == sMenuNameID) {
        // do nothing - we're on this menu already        
    } else {
        // set a timeout to actually show the menu
        dmTimeoutID = setTimeout("delayedShowHoverMenu()", 500);
    }
    sDelayedMenuID = sMenuNameID;
    
    
//    var sMenu = document.getElementById(sMenuName);
//    sMenu.style.display = "";
//    sMenu.style.zIndex = 50;

}

function delayedShowHoverMenu() {

    if (sCurrentMenuID == sDelayedMenuID) { // we are still hovering on same menu after the delay so show it.
        showHoverMenu(sDelayedMenuID);
    }
}

function showHoverMenu(sMenuNameID) {
    clearDMTimeout();
    var oMenu = document.getElementById(sMenuNameID);
    oMenu.style.display = "";
    oMenu.style.zIndex = 9005;
    
    var oSlider = document.getElementById("slider");
    
    if (oSlider != null) {
        oSlider.style.zIndex = -1;
    }
    
    
}

function hideHoverMenu(sMenuName) {
    
    try {
        var sMenu = document.getElementById(sMenuName);
        sMenu.style.display = "none";
        //sMenu.style.zIndex = -1001;
    } catch (e) {
        // just ignore it for now
    }

}


function hideAllHoverMenus() {

    hideHoverMenu("divBlindsHoverMenuB");
    hideHoverMenu("divWallpaperHoverMenu");
    hideHoverMenu("divDrapesHoverMenu");
    hideHoverMenu("divMeasuringAndInstallation");
    hideHoverMenu("divAboutStevesMain");
    hideHoverMenu("divHelpHoverMenu");
    sCurrentMenuID = "";
    sDelayedMenuID = "";

}

function setDmTimeout() {
    clearDMTimeout();
    dmTimeoutID = setTimeout("hideAllHoverMenus()", 500);
}

function clearDMTimeout() {
    try {
        clearTimeout(dmTimeoutID);
    } catch(e) {
        // do nothing
    }
}


function showHideSubMenu(sShowHide, oItem)
{
    var id = oItem.id;
    //var idInner = id.replace("tdBrandHeader2", "tdBrandHeader2Inner");
    var idDetails = id.replace("tdBrandHeader2", "tdBrandProducts2");
    
    switch (true) {

        case (id == "tdCurtainProducts"):
            idDetails = "divCurtainProducts";
            break;
        case (id == "tdSheerProducts"):
            idDetails = "divSheerProducts";
            break;
        case (id == "tdAdjustableRodProducts"):
            idDetails = "divAdjustableRodProducts";
            break;
        case (id == "tdCustomRodProducts"):
            idDetails = "divCustomRodProducts";
            break;



        case (id == "tdPopularThemes"):
            idDetails = "divPopularThemes";
            break;
        case (id == "tdPopularSearches"):
            idDetails = "divPopularSearches";
            break;
        case (id == "tdHottestDeals"):
            idDetails = "divHottestDeals";
            break;
        case (id == "tdCurrentPromotions"):
            idDetails = "divCurrentPromotions";
            break;
        case (id == "tdBlinds"):
            idDetails = "divBlinds";
            break;
        case (id == "tdAboutSteves"):
            idDetails = "divAboutSteves";
            break;
        case (id == "tdCustomerService"):
            idDetails = "divCustomerService";
            break;
        case (id == "tdWallpaper"):
            idDetails = "divWallpaper";
            break;
        case (id == "tdFeedback"):
            idDetails = "divFeedback";
            break;
        case (id == "tdPolicies"):
            idDetails = "divPolicies";
            break;
        case (id == "tdDrapesAndCurtains"):
            idDetails = "divDrapesAndCurtains";
            break;
        default:
            idInner = id.replace("tdBrandHeader2", "tdBrandHeader2Inner");
            idDetails = id.replace("tdBrandHeader2", "tdBrandProducts2");
            break;
    }

    var oMenu = document.getElementById(id);
    var aryMenuPos = findPos(oMenu)
    
//    var oMenuInner = document.getElementById(idInner);
//    var txtJunk = document.getElementById("txtJunk");
//    var oJunk = document.getElementById("txtJunk");

    var oSubMenu = document.getElementById(idDetails);

    if (sShowHide == "show") {
        oSubMenu.style.display = "";  
        var hSalesRepActive = document.getElementById("hSalesRepActive");
        var submenuPosition
        if (hSalesRepActive && hSalesRepActive.value == "True")
        {
            //oSubMenu.style.left = (aryMenuPos[0]) + "px";
            submenuPosition = (aryMenuPos[1] - 156); //oMenu.offsetTop ;// + 150; //sY; //window.event.y-150;
        } else {        
            //alert(aryMenuPos[0]);
            //oSubMenu.style.left = (aryMenuPos[0]) + "px";
            submenuPosition = (aryMenuPos[1] - 126); //oMenu.offsetTop ;// + 150; //sY; //window.event.y-150;
        }
        oSubMenu.style.top = submenuPosition + "px";
        
        //oSubMenu.style.left = -170 + "px"; //window.event.x;
   	   var documentTotalWidth = document.body.clientWidth;
   	   var HorizontalpositionOfMenu = aryMenuPos[0];
   	   var deltaX = documentTotalWidth - HorizontalpositionOfMenu;
   	   var remainingWidth = HorizontalpositionOfMenu - 170;

        if (deltaX <= 340) {
            // if the screen is not wide enough push the menu down 1 row and tuck it under
            oSubMenu.style.left = -170 + "px"; //window.event.x;
        } else {
            oSubMenu.style.left = 170 + "px"; //window.event.x;
        }
        //txtJunk.value = "id: " + id + ", aryMenuPos[0]: " + aryMenuPos[0] + ", aryMenuPos[1]: " + aryMenuPos[1];
        //txtJunk.value = "deltaX: " + deltaX + ", documentTotalWidth: " + documentTotalWidth + ", aryMenuPos[0]: " + aryMenuPos[0] + ", aryMenuPos[1]: " + aryMenuPos[1];
        oSubMenu.zIndex = 9005;
    }
    else {
        oSubMenu.style.display = "none";  
    }
}

function showHideSubSubMenu(sShowHide, oItem) {
    var id = oItem.id;
    var oSubMenu = document.getElementById(id);
    if (sShowHide == "show") {
        oSubMenu.style.display = "";          
        oSubMenu.zIndex = 9005; 
    } else {
        oSubMenu.style.display = "none";  
    }
}

// ******************************************************************************************
// ******************************************************************************************
// ******************************************************************************************
//          END OF - dynamic menus
// ******************************************************************************************
// ******************************************************************************************
// ******************************************************************************************
