// Maps functions
function ShowOnMap(link)
{
  $('#google_map').html("<iframe src='" + link + "' width='500' height='320' scrolling='no'>Sorry, your browser does not support iframes. <a href='" + link + "' target='_blank'>Click here</a> to open the map.</iframe>");
  $('#google_map').show();
  $('#show_link').hide();
}

function ClearLocation()
{
  $('#classified_lat').value = '';
  $('#classified_lng').value = '';
  $('#google_map').html("");
  $('#google_map').hide();
  $('#show_link').show();
  $('#location_status').html("Not set");
  $('#clear_link').hide();
}

// Autocomplete loader
jQuery(function($){//on document ready
  //autocomplete
  $('input.autocomplete').each(function(){
    var input = $(this);
    input.autocomplete(input.attr('autocomplete_url'),{
      matchContains:1,//also match inside of strings when caching
      // mustMatch:1,//allow only values from the list
      // selectFirst:1,//select the first item on tab/enter
      removeInitialValue:0//when first applying $.autocomplete
    });
  });
});

// Default value for text boxes
/**
* Written by Rob Schmitt, The Web Developer's Blog
* http://webdeveloper.beforeseven.com/
*/

/**
* The following variables may be adjusted
*/
var active_color = '#000'; // Colour of user provided text
var inactive_color = '#ccc'; // Colour of default text

/**
* No need to modify anything below this line
*/

$(document).ready(function() {
  $("input.default-value").css("color", inactive_color);
  var default_values = new Array();
  $("input.default-value").focus(function() {
    if (!default_values[this.id]) {
      default_values[this.id] = this.value;
    }
    if (this.value == default_values[this.id]) {
      this.value = '';
      this.style.color = active_color;
    }
    $(this).blur(function() {
      if (this.value == '') {
        this.style.color = inactive_color;
        this.value = default_values[this.id];
      }
    });
  });
});
