	
		/*
		function loadTimeXMLDoc() {
			if (window.XMLHttpRequest) {							// code for IE7+, Firefox, Chrome, Opera, Safari
				xmltimedoc = new XMLHttpRequest();
			}
			else {													// code for IE6, IE5
				xmltimedoc = new ActiveXObject("Microsoft.XMLHTTP");
		    }
		   
		    return xmltimedoc;
		}

		
		var http = loadTimeXMLDoc();
		
		function getTime() {
			
			var sourceURL = 'http://www.intstix.co.uk/test1.txt';
			var fix = parseInt(Math.random()*999999);
			var newURL = sourceURL;//+"?fix="+fix;
			
			http.open("GET", newURL, true);
			http.onreadystatechange = useHTTPResponse;		
			http.send(null);
			}
		
		function useHTTPResponse() {
		
			if (http.readyState == 4) {
				console.log(http.status);
				if(http.status == 200) {
					var currentxmlTime = http.responseText; //.getElementsByTagName("currenttime")[0];
					//var currentxmlTime = http.responseXML.getElementsByTagName("currenttime")[0];
					console.log(currentxmlTime);
					//document.getElementById('time').innerHTML = currentxmlTime.childNodes[0].nodeValue;
				}
			} 
			else {
				console.log(http.readyState);
				document.getElementById('time').innerHTML = "Waiting";
			}
		}
		*/
	
		
	
		function probusy(){
		$('#processing').show("slow").delay(2000).hide("slow");
		}
		
	
		
		$(document).ready(function(){
			$('#newterm').focus(function() {
				if($(this).val()){
					$(this).val('sorry'); 
					$('#newexplanation').val('probably better if I do this bit.');
					$(this).blur().css('background-color', '#CCC');
					$('#newexplanation').blur().css('background-color', '#CCC');
				}
			});	
		});
				
		$(document).ready(function(){
			$('#newexplanation').focus(function() {
				if($(this).val()){
					$(this).val('probably better if I do this bit.'); 
					$('#newterm').val('sorry');
					$(this).blur().css('background-color', '#CCC');
					$('#newterm').blur().css('background-color', '#CCC');
				}
			});	
		});
		
		
		$(document).ready(function(){
			$('#submitentry').click(function() {
				probusy();
				var newterm = $('#newterm').val();
				var newexplanation = $('#newexplanation').val();
				$.post("/index.php/home/addOption", {'newterm' : newterm , 'newexplanation' : newexplanation });
			});
		});	
				
			
				$(document).ready(function(){
					$('#submit_item').click(function() {
					var item = $('#item').val();
					$.post("/index.php/home/processit", { 'item' : item },
						function(data){
						alert(data.result);
						}, "json");
					});
				});
						
				$(document).ready(function(){				//Submit Data with JSON - works a treat.
					$('#submit_json').click(function() {
					var sel = $('#selection').val();
					$.post("/index.php/home/processjson", { 'sel' : sel },
					    function(data){
						$('#endup').text(data.result);
						}, "json");
					});
				});
				
				/*
				$(document).ready(function(){				//Submit TEXT Data with JSON cos ids don't match options
					$('#submit_json').click(function() {
					var sel = $('#selection').text();
					$.post("/intstixnew/index.php/home/processjson", { 'sel' : sel },
					    function(data){
						alert(data.result);
						}, "json");
					});
				});
				*/
				
				$(document).ready(function(){
					$('#submit').click(function() {
					var sel = $('#selection').val();
					$.post("/index.php/home/process", { 'sel' : sel },
					    function(data){
						$('#endup').text(data);
						});
					});
				});
								
				$(document).ready(function(){
					 $(":button[name=fade]").click(function(event){
					 $("#johnboy").fadeOut("slow");
					});
				});
				 
				$(document).ready(function(){
					$(":button[name=back]").click(function(event){
					$("#johnboy").fadeIn("slow");
					});
				}); 
								
				function fadeOut(){
					johnboy.style.opacity = 1;
					var amount = parseFloat(johnboy.style.opacity);
					setInterval(function() {
						if (amount >= 0){
							amount -= 0.01;
							johnboy.style.opacity = amount;
							console.log(amount);
						}
					}, 20);
					johnboy.style.opacity = 0;				
				};
				
				function fadeIn(){
					johnboy.style.opacity = 0;
					var amount = parseFloat(johnboy.style.opacity);
					setInterval(function() {
						if (amount <= 1){
							amount += 0.01;
							johnboy.style.opacity = amount;
							}
						}, 20)
					johnboy.style.opacity = 1;
				};
		
		$(document).ready(function(){
			$('.editbox').click(function() {
				$('#planner').fadeOut('2000', function(){
					$('#edit').fadeIn('2000');
				});
			});
		});

		$(document).ready(function(){
			$('.returnbox').click(function() {
			$('#edit').fadeOut('2000', function(){
				$('#planner').fadeIn('2000');
				});
			});
		});


	
		$(document).ready(function(){
			$('#send').click(function() {
				//alert("hello");
				postdate = $('#date').val();
				message = $('#message').val();
				password = $('#password').val();
				
				if (postdate != null){	
					$.ajax ({
						url : "http://www.intstix.co.uk/index.php/planner/display",
						type : 'POST',
						data : {
							date : postdate,
							content : message,
							password : password
						},
						success: function(msg){
							$('#edit').fadeOut('2000', function(){
								$('#box').fadeIn('2000');
								location.reload();
							});
						}
					});
				}
			});
		}); 
				
						

			

