/* 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 = "../images/nav/";
	 var navdir = "images/nav/";

function preload(loc) {
	if (loc = '1') {
	navdir = "../" + navdir;
 } else { 
	 navdir = "./" + navdir;
 }

	
top_2_off = new Image;
top_2_off.src = navdir + "homeoff.gif";
top_2_on = new Image;
top_2_on.src = navdir + "homeon.gif";

top_3_off = new Image;
top_3_off.src = navdir + "cartoff.gif";
top_3_on = new Image;
top_3_on.src = navdir + "carton.gif";

//alert (top_3_off.src)
//alert (top_3_on.src)

top_4_off = new Image;
top_4_off.src = navdir + "contactoff.gif";
top_4_on = new Image;
top_4_on.src = navdir + "contacton.gif";

top_5_off = new Image;
top_5_off.src = navdir + "trackoff.gif";
top_5_on = new Image;
top_5_on.src = navdir + "trackon.gif";


top_6_off = new Image;
top_6_off.src = navdir + "printoff.gif";
top_6_on = new Image;
top_6_on.src = navdir + "printon.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;

//alert(menuObj.src)
 }
}


// mouse over (on) and mouseoff(off) color values
var oncolor = "#003777";
var offcolor = "#FFFFFF";
//var oncolor = "#251D08";
//var offcolor = "#D7ACA9";
//var oncolor = "#A5D8F6";
//var offcolor = "#57001A";
function changecolor(divname,colorname) {
stopall();
if (!n4) {
menuObj = eval(doc + divname + sty);
menuObj.backgroundColor = colorname;
  }
}

// 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);
//  }

//WILL WANT TO ACTIVATE
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 = 500;

// 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) {
// changecolor(menuelem,oncolor);
// active_menuelem = menuelem;
// }
//WILL WANT TO ACTIVATE
if (topelem != null) {
// onoff('mainmenu',topelem,'on');
 active_topelem = topelem;
 }
}


// function switch pictures 
function switchpictures(topelem,direction) {
stopall();
closeallmenus();
if (topelem != null) {
 onoff('mainmenu',topelem,direction);
 active_topelem = topelem;
 }
}


function initialize(loc) {

preload(loc);
closeallmenus();
stopall();
//dimensions();
//if (win_width < 800) {
//mainmenuleft = centerhor - 80;
// }
//else {
//mainmenuleft = centerhor - 50;
//     }
mainmenuleft = 25;
offset1 = 80;
//offset2 = 85;
//offset3 = 85;
//offset4 = 95;
placeIt('StoreNavBar',mainmenuleft,30);
//placeIt('subscribe',mainmenuleft +offset1+offset2,60);
//placeIt('members',mainmenuleft +offset1+offset2+offset3,60);
//placeIt('contact',mainmenuleft +offset1+offset2+offset3+offset4,60);

//placeIt('membersmusic',mainmenuleft +offset1+offset2+offset3+offset4,65);
//placeIt('membersteacher',mainmenuleft +offset1+offset2+offset3+offset4,82);
//placeIt('membersstudent',mainmenuleft +offset1+offset2+offset3+offset4,102);
}


/* Receipt Window Function */
/* first, declare the variable newWin that will be used 
for the new window object. */
var newWin;

function basicWindow(url,w,h) {
/**/
settings = '"toolbar=no, directories=no,menubar=no,scrollbars=no,resizable=yes,status=no,width='+w+',height='+h+'"';
/**/
/*settings = '"toolbar=no, directories=no,menubar=no,scrollbars=no,resizable=yes,status=no"';*/
closeWindow();
newWin = window.open(url,'newWin',settings);
newWin.focus();
}

function closeWindow() {
if (newWin && !newWin.closed) {
newWin.close(); }
}
