
//*****************************
//
// Browser compatibility Check
//
// ***************************

var ez_strictHTML=0;
var ez_usefx = 0;
var ez_isMac = (navigator.appVersion.indexOf("Mac") != -1);
var ez_NN4 = document.layers?1:0;
var ez_IE4 = document.getElementById?0:1;
var ez_OPR = (navigator.userAgent.indexOf("Opera")!=-1)?1:0;
var ez_OPR7 = 0;
var ez_NS6 = (document.getElementById && !document.all && !ez_OPR)?1:0;
if (ez_codeRootPath == "undefined" ) ez_codeRootPath = "";
ez_codePath = ez_codeRootPath + "script/menu/EZMenu/";
if (ez_OPR) {
	temp = navigator.userAgent.split("Opera");
	if (temp[1].substring(0,1) == "/") {temp = temp[1].split("/");}
	ver = parseFloat(temp[1]);
	if (ver >= 7) ez_OPR7 = 1;
	if (ver < 7) ez_strictHTML=0;
}
if (navigator.appVersion.indexOf("MSIE")>-1) {
	temp = navigator.appVersion.split("MSIE");
	ver = parseFloat(temp[1]);
	if ((ver >= 5.5) && !ez_NS6 && !ez_OPR && !ez_isMac) ez_usefx = 1;
	if (ver<6 && !ez_isMac && !ez_OPR && !ez_NS6) ez_strictHTML=0;
}

if(ez_NN4) {
	document.write("<SCR" + "IPT  SRC='" + ez_codePath + "ezmenuns.js' TYPE='text/javascript'><\/SCR" + "IPT>");
} else {
	document.write("<SCR" + "IPT  SRC='" + ez_codePath + "ezmenuie.js' TYPE='text/javascript'><\/SCR" + "IPT>");
}

//*********************************
//
// Menu Database Handling Function
//
// ********************************
// declare variable
var mainMenuColor="#805700";
var menuItemColor="#ffeeee";
var highlightColor="#ffffee";
var borderWidth=1;
var borderHeight=1;
var paddingWidth=3;
var paddingHeight=3;
var itemWidth=168;
var itemHeight=20;
var hAlign="left";
var vAlign="middle";
var anchorClass="menuAnchor";
var itemTagsOpen="<font class='menuAnchor' face='Arial' size='2' color='#000000'>";
var itemTagsClose="</font>";
var menuDelay=0.3; 
var imageArrowOff = "/images/bullet/arrow.gif";
var imageArrowOn = "/images/bullet/arrowhi.gif";
var imageArrowOff1 = "/images/bullet/arrow.gif";
var imageArrowOn1 = "/images/bullet/arrowhi.gif";

// declare important arrays
var ez_Menu = new Array();
var ez_fontInfo = new Array();
var ez_tfontInfo = new Array();
var ez_colInfo = new Array();
var ez_borSize = new Array();
var ez_txtPad = new Array();
var ez_arrow = new Array();
var ez_root = new Array();
var ez_isBar = new Array();
var ez_isChild = new Array();
var ez_xover = new Array();
var ez_yover = new Array();
var ez_bg = new Array();
var ez_pname = new Array();
var ez_pwidth = new Array();
var ez_3D = new Array();
var ez_sfx = new Array();
var ez_animate = new Array();
var ez_imageRoot = new Array();
var ez_imageRootPath = "";
var ez_xCord = new Array();
var ez_yCord = new Array();
var ez_childPos = new Array();
var menus = new Array();
var menusImageOff = new Array();
var menusImageOn = new Array();
var menuCount=0;
var rootCount=0;
var menuItemCount=0;

var lockArray=new Array();
var clrByJump = false;

	// Added 3/27/01 JS
	// For OK Farm site
function getLock(name){
	if(lockArray[name]!=true)
		return false;
	else    return true;
}

function clearLock(name){
	lockArray[name]=false;
}

function setLock(name){
	lockArray[name]=true;
}

function clearLocks() {
	for (a=0; a<lockArray.length;a++)
		lockArray[a]=false;
}

function clearByJump() {
	// Image restore goes here
	clrByJump = true;
}



// press: Menu On
function menuOn(index)
{
 		 if (index != "undefined" && index < ez_Menu.length ) {
		 	var currentMenu, xCord,yCord;
			currentMenu = ez_Menu[index];
			xCord =  ez_xCord[index];			
			yCord =  ez_yCord[index];
			showPanel(index +'',xCord,yCord);
		 }
		 
}

// relase: Menu Off
function menuOff(index)
{
 		if (index != "undefined" && index < ez_Menu.length ) {
 		 	hidePanel();
		}
}

// add the Menu List
function addMenu(xCord,yCord)
{
 		 var menuName = menuCount;
		 // set the 
		 if (xCord == "undefined" || xCord == "" ) {
		 	  	ez_isChild[menuCount] = true;
				ez_imageRoot[menuCount] = yCord;
				ez_imageRootPath = yCord;
				
		 }
		 else {
			 if ( Regexp(xCord,"^[0-9]") == false) {
				ez_isChild[menuCount] = true;
				ez_imageRoot[menuCount] = yCord;
				ez_imageRootPath = yCord;
				ez_childPos[menuCount] = xCord; 
			 }
			 else {
		         ez_imageRoot[menuCount] = ""; 
		 		 ez_isChild[menuCount] = false;
		 		 ez_xCord[menuCount] = xCord;
		 		 ez_yCord[menuCount] = yCord;
				 ez_childPos[menuCount] = "rb";
			 }
		 }
		 
		 ez_pname[menuCount] = menuCount + '';
		 menus[menuCount] = new Array();
		 menusImageOn[menuCount] = new Array();
		 menusImageOff[menuCount] = new Array();
		 menuItemCount = 0;		 
 		 menuCount++;
}

