// JavaScript Document
$(document).ready(function() {
    var search_city   = false;
    var search_phrase = false;
    $('#lnk-login').click(function() {
        document.getElementById('lnk-login').className = document.getElementById('lnk-login').className== '' ? 'active' : '';
        document.getElementById('popup-login').style.display = document.getElementById('popup-login').style.display== 'none' ? 'block' : 'none';
        return false;
    });
    $('#search-city').click(function() {
        if (search_city == false) {
            $(this).val('');
            search_city = true;
        }
    });
    $('#search-phrase').click(function() {
        if (search_phrase == false) {
            $(this).val('');
            search_phrase = true;
        }
    });

    /*
    $('#search-phrase-submit').click(function() {
        var phrase = $('#search-phrase').val();
        $('#search-phrase-form').attr('action', '/suchen?suche='+phrase+'.html')
        return true;
    });*/

    $("#search-city").autocomplete('/search/city/', {
        width: 163,
        max: 5,
        delay: 100,
        selectFirst: false,
        minChars: 3
    });
    $('#sort').change(function() {
        var index = $(this).get(0).selectedIndex; 
        var val = $(this).get(0).options[index].value;
        if (val == 'none') {
            document.location.href = '/fotografen/';
        }
        else {
            //document.location.href = '/fotografen/sort/'+val+'/';
            document.location.href = '/fotografen-'+val+'.html';
        }
        return false;
    });
    $('#b-werbung .b-prew-item').tooltip({
        track: true,
        delay: 0,
        showURL: false,
        showBody: ' - '
    });
})


function facebook(u, t) {
    var width = 500;
    var height = 400;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + ",status=0,resizable=0,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
    var title = "";
    if(t != "") title = t;
    var obj = window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(title),'sharer',windowFeatures);
    return false;
}

