jQuery(document).ready(function(){ 	

	var currentSelectionId = 0;

	jQuery("#editicon a img").click(function() {
			
			currentSelectionId = this.id;
			var currentLanguage = document.getElementById("currentLanguage").value;
			var currentCountry = document.getElementById("currentCountry").value;
			
		
			jQuery.ajax({  
				type: "POST",  
				url: "queryshops.jsp",  
				data: { currentVal: this.id, action: "queryshops", currentLanguage: currentLanguage, currentCountry: currentCountry},  
				success: function(theResponse) {
					
					jQuery("#cart_block").before(theResponse);
					
				}  // end function(theResponse) 
			}); //end ajax call
			
			});//end function
	
	jQuery("#closeshopselector").live("click", function(event) {
		jQuery("#shopslistcontainer").remove();
	});
	
	jQuery("#shopslist").live("click", function(event) {
			
		var selectedShopId = this.value;
		
		
		jQuery.ajax({  
			type: "POST",  
			url: "selectShopFromShopSelector.jsp",  
			data: { selShopId: selectedShopId},  
			success: function(theResponse) {
				
				var selShopId = theResponse.trim().substring(0,3);
				var userShopDiv = theResponse.trim().substring(3);
				
				document.getElementById(currentSelectionId).id = selShopId;
				
				jQuery("#usershop").hide();
				jQuery("#editicon").after(userShopDiv);
				jQuery("#shopslistcontainer").remove();
				
				location.reload(true);
			
			}  
		});  
	});
	
	
	
}); //end document ready function
