﻿// JScript File
<!--

var DDSPEED = 2;
var DDTIMER = 50;

function topBarOver(sender)
{
    if(sender.id.indexOf('ProductsMenuLink')>=0)
    {
        var x = document.getElementById("ProductsMenu");
        
        if(x==null)
        {
            var x = document.getElementById("ctl00_ProductsMenu");
            
            if(x==null)
            {
                var x = document.getElementById("_ctl0_ProductsMenu");
            }
        }
        
        x.style.display = 'block';
    }

    if(sender.id.indexOf('PDHeader')>=0)
    {
        var x = document.getElementById("PDMenu");
        
        if(x==null)
        {
            var x = document.getElementById("ctl00_PDMenu");
            
            if(x==null)
            {
                var x = document.getElementById("_ctl0_PDMenu");
            }
        }
        
        x.style.display = 'block';
    }
}

function topBarOut(sender)
{

    if(sender.id.indexOf('ProductsMenuLink')>=0)
    {
        var x = document.getElementById("ProductsMenu");
        
        if(x==null)
        {
            var x = document.getElementById("ctl00_ProductsMenu");
            
            if(x==null)
            {
                var x = document.getElementById("_ctl0_ProductsMenu");
            }
        }
        
        x.style.display = 'none';
    }
    
    if(sender.id.indexOf('PDHeader')>=0)
    {
        var x = document.getElementById("PDMenu");
        
        if(x==null)
        {
            var x = document.getElementById("ctl00_PDMenu");
            
            if(x==null)
            {
                var x = document.getElementById("_ctl0_PDMenu");
            }
        }
        
        x.style.display = 'none';
    }

}

