var maiDatum = new Date(); var maiYear = maiDatum.getYear(); var maiMonth = maiDatum.getMonth()+1; var maiDay = maiDatum.getDate(); if (maiYear<1900) maiYear+=1900; var maiDatumString = maiYear.toString(); if(maiMonth<10) maiDatumString += '0'; maiDatumString += maiMonth.toString(); if(maiDay<10) maiDatumString += '0'; maiDatumString += maiDay.toString(); function positionInfo(object) { var lang='en'; var p_elm = object; this.getElementLeft = getElementLeft; function getElementLeft() { var x = 0; var elm; if(typeof(p_elm) == "object"){ elm = p_elm; } else { elm = document.getElementById(p_elm); } while (elm != null) { x+= elm.offsetLeft; elm = elm.offsetParent; } return parseInt(x,10); } this.getElementWidth = getElementWidth; function getElementWidth(){ var elm; if(typeof(p_elm) == "object"){ elm = p_elm; } else { elm = document.getElementById(p_elm); } return parseInt(elm.offsetWidth,10); } this.getElementRight = getElementRight; function getElementRight(){ return getElementLeft(p_elm) + getElementWidth(p_elm); } this.getElementTop = getElementTop; function getElementTop() { var y = 0; var elm; if(typeof(p_elm) == "object"){ elm = p_elm; } else { elm = document.getElementById(p_elm); } while (elm != null) { y+= elm.offsetTop; elm = elm.offsetParent; } return parseInt(y,10); } this.getElementHeight = getElementHeight; function getElementHeight(){ var elm; if(typeof(p_elm) == "object"){ elm = p_elm; } else { elm = document.getElementById(p_elm); } return parseInt(elm.offsetHeight,10); } this.getElementBottom = getElementBottom; function getElementBottom(){ return getElementTop(p_elm) + getElementHeight(p_elm); } } function CalendarControl() { var calendarId = 'CalendarControl'; var currentYear = 0; var currentMonth = 0; var currentDay = 0; var selectedYear = 0; var selectedMonth = 0; var selectedDay = 0; var months = ['January','February','March','April','May','June','July','August','September','October','November','December']; var dateField = null; function getProperty(p_property){ var p_elm = calendarId; var elm = null; if(typeof(p_elm) == "object"){ elm = p_elm; } else { elm = document.getElementById(p_elm); } if (elm != null){ if(elm.style){ elm = elm.style; if(elm[p_property]){ return elm[p_property]; } else { return null; } } else { return null; } } } function setElementProperty(p_property, p_value, p_elmId){ var p_elm = p_elmId; var elm = null; if(typeof(p_elm) == "object"){ elm = p_elm; } else { elm = document.getElementById(p_elm); } if((elm != null) && (elm.style != null)){ elm = elm.style; elm[ p_property ] = p_value; } } function setProperty(p_property, p_value) { setElementProperty(p_property, p_value, calendarId); } function getDaysInMonth(year, month) { return [31,((!(year % 4 ) && ( (year % 100 ) || !( year % 400 ) ))?29:28),31,30,31,30,31,31,30,31,30,31][month-1]; } function getDayOfWeek(year, month, day) { var date = new Date(year,month-1,day) return date.getDay(); } this.clearDate = clearDate; function clearDate() { dateField.value = ''; hide(); } this.setDate = setDate; function setDate(year, month, day) { if (dateField) { //if (month < 10) {month = "0" + month;} //if (day < 10) {day = "0" + day;} // var dateString = month+"-"+day+"-"+year; var dateString = year+"-"+month+"-"+day; dateField.value = dateString; hide(); } return; } this.changeMonth = changeMonth; function changeMonth(change) { //a hivo oldalon be lehet allitani maximum es minimum currentMonth += change; currentDay = 0; if(currentMonth > 12) { currentMonth = 1; currentYear++; } else if(currentMonth < 1) { currentMonth = 12; currentYear--; } calendar = document.getElementById(calendarId); calendar.innerHTML = calendarDrawTable(); } this.changeYear = changeYear; function changeYear(change) { currentYear += change; currentDay = 0; calendar = document.getElementById(calendarId); calendar.innerHTML = calendarDrawTable(); } function getCurrentYear() { var year = new Date().getYear(); if(year < 1900) year += 1900; return year; } function getCurrentMonth() { return new Date().getMonth() + 1; } function getCurrentDay() { return new Date().getDate(); } function calendarDrawTable() { var dayOfMonth = 1; var validDay = 0; var startDayOfWeek = getDayOfWeek(currentYear, currentMonth, dayOfMonth); //mod by jesus startDayOfWeek=startDayOfWeek-1; if(startDayOfWeek<0)startDayOfWeek=6; var daysInMonth = getDaysInMonth(currentYear, currentMonth); var css_class = null; //CSS class for each day var table = ""; table = table + ""; table = table + " "; table = table + " "; table = table + " "; table = table + ""; //table = table + ""; table = table + ""; for(var week=0; week < 6; week++) { table = table + ""; for(var dayOfWeek=0; dayOfWeek < 7; dayOfWeek++) { if(week == 0 && startDayOfWeek == dayOfWeek) { validDay = 1; } else if (validDay == 1 && dayOfMonth > daysInMonth) { validDay = 0; } if(validDay) { if (dayOfMonth == selectedDay && currentYear == selectedYear && currentMonth == selectedMonth) { css_class = 'current'; // } else if (dayOfWeek == 0 || dayOfWeek == 6) { } else if (dayOfWeek == 5 || dayOfWeek == 6) { css_class = 'weekend'; } else { css_class = 'weekday'; } var currentDatumString=currentYear.toString(); if(currentMonth<10)currentDatumString+='0'; currentDatumString+=currentMonth.toString(); if(dayOfMonth<10)currentDatumString+='0'; currentDatumString+=dayOfMonth.toString(); if( currentDatumString < maiDatumString )table = table + ""; else table = table + ""; dayOfMonth++; } else { table = table + ""; } } table = table + ""; } table = table + ""; table = table + "
< " + months[currentMonth-1] + "
" + currentYear + "
>
SMTWTFS
MonTueWedThuFriSatSun
"+dayOfMonth+""+dayOfMonth+" 
Close
"; return table; } this.show = show; function show(field) { can_hide = 0; // If the calendar is visible and associated with // this field do not do anything. if (dateField == field) { return; } else { dateField = field; } if(dateField) { try { var dateString = new String(dateField.value); var dateParts = dateString.split("-"); selectedYear = parseInt(dateParts[0],10); selectedMonth = parseInt(dateParts[1],10); selectedDay = parseInt(dateParts[2],10); /* selectedMonth = parseInt(dateParts[0],10); selectedDay = parseInt(dateParts[1],10); selectedYear = parseInt(dateParts[2],10); */ } catch(e) {} } if (!(selectedYear && selectedMonth && selectedDay)) { selectedMonth = getCurrentMonth(); selectedDay = getCurrentDay(); selectedYear = getCurrentYear(); } currentMonth = selectedMonth; currentDay = selectedDay; currentYear = selectedYear; if(document.getElementById){ calendar = document.getElementById(calendarId); calendar.innerHTML = calendarDrawTable(currentYear, currentMonth); setProperty('display', 'block'); var fieldPos = new positionInfo(dateField); var calendarPos = new positionInfo(calendarId); var x = fieldPos.getElementLeft(); var y = fieldPos.getElementBottom(); setProperty('left', x + "px"); setProperty('top', y + "px"); if (document.all) { setElementProperty('display', 'block', 'CalendarControlIFrame'); setElementProperty('left', x + "px", 'CalendarControlIFrame'); setElementProperty('top', y + "px", 'CalendarControlIFrame'); setElementProperty('width', calendarPos.getElementWidth() + "px", 'CalendarControlIFrame'); setElementProperty('height', calendarPos.getElementHeight() + "px", 'CalendarControlIFrame'); } } } this.hide = hide; function hide() { if(dateField) { setProperty('display', 'none'); setElementProperty('display', 'none', 'CalendarControlIFrame'); dateField = null; } } this.visible = visible; function visible() { return dateField } this.can_hide = can_hide; var can_hide = 0; } var calendarControl = new CalendarControl(); var editedField=''; function showCalendarControl(textField) { editedField=textField; // textField.onblur = hideCalendarControl; calendarControl.show(textField); } function clearCalendarControl() { calendarControl.clearDate(); } function hideCalendarControl() { if (calendarControl.visible()) { calendarControl.hide(); } } function setCalendarControlDate(year, month, day) { calendarControl.setDate(year, month, day); if(editedField.name==icCorrigFieldAx)ic_calendar_corrig_days_in_month(icCorrigFieldAday,year,month); if(editedField.name==icCorrigFieldBx)ic_calendar_corrig_days_in_month(icCorrigFieldBday,year,month); rrobotSetPageDates(); ic_calendar_date_corrig(); ic_calendar_set_page_dates_step_2(); ic_calendar_save_date(); } function changeCalendarControlYear(change) { calendarControl.changeYear(change); } function changeCalendarControlMonth(change) { calendarControl.changeMonth(change); } document.write(""); document.write("
"); //visszaadja a pageform-bol x mezo erteket function icGetPageformValue(x){ return document.forms.pageform[x].value; } //beallitja a pageformban x mezo erteket function icSetPageformValue(x,y){ document.forms.pageform[x].value=y; } //a calendar mezobol beallitja a selecteket function rrobotSetPageDates(){ //arrival if(icGetPageformValue(icCorrigFieldAx)!=''){ var tmp1=icGetPageformValue(icCorrigFieldAx).split("-") icSetPageformValue(icCorrigFieldAyear,tmp1[0]); icSetPageformValue(icCorrigFieldAmonth,parseInt(tmp1[1],10)); icSetPageformValue(icCorrigFieldAday,parseInt(tmp1[2],10)); icSetPageformValue(icCorrigFieldAxyear,icGetPageformValue(icCorrigFieldAyear)+'-'+icGetPageformValue(icCorrigFieldAmonth)); } //departure if(icCorrigFieldBx!=''){ if(icGetPageformValue(icCorrigFieldBx)!=''){ var tmp2=icGetPageformValue(icCorrigFieldBx).split("-") icSetPageformValue(icCorrigFieldByear,tmp2[0]); icSetPageformValue(icCorrigFieldBmonth,parseInt(tmp2[1]),10); icSetPageformValue(icCorrigFieldBday,parseInt(tmp2[2]),10); icSetPageformValue(icCorrigFieldBxyear,icGetPageformValue(icCorrigFieldByear)+'-'+icGetPageformValue(icCorrigFieldBmonth)); } } } //a selectekbol beallitja az input mezot a calendarnak function ic_calendar_set_page_dates_step_2(){ //arrival var tmp1=icGetPageformValue(icCorrigFieldAxyear).split("-"); icSetPageformValue(icCorrigFieldAyear,tmp1[0]); icSetPageformValue(icCorrigFieldAmonth,parseInt(tmp1[1]),10); icSetPageformValue(icCorrigFieldAx,icGetPageformValue(icCorrigFieldAxyear)+'-'+icGetPageformValue(icCorrigFieldAday)); //departure if(icCorrigFieldBx!=''){ var tmp1=icGetPageformValue(icCorrigFieldBxyear).split("-"); icSetPageformValue(icCorrigFieldByear,tmp1[0]); icSetPageformValue(icCorrigFieldBmonth,parseInt(tmp1[1]),10); icSetPageformValue(icCorrigFieldBx,icGetPageformValue(icCorrigFieldBxyear)+'-'+icGetPageformValue(icCorrigFieldBday)); } } function ic_calendar_date_corrig(){ //ha az A kivalasztott datum kisebb, mint ma, akkor korrigaljuk arrtomb=icGetPageformValue(icCorrigFieldAx).split("-"); tmparr=arrtomb[0]; if(arrtomb[1]<10)tmparr+='0'; tmparr+=arrtomb[1]; if(arrtomb[2]<10)tmparr+='0'; tmparr+=arrtomb[2]; if( tmparr < maiDatumString ) { icSetPageformValue(icCorrigFieldAday,maiDay); } if(icCorrigFieldBx!=''){ arrtomb=icGetPageformValue(icCorrigFieldAx).split("-"); tmparr=arrtomb[0]; if(arrtomb[1]<10)tmparr+='0'; tmparr+=arrtomb[1]; if(arrtomb[2]<10)tmparr+='0'; tmparr+=arrtomb[2]; deptomb=icGetPageformValue(icCorrigFieldBx).split("-"); tmpdep=deptomb[0]; if(deptomb[1]<10)tmpdep+='0'; tmpdep+=deptomb[1]; if(deptomb[2]<10)tmpdep+='0'; tmpdep+=deptomb[2]; if(tmpdep<=tmparr){ var indulas=new Date(); indulas.setYear(arrtomb[0]); indulas.setMonth(arrtomb[1]-1); indulas.setDate(arrtomb[2]); indulas.setDate(indulas.getDate()+1); //ha a kovetkezo nap a kovetkezo honap elseje if(indulas.getMonth()!=arrtomb[1]-1){ //nincs kovetkezo nap if(icGetPageformValue(icCorrigFieldAxyear).length==document.forms.pageform[icCorrigFieldBxyear].selectedIndex+1){ icSetPageformValue(icCorrigFieldBxyear,icGetPageformValue(icCorrigFieldAxyear)); icSetPageformValue(icCorrigFieldBday,icGetPageformValue(icCorrigFieldAday)); } else { //kovetkezo honap elso nap ic_calendar_corrig_days_in_month(icCorrigFieldBday,indulas.getYear(),indulas.getMonth()+1); document.forms.pageform[icCorrigFieldBxyear].selectedIndex=document.forms.pageform[icCorrigFieldAxyear].selectedIndex+1; icSetPageformValue(icCorrigFieldBday,'1'); } } else { ic_calendar_corrig_days_in_month(icCorrigFieldBday,indulas.getYear(),indulas.getMonth()+1); icSetPageformValue(icCorrigFieldBxyear,icGetPageformValue(icCorrigFieldAxyear)); icSetPageformValue(icCorrigFieldBday,indulas.getDate()); } } } } function ic_calendar_save_date(){ var datex = new Date(); datex.setTime(datex.getTime()+(600*24*60*60*1000)); with(document.forms.pageform){ setCookie(icCorrigFieldAx,icGetPageformValue(icCorrigFieldAx),datex,'/'); if(icCorrigFieldBx!='')setCookie(icCorrigFieldBx,icGetPageformValue(icCorrigFieldBx),datex,'/'); } } function rrobotGetDate(){ currentDate='2017-11-23'; currentDatex='2017-11-23'; currentDatePlusDay='2017-11-24'; currentDatePlusDayx='2017-11-24'; arr=getCookie(icCorrigFieldAx); if(icCorrigFieldBx!=''){ dep=getCookie(icCorrigFieldBx); if(dep!=null){ //regebbi mint ma+1? tmpdep=ic_calendar_uniform_date(dep); if( tmpdep < currentDatePlusDay ) dep = currentDatePlusDayx; icSetPageformValue(icCorrigFieldBx,dep); //xdeparture.value=dep; } else icSetPageformValue(icCorrigFieldBx,currentDatePlusDayx); } if(arr!=null){ //regebbi mint ma? tmparr=ic_calendar_uniform_date(arr); if( tmparr < currentDate ) arr = currentDatex; icSetPageformValue(icCorrigFieldAx, arr); //xarrival.value=arr; } else icSetPageformValue(icCorrigFieldAx, currentDatex); rrobotSetPageDates(); } function ic_calendar_corrig_days_in_month(f,ev,ho){ ennyinap=ic_calendar_get_days_in_month(ev,ho); elSel=document.getElementById(f); if(elSel.length!=ennyinap){ //elmentjuk a jelenleg kivalasztottat currentNap=elSel.value; //nullazzuk a select ertekeit for(i=elSel.length;i>=0;i--)elSel.remove(i); //feltoltjuk a napok szamaval for(i=1;i<=ennyinap;i++){ newOption=new Option(i, i, false); elSel.options[i-1]=newOption; } //kivalasztjuk az eredetileg kivalasztva volt napot, ha lehet if(currentNap<=ennyinap)elSel.selectedIndex=currentNap-1; //ha nem lehet, akkor kivalasztjuk az utolsot else elSel.selectedIndex=ennyinap-1; } } function ic_calendar_get_days_in_month(year,month) { return [31,((!(year % 4 ) && ( (year % 100 ) || !( year % 400 ) ))?29:28),31,30,31,30,31,31,30,31,30,31][month-1]; } function ic_calendar_uniform_date(x) { if( x == '' ) return ''; var uniformDate=x.split("-"); x = uniformDate[0]+'-'; if(parseInt(uniformDate[1],10)<10)x+='0'; x += uniformDate[1]+'-'; if(parseInt(uniformDate[2],10)<10)x+='0'; x += uniformDate[2]; return x; }