submitForm = function()
{
	var q 			= ($('#left_form input#q').length) ? $('#left_form input#q').val() : '';
	var media 	= ($('#left_form select#media').length) ? $('#left_form select#media').val() : 'x';
	var areas 	= ($('#left_form select#areas').length) ? $('#left_form select#areas').val() : 'x';
	var search_lang = ($("#left_form input[@name='search_lang']:checked").length) ? $("#left_form input[@name='search_lang']:checked").val() : '';
	
	var date_filter = ($('select#date_filter').length) ? $('select#date_filter').val() : '';
	
	if ($('div#search_results').length) // lets go ajax...
	{
		hashQs = 'q=' + q + '&areas=' + areas + '&media=' + media + '&search_lang=' + search_lang + '&date_filter=' + date_filter;
		
		window.location = location.pathname + location.search + '#' + hashQs;
		
		//$('div#search_results').load('index.php?module=search&action=searchajax&q=' + escape(q) + '&media=' + media + '&areas=' + areas + '&search_lang=' + search_lang + '&date_filter=' + date_filter);
	} else // lets go round the old way...
	{
		// change this if URL formats change i.e. index/[module]/[action]/[var1]/[val1]/[var2]/[val2]/ etc etc
		window.location='index.php?module=search&action=index&q=' + q + '&media=' + media + '&areas=' + areas + '&search_lang=' + search_lang + '&date_filter=' + date_filter;
	}
}

$(function(){
    $('input#q').keydown(function(e)
    {
        if (e.keyCode == 13)
         {
            submitForm();
            return false;
        }
    });
});

var rateMedia = function(id, polarity, key)
{
var button=$('#rate-button');
	$.ajax({
		method: "get",url: "index.php?module=index&action=ratemedia",data: "media_id="+id+"&polarity="+polarity,
		beforeSend: function(){ $('#rate-button').attr("src", 'img/was-this-useful-faded.png');  }, 
		complete: function() { /* $("#loading").hide("fast"); */ }, //stop showing loading when the process is complete
		success: function(html){ $('#rate-button').attr("src", 'img/was-this-useful-rated.png');  $('#rate-button').attr("usemap", '#null');  }
	}); //close $.ajax(
}