/* define variables for "if n4 (Netscape 4), if IE (IE 4.x), 
and if n6 (if Netscape 6/W3C-DOM compliant)" */

var n4, ie, n6;

/* detecting browser support for certain key objects/methods and 
assembling a custom document object */


var doc,doc2,doc3,sty;

if (document.layers) {
  doc = "document.";
  doc2 = ".document.";
  doc3 = "";
  sty = "";
  n4 = true;
  }
else if (document.all) {
  doc = "document.all.";
  doc2 = "";
  doc3 = "";
  sty = ".style";
  ie = true;
}

else if (document.getElementById) {
  doc = "document.getElementById('";
  doc2 ="')";
  doc3 ="')";
  sty = "').style";
  n6 = "true";
 } 
 
 
// the variables for the window dimensions
var win_width,win_height;
var centerhor, centerver;


//Get dimensions of the window
function dimensions() {
if(n4 || n6){
 win_width=window.innerWidth;
 win_height=window.innerHeight;
}

else if(ie) {
  win_width=document.body.clientWidth;
  win_height=document.body.clientHeight;
     }

centerhor = win_width/2;
centerver = win_height/2;
}


//position the element on the page.

function placeIt(elem,leftPos,topPos) {
docObj = eval(doc + elem + sty);
if (n4 || n6) {
docObj.left = leftPos;
docObj.top= topPos;
 }
if (ie) {
docObj.pixelLeft = leftPos;
docObj.pixelTop = topPos;
 }
}

// preload navigation images

var loaded = 0;
var navdir = "navgfx/";

function preload() {

toolbox_off = new Image;
toolbox_off.src= navdir + "toolbox_off.gif"
toolbox_on = new Image;
toolbox_on.src=navdir + "toolbox_on.gif"

video_off = new Image;
video_off.src = navdir + "work_off.gif";
video_on = new Image;
video_on.src = navdir + "work_on.gif";

news_off = new Image;
news_off.src = navdir + "news_off.gif";
news_on = new Image;
news_on.src = navdir + "news_on.gif";

clients_off = new Image;
clients_off.src = navdir + "clients_off.gif";
clients_on = new Image;
clients_on.src = navdir + "clients_on.gif";

music_off = new Image;
music_off.src = navdir + "music_off.gif";
music_on = new Image;
music_on.src = navdir + "music_on.gif";

mix_off = new Image;
mix_off.src = navdir + "mix_off.gif";
mix_on = new Image;
mix_on.src = navdir + "mix_on.gif";

about_off = new Image;
about_off.src = navdir + "about_off.gif";
about_on = new Image;
about_on.src = navdir + "about_on.gif";

contact_off = new Image;
contact_off.src = navdir + "contact_off.gif";
contact_on = new Image;
contact_on.src = navdir + "contact_on.gif";

submenucommercial_off = new Image;
submenucommercial_off.src = navdir + "submenucommercial_off.gif";
submenucommercial_on = new Image;
submenucommercial_on.src = navdir + "submenucommercial_on.gif";

submenufeatured_off = new Image;
submenufeatured_off.src = navdir + "submenufeatured_off.gif";
submenufeatured_on = new Image;
submenufeatured_on.src = navdir + "submenufeatured_on.gif";

submenupromo_off = new Image;
submenupromo_off.src = navdir + "submenupromo_off.gif";
submenupromo_on = new Image;
submenupromo_on.src = navdir + "submenupromo_on.gif";

submenureel_off = new Image;
submenureel_off.src = navdir + "submenureel_off.gif";
submenureel_on = new Image;
submenureel_on.src = navdir + "submenureel_on.gif";

submenuscoring_off = new Image;
submenuscoring_off.src = navdir + "submenuscoring_off.gif";
submenuscoring_on = new Image;
submenuscoring_on.src = navdir + "submenuscoring_on.gif";

submenutv_off = new Image;
submenutv_off.src = navdir + "submenutv_off.gif";
submenutv_on = new Image;
submenutv_on.src = navdir + "submenutv_on.gif";

submenu_clientsclientlog_off = new Image;
submenu_clientsclientlog_off.src = navdir + "submenuclientlog_off.gif";
submenu_clientsclientlog_on = new Image;
submenu_clientsclientlog_on.src = navdir + "submenuclientlog_on.gif";

loaded = 1;
}

// img src swap function
function onoff (elemparent,elem,state) {
if (loaded) {
newstate = eval(elem+"_"+state);
if (n4) {
menuObj = eval (doc + elemparent + doc2 + elem);
 }
else if (ie || n6) {
menuObj = eval (doc + elem + doc2);
 }
menuObj.src = newstate.src;
 }
}


// submenu mouseovers
function changecolor (elemparent, elem, state) {
stopall();
if (loaded) { 
statechange = eval(elemparent + elem+"_"+state);
if (n4) {
//
// Works with N4???
//
 submenuObj = eval (doc + elemparent + doc2 + elem);
  }
 else if (ie || n6) {
submenuObj = eval (doc + elem + doc2);
  }
submenuObj.src = statechange.src;
 }
}

// show or hide DIV element
function showhide(divname,state) {
if (n4) {
divObj = eval (doc + divname);
 }
else {
divObj = eval (doc + divname + sty);
}
divObj.visibility = state;
}


// variables that hold the value of the currently active (open) menu
var active_submenu1 = null;
var active_submenu2 = null;
var active_menuelem = null;
var active_topelem = null;

// function closes all active menus and turns back to 'off' state
function closeallmenus() {
if(active_submenu1 != null) {
  showhide(active_submenu1,'hidden');
  }
if(active_submenu2 != null) {
  showhide(active_submenu2,'hidden');
  }
if(active_menuelem != null) {
  changecolor(active_menuelem,offcolor);
  }
if(active_topelem != null) {
  onoff('mainmenu',active_topelem,'off');
  }
}

// the menu close timeout variable
var menu_close_timeout = 0;

// delay in miliseconds until the open menus are closed
var delay = 300;

// function calls the closeallmenus() function after a delay
function closeall() {
menu_close_timeout = setTimeout('closeallmenus()',delay);
}

// stop all timeout functions (stops menus from closing)
function stopall() {
clearTimeout(menu_close_timeout);
}

// function controls submenus 
function controlsubmenu(submenu1,submenu2,menuelem,topelem) {
stopall();
closeallmenus();
if (submenu1 != null) {
  showhide(submenu1,'visible');
  active_submenu1 = submenu1;
  }
if (submenu2 != null) {
 showhide(submenu2,'visible');
 active_submenu2 = submenu2;
  }
if (menuelem != null) {
 onoff('subm',menuelem,'on');
 active_menuelem = menuelem;
 }
if (topelem != null) {
 onoff('mainmenu',topelem,'on');
 active_topelem = topelem;
 }
}


function initialize() {
preload();
closeallmenus();
stopall();
dimensions();
if (win_width < 800) {
mainmenuleft = centerhor - 316;
 }
else {
mainmenuleft = centerhor - 316;
     }
offset1 = 55;
offset2 = 85;
offset3 = 85;
offset4 = 95;
placeIt('menu',mainmenuleft,0);
placeIt('submenu',mainmenuleft + 117,60);
placeIt('submenu_clients',mainmenuleft + 224,60);
}