// add Item to the Current List
function addMenuItem(LinkText,LinkURL,referIndex)
{
		 // split the referIndex
		 var childPos = "";
		 var refIndex = "";
		 if ( referIndex != "undefined" && referIndex != "" ) {
			 var indexData  = referIndex.split(",");
			 if ( indexData.length > 0 ) {
				 // refer index
				 refIndex = indexData[0];
				 
				 if ( indexData.length == 2 ) {
					 childPos = indexData[1];
				 }
				 
				 
			 }
		 }
		 
 		 // 2-D data
		 if ( LinkText != "undefined" && LinkText != "" ) {
		 	 var links = LinkText;
		
			 // url href
			 if ( LinkURL != "undefined" && LinkURL != "" ) {
		 	  	 		 links = links + "^" + LinkURL;
		 	}
		 
		    //refer Index and etc
			 if ( referIndex != "undefined" && referIndex != "" ) {
			     links = links + "^^" + referIndex;
				 childPos = (childPos.length > 0 ) ? childPos : "rd";
			 	 links = links + "," + childPos;
			 }


		 	// add the data
			 var imagesOff = ez_imageRoot[menuCount] + imageArrowOff;
		     var imagesOn = ez_imageRoot[menuCount] + imageArrowOn;
			 var currentMenuCount = menuCount-1;			 
			 menus[currentMenuCount][menuItemCount] = links;
			 
			 if  ( Regexp(childPos,"^l") == true) {
			 	imagesOff = ez_imageRoot[menuCount] + imageArrowOff1;
			 	imagesOn = ez_imageRoot[menuCount] + imageArrowOn1;
			 }

			 menusImageOff[currentMenuCount][menuItemCount] = imagesOff;
			 menusImageOn[currentMenuCount][menuItemCount] = imagesOn;
			 //document.write(menus[currentMenuCount][menuItemCount] + "<br>\n");			 
			 menuItemCount++;
		 }
}

// Draws the menus.
function drawMenus () {
		 // Loop through the menu items, looking for items that are parents of submenus.
		 // For each one we find, set it's child menu's parentMenuIndex.
		 for (var n=0; n<menuCount; n++) {
		 	  var v;
			  if ( isArray( menus[n] ) == true ) {
				 v = menus[n];
				 ez_Menu[n] = menus[n];

				 if ( ez_isChild[n] == false )
				 {
				  	  ez_fontInfo[rootCount] = "Arial,11px,#000000,#000000";
				 	  ez_tfontInfo[rootCount] = "Arial,11px,#FFFFFF";
				 	  ez_colInfo[rootCount] = menuItemColor + "," + highlightColor + "," + mainMenuColor + "," + "#111111";
					  var imagesOff = ez_imageRootPath + imageArrowOff;
				          var imagesOn = ez_imageRootPath + imageArrowOn;
	  			   
				 	  ez_arrow[n] = imagesOff + "," + imagesOn + ",10";
				 	  //ez_arrow[rootCount] = ",,10";
					  ez_borSize[rootCount] = "0,0";
				      	  ez_txtPad[rootCount] = "3";
				          ez_root[rootCount] = '' + n;
					  ez_xover[rootCount] = "0";
				          ez_yover[rootCount] = "0";
					  ez_bg[rootCount] = "";
					  ez_3D[rootCount] = "3D1";
					  ez_sfx[rootCount] = "progid:DXImageTransform.Microsoft.Shadow(direction=135,color=#aaaaaa,strength=5)";
				 	  ez_animate[rootCount] = "progid:DXImageTransform.Microsoft.Fade(Overlap=1.00,duration=0.5)";
					  //"progid:DXImageTransform.Microsoft.Inset(duration=0.5)";


					  rootCount++;
	
				 }
				 else {
				    var imagesOff = ez_imageRoot[n] + imageArrowOff;
				    var imagesOn = ez_imageRoot[n] + imageArrowOn;			   
				 	//ez_arrow[n] = imagesOff + "," + imagesOn + ",10";
				 }
				 
				 
				 ez_isBar[n] = false;
				 ez_pwidth[n] = 0;	

			  }
			  		  
			  
		 }


		 setup();
		 menusGo();
}

// Return a boolean value telling whether 
// the first argument is an Array object. 
function isArray() {

if (typeof arguments[0] == 'object') {
  var criterion =  arguments[0].constructor.toString().match(/array/i);
   return (criterion != null);
  }
return false;
} 

// Return a boolean value telling whether 
// the first argument is a string. 
function isString() {

if (typeof arguments[0] == 'string') return true;
if (typeof arguments[0] == 'object') {
  var criterion =  arguments[0].constructor.toString().match(/string/i);
   return (criterion != null);
  }
return false;
} 

function Regexp(src,syntax) {
     var numReg = syntax;
     var regex = new RegExp(numReg);
     return regex.test(src);  
}



