$('document').ready(function () {
	$.datepicker.setDefaults({
        duration: "",
        firstDay: 1,
        dateFormat: "dd.mm.yy",
        showOn: "both",
        buttonImage: '/public/images/calendar_ico.png',
        buttonText: "Kalendár",
        buttonImageOnly: true,
        showAnim: "",
        changeYear: true,
        changeMonth: true
	});
	$("input.datepicker[name=availableFrom]").datepicker({minDate: 0, onSelect: function(date){if ($(this).datepicker('getDate') > $("input.datepicker[name=expired]").datepicker('getDate')) $("input.datepicker[name=expired]").val(date)}});
	$("input.datepicker[name=expired]").datepicker({beforeShow: function(){$(this).datepicker('option', 'minDate', $("input.datepicker[name=availableFrom]").datepicker('getDate') || 0)}});
/*
	sfp_LoadEditor('section[1]', 'mini.js', '300');
    sfp_LoadEditor('section[2]', 'mini.js', '300');
    sfp_LoadEditor('section[3]', 'mini.js', '300');
    sfp_LoadEditor('section[4]', 'mini.js', '300');
    sfp_LoadEditor('section[5]', 'mini.js', '300');
*/

/*     pre ckeditor  */
	sfp_LoadEditor('section[1]', '/public/js/ckeditor/default-config.js', '300', 1);
	sfp_LoadEditor('section[2]', '/public/js/ckeditor/default-config.js', '300', 2);
	sfp_LoadEditor('section[3]', '/public/js/ckeditor/default-config.js', '300', 3);
	sfp_LoadEditor('section[4]', '/public/js/ckeditor/default-config.js', '300', 4);
	sfp_LoadEditor('section[5]', '/public/js/ckeditor/default-config.js', '300', 5);

	$('.answerinput').each(function () {
        if($(this).val() != ''){
            var id = $(this).attr('id');
            $('#correct_'+id).removeAttr("disabled");
        }
    });
    
    $('.answerinput').keyup(function () {
        var id = $(this).attr('id');
        if($(this).val() != ''){
            $('#correct_'+id).removeAttr("disabled");
        } else {
            $('#correct_'+id).attr('disabled','true');
        }
    });
    
    $('.presentation_radio').click(function () {
        $('#article_price').html($(this).attr('rel')+' EUR');
    });
//    $('.fb_comments_radio').click(function () {
//        $('#article_price_fb').html($(this).attr('rel')+' EUR');
//    });
    $('.fb_likes_radio').click(function () {
        $('#article_price_fb').html($(this).attr('rel')+' EUR');
    });
    
});

function sfp_LoadEditor(eid,configFile,height, editor_position) {
    //alert(editor_position);
    if (editor_position > 0) {
        window.setTimeout(function () {
            CKEDITOR.replace(eid,{
                customConfig: configFile,
                height: height
            });
        }, editor_position * 100);
    } else {
        CKEDITOR.replace(eid,{
            customConfig: configFile,
            height: height
        });
    }
    
    // oEditor.Config["CustomConfigurationsPath"] = configFile;
    // oEditor.Config["WEBPAGE_ROUTE_BASEURL"] = WEBPAGE_ROUTE_BASEURL;
    // oEditor.ToolbarSet = 'Default';
    // oEditor.Height = height;
    // oEditor.ReplaceTextarea();
}
