// JavaScript Document
$(document).ready(function () {
   	$(".promo_body li:last-child").addClass('last-child');
	$(".signin").click(function(e) {
		e.preventDefault();
		$("fieldset#signin_menu").toggle();
        $('#login-username').focus();
        $('#login-username').select();
		$(".signin").toggleClass("menu-open");
	});
	
	$('div.results_list').find('div.result_item').hover(function () {
		//$(this).css('border', '1px solid #edeff4');
	}, function () {
		//$(this).css('border', 'none');	
	});
	
	$("fieldset#signin_menu").mouseup(function() {
		return false
	});
	$(document).mouseup(function(e) {
		if($(e.target).parent("a.signin").length==0) {
			$(".signin").removeClass("menu-open");
			$("fieldset#signin_menu").hide();
		}
	});

    //On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).show(); //Fade in the active ID content
		return false;
	});

    var reallyLoadMap = false;
	$('div.viewMapLink a').click(function() {
        $list_business_id = $('#list_business_id').val();
        if($list_business_id != ""){
            if(reallyLoadMap == false){
                $('#search_map_iframe').attr('src', '/ajax/multi-map?ids=' + $list_business_id);
                reallyLoadMap = true;
            }
            $('#mapBox').slideToggle('normal');
            return false;
        }

	});
	$('.closeMap').click(function() {
		$('#mapBox').slideUp('normal', function() {
			$(this).hide();
		});
	});

    $('.share_fb_link').popupWindow({
        height:500,
        width:600
    });
    
    $("#city_id").change(function() {
        var city_id = $('#city_id').val();        
        if (city_id > 0){
            $.post("/ajax/get-districts/?city_id=" + city_id, function(data){            	
            	$('#district_id').html(data);
            	Custom.init();
            });
        } else {
            $('#district_id').html('');
            Custom.init();
        }
     });
    

     //Cuong insert
     $(".viewall").click(function(){
        var elements = $('.viewall');
        var div = $(this).attr('href');
        elements.each(function() {
            var eachDiv = $(this).attr('href');
            if(eachDiv != div){
                $(eachDiv).slideUp('normal');
            }
        });

		$(div).slideToggle('normal');
		return false;
	});
    $('.alldrops, .result_cont').find('a.close').click(function() {
		$(this).parent().parent().slideToggle('normal');
                return false;
	});

    $(".badgesCont").hide();
	$("ul.badgeTab li:first").addClass("active").show();
	$(".badgesCont:first").show();

	$("ul.badgeTab li").click(function() {
		$("ul.badgeTab li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".badgesCont").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).show(); //Fade in the active ID content
		return false;
	});

//	$(".tooltip").tipTip();

//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).show(); //Fade in the active ID content
		return false;
	});
    //End cuong insert
})



