$(document).ready(function () {
	var default_text = "Search";
	if ($('#searchbox').val() === ""){
		$('#searchbox').val(default_text);
	}
	$('#searchbox').focus(function(){
		if ($(this).val() === default_text){
			$(this).val("");
		}
	});
	$('#searchbox').blur(function(){
		if ($(this).val() === ""){
			$(this).val(default_text);
		}
	});
	
	var store_search_default_text = "Search in Category";
	if ($('#store-search-box').val() === ""){
		$('#store-search-box').val(store_search_default_text);
	}
	$('#store-search-box').focus(function(){
		if ($(this).val() === store_search_default_text){
			$(this).val("");
		}
	});
	$('#store-search-box').blur(function(){
		if ($(this).val() === ""){
			$(this).val(store_search_default_text);
		}
	});
	
	$("input").focus(function() {
		$(this).addClass("form-field-focus")
	});
	$("input").blur(function() {
		$(this).removeClass("form-field-focus")
	});
	/*$("select").focus(function() {
		$(this).addClass("form-field-focus")
	});
	$("select").blur(function() {
		$(this).removeClass("form-field-focus")
	});*/
	$("textarea").focus(function() {
		$(this).addClass("form-field-focus")
	});
	$("textarea").blur(function() {
		$(this).removeClass("form-field-focus")
	});
});

function strip_whitespace(value){
	return value.replace(/^\s*|\s*$/g,'');
}

function url_encode( s ){
   return encodeURIComponent( s ).replace( /\%20/g, '+' ).replace( /!/g, '%21' ).replace( /'/g, '%27' ).replace( /\(/g, '%28' ).replace( /\)/g, '%29' ).replace( /\*/g, '%2A' ).replace( /\~/g, '%7E' );
}

function url_decode( s ){
   return decodeURIComponent( s.replace( /\+/g, '%20' ).replace( /\%21/g, '!' ).replace( /\%27/g, "'" ).replace( /\%28/g, '(' ).replace( /\%29/g, ')' ).replace( /\%2A/g, '*' ).replace( /\%7E/g, '~' ) );
}

function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}

function disable_fields(id){
	$('#'+id+' input').attr("disabled","disabled");
  $('#'+id+' select').attr("disabled","disabled");
}
function enable_fields(id){
	$('#'+id+' input').removeAttr("disabled");
  $('#'+id+' select').removeAttr("disabled");
}

function display_interactive_map(query){
	var map_url = '/interactive-map-display';
	if (query){
		map_url += '?'+query;
	}
    Shadowbox.open({
        player:     'iframe',
        content:    map_url,
        width:     860,
        height:      480,
        options:	{
    		viewportPadding: 10,
    		modal: true,
        	fadeDuration: 0.10,
        	resizeDuration: 0.10
        }
    });
    return false;
}


