(function(){
	var $ = function(id){ return typeof(id) == "string"?document.getElementById(id):id}
	var todoList = {
		initListAdd: function(){
			$('list-add').onclick = function(){
				$('list-add-form').style.display = 'block';
				$('list-add-cancel').style.display = 'inline-block';
				this.style.display = 'none';
				return false;
			}
			$('list-add-cancel').onclick = function(){
				$('list-add-form').style.display = 'none';
				$('list-add').style.display = 'block';
				this.style.display = 'none';
				return false;
			}
		},
		initItemAdd: function(){
			$('item-add').onclick = function(){
				$('item-add-form').style.display = 'block';
				$('item-add-cancel').style.display = 'inline-block';
				this.style.display = 'none';
				return false;
			}
			$('item-add-cancel').onclick = function(){
				$('item-add').style.display = 'block';
				$('item-add-form').style.display = 'none';
				this.style.display = 'none';
				return false;
			}
		},
		initItemApp: function(){
			todoList.initItemAdd();
			var completedItems = $("completedItems").getElementsByTagName('li');
			for(var i = 0, j = completedItems.length; i < j; i++){
				var chkBox = $(completedItems[i].id + 'checkbox');
				chkBox.onclick = function(){
					this.blur();
					//alert($(""+parseInt(this.id)))
					$('container').appendChild($(""+parseInt(this.id)));
				}
			}
		}
	}
	window.todoList = todoList;
})()