/*
 * Copyright 2012 Amadeus s.a.s.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

 {CSSTemplate {
    $classpath : "aria.widgets.calendar.CalendarStyle",
    $extends : "aria.widgets.WidgetStyle",
    $hasScript: true
}}

    {var skinnableClassName="Calendar"/}

    {var weekEndDefault = {
        backgroundColor : "#F2ECDE",
        borderColor : "#F2ECDE",
        color : "black"
    }/}

    {var todayDefault = {
        borderColor : "black",
        backgroundColor : "transparent",
        color : "black"
    }/}

    {var selectedDateDefault = {
        backgroundColor : "#FFCC66",
        borderColor : "black",
        color : "black"
    }/}

    {var focusedDateDefault = {
        borderStyle : "dotted",
        borderColor : "black"
    }/}

    {var selectedFromDateDefault = {
        backgroundColor : "#FFCC66",
        borderColor : "#FFCC66",
        color : "black",
        fontWeight : "bold"
    }/}

    {var selectedToDateDefault = {
        backgroundColor : "#FFCC66",
        borderColor : "#FFCC66",
        color : "black",
        fontWeight : "bold"
    }/}


    {var selectedFromToDateDefault = {
        backgroundColor : "#FFEE88",
        borderColor : "#FFEE88",
        color : "black"
    }/}

    {var selectedSameFromToDateDefault = {
        backgroundColor : "#FFCC66",
        borderColor : "#FFCC66",
        color : "black",
        fontWeight : "bold"
    }/}

    {macro writeSkinClass(info)}
        /* Calendar classes. Should only be used in the calendar templates. */
        {var skinClassName=info.skinClassName/}
        {var prefix="x"+skinnableClassName+"_"+skinClassName/}
        {var skinClass=info.skinClass/}
        .${prefix}_general {
            {if skinClass.generalBackgroundColor}
                background-color:${skinClass.generalBackgroundColor};
            {/if}
        }
        .${prefix}_label {
            font-weight:bold;
            margin: 2px;
        }
        .${prefix}_general a:hover {
            text-decoration: underline;
        }
        table.${prefix}_month {
            font-size:${skinClass.fontSize}px;
            text-align: center;
            border: 0px none;
            border-collapse:separate;
            border-spacing:0;
            {if skinClass.fontFamily}
                font-family:${skinClass.fontFamily};
            {/if}
            {if skinClass.fontVariant}
                font-variant:${skinClass.fontVariant};
            {/if}
        }
        .${prefix}_monthTitle {
            width: 100%;
            border-color:${skinClass.monthTitleBorderColor};
            border-style:solid;
            border-width:1px 0;
            color:${skinClass.monthTitleColor};
            font-weight:bold;
            background-color:${skinClass.monthTitleBackgroundColor};
            padding-top:${skinClass.monthTitlePaddingTop};
            padding-bottom:${skinClass.monthTitlePaddingBottom};
            {if skinClass.monthTitleFontSize}
                font-size:${skinClass.monthTitleFontSize}px;
            {/if}
        }
        .${prefix}_day {
            border-width: 1px;
            width: 13px;
            padding:${skinClass.dayPadding};
            {call dateStyle(skinClass, "day", "day", getDayDefault(skinClass))/}
        }
        .${prefix}_weekEnd {
            {call dateStyle(skinClass, "weekEnd", "weekEnd")/}
        }
        .${prefix}_selectable  {
            cursor: pointer;
        }
        .${prefix}_unselectable {
            {call dateStyle(skinClass, "unselectableDate", "unselectable", getUnselectableDefault(skinClass))/}
        }
        .${prefix}_today {
            {call dateStyle(skinClass, "today", "today")/}
        }
        .${prefix}_weekNumber {
            background-color:${skinClass.weekNumberBackgroundColor};
            border:1px solid ${skinClass.weekNumberBorderColor};
            font-weight:bold;
            width: 13px;
        }
        .${prefix}_weekDaysLabel {
            background-color:${skinClass.weekDaysLabelBackgroundColor};
            border:1px solid ${skinClass.weekDaysLabelBorderColor};
            font-weight:${skinClass.weekDaysLabelFontWeight};
            color:${skinClass.weekDaysLabelColor};
            width: 13px;
            padding:${skinClass.weekDaysLabelPadding};
        }

        // The following rules include ${prefix}_day and ${prefix}_selectable
        // to increase their priority

        .${prefix}_day.${prefix}_selectable.${prefix}_selected {
            {call dateStyle(skinClass, "selectedDate", "selected")/}
        }
        .${prefix}_day.${prefix}_selectable.${prefix}_selected_from_to {
            {call dateStyle(skinClass, "selectedFromToDate")/}
        }

        .${prefix}_day.${prefix}_selectable.${prefix}_selected_from {
            {call dateStyle(skinClass, "selectedFromDate")/}
        }

        .${prefix}_day.${prefix}_selectable.${prefix}_selected_to {
            {call dateStyle(skinClass, "selectedToDate")/}
        }

        .${prefix}_day.${prefix}_selectable.${prefix}_selected_same_from_to {
            {call dateStyle(skinClass, "selectedSameFromToDate")/}
        }

        .${prefix}_day.${prefix}_selectable.${prefix}_focused {
            {call dateStyle(skinClass, "focusedDate")/}
        }

        .${prefix}_day.${prefix}_selectable.${prefix}_mouseOver {
            {call dateStyle(skinClass, "mouseOverDate", "mouseOver", getMouseOverDefault(skinClass))/}
        }
    {/macro}

    {macro dateStyle(skinClass, propertyName, oldPrefix, defaultValues)}
        {var obj = getStyleFor(skinClass, propertyName, oldPrefix, defaultValues) /}
        {if obj}
            {if isSet(obj.backgroundColor)}
                background-color: ${obj.backgroundColor};
            {/if}
            {if isSet(obj.borderStyle)}
                border-style: ${obj.borderStyle};
            {/if}
            {if isSet(obj.borderColor)}
                border-color: ${obj.borderColor};
            {/if}
            {if isSet(obj.color)}
                color: ${obj.color};
            {/if}
            {if isSet(obj.fontWeight)}
                font-weight: ${obj.fontWeight};
            {/if}
            {if isSet(obj.fontStyle)}
                font-style: ${obj.fontStyle};
            {/if}
        {/if}
    {/macro}

{/CSSTemplate}