    $(document).click(function(){
	$('#search_suggestions, #location_suggestions').fadeOut('fast');
    });
    
    $(document).ready(function(){
        $('#phone_number').focus(function () {
            $("#search-box, #location-box").attr("disabled", "disabled").val('');
        });
        
        $('#phone_number').blur(function () {
            if($("#phone_number").val() == "") {    
                $("#search-box, #location-box").removeAttr("disabled");
            }
        });
        
        $('#search-box, #location-box').focus(function () {
            $("#phone_number").attr("disabled", "disabled");
        });
        
        $('#search-box, #location-box').blur(function () {
            $("#phone_number").removeAttr("disabled").val('');
        });
    });
        
    $(document).ready(function () {
	$('#basic').click(function (e) {
		e.preventDefault();
		$('#basic-modal-content').modal();
	});
    });
    
    $(document).ready(function () {
	$('#discount').click(function() {
	    window.location= "http://jewishyellow.com/consumer.html";
	    return false;
	});
    });
    
    // client page tabs //
    
    $(document).ready(function(){
	$('.tab').click(function () {
	    $('.tabs > li.active').removeClass('active');
	    $(this).parent().addClass('active');
	    $('div.tab_contents_container > div.tab_contents_active').removeClass('tab_contents_active');
	    $(this.rel).addClass('tab_contents_active');
	});
    });
    
    $(document).ready(function(){
         var hashAnchor = self.document.location.hash.substring(1);
         //alert(fileurl);
         if(hashAnchor == "view_ad") {
             $("a[rel^='#tab_2_contents']").trigger('click');
         }
         if(hashAnchor == "view_coupon") {
             $("a[rel^='#tab_3_contents']").trigger('click');
         }
    });
    
    // makes jewish referral banner linkable //
    
    $("#jewish_referral").click(function(){
        window.location=$(this).find("a").attr("href");
        return false;
    });
    
    // makes jwiz banner linkable //
    
    $("#jwiz").click(function(){
        window.location=$(this).find("a").attr("href");
        return false;
    });
    
    
    // search suggestions //
    
    $('document').ready(function() {
        
        // Search term suggestions
        $('#search-box')
            .bind('keyup', function() {
                var inputString = $(this).val();
                if(inputString.length == 0) {
                    $('#search_suggestions').fadeOut('fast').slideUp('fast');
                } else {
                    $.post("/ajax/search_terms_suggest", {search_terms: ""+inputString+""},
                    function(data){
                        if(data.length > 0) {
                            $('#search_suggestions').fadeIn('fast').slideDown('fast');
                            $('#search_suggestions_list').html(data);
                        }
                    });
                } 
             })
            
             .bind('blur', function() {
                $('#search_suggestions_list li').click(function() {
                    var selectedString = $(this).text();
                    $('#search-box').val(selectedString);
                    setTimeout("$('#search_suggestions').fadeOut('fast');", 200);
                })
             })
             
        // Location Suggestions     
        $('#location-box')
            .bind('keyup', function() {
                var inputString = $(this).val();
                if(inputString.length == 0) {
                    $('#location_suggestions').fadeOut('fast').slideUp('fast');
                } else {
                    $.post("/ajax/search_location_suggest", {search_location: ""+inputString+""},
                    function(data){
                        if(data.length > 0) {
                            $('#location_suggestions').fadeIn('fast').slideDown('fast');
                            $('#location_suggestions_list').html(data);
                        }
                    });
                } 
             })
            
             .bind('blur', function() {
                $('#location_suggestions_list li').click(function() {
                    var selectedString = $(this).text();
                    $('#location-box').val(selectedString);
                    setTimeout("$('#location_suggestions').fadeOut('fast');", 200);
                })
             })
             
    });
