var storeUrl;

$(document).ready(function() {
        $("#select_prov>dt>a").click(function() {
            $("#select_prov>dd>ul").toggle("normal");
						return false;
        });
            
            $("#select_prov dd ul a").click(function() {
            	    	//alert("a");
                var text = $(this).html();
                $("#select_prov dt a span").html(text);
                
                var province=$(".value").html();
                
                storeUrl = "/stores/store?city_id="+province;
                              
                $.get("/stores/get_store_info.php?province_id="+province,null,
                
											function(response){
												
												//alert(response);
												
										$("#store").html(response);

										
										$("#searchStores a").attr("href",storeUrl);							
									 
								});            
                
                $("#select_prov dd ul").hide();
                
								return false;
            });
                        
            function getSelectedValue(id) {
                return $("#" + id).find("dt a span.value").html();
            }

            $(document).bind('click', function(e) {
                var $clicked = $(e.target);
                if (! $clicked.parents().hasClass("dropdown"))
                $("#select_prov dd ul").hide();
        		});
        		
		return false;
		
});

$(document).ready(function() {
	 
        $("#select_store>dt>a").click(function() {
            $("#select_store>dd>ul").toggle("normal");
						return false;
        });
            
           
            $("#select_store dd ul li a").click(function() {    
            	alert(this);        	
                var text = $(this).html();           
                
                var province=$(".value").html();
                $("#select_store dd ul").hide();
								return false;
            });
                        
            function getSelectedValue(id) {
                return $("#" + id).find("dt a span.value").html();
            }


            $(document).bind('click', function(e) {
            	  
                var $clicked = $(e.target);
                
                if ($clicked.parents("ul:first").attr("id") == "store") {
                	
                	$("#select_store dt a span").html($clicked.html());
                	
                	var storeid = $("#select_store dt a span span").html();
                	
                	$("#searchStores a").attr("href","/stores/store.php?store_id="+storeid);
                	
                	$("#select_store dd ul").hide();
                	
                	return false;
                
              	}
        		});
		
});

/*
$(document).ready(function(){
	
			$(".showanswers input").click(function(){
				
				var answer = $(this).val();
				var answers = $(this).val();
				var surveysid = $("#surveysid").val();
				var questionid = $("#questionid").val();
				
				$.get(
							"/surverys/index.php?answer="+answer,
							{a:0,answer:answer,surveysid:surveysid,questionid:questionid,answers:answers},
							function(responseText){

								$(".showanswers").html(responseText);
								
							},

							"html"
							
						)
			
			});

});
*/
