//file: ziptocity.js   Version 1.2, 16/08/2004  by Thorsten Sprenger

var outputfield;
var zipcode;

function ziptocity(inputfield_zip, inputfield_city, inputfield_country)
{
  try 
  {
    outputfield = getElementById(inputfield_city);
    if(inputfield_country) 
		  //country = getElementById(inputfield_country).value;
		  country = getElementById(inputfield_country).options[getElementById(inputfield_country).selectedIndex].value
	  else
		  country = "DE";
		
		
    zipcode = getElementById(inputfield_zip).value;
    // trim out spaces
    while (zipcode.indexOf(' ') != -1) 
    {
      var i = zipcode.indexOf(' ');
      zipcode = zipcode.substring(0,i) + zipcode.substring(i+1);
    }
    var a = zipcode.substring(0,1);
    var b = zipcode.substring(0,3);
    var rootPath = ziptocityframe.location.href.substring(0,ziptocityframe.location.href.indexOf('ziptocity/'));
    var path = rootPath + 'ziptocity/'+country+"/"+a+"/"+b+".html";
    ziptocityframe.location.href = path;    
  }catch(e) {}
}

function getElementById(id)
{
	var element = document.getElementById && document.getElementById(id) || document.all && document.all(id);
	return element;
}

