function StayiSelector() 
{
    /**
     * internal method to see if we are inserting are overwriting if obj is selected
     */
    this.inserting = function(obj) {
	return (NotationEditModeController.insertMode() || (obj && obj.partType() == ROWVIEWPART_NEWSWARASPACER));
    }

    /**
     * change the octave
     */
    this.setOctave = function(octave) {
	if( octave != -1 && octave != 0 && octave != 1 )  return false;
	if( !this.fSwara ) return false;
	this.fSwara.setOctave(octave);
	this.fLabelView.nodeValue = this._getStayi();
	EventManager.postEvent(EventManager.EVENT_SWARATOOLBAR_STAYICHANGED, this, octave);
	return true;
    }

    /**
     * called when an octave is selected (used in testing also)
     * @private
     */
    this.onOctave = function(octave) {
	this.setOctave(octave);
    }

    /**
     * implementation of @{link EventHandler} interface
     */
    this.onEvent = function(evt, src, data) {
	if( evt == EventManager.EVENT_SWARA_SELECTED || evt == EventManager.EVENT_NEWSWARASPACER_SELECTED )
	{
	    this.getContent().style.display = "";
	    this.fSwara.setLabel(data.getLabel());
	    if( this.inserting(src) )
		this.fSwara.setOctave(0);
	    else
		this.fSwara.setOctave(data.getOctave());
	    this.fLabelView.nodeValue = this._getStayi();
	}
	else if( evt == EventManager.EVENT_LYRIC_SELECTED )
	    this.getContent().style.display = "none";
	else if( evt == EventManager.EVENT_MENU_CLOSED )
	    this.setSelected(false);
    }

    /**
     * implementation of @{link ActionHandler} interface
     */
    this.doAction = function(src, actionID) {
	if( src == this ) {
	    var obj = src.getContent();
	    var x = LookAndFeel.findPosX(obj);
	    var y = LookAndFeel.findPosY(obj) + obj.offsetHeight;
	    this.fMadyaMenuItem.update(this.fSwara);
	    this.fTaraMenuItem.update(this.fSwara);
	    this.fMandraMenuItem.update(this.fSwara);
	    this.fStayiMenu.show(x,y);
	}
	else {
	    // menu item is selected
	    this.onOctave(actionID);
	}
    }

    /**
     * override of base-class method to provide real content
     */
    this.provideContent = function() {
	var div = document.createElement("div");
	div.style.fontSize   = "85%";	// need to to this to match toolbar font
	div.style.fontWeight = "bold";	// need to to this to match toolbar font
	div.style.width      = "100%";
	if( !Utils.isIE() )		// IE doesnt support table
	    div.style.display  = "table";	// very important for firefox so that arrow
					// div below has a chance to occupy same
					// height as others (and draw at the bottom)
	div.style.height   = "1.5em";	// give some height
	div.style.width    = "5.75em";


	var div2 = document.createElement("div");
	div2.style.cssFloat = "left";
	div2.style.display  = "inline";
	div2.style.height = "100%";
	div2.style.width  = "4em";
	this.fLabelView = document.createTextNode(this._getStayi());
	div2.appendChild(this.fLabelView);
	div.appendChild(div2);

	var arrow = document.createElement("div");
	arrow.style.width = "1.75em";
	arrow.style.height = "100%";
	arrow.style.background = LookAndFeel.url("but_arrow.png") + " center right no-repeat";	
	arrow.style.cssFloat = "right";
	arrow.style.display  = "inline";
	div.appendChild(arrow);

	return div;
    }

    /**
     * internal method to get stringized form of the octave/stayi
     * @return get stringized form of the current octave/stayi
     * @type String
     * @private
     */
    this._getStayi = function() {
	var octave = 0;
	if(this.fSwara) {
	     octave = this.fSwara.getOctave();
	}
	var str = "";
	if( octave == 0 ) str += "madya";
	else if( octave > 0 ) str += "tara";
	else str +=  "mandra";
	return str;
    }

    /**
     * a local Swara model object which is modified as stayi changes
     * @type Swara
     * @private
     */
    this.fSwara = s = new Swara("S", false, 0, 1, 0); 

    /**
     * the stayi menu which is popped-up when the selector is selected
     * @type Menu
     * @private
     */
    this.fStayiMenu = new Menu();
    this.fStayiMenu.initMenu();

    /**
     * the madya stayi menu item
     * @type MenuItem
     * @private
     */
    this.fMadyaMenuItem = new StayiMenuItem(0);
    this.fStayiMenu.addItem( this.fMadyaMenuItem, this, 0 );
	

    /**
     * the tara stayi menu item
     * @type MenuItem
     * @private
     */
    this.fTaraMenuItem = new StayiMenuItem(1);
    this.fStayiMenu.addItem( this.fTaraMenuItem, this, 1 );

    /**
     * the mandra stayi menu item
     * @type MenuItem
     * @private
     */
    this.fMandraMenuItem = new StayiMenuItem(-1);
    this.fStayiMenu.addItem( this.fMandraMenuItem, this, -1 );

    this.initButton(this, null);
    EventManager.addListener(EventManager.EVENT_SWARA_SELECTED, this);
    EventManager.addListener(EventManager.EVENT_NEWSWARASPACER_SELECTED, this);
    EventManager.addListener(EventManager.EVENT_LYRIC_SELECTED, this);
    EventManager.addListener(EventManager.EVENT_MENU_CLOSED, this);
}
/**
 * @class
 * stayi selector, which is part of the swara tool bar. It also
 * implements the @{link EventListener} and @{link ActionHandler} interfaces
 */
