var inputPlaceholder = function(event, el, className) {
event = event || window.event;
el = el || this;
className = className || 'placeholder';

if (el.defaultValue == '') return false;

if (event) {
    if (event.type == 'focus' && el.value == el.defaultValue) {
        el.value = '';
    }
    else if (event.type == 'blur' && el.value == '') {
        el.value = el.defaultValue;
    }
}

if (el.value == el.defaultValue) {
    $(el).addClass(className);
}
else {
    $(el).removeClass(className);
    }
}
  
$(document).ready(function()
{
    $(':submit, :reset, :button, :image').each(function () {
        var title = $(this).val();
        $(this).attr('title', title);
    });

    $('#logo, h1, h2, #fn li, #menu li, #bm1 li, a.rss').each(function () {
        var title = $(this).text();
        $(this).attr('title', title);
    });

    $('ul, ol').each(function () {
        for (var i = 0; i < $(this).children().size(); i++)
        {
            var n = i + 1;
            $(this).children().eq(i).addClass('item'+n);
        }
    });

    $(':text').addClass('text');
    $(':password').addClass('text password');
    $(':radio').addClass('radio');
    $(':checkbox').addClass('checkbox');
    $(':submit').addClass('butt submit');
    $(':reset').addClass('butt reset');
    $(':button').addClass('butt button');
    $(':image').addClass('butt image');
    $(':file').addClass('file');

    $('tr th:last-child, tr td:last-child, ul li:last-child, ol li:last-child').addClass('last-child');

    $('form#login p.info span a:first-child').css({'float':'left'});
    $('form#login p.info span a:last-child').css({'float':'right'});

    $(".placeholder").focus(inputPlaceholder);
    $(".placeholder").blur(inputPlaceholder);
    $(".placeholder").change(inputPlaceholder);
    $(".placeholder").each(inputPlaceholder);

    $('#faq div.ob img').click(function()
    {
        $(this).parent().animate(
        {
            height: 'toggle',
            opacity: 'toggle'
        },
        'normal');
        
        $(this).parent().next().animate(
        {
            height: 'toggle',
            opacity: 'toggle'
        },
        'normal');
    });

    $('#faq dl.otvholder').click(function()
    {
        $(this).animate(
        {
            height: 'toggle',
            opacity: 'toggle'
        },
        'fast');
        
        $(this).prev().animate(
        {
            height: 'toggle',
            opacity: 'toggle'
        },
        'fast');
    });

    var days = $('ul#days').children().size() * 61;
    $('ul#days').css({'width':days + 'px'});
    
    $('ul#days dt a').hover(function() {
        $(this).parent().next().css({'display':'block'});
    },
    function() {
        $(this).parent().next().css({'display':'none'});
    });
    
    $('ul#bigprog table tr td:nth-child(2)').css({'width':'280px'});
    $('ul#bigprog table tr td:nth-child(3)').css({'text-align':'center','padding-left':'0','color':'#7a7a7a'});
    
    $('.fotkoholder li a').click(function(){
        window.open(this.href,null,'width=394,height=640,top=100,left=300,screenX=300,screenY=100,titlebar=0,toolbar=0,location=0,status=1,menubar=0,scrollbars=0,resizable=1,fullscreen=0;');
        return false;
    });
    $('.sertlist dt a').click(function(){
        window.open(this.href,null,'width=375,height=604,top=100,left=300,screenX=300,screenY=100,titlebar=0,toolbar=0,location=0,status=1,menubar=0,scrollbars=0,resizable=1,fullscreen=0;');
        return false;
    });
    

    $('td.togglecomm img').click(function()
    {
        $(this).parent().parent().parent().next().toggleClass('plus');
    });
    
    $('td.togglecomm a').click(function()
    {
        return false;
    });

    
    //if ($.browser.opera) {}
    //if ($.browser.safari) {}
    
});

jQuery.extend({
	randomString: function() {
	    return String((new Date()).getTime()).replace(/\D/gi,'')
	}
});

