// File Name:     Calendar.js
// Creation Date: 19.01.2005
// Author:        Adrian POPESCU

// Function used to change the year or month from the list box above the calendar
// Creation Date: 19.01.2005
// Description: Select a month or a year from the coresponding list box above the calendar
// and the displayed month will change acordingly.

function changeMonthOrYear(year, month)
{

    date = ""+year+"-"+month+"-00";

    redirectionURL = "check_av.php?dateComponents="+date;
    self.location.href = redirectionURL;
    //document.location.href = "blogs.php?date="+wert;
    //'blogs.php?dateComponents=$dateToSend'
    //alert(date);
}

// Function used for test - now is not used
function changeOrderDate(d_year,d_day,d_month,d_Nr)
{
    date = ""+d_year+"-"+d_month;

    redirectionURL = "check_av.php?orderDateComponents="+date;
    self.location.href = redirectionURL;
    alert(date+" Function name: changeOrderDate; in file: Calendar.js");
}

// Global Var
// Store the className(style name from stylesheet.css file) that was set for the day before MouseOver event
var storeCurrentDayClassName = "";

// When mouse is over a day in calendar, change the color of this cell.
function highlightDayOnCalendar(Obj, day)
{
    // Save the curent style(ClassName)
    storeCurrentDayClassName = Obj.className;
    // Change the curent style(ClassName)
    Obj.className = 'highlightOnMouseOver';
    //alert(day);
}

// When mouse is out, change the color of the cell back.
function restoreDayStyleOnCalendar(Obj, day)
{
    // Restore the style(ClassName)
    Obj.className = storeCurrentDayClassName;
    //alert(day);
}

// When mouse is out, change the color of the cell back.
function setEventDateOnMouseClick(Obj, day, month, year)
{
    //dayStr = ""+ month + "." + day + "." + year;
    //alert(dayStr);
    if(document.forms[0] != null)
    {
        if(document.forms[0].name == "order_form")
        {
            // Set the selected date
            document.forms[0].elements['date1_month'].options[month].selected = true;
            document.forms[0].elements['date1_day'].options[day].selected = true;
            //alert(document.order_form.date1_year.value);
            //alert(document.order_form.date1_year.name);
            for(var i=0; i < document.order_form.date1_year.options.length; i++)
            {
                if(document.order_form.date1_year.options[i].value == year)
                {
                    document.order_form.date1_year.options[i].selected = true;
                    break;
                }
            }
        }
    }
    else
    {
        //Do nothing - or alert("Error!"); in case of error
    }
}
