﻿// Checks if included UtilityLibrary.js
if( typeof( Syncfusion_UtilityLibrary_version ) == "undefined" || Syncfusion_UtilityLibrary_version != "1.0" )
  alert( "\"UtilityLibrary.js (1.0 version)\" not included!" );

// Version info
Syncfusion_BaseEdit_version = "1.0";

/*******************************************************
------------------------
Class Tree Inheritance:
------------------------
- BaseEditKeyHndl
  |
  + MaskedEditKeyHndl
  | |
  | + DateTimeEditKeyHndl
  |   | 
  |   + DropDownCalendarControl
  |
  + NumericEditKeyHndl
    |
    + PercentEditKeyHndl
    |
    + CurrencyEditKeyHndl
  
********************************************************/
/////////////////////////////////////////////////////////////
// BaseEditKeyHndl class
/////////////////////////////////////////////////////////////
function SF_BaseEditTextBox( sRootID )
{
  ////////////////////////////////////////////////////////////////
  // Constants
  ////////////////////////////////////////////////////////////////
  
  var m_oSelf = this;
  var c_etbTypeBrowser	= null;
  var c_sAttrClntID		= "ClntID";
  var c_sAttrClntText	= "ClntText";
  var c_sAttrClntTooltip		= "ClntTooltip";
  var c_sAttrClntValue			= "ClntValue";
  var c_sAttrClntInstanceName	= "ClntInstanceName";
  var c_sAttrClntTextBoxID		= "ClntTextBoxID";

  var c_sOnValueChange	= "ClientOnValueChange";
  var c_sOnMouseOver	= "ClientOnMouseOver";
  var c_sOnMouseOut	 = "ClientOnMouseOut";
  var c_sOnFocusIn	 = "ClientOnFocusIn";
  var c_sOnFocusOut	 = "ClientOnFocusOut";
  
  ////////////////////////////////////////////////////////////////
  // Fields
  ////////////////////////////////////////////////////////////////
    
  this.hlp = document._helper;
  this.keys = document._helper.keys;
  this.insertMode = true;
  this.textbox = null;
  this.bIsArrowButtonClick = false;
  this.oInterval = "";
  this.lastSpecChar;
  //sometimes under Netscape it required to lock arrows-keys
  this.lockArrows = false;
 
  var m_oParent		= null;
  var m_oTextBox	= null;
  var m_sClientInstanceName = "";
  var m_bFocused	= false;
  
  ////////////////////////////////////////////////////////////////
  // Propeties
  ////////////////////////////////////////////////////////////////
  this.GetRoot = function()
  {	
	var oRes = null;
	
	if( null == m_oParent )
	{
		m_oParent = document.getElementById( sRootID )
	}
	oRes = m_oParent;
	
	return oRes;
	
  }
  ////////////////////////////////////////////////////////////////
  this.GetTextBox = function()
  {
	var oRes = null;
	
	if( null == m_oTextBox )
	{
		var oRoot = this.GetRoot();
		var aInputs = oRoot.getElementsByTagName("INPUT");
		m_oTextBox = aInputs[0];
		if (!m_oTextBox)
		{
			// should not be here!
			var sTextBoxID = oRoot.getAttribute( c_sAttrClntTextBoxID );
			m_oTextBox = document.getElementById( sTextBoxID );
		}
	}
	oRes = m_oTextBox;
	
	return oRes;
  }
  
	this.EnsureTextBox = function()
	{
		if (!this.textbox)
		{
			this.textbox = this.GetTextBox();
		}
	}
  
	this.GetHiddenData = function()
	{
		var oRes = document.getElementById( sRootID + "_hidden" );
		return oRes.value;
	}
	
	this.SetHiddenData = function( sVal )
	{
		var oRes = document.getElementById( sRootID + "_hidden" );
		oRes.value = sVal;
	}
	
  ////////////////////////////////////////////////////////////////
  this.Self = function()
  {
	return m_oSelf;
  }
  ////////////////////////////////////////////////////////////////
  this.GetClientInstanceName = function()
  {
	var sRes = ""
	
	if( "" == m_sClientInstanceName )
	{
		var oParent = this.GetRoot();
		m_sClientInstanceName = oParent.getAttribute( c_sAttrClntInstanceName );
	}
	sRes = m_sClientInstanceName;
	
	return sRes;
  }
  ////////////////////////////////////////////////////////////////
  this.GetTypeBrowser = function()
  {
	if( null == c_etbTypeBrowser )
	{
		c_etbTypeBrowser = GetInternalTypeBrowser();
	}
	
	function GetInternalTypeBrowser()
	{
		var sRes = null;
		
		switch( window.navigator.appName )
		{
			case ETypeBrowser.IE: 
			{
				if( navigator.userAgent.indexOf( 'Opera' ) != -1 )
       				sRes = ETypeBrowser.Opera;
				else
					sRes = ETypeBrowser.IE;
				break;
			}  
			case ETypeBrowser.Netscape: 
			{
				sRes = ETypeBrowser.Netscape;
				break;
			}
			default:
			{
				sRes = ETypeBrowser.Unknown;
				break;
			}
		}
		return sRes;
	}
	return 	c_etbTypeBrowser;
  }
  ////////////////////////////////////////////////////////////////
  this.IsIE = function()
  {
	var bRes = false;
	
	var etbBrowser = this.GetTypeBrowser();
	if( ETypeBrowser.IE == etbBrowser )
	{
		bRes = true;
	}
	
	return bRes;
  }
  ////////////////////////////////////////////////////////////////
  this.IsNetscape = function()
  {
	var bRes = false;
	
	var etbBrowser = this.GetTypeBrowser();
	if( ETypeBrowser.Netscape == etbBrowser )
	{
		bRes = true;
	}
	
	return bRes;
  }
  ////////////////////////////////////////////////////////////////
  this.IsOpera = function()
  {
	var bRes = false;
	
	if( !this.IsIE() && !this.IsNetscape() )
	{
		bRes = true;
	}
	
	return bRes;
  }
  
  ////////////////////////////////////////////////////////////////
  // Event handlers
  ////////////////////////////////////////////////////////////////
  this.OnFocus = function( event, element )
  {
   	this.keys.lastEvent = event;
   	this.textbox = element;
	
	if ( null == this.m_sSavingValue )
	{
		this.SaveDefaultValue();
	}
	if( !IsTrue( this.bIsArrowButtonClick ) )
    {
		this.ProcessOnFocusIn( this.GetRoot(), event )
    }
	
	this.CorrectStartSelection();
	this.Preparing();
	
	if( this.IsNetscape() )
	{
		this.SelectControlInNetscape();
	}
	
	m_bFocused = true;	
  }
  /////////////////////////////////////////////////////////////
  this.SelectControlInNetscape = function()
  {
	function CorrectStartSelection()
	{
		m_oSelf.CorrectStartSelection();
	}
	
	window.setTimeout( CorrectStartSelection, 1 );
  }
  /////////////////////////////////////////////////////////////
  this.OnBlur = function( event, element )
  {
    m_bFocused = false;

    this.SaveDefaultValue();
    
    if( !IsTrue( this.bIsArrowButtonClick ) )
    {
		this.ProcessOnFocusOut( this.GetRoot(), event );
    }
  }   
  ////////////////////////////////////////////////////////////////
  this.OnKeyPress = function( event, element )
  {
    //alert( "keypress: " + event.keyCode + " CHAR: " + String.fromCharCode( event.keyCode ));
    if( !this.IsOpera() )
		this.keys.lastEvent = event;
   
    if( this.keys.bc.specKeyAndNetscape( this.lastSpecChar, this.keys.lastEvent, this.lockArrows ) )
      return true;
    
    this.lastSpecChar = this.keys.bc.getKeyCode( this.keys.lastEvent );
    
    var bRes =  this.ProcessKey();
    
    // Refresh text value
    if( this.IsOpera() && !bRes )
		this.RunTimeOut();
    
    return bRes;
  }
  ////////////////////////////////////////////////////////////////
  this.OnPaste = function( event, element )
  {
	var clipboardText = this.keys.bc.getClipboardData(); 
	
	var newText = this.ProcessPasteValue( clipboardText );
	this.ValidateAndSet( newText );
	
	return false;
  }
  ////////////////////////////////////////////////////////////////
  this.RunTimeOut = function()
  {
     var sValue	   = this.GetTextBox().value;
     var nPosCarret = this.posCaret;
	 var tb = this.GetTextBox();

	function RefreshValue()
	{
		// correct caret position
		tb.setSelectionRange( nPosCarret, nPosCarret );   
		tb.value = sValue;
	}
    
     window.setTimeout( RefreshValue, 1 );
  }

	this.SetSelectionDelayed = function( nPosCarret, nSelLen )
	{
		var tb = this.GetTextBox();

		function fn()
		{
			m_oSelf.hlp.selectText( tb, nPosCarret, nSelLen );
		}
		window.setTimeout( fn, 1 );
	}

  ////////////////////////////////////////////////////////////////
  this.AddKeyCaptHandler = function()
  {
	  if( ETypeBrowser.Netscape == this.GetTypeBrowser() )
	  {	
		 var sClientID = this.textbox.getAttribute("ClientID");
		 var oTextBox = document.getElementById( sClientID );
		 if ( oTextBox )
		 {
			oTextBox.addEventListener( "keypress", OnKeyCapt, true );
		 }
	 }
	 
	 return false;
  }
  ////////////////////////////////////////////////////////////////
  this.RemoveKeyCaptHandler = function()
  {
    if( ETypeBrowser.Netscape == this.GetTypeBrowser() )
    {
		var sClientID = this.textbox.getAttribute("ClientID");
		var oTextBox = document.getElementById( sClientID );
		if ( oTextBox )
		{
			oTextBox.removeEventListener( "keypress", OnKeyCapt, true );
		}
	}
  }
  //////////////////////////////////////////////////////////////////////
  this.SaveDefaultValue = function()
  {
	var sValue = this.textbox.value;
    if( "" != sValue && null != sValue)
    {
	    this.m_sSavingValue = sValue;
  	}
  }
  /////////////////////////////////////////////////////////////////////
  function OnKeyCapt( event )
  {
    event.preventDefault();
    event.stopPropagation();
  }
  
  /////////////////////////////////////////////////////////////
  this.OnKeyDown = function ( event, element )
  { 
	this.keys.lastEvent = event;
    //alert( "keydown:" + event.keyCode + " CHAR: " + String.fromCharCode( event.keyCode ) );
    
    this.lastSpecChar = this.keys.bc.getKeyCode( this.keys.lastEvent );
    //alert(this.lastSpecChar);
    this.textbox = element;
    
    var bRes = false;
    	 
    do
    {
		if ( this.keys.isPasteKey() )
		{
			bRes = this.ProcessKey();
			break;
		}
		// If space symbol
		if( 32 == this.keys.lastEvent.keyCode )
		{
			bRes = true;
			break;
		}
	      
		if( 27 == event.keyCode )
		{
			this.ResetValueToDefault();
			this.ProcessEscKey();
			bRes = this.AddKeyCaptHandler();
			break;
		}
		
		this.RemoveKeyCaptHandler();
		
		if( ETypeBrowser.Opera == this.GetTypeBrowser() )
		{
			break;
		}
	    
	    	    
		if( ETypeBrowser.Netscape == this.GetTypeBrowser() && this.keys.isBackSpaceKey() )
		{
			bRes = true;
			break;
		}
		
		bRes = this.ProcessSpecificKey();
    }
    while( false );
    
    return bRes;
  }
  
  this.ProcessEscKey = function()
  {
  }
  
  /////////////////////////////////////////////////////////////
  this.StartIncrementValue = function( event, textboxId )
  {
	this.RemoveKeyCaptHandler();
    this.keys.lastEvent = event;
    
    var oParent = document.getElementById( textboxId );
    var tags = oParent.getElementsByTagName( "INPUT" );
    this.textbox = tags[ 0 ];
    
    if( this.textbox != null )
    {
      return this.IncrementValue();
    }
  }
  this.StopIncrementValue = function( event, textboxId )
  {
	this.keys.lastEvent = event;
    
    var oParent = document.getElementById( textboxId );
    var tags = oParent.getElementsByTagName( "INPUT" );
    this.textbox = tags[ 0 ];

    if( this.StopAutoIncrement != null )
    {
      this.StopAutoIncrement();
    }
    
    this.SaveDefaultValue();
  }
  this.StartDecrementValue = function ( event, textboxId )
  {
	this.RemoveKeyCaptHandler();
    this.keys.lastEvent = event;
    
    var oParent = document.getElementById( textboxId );
    var tags = oParent.getElementsByTagName( "INPUT" );
    this.textbox = tags[ 0 ];
	
    if( this.textbox != null )
    {
      return this.DecrementValue();
    }
  }
  this.StopDecrementValue = function ( event, textboxId )
  {
	this.keys.lastEvent = event;
    
    var oParent = document.getElementById( textboxId );
    var tags = oParent.getElementsByTagName( "INPUT" );
    this.textbox = tags[ 0 ];
    
    if( this.StopAutoIncrement != null )
    {
      this.StopAutoIncrement();
    }
    
    this.SaveDefaultValue();
  }
  /////////////////////////////////////////////////////////////
  this.OnMouseClickIncr = function ( event, textboxId )
  {
    this.StopIncrementValue( event , textboxId );
    return false;
  }
  /////////////////////////////////////////////////////////////
  this.OnMouseClickDecr = function ( event, textboxId )
  {
    this.StopDecrementValue( event, textboxId ); 
    return false;
  }
  /////////////////////////////////////////////////////////////
  this.OnMouseUpIncr = function ( event, textboxId )
  {
    this.StopIncrementValue( event , textboxId );
  }
  /////////////////////////////////////////////////////////////
  this.OnMouseUpDecr = function ( event, textboxId )
  {
    this.StopDecrementValue( event, textboxId ); 
  }
  /////////////////////////////////////////////////////////////
  this.OnMouseDownIncr = function ( event, textboxId )
  { 
	this.bIsArrowButtonClick = true;
	this.StartIncrementValue( event, textboxId );
  }
  /////////////////////////////////////////////////////////////
  this.OnMouseDownDecr = function ( event, textboxId )
  {
	this.bIsArrowButtonClick = true;
	this.StartDecrementValue( event, textboxId );
  }   
  /////////////////////////////////////////////////////////////
  this.OnMouseOver = function( event, oEl )
  {
	this.textbox = this.GetTextBox();
	this.ProcessOnMouseOver( oEl, event );
  }
  /////////////////////////////////////////////////////////////
  this.OnMouseOut = function( event, oEl )
  {
	this.textbox = this.GetTextBox();
	this.ProcessOnMouseOut( oEl, event );
  }
  /////////////////////////////////////////////////////////////
  this.OnDblClickIncr = function( event )
  {
    if( ETypeBrowser.IE == this.GetTypeBrowser() ||
		ETypeBrowser.Opera == this.GetTypeBrowser() )
    {
		var sClientID = this.textbox.getAttribute("ClientID");
		this.StartIncrementValue( event , sClientID );
		this.InternalStopAutoChangeValue( true );
	}
  }
  /////////////////////////////////////////////////////////////
  this.OnDblClickDecr = function( event )
  {
    if( ETypeBrowser.IE == this.GetTypeBrowser() ||
		ETypeBrowser.Opera == this.GetTypeBrowser())
    {
		var sClientID = this.textbox.getAttribute("ClientID");
		this.StartDecrementValue( event , sClientID );
		this.InternalStopAutoChangeValue( false );
	}
  }  
  /////////////////////////////////////////////////////////////    
  this.InternalStopAutoChangeValue = function( bIsUpDirect )
  {
	var c_nTimeOutInterval = 30;
	
	var m_sClientID = this.textbox.getAttribute("ClientID");
	var m_oEvent	= this.keys.lastEvent;
	var m_oSelf		= this;

	function StopIncrement()
	{
		m_oSelf.StopIncrementValue( m_oEvent , m_sClientID );
	}
	function StopDecrement()
	{
		m_oSelf.StopDecrementValue( m_oEvent , m_sClientID );
	}
	
    if( bIsUpDirect )
		window.setTimeout( StopIncrement, c_nTimeOutInterval );
	else
		window.setTimeout( StopDecrement, c_nTimeOutInterval );
  }                                   
  /////////////////////////////////////////////////////////////
  // Helper methods
  /////////////////////////////////////////////////////////////
  this.ProcessSpecificKey = function()
  {
    var sClientID = this.textbox.getAttribute("ClientID");
    
    if( this.keys.DEF_UP == this.keys.lastEvent.keyCode )
    {
		this.StartIncrementValue( this.keys.lastEvent , sClientID );
		this.InternalStopAutoChangeValue( true );
		this.SaveDefaultValue();
    }
    if( this.keys.DEF_DOWN == this.keys.lastEvent.keyCode )
    {
		this.StartDecrementValue( this.keys.lastEvent , sClientID );
		this.InternalStopAutoChangeValue( false );
		this.SaveDefaultValue();
    } 
   
    if( this.keys.isMoveCaretKey() || 
        this.keys.isTabKey() || 
        this.keys.isAlphanumericKey()
      )
    { 
       return true;
    }
    
    return this.ProcessKey();
  }
  /////////////////////////////////////////////////////////////
  this.GetParentElement = function( oElement )
  {
	var oParentElement;
	
	if( ETypeBrowser.IE == this.GetTypeBrowser() )
	{
		oParentElement = oElement.parentElement;
	}
   	else		
	{
		oParentElement = oElement.parentNode;
	}
				
	return oParentElement;
  }
  /////////////////////////////////////////////////////////////
  this.CorrectStartSelection = function()
  {
	var oElement = this.textbox;
	if( oElement &&  "" == this.oInterval )
	{
		var sEditableText = this.RemoveMask( oElement.value );
	
		var nStartIndex = oElement.value.indexOf( sEditableText );
		var nLength = sEditableText.length;
		this.hlp.selectText( oElement, nStartIndex, nLength );
	}
  }
  ////////////////////////////////////////////////////////////////
  this.IsKeyDownEvent = function()
  {
	var bRes = ( "keydown" == this.keys.lastEvent.type );
	return bRes;
  }
  ////////////////////////////////////////////////////////////////
  this.IsKeyPressEvent = function()
  {
	var bRes = ( "keypress" == this.keys.lastEvent.type );
	return bRes;
  }
  
  /////////////////////////////////////////////////////////////
  // Abstract methods
  /////////////////////////////////////////////////////////////
  this.ValidateAndSet = null;
  this.ProcessKey = null;
  this.IncrementValue = null;
  this.DecrementValue = null;
  this.StopAutoIncrement = null;
  this.GetText = null;
  this.GetValue = null;

  /////////////////////////////////////////////////////////////
  // PseudoVirtual methods
  /////////////////////////////////////////////////////////////
  this.Preparing = function(){ return null; }
  /////////////////////////////////////////////////////////////
  this.Validate = this.base_Validate = function( value )
  {
    var strRegExp = this.textbox.getAttribute( "regExp" );
    var regExp = new RegExp( strRegExp );
    return regExp.test( value );    
  }
 
/////////////////////////////////////////////////////////////
function InvokeClientHandler( sFnOnItemSelect, oEl, oEv )
{
	var bCont = true;
	if ( sFnOnItemSelect )
	{
		try
		{
			function fn()
			{
				eval( "bCont=(" + sFnOnItemSelect + ")" );
			}

			var oData = SureGetItemData( oEl );
			oData.Event = oEv;

			fn.call( oData );
			// if function does not return value we do not break execution
			if (null == bCont) bCont = true;						
		}
		catch(e){}
	}
	return bCont;
}
/////////////////////////////////////////////////////////////
this.ProcessOnValueChange = function( oEl, oEv )
{
	var bRes = false;
	var bFocused = m_bFocused;
	
	var tb = this.GetTextBox();
	var posCaret = 0;
	var lenSelect = 0;
	if (bFocused)
	{
		posCaret = this.hlp.getCaretPos( tb );
		lenSelect = this.hlp.getSelectedLength( tb );
	}

	var sOnValueChange = oEl.getAttribute( c_sOnValueChange );
	bRes = InvokeClientHandler( sOnValueChange, oEl, oEv );
	
	if (bFocused)
	{
		this.GetTextBox().focus();
		this.SetSelectionDelayed( posCaret, lenSelect );
	}
	return bRes;
}
/////////////////////////////////////////////////////////////
function IsCompleteMouseOut_IE( oEl, oEv )
{
	var bFromExternalEl = !oEl.contains( oEv.toElement );
	return bFromExternalEl;
}	
function IsCompleteMouseOut_MOZ( oEl, oEv )
{
	// XULDOM utils
	function GetElRelationship( oEl, oOther, nCode )
	{
		var bRes = false;

		var nRes = oEl.compareDocumentPosition( oOther );
		bRes = (0 != (nCode & nRes));

		return bRes;	
	}
	
	// True if oOther contains oEl
	function IsElContaining( oEl, oOther )
	{
		return GetElRelationship( oEl, oOther, oEl.DOCUMENT_POSITION_CONTAINED_BY );
	}
	
	var bFromExternalEl = !( IsElContaining( oEl, oEv.explicitOriginalTarget ) )
	return bFromExternalEl;
}

this.IsCompleteMouseOut = function( oEl, oEv )
{
	var bRes = this.IsIE() ? IsCompleteMouseOut_IE( oEl, oEv ) : IsCompleteMouseOut_MOZ( oEl, oEv );
	return bRes;
}
		
this.ProcessOnMouseOver = function( oEl, oEv )
{
	if( !this.GetRoot().isMouseOver )
	{
	var sOnMouseOver = oEl.getAttribute( c_sOnMouseOver );
	InvokeClientHandler( sOnMouseOver, oEl, oEv );
		
		this.GetRoot().isMouseOver = true;
	}
}
/////////////////////////////////////////////////////////////
this.ProcessOnMouseOut = function( oEl, oEv )
{
	if( this.IsCompleteMouseOut( oEl, oEv ) )
	{
	var sOnMouseOut = oEl.getAttribute( c_sOnMouseOut );
	InvokeClientHandler( sOnMouseOut, oEl, oEv );
		
		this.GetRoot().isMouseOver = false;
	}
}
/////////////////////////////////////////////////////////////	
this.ProcessOnFocusIn = function( oEl, oEv )
{
	var sOnFocusIn = oEl.getAttribute( c_sOnFocusIn );
	InvokeClientHandler( sOnFocusIn, oEl, oEv );
}
/////////////////////////////////////////////////////////////
this.ProcessOnFocusOut = function( oEl, oEv )
{
	var sOnFocusOut = oEl.getAttribute( c_sOnFocusOut );
	InvokeClientHandler( sOnFocusOut, oEl, oEv );
}
/////////////////////////////////////////////////////////////	
function SureGetItemData( oEl )
{
	//if ( oEl.m_oSFData )
	{
		var sID		= GetStrAttribute( oEl, c_sAttrClntID );
		var sTooltip = GetStrAttribute( oEl, c_sAttrClntTooltip );
		
		oEl.m_oSFData = 
		{
			ID		: sID,
			Text	: m_oSelf.GetText(),
			Tooltip	: sTooltip,
			Value	: m_oSelf.GetValue(),
			InstanceName : m_oSelf.GetClientInstanceName(),
			Instance: m_oSelf,
			
			HtmlID	: oEl.id,
			Element	: oEl,
			TextBox	: m_oSelf.GetTextBox()
		}
	}
	return oEl.m_oSFData;
}
/////////////////////////////////////////////////////////////
function GetStrAttribute( oEl, sAttr )
{
	var sVal = oEl.getAttribute( sAttr );
	if (!sVal)
		sVal = "";
	return sVal;
}
/////////////////////////////////////////////////////////////
this.IsXHTMLDocType = function()
{
	var bRes = false;
	
	var sDocType = document.doctype;
	if( this.IsOpera() )
	{
		if( "QuirksMode" != document.compatMode )
		{
			bRes = true;
		}
	}
	else if( null != sDocType )
	{
		bRes = true;
	}
	
	return bRes;
}
/////////////////////////////////////////////////////////////
function SetButtonStyles( oParent )
{
	if( null != oParent )
	{
		var aButtons = oParent.getElementsByTagName( "Button" );
		m_oSelf.ProcessSetButtonStyles( aButtons );
		
		var aImages = oParent.getElementsByTagName( "IMG" );
		m_oSelf.ProcessSetImageStyles( aImages );
		SetupTextElementStyle( oParent );
	}
}
/////////////////////////////////////////////////////////////
function SetupTextElementStyle( oParent ) 
{ 
var arrTextEls = oParent.getElementsByTagName( "INPUT" ); 
var oTextEl = arrTextEls[0]; 
  
var oTextTd = oTextEl.parentElement; 
if( null == oTextTd ) 
{ 
oTextTd = oTextEl.parentNode; 
} 
oTextEl.style.width = oTextTd.offsetWidth + "px"; 
} 
///////////////////////////////////////////////////////////// 
this.ProcessSetButtonStyles = function( oBtns )
{
	for( var c=0; c<oBtns.length; ++c )
	{
		var button = oBtns[ c ];
		
		if( m_oSelf.IsXHTMLDocType() && m_oSelf.IsOpera() )
		{
		    var bSetDefStyle = true;
		    var oRtStyle = getComputedStyle( button );
		    if( oRtStyle &&( oRtStyle.borderBottomWidth == "0px" ) )
		    {
		        //not aply default style, when use AutoFormat
		        bSetDefStyle = false;
		    }   
		    if( bSetDefStyle )
		    {		        
			    button.style.width = "11px";
			    button.style.height = "6px";
			}
		}
	}
}
/////////////////////////////////////////////////////////////	
this.ProcessSetImageStyles = function( oImgs )
{
	for( var c=0; c< oImgs.length; ++c )
	{
		var img = oImgs[ c ];
		
		if( m_oSelf.IsXHTMLDocType() && m_oSelf.IsOpera() )
		{
			img.style.marginTop = "1px";
		}
		else if( m_oSelf.IsNetscape() )
		{
			img.style.marginTop = "-2px";
			img.style.marginLeft = "-2px";
		}
	}
}
/////////////////////////////////////////////////////////////
function ctor()
{
	var oRoot = m_oSelf.GetRoot();
	SetButtonStyles( oRoot );
}

window.setTimeout( ctor, 1 );
 
}

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();