$(function () {
    //sidebar.joboffersearch - input helper text
    sidebarJoboffersearchShowHint();
    $('div.sidebarJobofferSearch div.input input').focus(sidebarJoboffersearchHideHint);
    $('div.sidebarJobofferSearch div.input input').blur(sidebarJoboffersearchShowHint);
    
    //celo-klikatelna anotacia
    $('div.list-item-container').css('cursor','pointer').click(function () {
        location.href = $('dt.title a:eq(0)',this).attr('href');
        return false;
    });
    
    JobScroll();
});

function JobScroll(curTop) {
    if (typeof(curTop) == 'undefined') {
        var curTop = parseInt($('#jobscrollerContent').css('top'));
    }
    var newTop = curTop - 1;
    $('#jobscrollerContent').css('top',newTop + 'px');
    var firstH = $('#jobscrollerContent div.scrollitem:eq(0)').height();
    if (firstH + newTop < 0) {
        newTop += firstH;
        $('#jobscrollerContent').css('top',newTop + 'px');
        $('#jobscrollerContent div.scrollitem:eq(0)').appendTo($('#jobscrollerContent'));
    }
    window.setTimeout(function () {
        JobScroll(newTop);
    },100);
}

function sidebarJoboffersearchShowHint() {
    var spfq = $('div.sidebarJobofferSearch div.input input');
    if (spfq.val() == spfq.attr('title') || spfq.val() == '') {
        spfq.addClass('hint').val(spfq.attr('title'));
    }
}
function sidebarJoboffersearchHideHint() {
    var spfq = $('div.sidebarJobofferSearch div.input input');
    spfq.removeClass('hint');
    if (spfq.val() == spfq.attr('title')) {
        spfq.val('');
    }
}

// 
// function organizationLoadReference(ref_id) {
//     var div = $('#reference_' + ref_id);
//     div.load('/organization/search/ajaxloadreference/', {
//         refid: ref_id
//     });
// }
// 
// 
// $(document).ready(function () {
//     // profil uzivatela
//     if ($('#country1').val() != 'United States' && $('#country1').val() != 'Canada') {
//         $('#state_usa_can_1').hide();
//     }
//     if ($('#country2').val() != 'United States' && $('#country2').val() != 'Canada') {
//         $('#state_usa_can_2').hide();
//     }
//     $('#country1').change(function () {
//         if ($(this).val() == 'United States') {
//             $('#state_usa_can_1').show();
//         }
//         else if ($(this).val() == 'Canada') {
//             $('#state_usa_can_1').show();
//         }
//         else {
//             $('#state_usa_can_1').hide();
//         }
//     });
//     $('#country2').change(function () {
//         if ($(this).val() == 'United States') {
//             $('#state_usa_can_2').show();
//         }
//         else if ($(this).val() == 'Canada') {
//             $('#state_usa_can_2').show();
//         }
//         else {
//             $('#state_usa_can_2').hide();
//         }
//     });
//     
//     // registracia organizacie
//     if ($('#address_country').val() != 'United States' && $('#address_country').val() != 'Canada') {
//         $('#org_state_usa_can').hide();
//     }
//     $('#address_country').change(function () {
//         if ($(this).val() == 'United States') {
//             $('#org_state_usa_can').show();
//         }
//         else if ($(this).val() == 'Canada') {
//             $('#org_state_usa_can').show();
//         }
//         else {
//             $('#org_state_usa_can').hide();
//         }
//     });
//     
//     $('#program_prax').click(function () {
//         if ($(this).attr('checked') == true) {
//             $('#label_employer').text('NĂˇzov PRAX tĂ­mu');
//             $('#label_popisprace').text('Popis vĂˇĹˇho PRAX projektu');
//             $('#row_mesto').hide();
//         }
//         else {
//             $('#label_employer').text('OrganizĂˇcia');
//             $('#label_popisprace').text('StruÄŤnĂ˝ popis prĂˇce');
//             $('#row_mesto').show();
//         }
//     });
// });
