function popup(f, w, h, n)
{
	if (!n) n = '';
    //n += 'search';
	winPopImg = window.open(f, n, 'toolbar=no,location=no,status=no,menubar=no,resizable=yes,scrollbars=yes,copyhistory=no,width=' + w + ',height=' + h);
    winPopImg.focus();
}

function setPopup(project, type, w, h) {
  var f = project + '/search/index.php?project=' + project + '&searchname=' + type; 
  newWindow = window.open(f, 'popup', "toolbar=no,location=no, status=no,menubar=no,resizable=yes,scrollbars=yes,copyhistory=no,width=" + w + ",height=" + h);
  newWindow.focus();
}

function setSearchFrame(project, type) { 
  var ifr = document.getElementById('search');
  ifr.style.height = '350px';
  ifr.src = project + '/search/index.php?project=' + project + '&searchname=' + type; 
}
function resetSession() {
    elm = xGetElementById('fake_reset');
    elm.name = 'reset_session';
    elm.value = 'reset_session';
    document.carto_form.posted.value=0;
    addMapsizeToCookie();
    FormItemSelected();
}
function changeImages() {
  if (document.images) {       
    for (var i = 0; i < changeImages.arguments.length; i +=2) {       
      document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
    }       
  }       
}
function winopen(link, name, width, height)
{
  winPopImg = window.open(link,name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=1,resizable=1,width='+ width + ',height=' + height);

}

function addMapsizeToCookie() {
  var currentMapsize = xGetElementById('mapsize').value;
  document.cookie = 'currentMapsize='+currentMapsize+'; expires=; path=/';
}

function recenterXY() {
    $('recenter_doit').value = 1;
    if ($('recenter_scale').value == 0) {
      $('recenter_scale').value = 10000;
    }
    $('show_crosshair').value = 'on';

    CartoWeb.trigger('Location.Recenter');

    $('recenter_x').value = '';
    $('recenter_y').value = '';

    return false;
}