// If javascript is enabled, make the menu invisible until the proper mouseovers have been defined and give special styles to the submenus
if (document.getElementById && document.getElementsByTagName) {
	document.write("<link type=\"text/css\" rel=\"stylesheet\" href=\"jsmenustyle.css\" />");
}



function start() {
  init();
  initImgRotation2();
}

window.onload = start;


function init() {
	if (document.getElementById && document.getElementsByTagName) {
		var myMenu = document.getElementById("menu").getElementsByTagName("A");
		if (!myMenu) { return; }
		else {
			for (var i=0;i<myMenu.length;i++) {
				myMenu[i].onmouseover = navHoverStyle;
				myMenu[i].onfocus = navHoverStyle;
			}
			document.getElementById("menu").style.visibility = "visible";
		}
	}
}

// Stores the currently open UL objects
var openMenus = new Array();

// Stores the timer for closing the menu
var navTimer;

function navHoverStyle(e) {
	if (!e) var e = window.event;
	if (e.target) var tg = e.target;
	else if (e.srcElement) var tg = e.srcElement;

	var linkElm = tg;
	while (linkElm.nodeName != 'A')
		linkElm.parentNode;

	while (tg.nodeName != 'LI')
		tg = tg.parentNode;

	// Determine if and if so, which submenu items to close
	var tgParent = tg.parentNode;
	while (tgParent.nodeName != 'UL')
		tgParent = tgParent.parentNode;

	if (tgParent.id == 'menu') {
		closeAll(0);
	}
	else {
		var j=0;
		while (openMenus[j] != tgParent) {
			j++;
		}
		closeAll(j+1);
	}

	// Determine if the current item has a submenu and if so, open it
	for ( var i=0;i<tg.childNodes.length;i++) {
		if ( tg.childNodes[i].nodeName == 'UL') {
			var subMenuElm = tg.childNodes[i];
		}
	}

	if (subMenuElm) {
		linkElm.className = 'unfolded';
		subMenuElm.style.display = 'block';
		openMenus.push(subMenuElm);
	}

	// Set the timer
	checkNavTimer();

	return false;
}

function checkNavTimer() {
	if (navTimer) clearTimeout(navTimer);
	navTimer = setTimeout('closeAll(0)',5000);
}

function closeAll(lvl) {
	var oMl = openMenus.length-1;
	for ( var i=oMl;i>=lvl;i--) {
		var linkElm = openMenus[i].previousSibling;
		while (linkElm.nodeName != 'A')
			linkElm = linkElm.previousSibling;

		linkElm.className = '';
		openMenus[i].style.display = 'none';
		openMenus.pop();
	}
}
/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  Copyright 2001-3 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

function initImgRotation() {
  // create rotating image objects here 
  // arguments: image name, rotation speed
  var rotator1 = new rotateImgObj('img1',2500);
  // add the images to rotate into that image object  
  rotator1.addImages("anim1.jpg","anim2.jpg","anim3.jpg","anim4.jpg","anim5.jpg","anim6.jpg" );
  rotator1.rotate();
  
  rotateImgObj.start();
}

//rotation 2
function initImgRotation2() {
  // create rotating image objects here 
  // arguments: image name, rotation speed
  var rotator2 = new rotateImgObj('store1',3000);
  // add the images to rotate into that image object  
  rotator2.addImages("store_1.jpg","store_2.jpg","store_3.jpg","store_4.jpg","store_5.jpg","store_6.jpg","store_7.jpg","store_8.jpg","store_9.jpg","store_10.JPG","store_11.jpg","store_12.jpg","store_13.jpg");
  rotator2.rotate();
  
  rotateImgObj.start();
}

// If all the images you wish to display are in the same location, you can specify the path here 
rotateImgObj.imagesPath = "/store_pics/";

// no need to edit code below 
/////////////////////////////////////////////////////////////////////
rotateImgObjs = []; // holds all rotating image objects defined
// constructor 
function rotateImgObj(nm,s) {
  this.speed=s; this.ctr=0; this.timer=0;  
  this.imgObj = document.images[nm]; // get reference to the image object
  this.index = rotateImgObjs.length; rotateImgObjs[this.index] = this;
  this.animString = "rotateImgObjs[" + this.index + "]";
}

rotateImgObj.prototype = {
  addImages: function() { // preloads images
    this.imgObj.imgs = [];
    for (var i=0; arguments[i]; i++) {
      this.imgObj.imgs[i] = new Image();
      this.imgObj.imgs[i].src = rotateImgObj.imagesPath + arguments[i];
    }
  },

  rotate: function() {
    if (this.ctr < this.imgObj.imgs.length-1) this.ctr++;
    else this.ctr = 0;
    this.imgObj.src = this.imgObj.imgs[this.ctr].src;
  }
}

// sets up rotation for all defined rotateImgObjs
rotateImgObj.start = function() {
  for (var i=0; i<rotateImgObjs.length; i++) 
    rotateImgObjs[i].timer = setInterval(rotateImgObjs[i].animString + ".rotate()", rotateImgObjs[i].speed);                     
}





