// The White Company Flyout Navigation - draft 2 - Nazeer Ruhomutally

var brwsr=navigator.appVersion.indexOf('MSIE'); // variable used for IE6 detection
var limage="";

function showsubdepts(k)  // function to display flyouts and swap image for selected image
{
if (brwsr==-1)  // if browser is not IE6
{
limage=document.getElementById(k+"_img").src;
document.getElementById(k+"_img").src="images/eng/mainmenu/"+k+"_sltd.gif";
return;
}
else
{
limage = document.getElementById(k+"_img").src;
document.getElementById(k+"_mask").style.display="block";
document.getElementById(k+"_subs").style.display="block";
document.getElementById(k+"_img").style.borderColor="#CCCCCC";
document.getElementById(k+"_img").src="images/eng/mainmenu/"+k+"_sltd.gif";
}
}

function hidesubdepts(l)  // function to hide flyouts and swap image for unselected image
{
if (brwsr==-1)  // if browser is not IE6
{
document.getElementById(l+"_img").src=limage;
//document.getElementById(l+"_img").src="images/eng/mainmenu/"+l+"_unsltd.gif";
return;
}
else
{
document.getElementById(l+"_mask").style.display="none";
document.getElementById(l+"_subs").style.display="none";
document.getElementById(l+"_img").style.borderColor="#FFFFFF";
//document.getElementById(l+"_img").src="images/eng/mainmenu/"+l+"_unsltd.gif";
document.getElementById(l+"_img").src=limage;
}
}


function preloader(g)  // function for preloading selected version images - runs as navigation images are loaded
{
var lImg=g;
var pImg=lImg.replace('_img','_sltd');
var p=new Image();
p.src="images/eng/mainmenu/"+pImg+".gif";
//flyoutAdjust(g);
return;
}

function flyoutAdjust(q)  // function that checks and adjusts flyout position if too far right
{
//var foID=q.replace('_img','_subs');
//var maskID=q.replace('_img','_mask');
nl=780;  // This adjuster function needs this nl variable to be the same as the width of the navigation or 'container' - have to figure out how to dynamically set this
foW=200;
imgOS=document.getElementById(q+"_subs").offsetLeft;
imgW=document.getElementById(q+"_img").width;
totalVal=imgOS+foW;
adjustVal=((foW-imgW)+2);

if (totalVal>nl)
{
document.getElementById(q+"_subs").style.marginLeft="-"+adjustVal+"px";
document.getElementById(q+"_subs").style.backgroundImage="url(../images/eng/mainmenu/"+q+"_mask.gif)";
//document.getElementById(q+"_mask").style.width=imgW+"px";
}
else
{
//document.getElementById(q+"_mask").style.width=imgW+"px";
document.getElementById(q+"_subs").style.backgroundImage="url(../images/eng/mainmenu/"+q+"_mask.gif)"
return;
}
}