var searchText = 'Szukaj na stronie';
$(function() {
    $('#menu li, #menu .sub').hover(menuHover, menuOver);
    $('#searchForm .text').attr('value', searchText).focus( function() {
        if($(this).attr('value') == searchText) {
            $(this).attr('value', '');
        }
    }).blur( function() {
        if($(this).attr('value') == '') {
            $(this).attr('value', searchText);
        }
    } );
    $('[rel=lightbox[gallery]]').prettyPhoto();
});

function menuHover() {
    var li = $(this);
    if($('> div', li).get().length==1) {
        $('> div', li ).attr('style', '').removeAttr('style').show('fast');
        $( '>a', li ).addClass('active');
        
    } else {
        $( '#menu > div ' ).stop().hide();
        //$('#menu li > a').removeClass('active');
    }
}
function menuOver() {
    $('> a', this).removeClass('active');
    $('> div', this ).stop().hide();
}

$(function() {
    $('#addForm .text').each(function(i) {

        if($(this).attr('value')=='')
            $(this).attr('value', $(this).attr('defaulttext'))
    }).focus( function() {
        if($(this).attr('value') == $(this).attr('defaulttext'))
            $(this).attr('value', '');
    }).blur( function() {
        if($(this).attr('value') == '')
            $(this).attr('value', $(this).attr('defaulttext'));
    } );
    $( '#addForm .cat input[type=checkbox]' ).change( function() {
        if( $(this).is(':checked') ) {
            $(this).next().next().slideDown('fast');
        } else {
            $(this).next().next().slideUp('fast');
        }
    } );
});

/*kontakt */
$( function() {
    $( '#contactForm input[type=text], #contactForm textarea' ).each( function( i ) {
        var el = $(this);
        if( el.attr('type') == 'text' ) {
            el.attr( 'defaultText', el.attr('value') );
        } else {
            el.attr( 'defaultText', el.val() );
        }
    } ).focus( function() {
        var el = $(this);
        if( el.attr('type') == 'text' && el.attr('value') == el.attr('defaultText')  ) {
            el.attr( 'value', '' );
        } else if( el.attr( 'defaultText' ) == el.val() ) {
            el.text( '' );
        }
    } ).blur( function() {
        var el = $(this);
        if( el.attr('type') == 'text' && el.attr('value') == ''  ) {
            el.attr( 'value', el.attr('defaultText') );
        } else if( '' == el.val() ) {
            el.val( el.attr('defaultText') );
        }
    } );
} );


$( function() {
    $( 'form' ).submit( function() {
        $('input[type=text]').each( function() {
            if( $(this).attr('value') == $(this).attr('defaulttext') ) {
                $(this).attr('value', '');
            }
        } );
    } );
} );

