    //<![CDATA[
	var map;
	var icon;
	var to_htmls = [];
	var from_htmls = [];
	var marker = new Array();
	
	// Function to submit the form throught the enter key in IE
	$(function(){
	    $('input').keydown(function(e){
	        if (e.keyCode == 13) {
	            $(this).parents('form').submit();
	            return false;
	        }
	    });
	});
	
	//Start JQuery call
	jQuery(document).ready(function($){
	
	//Set some vars
	var text_what = "project manager, business analyst, ...";
	var text_where = "new york, US";

	   //Setup the input text form
	   $('#box-what').val(text_what);
	   $('#box-where').val(text_where);

	   $('#box-what').focus(function() {
		this.value = "";
		$('#box-what').addClass("box-click");
		});
	   $('#box-where').focus(function() {
		this.value = "";
		$('#box-where').addClass("box-click");
		});

	//Submit the form
	$('#theform').submit(function() { 
		var q = $('#box-what').attr('value');
		var l = $('#box-where').attr('value');
		if (q == text_what) { $('#box-what').val(''); var q = ""; }
		if (l == text_where) { $('#box-where').val(''); var l = ""; }
		if (q == "" && l == "") {
			return false;
		} else {
		TheSearch(q, l);
		return false;
		}
	});

	$('#tweetme').click(function() {
		window.location.href="http://twitter.com/home?status=New+job+finder+mashup+at+http%3A%2F%2Fwww.elaboratorium.com%2F+%23mashup+%23app+%23jobs";
	});

	$('.link-about').click(function() { 
		$('.link-about').addClass('about');
		$('#about').slideDown(1000);
	});

	$('.close-about').click(function() { 
		$('#about').slideUp(500);
		$('.link-about').removeClass('about');
	});
  });

  //
  //Here start the main functions
  //
	function TheSearch(q, l, s) {
  	jQuery(document).ready(function($){
		$.ajax({
		url: "submit.php?a=addTabs&q=" + q + "&l=" + l + "&s=" + s,
		async: true,
		success: function(data){
		if (data != "error!") {
			search_jobs(q, l, s);
			$('#results').fadeIn('slow');
			$('#searches_list').append(data);
			$('#boxsearches').fadeIn('slow');
		} else {
			search_jobs(q, l, s);
		}
			}
		})
		return false;
	});
	} 

	//Search in the APIs
	function search_jobs(q, l, s) {
  	jQuery(document).ready(function($){
		$.ajax({
		url: "submit.php?a=search&q=" + q + "&l=" + l + "&s=" + s,
		async: true,
		beforeSend: function(){
			$('html').scrollTo(0, 300);
			$('#dialogloading').fadeIn(1000);
			$('#loading').toggle();
		},
		success: function(jobs){
			$('#results').html(jobs);
			$('#dialogloading').fadeOut(1000);
			$('#loading').toggle();
			}
		});
	});
	}

	//Add the job into the session
	function add_id(id, jobtitle, jobcompany, joblocation, joburl) {
  	jQuery(document).ready(function($){
		$.ajax({
		url: "submit.php?a=addto&id=" + id + "&jobtitle=" + jobtitle + "&jobcompany=" + jobcompany + "&joblocation=" + joblocation + "&joburl=" + joburl,
		async: true,
		success: function(html){
			$('#boxjobs').fadeIn('slow');
			$('#boxjobs>ul').append(html);
			$('#box-' + id).fadeIn('slow');
			}
		});
	});
	}
	
	//Remove the job from the session
	function removeFrom(id) {
  	jQuery(document).ready(function($){
		$.ajax({
		url: "submit.php?a=removeFrom&id=" + id,
		async: true,
		success: function(html){
			$('#box-' + id).remove();
			}
		});
	});
	}

	//Remove the job from the session
	function removeSearch(id) {
  	jQuery(document).ready(function($){
		$.ajax({
		url: "submit.php?a=removeSearch&id=" + id,
		async: true,
		success: function(html){
			$('#tab-' + id).remove();
			}
		});
	});
	}

	//Ad a Marker into the map
	function createMarker(x, y, id, title, location, iconid, jurl) {
		var icon = new GIcon();
		icon.image = 'images/icon/' + iconid + '.png';
		icon.shadow = 'images/icon/shadow.png';
		icon.iconSize = new GSize(20.0, 34.0);
		icon.shadowSize = new GSize(38.0, 34.0);
		icon.iconAnchor = new GPoint(10.0, 17.0);
		icon.infoWindowAnchor = new GPoint(10.0, 17.0);

		var point = new GLatLng(x,y);
		marker[id] = new GMarker(point, {title: title, icon:icon});
		map.addOverlay(marker[id]);
		//Open the infobubble
		addInfoMarker(x, y, id, title, location, jurl)
		//Add the infobubble click event
		GEvent.addListener(marker[id], 'click', function() {
		  addInfoMarker(x, y, id, title, location, jurl)
		});
	}

  function addInfoMarker(x, y, id, title, location, jurl) {
	var title = urldecode(title);
	var location = urldecode(location);
        // The info window version with the "to here" form open
        to_htmls[id] = '<span class="dir">Directions: <b>To here</b> - <a href="javascript:fromhere(\'' + id + '\')">From here</a>' +
           '<br>Start address:<form action="http://maps.google.com/maps" method="get" target="_blank">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br>' +
           '<INPUT value="Get Directions" TYPE="SUBMIT">' +
           '<input type="hidden" name="daddr" value="' + x + ',' + y +
                  // "(" + name + ")" + 
           '"/></span>';
        // The info window version with the "to here" form open
        from_htmls[id] = '<span class="dir">Directions: <a href="javascript:tohere(\'' + id + '\')">To here</a> - <b>From here</b>' +
           '<br>End address:<form action="http://maps.google.com/maps" method="get"" target="_blank">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="daddr" id="daddr" value="" /><br>' +
           '<INPUT value="Get Directions" TYPE="SUBMIT">' +
           '<input type="hidden" name="saddr" value="' + x + ',' + y +
                  // "(" + name + ")" + 
           '"/></span>';
        // The inactive version of the direction info
        html = '<br />Directions: <a href="javascript:tohere(\'' + id + '\')">To here</a> - <a href="javascript:fromhere(\'' + id + '\')">From here</a>';

      marker[id].openInfoWindowHtml('<div style="white-space:nowrap"><div class="bubbletxt"><span><strong><a href="' + jurl + '" target="_BLANK">' + title + '</a></strong></span><br /><span>Location: ' + location + '</span><div class="zoom">Zoom: <a href="javascript:zoomIt(\'' + x + '\', \'' + y + '\', \'in\')">In</a> - <a href="javascript:zoomIt(\'' + x + '\', \'' + y + '\', \'out\')">Out</a>' + html + '</div></div></div>');
		  map.panTo(new GLatLng(x,y),3);
  }

  // functions that open the directions forms
  function tohere(i) {
     marker[i].openInfoWindowHtml(to_htmls[i]);
  }
  function fromhere(i) {
     marker[i].openInfoWindowHtml(from_htmls[i]);
  }
  function zoomIt(x, y, type) {
      if (type == "in") { level = 15 } else { level = 3 }
      map.setCenter(new GLatLng(x, y),level);
  }

function urldecode( str ) {
    var histogram = {};
    var ret = str.toString();
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urlencode.
    histogram["'"]   = '%27';
    histogram['(']   = '%28';
    histogram[')']   = '%29';
    histogram['*']   = '%2A';
    histogram['~']   = '%7E';
    histogram['!']   = '%21';
    histogram['%20'] = '+';
 
    for (replace in histogram) {
        search = histogram[replace]; // Switch order when decoding
        ret = replacer(search, replace, ret) // Custom replace. No regexing   
    }
    
    // End with decodeURIComponent, which most resembles PHP's encoding functions
    ret = decodeURIComponent(ret);
 
    return ret;
}

    //]]>
