<?php
	FNTH_class( "Textbox" );

	class FrontendTextbox extends FNTHTextbox {
		protected $bMandatory = false;
		protected $bInvalid = true;
		protected $bShowTitle = false;
		public function setShowTitle( $v ) { $this->bShowTitle = $v; }

		public function setMandatory( $v ) { $this->bMandatory = $v; }

		public function __construct( $id = "FrontendTextbox" , $parent = null ) {
			$this->addMediaDirectory( $GLOBALS["site_root"] , $GLOBALS["site_www"] , "design/rp/","widgets/");
			parent::__construct( $id , $parent );
			$this->setParam("language",$GLOBALS["language"]);
			$this->setAttribute( "class" , "FrontendTextbox" );
		}

		public function render() {
			if ($this->bMandatory) {
				$this->bInvalid = (!strlen( $this->sValue ));
				$this->setParam( "bInvalid" , $this->bInvalid );
				if ($this->bInvalid)
					$this->setAttribute( "class" , $this->getAttribute( "class" ) . " invalid" );
				$this->setAttribute( "onchange" , sprintf( "FrontendTextboxNonEmptyChanged( '%s' );" , $this->sId ) );
			}
			$this->setParam( "bShowTitle" , $this->bShowTitle );
			return parent::render();
		}
	}

?>
