
function nayta(osoite, divi, nimi)
{
	if(divi == undefined)
		var divi = "map";
	if (GBrowserIsCompatible()) 
	{
		var geocoder = new GClientGeocoder();
		geocoder.setBaseCountryCode("fi");
		//geocoder.getLatLng("keskustie 11 alavieska", function(point) { 
		geocoder.getLatLng(osoite, function(point) 
		{ 
			if(!point){alert("Osoitetta ei löydy")}
			else
			{
				document.getElementById(divi).style.display = "block";
				var map = new GMap2(document.getElementById(divi));
				map.addControl(new GSmallMapControl());
				//map.addControl(new GMapTypeControl());

				map.setCenter(point, 13);
				var marker = new GMarker(point);
				map.addOverlay(marker);
				marker.openInfoWindowHtml(nimi+"<br />"+osoite);
			}
		})
	}
}
/*function goTo(to,lah)
{
	location.href = "?m=2&shop="+to+"&t="+lah;
	
}*/

function checkEnterAndGoto(e,to,lah,textid)
{ //e is event object passed from function invocation
	var characterCode //literal character code will be stored in this variable

	if(e && e.which)
	{ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}
	else
	{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}

	if(characterCode == 13)
	{ //if generated character code is equal to ascii 13 (if enter key)
		if(document.getElementById(textid).value == "")
			return false;
		goTo(to,lah);
		return false
	}
	else
		return true
}



// autocompletioinniin
function showHint(str)
{
	if (str.length==0)
	{ 
	  document.getElementById("txtHint").innerHTML="";
	  return;
	}
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	var url="showhint.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
	}
}

function aseta(value)
{
document.cookie="omakauppa="+value
}
