	$(document).ready(function(){

  // $("#container").css("opacity","0.95");

 $(".location").autocomplete('/calendar/-find-location.php');
 $(".postcode").autocomplete('/calendar/-find-postcode.php');
 

// ============== start calendar
				$('#datepicker').datepicker({
					inline: false,
					minDate: 0,
					firstDay: 1,
					dateFormat: 'yy-mm-dd',
					onSelect: function(x, y){
					    $("#content").html('<img src="/calendar/i/ajax-loader.gif" alt="loading" />');
              $.get("/calendar/-list.php", { q: x},
                function(data){
                  $("#content").html(data)
                  $("#accordion").accordion('destroy').accordion({
                      autoHeight: false,
                      active: false
                  });
                });
                $("#upcoming").remove('');
                
          },
          numberOfMonths: 1
				});

      var prompt = "enter event name or venue";
      $(".search-field").val(prompt);
      
      $(".search-field").focus(function(){
          $(this).val('');

      });
      
         
		  $(".search-field").blur(function(){
	       if($(this).val()=='')
	       {
	          $(this).val(prompt);
	       }
	    });

			$(function() {
    		$("#accordion").accordion({
            autoHeight: false,
            active: false

        });
    	});
      
      
      
      $(".ibutton").hover(
      function () {
        var id = $(this).attr("id");
        $(this).attr("src", "/calendar/i/"+id+"2.png");
      }, 
      function () {
        var id = $(this).attr("id");
        $(this).attr("src", "/calendar/i/"+id+".png");
      });
      
  $(".remove").click(function(){
      return confirm("Are you sure?");
  });    
   
  $("#form").submit(function(){
      $("#form input[name='spam']").val("2");
	});
   
  $(".delete").click(function(){
      return confirm('Are you sure you want to permanently delete this item?');
  });         
         
          if ($.browser.msie) {
                      this.element.find('a').css('zoom', '1');
                     $('#accordion div').css('zoom', '1');
                } 

        
        $(".recurring-content").hide();
        
       
        $(".recurring").click(function(){
            $(".recurring-content").slideToggle();
            
            $(".multiday").toggle();
            $("#multiday").val(1);
            
        });
        
  
  
   $("#occurrences").keypress(function (e){
     if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)){
        return false;
      }
    });
    
    
    $("#occurrences").keyup(function(e){
       var v = $(this).val();
       if(v>52){
          alert('You can submit up to 52 occurrences');
          $("#occurrences").val('');
       }
        
    })
    
});

