// <![CDATA[
$(function() {
	// Slider
    $('#coin-slider').coinslider({width:960,height:328,opacity:50});

    $('#nivoSlider').nivoSlider({
        directionNav : true,
        controlNav : false,
        manualAdvance : true,
        // TODO : change the path...
        prevText : '<img src="/wp-content/themes/blackwhite/images/prevgr.png" alt="prev" />',
		nextText : '<img src="/wp-content/themes/blackwhite/images/nextgr.png" alt="next" />'
    });

    $('.controls a.index_rmb').colorbox({opacity: 0.5, width: 350});

    $('.wtitle h2').each(function(){
        if($(this).val() == " ") {
            $(this).css({ borderBottom : '0 none', height : '0'});
        }
    });

//    $('.menu a[href*=forum]').attr('target', '_blank');

    $('.cbox').colorbox({maxWidth: '95%', maxHeight: '95%'});

	// radius Box
	$('.wp-pagenavi a, .wp-pagenavi .current, ul.menusm li a.top_level, ul.menusm li ul, .index_rmb, .post-leav a').css({"border-radius":"5px", "-moz-border-radius":"5px", "-webkit-border-radius":"5px"});

    var all_questions = parseInt($('span#all').html());
    var questions = new Array();

    if(!Array.indexOf){
        Array.prototype.indexOf = function(obj){
            for(var i=0; i<this.length; i++){
                if(this[i]==obj){
                    return i;
                }
            }
            return -1;
        }
    }

    $('form[name=hexamform] input[type=radio]').click(function(){
        var current = parseInt($('#current').html());
        var name = $(this).attr('name');
        var arr_el = questions.length + 1;

        current++;
        if(questions.indexOf(name) < 0) {
            questions[arr_el] = name;
            $('#current').html(current);
        }
    });

    $('form[name=hexamform]').submit(function(){
        var current = parseInt($('#answered #current').html());
        var all = parseInt($('#answered #all').html());

        if(current == all) {
            return true;
        } else {
            alert('Моля отговорете на всички въпроси!');
            return false;
        }
    });


});

// Cufon
Cufon.replace('h1, h2 :not(".footer2 h2"), h3, .rss p, .list_categories a, .form_title', { hover: true });

// ]]>
