function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};


function tabsZ() {
	var z = 90;
	$('div.rules-viewer dt').each(function(index){
		if ($(this).hasClass('selected')) {
		} else
			$(this).css('z-index', z--);
	});
};
	
$(document).ready(function() {
	
	tabsZ();

	$('div.rules-viewer dt').click(function(){
		$(this)
		.siblings().removeClass('selected').end()
		.next('dd').andSelf().addClass('selected').css('z-index', '100');
		tabsZ();
	});

    $('#partners-list').jcarousel({
        auto: 1,
        scroll: 1,
        wrap: 'circular',
        initCallback: mycarousel_initCallback
    });
    
    $('a.answer-link').click(function(e){
    	e.preventDefault();
    	$(this).parent().prev().slideToggle();
    	if($(this).hasClass('show-answer-link')) {
    		$(this).removeClass('show-answer-link').addClass('hide-answer-link');
	    	$(this).html('Свернуть текст ответа');
	    } else {
    		$(this).removeClass('hide-answer-link').addClass('show-answer-link');
	    	$(this).html('Показать ответ');
	    }
    })
    
	//placholder кроссбраузерный
	$('.placeholder P').click(function(){
		$(this).children('label').hide();
		$(this).children('input').focus();
		$(this).children('textarea').focus();
    });
    $('.placeholder input').focus(function(){
		$(this).next('label').hide();
    });
    $('.placeholder input').focusout(function(){
    	if($(this).val() == "")
	    	$(this).next().show();
    });
    $('.placeholder input').each(function(){
    	if($(this).val() == "")
	    	$(this).next().show(); 	
    });
    $('.placeholder textarea').focus(function(){
		$(this).next('label').hide();
    });
    $('.placeholder textarea').focusout(function(){
    	if($(this).val() == "")
	    	$(this).next().show(); 	
    });
    $('.placeholder textarea').each(function(){
    	if($(this).val() == "")
	    	$(this).next().show(); 	
    });
});
