/**
  * FormMagick - Option/Select
  * 
  * constructor( document.forms['aForm'].aSelectObject ), Init a object
  * getIndex(), Returns current index
  * gotoValue( aValue ), Moves index to the position of the given value
  * gotoIndex( aIndex ), Moves to the index given
  */
function fmOption( SelectionList )
{
	var index = null;
	var list = SelectionList;
//	this.getValue=optionGetValue;
//	this.remove=optionRemove;
//	this.add=optionAdd;
//	this.sortAcordingToValue=optionSortValue;
//	this.sortAcordingToContent=optionSortContent;
//	this.length=optionLength;
//	this.disable=optionDisbale;
//	this.selectedIndex=optionSelectedIndex;
//	this.selectedContent=optionSelectedContent;

	this.getIndex=function(){
		return index;
	}

	this.gotoValue=function(s) {
		index = false;
		
		for(p=0;p<list.length;p++)
		{
			if (list.options[p].value==s)
			{
				index = p;
			}
		}
		
		return index;
	}

	this.gotoIndex=function(i) {
		if ( list.length>i & 0<=i )
		{
			index=i;
			return true;
		} else {
			return false;
		}
		
	}
	
	this.setContent=function(c)
	{
		if(index!==null)
		{
			list.options[index].text=c;
			return true;
		} else {
			return false;
		}
	}
	
	this.getContent=function()
	{
		if(index!==null || index!==false)
		{
			return list.options[index].text;
		} else {
			return false;
		}
	}
	
	this.setValue=function(v)
	{
		if(index!==null)
		{
			list.options[index].value=v;
			return true;
		} else {
			return false;
		}
	}
	
	this.getValue=function()
	{
		if(index!==null || index!==false)
		{
			return list.options[index].value;
		} else {
			return false;
		}
	}
	
	this.remove=function()
	{
		if(index!==null || index!==false)
		{
			list.options[index]=null;
			return true;
		} else {
			return false;
		}		
	}
	
	this.add=function( c, v )
	{
		list.options[list.length]=new Option( c, v );;
		return true;
	}
	
	this.overwrite=function( c, v, i )
	{
		if ( list.length>i & 0<=i )
		{
			list.options[i]=new Option( c, v );;
			return true;
		} else
		{
			return false;
		}
	}
	
	this.selectedValue=function()
	{
		
		for(p=0;p<list.length;p++)
		{
			if (list.options[p].selected)
			{
				return list.options[p].value;
			}
		}
	}
	
	this.showIndex=function(i)
	{
		list.selectedIndex = i;
	}
}
