/*
Copyright by .:ArTuR:.
Author Artur Grzybowski
*/
var monthsLengths = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var weekdaysNames = new Array('Mon','Tue','Wed','Thu','Fri','Sat','Sun');
var monthsNames = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
function calendar(day,month,year,whereSign) {
bName = navigator.appName;
var calendarCode = "";
/*if (bName.substring(0,9) == "Microsoft") {
calendarCode = calendarCode + "
";
}*/
var calendarCode = calendarCode + "
";
firstDayOfMonth = new Date(year,(month-1),1);
var firstDay = firstDayOfMonth.getDay();
if (firstDay == 0) {
firstDay = 7;
}
if(year%4==0) monthsLengths[1]=29;
leftLink = "<<";
rightLink = ">>";
calendarCode = calendarCode + "| "+leftLink+" | "+year+" | "+rightLink+" | ";
leftLink = "<<";
rightLink = ">>";
calendarCode = calendarCode + "
|---|
| "+leftLink+" | "+monthsNames[month-1]+" | "+rightLink+" |
|---|
";
calendarCode = calendarCode + "";
var currentDay = 0;
var endDay = 7;
while (currentDay"+weekDayName+"";
currentDay++;
}
calendarCode = calendarCode + " ";
currentDay = 1;
endDay = firstDay;
var newWeekDay = 0;
while (currentDay < endDay){
background='';
background=(currentDay==6)?'class=\"saturday\"':background;
background=(currentDay==7)?'class=\"sunday\"':background;
calendarCode = calendarCode + "| | ";
newWeekDay++;
currentDay++;
}
currentDay = 1;
endDay = monthsLengths[month-1];
var invalid = 0;
while (currentDay <= endDay){
if (newWeekDay >= 7) {
calendarCode = calendarCode + " ";
newWeekDay=0;
}
background='';
background=(newWeekDay==5)?'class=\"saturday\"':background;
background=(newWeekDay==6)?'class=\"sunday\"':background;
background=((currentDay==05&&month==02&&year==2012))?'class=\"calendar_sign\"':background;
invalid = 0;
var min_delivery_date_hidden = document.getElementById('min_delivery_date_hidden').value ;
if(currentDay == 1) {
if(month < 10) month='0'+month;
}
if(currentDay < 10) curDay='0'+currentDay;
else curDay=currentDay;
var thisDay = year+'-'+month+'-'+curDay;
//zeby nie dalo sie wybrac okresu Bozego narodzenia
var thisDate = month+'-'+curDay;
var beginHolidays = '12-22';
var endHolidays = '01-05';
//if(beginHolidays < thisDate && endHolidays > thisDate) invalid = 1; //not the turn of the year
if(beginHolidays < thisDate || endHolidays > thisDate) invalid = 1; //the turn of the year
//koniec
if(min_delivery_date_hidden > thisDay) invalid = 1;
background=(invalid==1 && newWeekDay!=5 && newWeekDay!=6)?'class=\"invalid\"':background;
if(newWeekDay==5 || newWeekDay==6 || invalid == 1) {
calendarCode = calendarCode + "| "+((currentDay<10)?'0'+currentDay:currentDay);+" | ";
}
else {
calendarCode = calendarCode + ""+((currentDay<10)?'0'+currentDay:currentDay);+" | ";
}
newWeekDay++;
currentDay++;
}
while (newWeekDay < 7){
calendarCode = calendarCode + " | ";
newWeekDay++;
}
calendarCode = calendarCode + "
|
";
change(whereSign+'_create_calendar','html',calendarCode);
}
function createCalendar(whereSign) {
style(whereSign+'_create_calendar','display','block','none');
calendar(05,02,2012,whereSign);
}
function signDate(day,month,year,whereSign){
day=((day<10)?'0'+day:day);
month=((month<10)?'0'+month:month);
change(whereSign,'value',year+'-'+month+'-'+day);
//wielka proteza bo nie dziala pod FF
if(whereSign == 'delivery_date') document.getElementById('delivery_date_hidden').value = year+'-'+month+'-'+day;
if(whereSign == 'delivery_date') document.getElementById('delivery_date').value = day+'-'+month+'-'+year;
//if(whereSign == 'logout_search_data_to') document.form_data.logout_search_data_to.value = year+'-'+month+'-'+day;
//if(whereSign == 'logout_search_data_from') document.form_data.logout_search_data_from.value = year+'-'+month+'-'+day;
//if(whereSign == 'article_manual_add_date') document.form_data.article_manual_add_date.value = year+'-'+month+'-'+day;
}