var scrollbar_options = {
        showArrows : true,
        scrollbarWidth : 5,
        scrollbarMargin : 10,
        animateTo : true,
        dragMinHeight : 24,
        dragMaxHeight : 24
};
var dropdown_check = new Object();
$(document).ready(function() {
    var tempX = 0;
    var tempY = 0;
    var stagewidth = $('body').width();
    
    $('.dropdown .ddopen').hide();
    $('.dropdown a.ddbutton, .dropdown div.ddtextcontainer').bind('click', function(event) {
        event.preventDefault();
        var id = $(this).parents('.dropdown:first').attr('id');
        if (dropdown_check[id] == undefined || dropdown_check[id] == 'closed'){
            $('#'+id+' .ddopen').show();
            $('#'+id+' .ddlist').jScrollPane(scrollbar_options);
            dropdown_check[id] = 'open';
            closeAllDropDownsBut(id);
        }else{
            $('#'+id+' .ddopen').hide();
            dropdown_check[id] = 'closed';
        }
    });
/*
    $('.front_error').ready(function(event) {
        var errormsg = $('.error_text .error_message').text();
        if (errormsg.length > 0) {
            $('.front_error').stop();
            $('.front_error').animate( {
                height : '200px'
            }, {
                duration : 300
            });
        }
    });
    $('.front_error').click(function(event) {
        $(this).stop();
        $(this).animate( {
            height : '0px'
        }, {
            duration : 800
        });
        $('.error_text').hide();
    });
    
    dynamic_front_tooltip = {
            delay: 0,
            showURL: false,
            fade: 250,
            track: true,
            fixPNG: true,
            left: 5,
            top: 5,
            bodyHandler: function() {
                var container = $('#dynamic_tooltip_container').clone();
                var content = $('.dynamic_value', container);
                if($(this).hasClass('attribute_tooltip')) {
                    content.html($('#' + $(this).attr('id') + '_tooltip').html());
                }
                return $(container).html();
            }
    }

    $(".dynamic_front").tooltip(dynamic_front_tooltip);
*/    
    
    $('.attacklink').click(function(event) {
    	event.preventDefault();
    	args = $(this).attr('rel').split('-');
    	if(args[0] == 'fight') {
    		document.location.href = '/fights/start/'+args[1]+'/'+args[2]+'/'+args[3]+'/'+args[4]; 
    	} else if(args[0] == 'wait') {
    		document.location.href = '/fights/waitFight/buy/'+args[1]+'/'+args[2]+'/'+args[3]+'/'+args[4];
    	} else {
    		document.localtion.href = '/fights/start';
    	}
    });
});

function closeAllDropDownsBut(id){
    for(var i in dropdown_check){
        if(i != id && dropdown_check[i] == 'open'){
            dropdown_check[i] = 'closed';
            $('#'+i+' .ddopen').hide(0);
        }
    }
}

/*
onFlashMessageClose = undefined;

function showFlashMessage(title, text, onClose, buttons) {
    onFlashMessageClose = onClose;

    $("#flashmsg .flashtext .content").html('<h1>'+title+'</h1>'+'<p>'+text+'</p>');

    $("#flashmsg").css("display", "block");
    $('#flashmsg .blood .red').css("height", "0%").animate(
            {height: '100%'},
            {duration: 10000}
    );

    $("#flashmsg .buttons").html("");

    if(buttons == undefined || buttons.length == 0) {
        buttons = [OK_BUTTON];
    }

    for(var i = 0; i < buttons.length; ++i) {
        $("#flashmsg .buttons").append('<a style="float:left;" class="flashmsg_button_' + buttons[i].imgClass + '" title="' + buttons[i].caption + '" onclick="hideFlashMessage(' + i + '); return false;"></a>');
    }
}

function showDialog(title, text, onClose, buttons) {
    showFlashMessage.apply(null,arguments);
}

function hideFlashMessage(buttonId) {
    $("#flashmsg").css("display", "none");
    onFlashMessageClose != undefined && onFlashMessageClose(buttonId);
}
*/
