
	function newItem(){
		$("#newitem").fadeIn("fast");	
	}
	
	$tasks = "";
	$numtasks = 0;
	$comtasks = 0;
	function addItem(){
		$item = document.getElementById("itemname").value;
		if ($item == ""){
			$("#warning").fadeIn("fast");
			$("#warning").html("Please be sure to enter an item name.. :)");
			$("#warning").fadeOut(10000);
		} else {
		$newitem = "<li onclick='javascript:$comtasks++;updateStats();$(this).css({textDecoration: \"line-through\"});$(this).fadeTo(100, 0.5)'>"+$item+"</li>";
		$("#items").append($newitem);	
		document.getElementById("itemname").value = "";
		$numtasks++;
		$tasks = $tasks+$item+"@";
		}
		document.additem.itemname.focus();
		updateStats();
	}
	
	function getStats(){
		$("#stats").html("<p><strong>Stats:</strong> Number of tasks: "+$numtasks+" | Number of tasks completed: "+$comtasks+"</p>")
		$("#stats").slideToggle("normal");
	}
	
	function updateStats(){
		$("#stats").html("<p><strong>Stats:</strong> Number of tasks: "+$numtasks+" | Number of tasks completed: "+$comtasks+"</p>")
	}
	
	function clearList(){
		$("#items").html("");
		$numtasks = 0;
		$comtasks = 0;
		updateStats();
	}
	
	function doneAdd(){
		$("#newitem").fadeOut("fast");	
	}
	
	function changeTitle() {
		$("#lname").load("form.html");	
	}
	function newName(){
		$name = document.getElementById("listname").value;
		$("#lname").html("<p onclick='changeTitle()'>"+$name+"</p>");
	}
	
	function getPrint(){
		window.print(); 	
	}
	
	function uploadFile(){
		$("#upload").slideDown("fast");	
		$("#importbtn").addClass("imon");
	}
	
	function about(){
		$("#about").fadeIn("normal")
	}
	
	function closeAb(){
		$("#about").fadeOut("normal")
	}
	/* Importin Code */
	function canUp(){
		$("#upload").fadeOut("fast");
		$("#importbtn").removeClass("imon")
	}
	function importList(){
		$("#uploadStat").fadeIn("fast");
		//$cont = document.getElementById("import").value;
		var a = document.getElementsByTagName('textarea')[0].value.match(/^.+$/gm);
		if (a == "") {
			$("#warning").html("Cannot import a blank list, please try again");
		} else {
			a.sort();
			for (var i = 0; i < a.length; i++)
				{
					$item = (a[i]);
					$newitem = "<li onclick='javascript:$comtasks++;updateStats();$(this).css({textDecoration: \"line-through\"});$(this).fadeTo(100, 0.5)'>"+$item+"</li>";
					$("#items").append($newitem);
					$tasks = $tasks+$item+"@";
				}
				$numtasks = i;
				updateStats();	
				document.getElementById("import").value = "";
				$("#upload").slideUp("normal");
				$("#uploadStat").fadeOut("fast");
				$("#importbtn").removeClass("imon")
		}
	}
	
	/* Exporting Code */
	function exportList(){
		if ($tasks == "") {
			$("#warning").fadeIn("fast");
			$("#warning").html("You have not started a list yet.");
			$("#warning").fadeOut(10000);
		} else {
			$newW = Trim($tasks);
			//$newW = jQuery.trim($tasks);
			$("#fileready").load("backend/export.php?content="+$newW);
			//alert($tasks);
			$("#fileready").slideDown("fast");
		}
	}
	
	function Trim(str){
		str = str.replace(/\s+/g,'%20');
		return str;
	}