 $(document).ready(function(){
	
	$("#about").click(function(){
		$("#content").load("about.html");
	});
	
	$("#api").click(function(){
		$("#content").load("api.html");
	});
	
	$("#firefox").click(function(){
		$("#content").load("firefox.html");
	});
	
	$("#bttn").click(function(){
		murl = $("#maskedURL").val();
		
		if (murl.length == 0) {
			$("#result").html('<p>Please insert a valid URL in the textbox!</p>');
			$("#result").fadeIn("slow");
		}
		else {
			res = $.get ("foresee.php", { maskedURL: murl } , function() {
				if (res.readyState == 4) {
					if (res.status == 200) {
						if (res.responseText == 'None')
							$("#result").html('<p>Please insert a valid tinyurl!</p>');
						else
							$("#result").html('<p><label class="bold">Real URL:</label> <a href="'+res.responseText+'>'+res.responseText+'</a></p>');
					}
				}
			});
		}
	});
	
	$("$form:first").submit(function(){
		return false;
	});
	
	//show the loader while fetching data with ajax
	$().ajaxStart(function(){
		$("#result").hide();
		$("#result").html ("<p><img src='img/loading.gif' alt='loading...' /></p>");
		$("#result").fadeIn("slow");
	});
	
	
});