var p1 = new Object();

$(document).ready(function(){

  $('.facebox-submit').submit(function(){
    //alert(123);
  });

  $('.category-remove-button').live('click', function(){
    $(this).parent('.category-holder').remove();
    return false;
  });

  $('.add-another-category-button').live('click', function(){
    holder_html = $(this).prev('.category-holder').clone();
    $(this).prev('.category-holder').after(holder_html);
    return false;
  });

  $('.cpv-code-remove-button').live('click', function(){
    $(this).parent('.cpv-code-holder').remove();
    return false;
  });

  $('.add-another-cpv-code-button').live('click', function(){
    holder_html = $(this).prev('.cpv-code-holder').clone();
    $(this).prev('.cpv-code-holder').after(holder_html);
    return false;
  });



  // If clicked, move up!
  /*
  $('.portal_checkbox').click(function(){
    $('.portal_checkbox input:checked').parents('.portal_checkbox').each(function(){
      $(this).appendTo('#selected_portals');
    });
    $('.portal_checkbox input[type=checkbox]').not(':checked').parents('.portal_checkbox').each(function(){
      $(this).appendTo('#not_selected_portals');
      $(this).hide();
    });
  });

  // Initially hide them all
  $('.portal_checkbox input[type=checkbox]').not(':checked').each(function(){
    $(this).parents('.portal_checkbox').hide();
  });

  // Bring back if term is right
  $('#portal_filter').keydown(function()
  {
    $('#not_selected_portals .portal_checkbox input').each(function(){

      checkbox = $(this).parents('div');

      str = $(this).attr('name').toLowerCase();

      if(str.indexOf($('#portal_filter').val().toLowerCase()) >= 0)
      {
        //alert(str);
        checkbox.show();
      }
      else
      {
        //checkbox.hide();
      }
    });
  });
  */

});

function setTimer()
{
  /*
  setTimeout(function(){
    alert('test');
    setTimer;
  }, 100);
  */
}

function recalc2points(lat1, lon1, lat2, lon2) {
  var p1 = new LatLon(Geo.parseDMS(lat1), Geo.parseDMS(lon1));
  var p2 = new LatLon(Geo.parseDMS(lat2), Geo.parseDMS(lon2));
  return p1.distanceTo(p2);
}

function roundNumber(num, dec) {
  if(!dec)
  {
    dec = 2;
  }
  var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
  return result;
}

