if(typeof tradetech=="undefined"){var tradetech=new Object();}
if(typeof tradetech.slideshow=="undefined"){tradetech.slideshow=new Object();}

function loginControlsPasswordFocus()
{
    document.getElementById('lcpwd').className='field';
    document.getElementById('lcpwdx').className='hidden field';
    document.getElementById('lcpwd').focus();
}

function loginControlsUsernameFocus()
{
    var x = document.getElementById('lcun');
    if(x.value=='User name')
        x.value = '';
}

function loginControlsUsernameBlur()
{
    var x = document.getElementById('lcun');
    if(x.value=='')
        x.value = 'User name';
}


function tellAFriend(pageId, config, culture)
{
    if(config == undefined)
        config = "Default";
    if(culture == undefined)
        culture = "en-US";
    var targetUrl = "/Templates/TellAFriend.aspx?keepThis=true&pageId="+pageId+"&CurrentConfig="+config+"&CurrentCulture="+culture;
        
    //These values must be placed last in the query...
    targetUrl += "&TB_iframe=true&height=330&width=382";
    tb_show("", targetUrl, false);
}


tradetech.slideshow = function(slideContainerId, delay, dorun)
{
    if(!document.getElementById) { return; }
    this.currentIndex = -1;
    this.slides=new Array();
    this.delay=delay;
    var minHeight = 0;
    var width = 0;
    
    var x = document.getElementById(slideContainerId);
    if(x!=null && x.parentNode!=null)
    {
        this.slideshowPanel = x.parentNode.parentNode;
        
        for(var i=0; i<x.childNodes.length; i++)
        {
            if(x.childNodes[i].src!=null)
            {
                var img = new Image();
                img.src = x.childNodes[i].src;
                if(img.height>minHeight)
                    minHeight = img.height;
                if(img.width>width)
                    width = img.width;
                this.slides.push(img);
            }
        }
        
        // This code causes the content to collapse
        this.slideshowPanel.style.display = 'none';
        this.slideshowPanel.style.minHeight = minHeight;
        if(this.slideshowPanel.id.indexOf('ideshow')==-1)
            this.slideshowPanel.style.height = minHeight;
        this.slideshowPanel.style.display = 'block';
        
        if(this.slides.length>0 && dorun)
            this.switchSlide();
    }
};

tradetech.slideshow.prototype={
    switchSlide:function()
    {
        this.currentIndex = this.currentIndex+1<this.slides.length ? this.currentIndex+1 : 0;
        this.slideshowPanel.style.background = 'transparent url(' + this.slides[this.currentIndex].src + ') 0 0 no-repeat';
        this.switchSlideTimeout(this.delay);
    },
    switchSlideTimeout:function(ms)
    {
        var _self = this;
        setTimeout(function(ms){_self.switchSlide();},ms);
    }
};

        function SlideshowTabsSwap(o)
        {
            var li = o.parentNode;
            var tabs = new Array();
            var content = new Array();
            var tabs_x = document.getElementById('SlideshowTabs').childNodes;
            var content_x = document.getElementById('SlideshowTabsContent').childNodes;
            
            // populate tabs
            for(var i=0;i<tabs_x.length;i++)
            {
                if(tabs_x[i].innerHTML!=null)
                {
                    tabs.push(tabs_x[i]);
                }
            }
                    
            // populate content
            for(var i=0;i<content_x.length;i++)
                if(content_x[i].innerHTML!=null)
                    content.push(content_x[i]);

            var idx = -1;
            for(var i=0; i<tabs.length; i++)
            {
                if(tabs[i]==li)
                    idx=i;
                if(tabs[i].className=='lastactive' || tabs[i].className=='last')
                    tabs[i].className='last';
                else
                    tabs[i].className='';
            }

            if(idx>0)
            {
                tabs[idx-1].className='preactive';
            }
            if(idx==(tabs.length-1))
            {
                tabs[idx].className='lastactive';
            }
            else if(idx!=-1)
            {
                tabs[idx].className='active';
            }

            
            for(var x=0; x<content.length; x++)
            {
                content[x].className = (x==idx ? 'active' : 'inactive');
            }
            o.blur();
            return false;
        }