var defaultLocation = 'e.g. Chicago, IL or 90210';

$(document).ready(function() {
    $('#szLocation').focus(function() {
        if($(this).val() == defaultLocation) {
            $(this).removeClass('example');
            $(this).val('');
        }
    });

    $('#szLocation').blur(function() {
        if($(this).val() == '') {
            $(this).addClass('example');
            $(this).val(defaultLocation);
        }
    });

    $('#proAdSearchLandingForm').submit(function() {
        loc = $('#szLocation').val().replace(/^\s+/, '');
        if(loc == '' || loc == defaultLocation || typeof($('input[name=iProAdProfessionID]:checked').val())  == 'undefined') {
            $('#errorWrap').show();
            return false;
        }
    });

    if(typeof(proAdIDs) != 'undefined' && proAdIDs != '') {
        $.ajax({
            url: '/proAd/proAdHits.php',
            type: 'POST',
            data: 'page=search&type=impression&proAdIDs='+proAdIDs,
            dataType: 'html',
            success: function() {
            },
            error: function(data, textStatus) {
            }
        });
    }

    $('a.proAdExtLink').click(function() {
        var proAdID = $(this).attr('rel');
        $.ajax({
            url: '/proAd/proAdHits.php',
            type: 'POST',
            data: 'page=search&type=urlclick&proAdIDs='+proAdID,
            dataType: 'html',
            success: function() {
                return true;
            },
            error: function(data, textStatus) {
                return true;
            }
        });
        return false;
    });
});
