//Function for creating menus from array chains
//Copyright (c) 2007-2008 by Shawn Olson http://www.shawnolson.net
//This file and the following functions
//may be used in any legitimate version of Webonizer
//For information on Webonizer go to http://www.webonizer.com

function fileMenu(id,values,names,selectedValue,target,emptyValues){
   this.id = id; // id of the controlling select menu (or other form field)
   this.values = values;
   //values should be an array; names is a corresponding
   //array of the names corresponding to the values
   this.names = names;
   this.selectedValue = selectedValue;
   this.target = target; //id of the target select menu that will change
   this.emptyValues = emptyValues;
   this.showSelect = showSelect;
}

function showSelect(){
     var a = 0;
     var theS = document.getElementById(this.target);
	 for(var i in theS) {
	   if(theS.options.remove){
	     theS.options.remove(i);
	   } else {
	     theS.remove(theS.options[i]);
	   }
	 }

	 for (a in this.values){
       theS.options[a] = new Option(this.names[a],this.values[a]);
     }
	 theS.options[a] =  new Option('Any',null);
	 theS.options.selectedIndex = a;
}

function changeMenuSelects(tparent,tchild,valueMap,nameMap){
    //This function changes the option list in a select menu
	//based on the selection of the controlling select menu
	       //(or other form element)
    //tparent is the id of the controlling element
	//tchild is the id of the target select menu
	//valueMap is the name of the array controlling values
	//nameMap is the name of the array controlling option display
    if(document.getElementById(tparent) && document.getElementById(tchild)){
      theParentMenu = document.getElementById(tparent);
	  str = 'var vs = '+valueMap+theParentMenu.value+';';
	  str += 'var ns = '+nameMap+theParentMenu.value+';';

	  eval(str);
	  var theM = new fileMenu(tparent,vs,ns,null,tchild,true);
      theM.showSelect();
   }
}

var webonizerInnovaEditor = new Array();