@class
stayi selector, which is part of the swara tool bar. It also
implements the @{link EventListener} and @{link ActionHandler} interfaces
@class stayi selector which is part of the swara tool bar . It also implements the @ { link EventListener } and @ { link ActionHandler } interfaces
function StayiSelector() 
{
    this.inserting = function(obj) {
	return (NotationEditModeController.insertMode() || (obj && obj.partType() == ROWVIEWPART_NEWSWARASPACER));
    }
    this.setOctave = function(octave) {
	if( octave != -1 && octave != 0 && octave != 1 )  return false;
	if( !this.fSwara ) return false;
	this.fSwara.setOctave(octave);
	this.fLabelView.nodeValue = this._getStayi();
	EventManager.postEvent(EventManager.EVENT_SWARATOOLBAR_STAYICHANGED, this, octave);
	return true;
    }
    this.onOctave = function(octave) {
	this.setOctave(octave);
    }
    this.onEvent = function(evt, src, data) {
	if( evt == EventManager.EVENT_SWARA_SELECTED || evt == EventManager.EVENT_NEWSWARASPACER_SELECTED )
	{
	    this.getContent().style.display = "";
	    this.fSwara.setLabel(data.getLabel());
	    if( this.inserting(src) )
		this.fSwara.setOctave(0);
	    else
		this.fSwara.setOctave(data.getOctave());
	    this.fLabelView.nodeValue = this._getStayi();
	}
	else if( evt == EventManager.EVENT_LYRIC_SELECTED )
	    this.getContent().style.display = "none";
	else if( evt == EventManager.EVENT_MENU_CLOSED )
	    this.setSelected(false);
    }
    this.doAction = function(src, actionID) {
	if( src == this ) {
	    var obj = src.getContent();
	    var x = LookAndFeel.findPosX(obj);
	    var y = LookAndFeel.findPosY(obj) + obj.offsetHeight;
	    this.fMadyaMenuItem.update(this.fSwara);
	    this.fTaraMenuItem.update(this.fSwara);
	    this.fMandraMenuItem.update(this.fSwara);
	    this.fStayiMenu.show(x,y);
	}
	else {
	    this.onOctave(actionID);
	}
    }
    this.provideContent = function() {
	var div = document.createElement("div");
	div.style.fontSize   = "85%";	
	div.style.fontWeight = "bold";	
	div.style.width      = "100%";
	if( !Utils.isIE() )		
	    div.style.display  = "table";	
	div.style.height   = "1.5em";	
	div.style.width    = "5.75em";
	var div2 = document.createElement("div");
	div2.style.cssFloat = "left";
	div2.style.display  = "inline";
	div2.style.height = "100%";
	div2.style.width  = "4em";
	this.fLabelView = document.createTextNode(this._getStayi());
	div2.appendChild(this.fLabelView);
	div.appendChild(div2);
	var arrow = document.createElement("div");
	arrow.style.width = "1.75em";
	arrow.style.height = "100%";
	arrow.style.background = LookAndFeel.url("but_arrow.png") + " center right no-repeat";	
	arrow.style.cssFloat = "right";
	arrow.style.display  = "inline";
	div.appendChild(arrow);
	return div;
    }
    this._getStayi = function() {
	var octave = 0;
	if(this.fSwara) {
	     octave = this.fSwara.getOctave();
	}
	var str = "";
	if( octave == 0 ) str += "madya";
	else if( octave > 0 ) str += "tara";
	else str +=  "mandra";
	return str;
    }
    this.fSwara = s = new Swara("S", false, 0, 1, 0); 
    this.fStayiMenu = new Menu();
    this.fStayiMenu.initMenu();
    this.fMadyaMenuItem = new StayiMenuItem(0);
    this.fStayiMenu.addItem( this.fMadyaMenuItem, this, 0 );
    this.fTaraMenuItem = new StayiMenuItem(1);
    this.fStayiMenu.addItem( this.fTaraMenuItem, this, 1 );
    this.fMandraMenuItem = new StayiMenuItem(-1);
    this.fStayiMenu.addItem( this.fMandraMenuItem, this, -1 );
    this.initButton(this, null);
    EventManager.addListener(EventManager.EVENT_SWARA_SELECTED, this);
    EventManager.addListener(EventManager.EVENT_NEWSWARASPACER_SELECTED, this);
    EventManager.addListener(EventManager.EVENT_LYRIC_SELECTED, this);
    EventManager.addListener(EventManager.EVENT_MENU_CLOSED, this);
}
function StayiSelector ( ) { this . inserting = function ( obj ) { return ( NotationEditModeController . insertMode ( ) || ( obj && obj . partType ( ) == ROWVIEWPART_NEWSWARASPACER ) ) ; } this . setOctave = function ( octave ) { if ( octave != - 1 && octave != 0 && octave != 1 ) return false ; if ( ! this . fSwara ) return false ; this . fSwara . setOctave ( octave ) ; this . fLabelView . nodeValue = this . _getStayi ( ) ; EventManager . postEvent ( EventManager . EVENT_SWARATOOLBAR_STAYICHANGED , this , octave ) ; return true ; } this . onOctave = function ( octave ) { this . setOctave ( octave ) ; } this . onEvent = function ( evt , src , data ) { if ( evt == EventManager . EVENT_SWARA_SELECTED || evt == EventManager . EVENT_NEWSWARASPACER_SELECTED ) { this . getContent ( ) . style . display = "" ; this . fSwara . setLabel ( data . getLabel ( ) ) ; if ( this . inserting ( src ) ) this . fSwara . setOctave ( 0 ) ; else this . fSwara . setOctave ( data . getOctave ( ) ) ; this . fLabelView . nodeValue = this . _getStayi ( ) ; } else if ( evt == EventManager . EVENT_LYRIC_SELECTED ) this . getContent ( ) . style . display = "none" ; else if ( evt == EventManager . EVENT_MENU_CLOSED ) this . setSelected ( false ) ; } this . doAction = function ( src , actionID ) { if ( src == this ) { var obj = src . getContent ( ) ; var x = LookAndFeel . findPosX ( obj ) ; var y = LookAndFeel . findPosY ( obj ) + obj . offsetHeight ; this . fMadyaMenuItem . update ( this . fSwara ) ; this . fTaraMenuItem . update ( this . fSwara ) ; this . fMandraMenuItem . update ( this . fSwara ) ; this . fStayiMenu . show ( x , y ) ; } else { this . onOctave ( actionID ) ; } } this . provideContent = function ( ) { var div = document . createElement ( "div" ) ; div . style . fontSize = "85%" ; div . style . fontWeight = "bold" ; div . style . width = "100%" ; if ( ! Utils . isIE ( ) ) div . style . display = "table" ; div . style . height = "1.5em" ; div . style . width = "5.75em" ; var div2 = document . createElement ( "div" ) ; div2 . style . cssFloat = "left" ; div2 . style . display = "inline" ; div2 . style . height = "100%" ; div2 . style . width = "4em" ; this . fLabelView = document . createTextNode ( this . _getStayi ( ) ) ; div2 . appendChild ( this . fLabelView ) ; div . appendChild ( div2 ) ; var arrow = document . createElement ( "div" ) ; arrow . style . width = "1.75em" ; arrow . style . height = "100%" ; arrow . style . background = LookAndFeel . url ( "but_arrow.png" ) + " center right no-repeat" ; arrow . style . cssFloat = "right" ; arrow . style . display = "inline" ; div . appendChild ( arrow ) ; return div ; } this . _getStayi = function ( ) { var octave = 0 ; if ( this . fSwara ) { octave = this . fSwara . getOctave ( ) ; } var str = "" ; if ( octave == 0 ) str += "madya" ; else if ( octave > 0 ) str += "tara" ; else str += "mandra" ; return str ; } this . fSwara = s = new Swara ( "S" , false , 0 , 1 , 0 ) ; this . fStayiMenu = new Menu ( ) ; this . fStayiMenu . initMenu ( ) ; this . fMadyaMenuItem = new StayiMenuItem ( 0 ) ; this . fStayiMenu . addItem ( this . fMadyaMenuItem , this , 0 ) ; this . fTaraMenuItem = new StayiMenuItem ( 1 ) ; this . fStayiMenu . addItem ( this . fTaraMenuItem , this , 1 ) ; this . fMandraMenuItem = new StayiMenuItem ( - 1 ) ; this . fStayiMenu . addItem ( this . fMandraMenuItem , this , - 1 ) ; this . initButton ( this , null ) ; EventManager . addListener ( EventManager . EVENT_SWARA_SELECTED , this ) ; EventManager . addListener ( EventManager . EVENT_NEWSWARASPACER_SELECTED , this ) ; EventManager . addListener ( EventManager . EVENT_LYRIC_SELECTED , this ) ; EventManager . addListener ( EventManager . EVENT_MENU_CLOSED , this ) ; }
@class
 stayi selector, which is part of the swara tool bar.
@class stayi selector which is part of the swara tool bar .
/**
     * internal method to see if we are inserting are overwriting if obj is selected
     */ /**
     * change the octave
     */ /**
     * called when an octave is selected (used in testing also)
     * @private
     */ /**
     * implementation of @{link EventHandler} interface
     */ /**
     * implementation of @{link ActionHandler} interface
     */ // menu item is selected
 /**
     * override of base-class method to provide real content
     */ // need to to this to match toolbar font
 // need to to this to match toolbar font
 // IE doesnt support table
 // very important for firefox so that arrow
 // div below has a chance to occupy same
 // height as others (and draw at the bottom)
 // give some height
 /**
     * internal method to get stringized form of the octave/stayi
     * @return get stringized form of the current octave/stayi
     * @type String
     * @private
     */ /**
     * a local Swara model object which is modified as stayi changes
     * @type Swara
     * @private
     */ /**
     * the stayi menu which is popped-up when the selector is selected
     * @type Menu
     * @private
     */ /**
     * the madya stayi menu item
     * @type MenuItem
     * @private
     */ /**
     * the tara stayi menu item
     * @type MenuItem
     * @private
     */ /**
     * the mandra stayi menu item
     * @type MenuItem
     * @private
     */