function sideBarOver(sender)
{
//    var btnimg = sender.childNodes[0];
//    btnimg.src = btnimg.src.split('.jpg')[0] + '-ov.jpg';

    var img = document.getElementById("MainImage");

    if(sender.id=="DetergentsButton")
    {
        var x = document.getElementById("DetergentsDescription");
        
        clearInterval(x.timer);
        clearTimeout(sender.timer);

        if(x.maxw && x.maxw <= x.offsetWidth)
        {
            return;
        }
        else if(!x.maxw)
        {
            x.style.display = 'block';
            //x.style.width = 'auto';
            x.maxw = x.offsetWidth;
            x.style.width = '0px';
        }
        
        x.timer = setInterval(function(){SlideDescription(x,1)}, DDTIMER);
        
        img.src = "images/Main-Detergents.jpg";
    }
    if(sender.id=="ProductsButton")
    {
        var x = document.getElementById("ProductsDescription");
        
        clearInterval(x.timer);
        clearTimeout(sender.timer);

        if(x.maxw && x.maxw <= x.offsetWidth)
        {
            return;
        }
        else if(!x.maxw)
        {
            x.style.display = 'block';
            //x.style.width = 'auto';
            x.maxw = x.offsetWidth;
            x.style.width = '0px';
        }
        
        x.timer = setInterval(function(){SlideDescription(x,1)}, DDTIMER);
        img.src = "images/Main-Products.jpg";
    }
    if(sender.id=="BentoniteButton")
    {
        var x = document.getElementById("BentoniteDescription");
        
        clearInterval(x.timer);
        clearTimeout(sender.timer);

        if(x.maxw && x.maxw <= x.offsetWidth)
        {
            return;
        }
        else if(!x.maxw)
        {
            x.style.display = 'block';
            //x.style.width = 'auto';
            x.maxw = x.offsetWidth;
            x.style.width = '0px';
        }
        
        x.timer = setInterval(function(){SlideDescription(x,1)}, DDTIMER);
        img.src = "images/Main-Bentonite.jpg";
    }
    
    if(sender.id=="ModifiedBenoniteButton")
    {
        var x = document.getElementById("ModifiedBentoniteDescription");
        
        clearInterval(x.timer);
        clearTimeout(sender.timer);

        if(x.maxw && x.maxw <= x.offsetWidth)
        {
            return;
        }
        else if(!x.maxw)
        {
            x.style.display = 'block';
            //x.style.width = 'auto';
            x.maxw = x.offsetWidth;
            x.style.width = '0px';
        }
        
        x.timer = setInterval(function(){SlideDescription(x,1)}, DDTIMER);
        img.src = "images/Main-ModifiedBentonite.jpg";
    }
    
    if(sender.id=="SurfactantsButton")
    {
        var x = document.getElementById("SurfactantsDescription");
        
        clearInterval(x.timer);
        clearTimeout(sender.timer);

        if(x.maxw && x.maxw <= x.offsetWidth)
        {
            return;
        }
        else if(!x.maxw)
        {
            x.style.display = 'block';
            //x.style.width = 'auto';
            x.maxw = x.offsetWidth;
            x.style.width = '0px';
        }
        
        x.timer = setInterval(function(){SlideDescription(x,1)}, DDTIMER);
        img.src = "images/Main-Surfactants.jpg";
    }
    if(sender.id=="AestheticsButton")
    {
        var x = document.getElementById("AestheticsDescription");
        
        clearInterval(x.timer);
        clearTimeout(sender.timer);

        if(x.maxw && x.maxw <= x.offsetWidth)
        {
            return;
        }
        else if(!x.maxw)
        {
            x.style.display = 'block';
            //x.style.width = 'auto';
            x.maxw = x.offsetWidth;
            x.style.width = '0px';
        }
        
        x.timer = setInterval(function(){SlideDescription(x,1)}, DDTIMER);
        img.src = "images/Main-Aesthetics.jpg";
    }    
    if(sender.id=="CustomisedButton")
    {
        var x = document.getElementById("CustomisedDescription");
        
        clearInterval(x.timer);
        clearTimeout(sender.timer);

        if(x.maxw && x.maxw <= x.offsetWidth)
        {
            return;
        }
        else if(!x.maxw)
        {
            x.style.display = 'block';
            //x.style.width = 'auto';
            x.maxw = x.offsetWidth;
            x.style.width = '0px';
        }
        
        x.timer = setInterval(function(){SlideDescription(x,1)}, DDTIMER);
        img.src = "images/Main-Customised.jpg";
    }
    if(sender.id=="BuilderButton")
    {
        var x = document.getElementById("BuilderDescription");
        
        clearInterval(x.timer);
        clearTimeout(sender.timer);

        if(x.maxw && x.maxw <= x.offsetWidth)
        {
            return;
        }
        else if(!x.maxw)
        {
            x.style.display = 'block';
            //x.style.width = 'auto';
            x.maxw = x.offsetWidth;
            x.style.width = '0px';
        }
        
        x.timer = setInterval(function(){SlideDescription(x,1)}, DDTIMER);
        img.src = "images/Main-Builder.jpg";
    }
    if(sender.id=="WhiteningButton")
    {
        var x = document.getElementById("WhiteningDescription");
        
        clearInterval(x.timer);
        clearTimeout(sender.timer);

        if(x.maxw && x.maxw <= x.offsetWidth)
        {
            return;
        }
        else if(!x.maxw)
        {
            x.style.display = 'block';
            //x.style.width = 'auto';
            x.maxw = x.offsetWidth;
            x.style.width = '0px';
        }
        
        x.timer = setInterval(function(){SlideDescription(x,1)}, DDTIMER);
        img.src = "images/Main-Whitening.jpg";
    }
    if(sender.id=="BentobriteButton")
    {
        var x = document.getElementById("BentobriteDescription");
        
        clearInterval(x.timer);
        clearTimeout(sender.timer);

        if(x.maxw && x.maxw <= x.offsetWidth)
        {
            return;
        }
        else if(!x.maxw)
        {
            x.style.display = 'block';
            //x.style.width = 'auto';
            x.maxw = x.offsetWidth;
            x.style.width = '0px';
        }
        
        x.timer = setInterval(function(){SlideDescription(x,1)}, DDTIMER);
        img.src = "images/Main-Bentobrite.jpg";
    }
    if(sender.id=="TechnicalButton")
    {
        var x = document.getElementById("TechnicalDescription");
        
        clearInterval(x.timer);
        clearTimeout(sender.timer);

        if(x.maxw && x.maxw <= x.offsetWidth)
        {
            return;
        }
        else if(!x.maxw)
        {
            x.style.display = 'block';
            //x.style.width = 'auto';
            x.maxw = x.offsetWidth;
            x.style.width = '0px';
        }
        
        x.timer = setInterval(function(){SlideDescription(x,1)}, DDTIMER);
        img.src = "images/Main-TechnicalSupport.jpg";
    }
}

