/*
Version 1.4
Automized Menu Item Selection routines by Justin Deltener
Copyright 1999 Mind Tremors Corp.  Any duplication in part or in full of this page is strictly prohibited
without the expressed permission of Mind Tremors. Licensed to Shasta Marketing Consultants.

DSS = Default Status String
Tag = Is used for loading the glow version of menu items. This way, we only have to pass the Load function one file name and the routines
      will automatically add on the Tag to load it. Ex: 2 Files (Links, Links-g) we would call SetTag("-g");
NEW:
Setup does nothing - the function is NOT needed
Load functions automatically increase NumberofObjects++ (less code needed for useage)
*/

window.onerror=null;
var netscape = 0;
var goodIE = 0;

browserName = navigator.appName.substring(0,8);
browserVer = parseFloat(navigator.appVersion);
if (browserName == "Netscape" && browserVer >= 3)   {netscape = 1;}
if (browserName == "Microsof" && browserVer >= 3.01){goodIE = 1;}


var Count=0,NumberOfObjects=0,Items=0,Path,DSS="",Tag;
var Over_errors,Over_error_count=0;

Items = new Array;

var SetBG;  //Sfunctions
var BGFile;
var MasterTag;

function SLoad(img,w,h,alt,nametag)
{ if(img==null || w==null || h==null || alt==null || nametag==null)
  {errorhandle("Incorrect Number Of Parameters!",window.location,"SLoad()");return;
  }
 if(netscape || goodIE)
  {Items[NumberOfObjects] = new xSLoad(img,w,h,alt,nametag);
   NumberOfObjects++;
  }
}

function xSLoad(img,w,h,alt,nametag)
{if(img==null || w==null || h==null || alt==null || nametag==null)
  {errorhandle("Incorrect Number Of Parameters!",window.location,"xSLoad()");return;
  }
 if(netscape || goodIE)
  {this.StatusString=alt;
   this.PicRegular = new Image(w,h);
   this.PicRegular.src=Path+BGFile; 
   this.PicGlow = new Image(w,h);
   this.PicGlow.src=Path+img;
   this.NameTag=nametag; 
   this.Width=w;
   this.Height=h;
   this.SRC=MasterTag;
  }
}

function SetBackground(name,tag)
{ if(name==null || tag==null)
   {errorhandle("Incorrect Number Of Parameters!",window.location,"SetBackground()");return;
   }
  SetBG=1;
  BGFile=name;
  MasterTag=tag
}



function Over_error_history(nametag)  //check Over_errors to see if tag has a error history
	{ for(var z=0;z < Over_errors.length;z++)
		{if(nametag == Over_errors[z]){return 1;}
		}
	 return -1;
	}

function Setup(NOO) //NOO number of objects
{ 
 return;  // this function is no longer needed in this version.

 if(NOO <=0)
  { errorhandle("Number Of Objects is 0 or NEGATIVE!!",window.location,"Setup()");return;
  }
  Items = new Array(NOO);
  Over_errors = new Array();
  if(Over_errors == null){errorhandle("Unable to Allocate Over_errors array!",window.location,"Setup()");return;}
  NumberOfObjects=NOO;
}

function SetPath(path)
{ if(path ==null){errorhandle("Path is NULL!!",window.location,"SetPath()");return;}
Path=path;
}

function SetTag(tag)
{if(tag ==null){errorhandle("Tag is NULL!!",window.location,"SetTag()");return;}
 this.Tag=tag;
}

function SetDefaultStatus(string)
{DSS=string;
 SetStatus(DSS);
}

function Load(img,w,h,alt,nametag)
{
if(img==null || w<=0 || h<=0 || alt==null || nametag==null)
  {errorhandle("Incorrect Number Of Parameters!",window.location,"Load()");return;
  }

 if(netscape || goodIE)
  {Items[NumberOfObjects] = new xLoad(img,w,h,alt,nametag);
  } 

 NumberOfObjects++;
}

function xLoad(img,w,h,alt,nametag)
{ if(img==null || w==null || h==null || alt==null || nametag==null)
  {errorhandle("Incorrect Number Of Parameters!",window.location,"xLoad()");return;
  }
 if(netscape || goodIE)
  {this.StatusString=alt;
   this.PicRegular = new Image(w,h);
   this.PicRegular.src=Path+img;
   this.PicGlow = new Image(w,h);
    var front,file;
   front= newsplit(img,'.');
   file=front[0];
   file+=Tag+'.'+front[1];
   this.PicGlow.src=Path+file;
   this.NameTag=nametag; 
   this.Width=w;
   this.Height=h;
   this.SRC=nametag;
  }
}

function Flip(nametag,onoff)
{ if(netscape || goodIE)
  {var pick = Locate(nametag);
   if(pick == -1)
	{var error_history = Over_error_history(nametag);
	 if(error_history == -1)
		{Over_errors[Over_error_count]=nametag;Over_error_count++;
              errorhandle('Tags Not Pressent! ['+Over_errors+']',window.location,"Flip()");
		} 
	 }
   else
   { var temp= new Image();
     if(onoff==1)
        {temp=Items[pick].PicGlow.src;SetStatus(Items[pick].StatusString);}
    else{temp=Items[pick].PicRegular.src;SetStatus(DSS);}
     document.images[Items[pick].SRC].src=temp;
   }
 }

}

function SetStatus(string)
{ if(netscape || goodIE)
   {window.status=string;
    return true;
   }
}

function Locate(name)
{ if(name==null){errorhandle("Incorrect Number Of Parameters!",window.location,"Locate()");return -1;}
 for(var c=0;c<NumberOfObjects;c++)
   { if(Items[c].NameTag == name){return c;}
   }
  return -1;
}

function OpenWindow(url,title,width,height)
{dimension='width='+width+','+'height='+height;
 if(netscape || goodIE)
   {window.open(url,title,dimension);
   }
}

function newsplit(string,spliter)
{ // getting how many entries there are
   var allocate=1;
   for(var l=0;l<=string.length;l++)
    {if(string.charAt(l) == spliter) {allocate++;}}

   var newstring = new Array(allocate);
   var segment ="";
   var counter = 0;

for(var c=0;c<=string.length;c++)
  { if(string.charAt(c) !=spliter && (c+1)<=string.length)
        {segment+=string.charAt(c);} else 
        {newstring[counter] = segment; segment = "";counter++;} 
    
  } 
return newstring;
}

