var spec_active = false;
var spec_different_language = false;

// Load when document finished loading
jQuery(document).ready(function (){
    klarna_specReady();
});

function klarna_specReady ()
{
    var foundBox = false;
    currentMinHeight_spec = jQuery('#klarna_box_spec').height();

    // Chosing the active language
    jQuery('#box_active_language').live('click', function () {
        jQuery('.klarna_box_top_flag_list').slideToggle('fast', function () {
            if (jQuery(this).is(':visible'))
            {
                jQuery('.klarna_box_top_flag').animate({
                    opacity: 1.0
                }, 'fast');
            }
            else {
                jQuery('.klarna_box_top_flag').animate({
                    opacity: 0.4
                }, 'fast');
            }
        });
    });

    jQuery('.klarna_box_bottom_languageInfo').live('mousemove', function (e) {
        showBlueBaloon(e.pageX, e.pageY, jQuery(this).find('img').attr("alt"));
    });

    jQuery('.klarna_box_bottom_languageInfo').live('mouseout', function () {
        hideBlueBaloon();
    });
    if(typeof global_countryCode != 'undefined'){
        if (jQuery('#getAddressUpdater').val() != "" && global_countryCode == "se")
        {
            getAddress();
        }
    }

    if(typeof global_countryCode != 'undefined'){
        if (global_countryCode == "de" || global_countryCode == "nl")
        {
            if(typeof select_spec_bday != 'undefined' && typeof select_spec_bmonth != 'undefined') {
                jQuery('[name="payment[klarna_specpayment_dob_day]').val(select_spec_bday);
                jQuery('[name="payment[klarna_specpayment_dob_month]').val(select_spec_bmonth);
            }

            if(typeof select_spec_byear != "undefined") {
                // Years box
                var date = new Date();
                for (i = date.getFullYear(); i >= 1900; i--) {
                    jQuery('<option/>').val(i).text(i).appendTo('#klarna_box_spec .selectBox_spec_year');
                }
                jQuery('[name="payment[klarna_specpayment_dob_year]').val(select_spec_byear);
            }
        }
    }
}

function resetListBox (listBox)
{
    listBox.find('li').each(function (){
        if (jQuery(this).attr("id") == "click")
        {
            jQuery(this).attr("id", "");
        }

        jQuery(this).find('div').find('img').remove();
    });
}