function sideBarOut(sender)
{
//    var btnimg = sender.childNodes[0];
//    if(btnimg.src.indexOf('-ov.') >= 0)
    {
//        btnimg.src = btnimg.src.replace('-ov', '');
    }

    if(sender.id=="DetergentsButton")
    {
        var x = document.getElementById("DetergentsDescription");
        clearInterval(x.timer);
        sender.timer = setTimeout(function(){Collapse(x)},50);
    }
    if(sender.id=="ProductsButton")
    {
        var x = document.getElementById("ProductsDescription");
        clearInterval(x.timer);
        sender.timer = setTimeout(function(){Collapse(x)},50);
    }
    if(sender.id=="BentoniteButton")
    {
        var x = document.getElementById("BentoniteDescription");
        clearInterval(x.timer);
        sender.timer = setTimeout(function(){Collapse(x)},50);
    }
    if(sender.id=="ModifiedButton")
    {
        var x = document.getElementById("ModifiedDescription");
        clearInterval(x.timer);
        sender.timer = setTimeout(function(){Collapse(x)},50);
    }
    if(sender.id=="SurfactantsButton")
    {
        var x = document.getElementById("SurfactantsDescription");
        clearInterval(x.timer);
        sender.timer = setTimeout(function(){Collapse(x)},50);
    }
    if(sender.id=="AestheticsButton")
    {
        var x = document.getElementById("AesthesticsDescription");
        clearInterval(x.timer);
        sender.timer = setTimeout(function(){Collapse(x)},50);
    }
    if(sender.id=="CustomisedButton")
    {
        var x = document.getElementById("CustomisedDescription");
        clearInterval(x.timer);
        sender.timer = setTimeout(function(){Collapse(x)},50);
    }
    if(sender.id=="BuilderButton")
    {
        var x = document.getElementById("BuilderDescription");
        clearInterval(x.timer);
        sender.timer = setTimeout(function(){Collapse(x)},50);
    }
    if(sender.id=="WhiteningButton")
    {
        var x = document.getElementById("WhiteningDescription");
        clearInterval(x.timer);
        sender.timer = setTimeout(function(){Collapse(x)},50);
    }
    if(sender.id=="BentobriteButton")
    {
        var x = document.getElementById("BentobriteDescription");
        clearInterval(x.timer);
        sender.timer = setTimeout(function(){Collapse(x)},50);
    }
    if(sender.id=="TechnicalButton")
    {
        var x = document.getElementById("TechnicalDescription");
        clearInterval(x.timer);
        sender.timer = setTimeout(function(){Collapse(x)},50);
    }
}

function sideBarOverMP(sender)
{
//    var btnimg = sender.childNodes[0];
//    btnimg.src = btnimg.src.split('.jpg')[0] + '-ov.jpg';
}

function sideBarOutMP(sender)
{
//    var img = sender.childNodes[0];
//    
//    if(img.src.indexOf('-ov.') >= 0)
//    {
//        img.src = img.src.replace('-ov', '');
//    }
}

function SlideDescription(x, dir)
{
    var currw = x.offsetWidth;
    var dist;
    if(dir == 1)
    {
        dist = (Math.round((x.maxw - currw) / DDSPEED));
    }
    else
    {
        dist = (Math.round(currw / DDSPEED));
    }
    if(dist < 1 && dir==1)
    {
        dist = 1;
    }
    x.style.width = currw + (dist * dir) + 'px';
    //c.style.opacity = currh / c.maxh;
    //c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
    if((currw < 2 && dir != 1) || (currw > 248 && dir == 1))
    {
        if(dir==1)
        {
            x.style.width='300px';
        }
        else
        {   
            x.style.width='0px';
        }
        clearInterval(x.timer);
    }
}

function Collapse(x)
{
    x.timer = setInterval(function(){SlideDescription(x,-1)},DDTIMER);
}

//-->

