function filter(c){
	$("#flags img").each(function(){
		$(this).css("border-bottom","3px solid #fff");
		});
	$("#flag_"+c).css("border-bottom","3px solid #233FBF");
	
	$("#search_results div").each(function(){
		$(this).css("display","none");
	});
	
	$("#search_results div.country_"+c).each(function(){
		$(this).css("display","");
	});
}


function _plus(s){
  return s.replace(' ',"+");
}

function change_deg(){
  s = _gel('deg_format').innerHTML;
  s = _send(URL_PATH + 'set?name=deg&val='+s);
  //document.location = './';
  window.location.reload();
}

function change_location(){
  b = _gel('location_box');
  s = b.options[b.selectedIndex].value;
  if (s=='logout')
    location.href = URL_PATH + '?search=true';
  else {
    /*d = parseInt(s);
    _a('./' + s);
    if (d < 10000) d = '0' + d;
    _a('./' + d);
    */
    location.href = URL_PATH + s;
  }
}

function _cap(a){
  return a.charAt(0).toUpperCase() + a.substr(1).toLowerCase();
}
function _up(a){
  return a.toUpperCase();
}

$.fn.ToolTip = function(bgcolour, fgcolour)
{
	this.mouseover(
		function(e)
		{
			if((!this.title && !this.alt) && !this.tooltipset) return;
			// get mouse coordinates
			// based on code from http://www.quirksmode.org/js/events_properties.html
			var mouseX = e.pageX || (e.clientX ? e.clientX + document.body.scrollLeft : 0);
			var mouseY = e.pageY || (e.clientY ? e.clientY + document.body.scrollTop : 0);
			//mouseX += 10;
			mouseY += 10;
			bgcolour = bgcolour || "#eee";
			fgcolour = fgcolour || "#000";
			// if there is no div containing the tooltip
			if(!this.tooltipdiv)
			{
				var shtml = (this.title || this.alt);
				shtml = shtml.replace(/\./,'.<br>');
				// create a div and style it
				var div = document.createElement("div");
				this.tooltipdiv = div;
				$(div).css(
				{
					border: "2px outset #ddd",
					padding: "2px",
					backgroundColor: bgcolour,
					color: fgcolour,
					position: "absolute"
				})
				// add the title/alt attribute to it
				.html(shtml);
				//.html((this.title || this.alt));
				$(div).css("z-index","4");
				this.title = "";
				this.alt = "";
				$("body").append(div);
				this.tooltipset = true;
			}
			$(this.tooltipdiv).show().css({left: mouseX + "px", top: mouseY + 3 + "px"});
		}
	).mouseout(
		function()
		{
			if(this.tooltipdiv)
			{
				$(this.tooltipdiv).hide();
			}
		}
	);
	return this;
}