/* SVN FILE: $Id: answer.js 164 2008-04-23 00:36:15Z bb_yujiro $ */
/**
 * 解答用入力欄の追加
 *
 * JavaScript
 *
 *    Hitsuji : Social Network Service <http://rakuto.net/rktSNS/>
 *    Copyright (c) 2007 Yujiro Takahashi
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @package         Hitsuji
 * @copyright       Copyright (c) 2007 Yujiro Takahashi
 * @link            http://rakuto.net/rktSNS/
 * @author          Yujiro Takahashi <yujiro@rakuto.net>
 * @version         $Revision: 164 $
 * @modifiedby      $LastChangedBy: bb_yujiro $
 * @lastmodified    $Date: 2008-04-23 09:36:15 +0900 (水, 23 4 2008) $
 * @license         http://opensource.org/licenses/mit-license.php The MIT License
 */

function addAnswer() {
	ul = YAHOO.util.Dom.get('Answers');

	var count = 0;
	for (var row=0; row<ul.childNodes.length; row++){
		if (ul.childNodes[row].lastChild){
			if (ul.childNodes[row].lastChild.value == ''){
				count ++;
			}
		}
	}
	if (count > 1){
		return ;
	}

	var li     = document.createElement('li');
	var answer = document.createElement('input');

	li.style.marginBottom = '8px';

	answer.setAttribute('type', 'text');
	answer.setAttribute('size', '42');
	answer.setAttribute('name', 'answers[]');

	YAHOO.util.Event.addListener(answer, 'focus', addAnswer);

	li.appendChild(answer);
	ul.appendChild(li);
}
