
$(document).ready(function(){
	  loadAjax('/donations/storeDropdown', 'storeAjax');
  
});

var storeStateValue;
var storeCityValue;
var storeAddressValue;

function pauseScripts(millis){
  var date = new Date();
  var curDate = null;
  do { curDate = new Date(); }
  while(curDate-date < millis);
} 

function doAjaxPost_stateDrop(selector, thisState){
  var thisCity = null;
  var thisUrl = null;
  if (!thisState) {
    thisState = $('#DonationStoreState').val();
  }
  if(selector == 'city'){
    thisCity = $('#DonationStoreCity').val();;
    thisUrl="/donations/storeDropdown/"+thisState+"/"+ thisCity;
  }
  else{    
    thisUrl="/donations/storeDropdown/"+thisState;
  }
  $.ajax({
    type: "POST",
		url: thisUrl,
		data: "post=true",
		success: function(resp){
		  // we have the response
      $('#storeAjax').html(resp);
      $('#DonationStoreState').val(thisState);
      if(thisCity){
        $('#DonationStoreCity').val(thisCity);
      }
		},
		error: function(e){
		  alert('Error: ' + e);
		}
  });
}


function loadAjax(thisUrl, divID){
	$.ajax({  
    url: thisUrl,  
    success: function(resp){  
      // we have the response  
      $('#'+divID).html(resp);
      
    },  
    error: function(e){  
      alert('Error: ' + e);  
    }  
  });
} 



