
function emptyDate(el)
{
	//oEl = "id" + el;
	//document.all[oEl].value=""
	toggleCal(el)
}

function putDate(el, m,d,y)
{
	//oEl = "id" + el;
	//document.all[oEl].value=d+"/"+(m+1)+"/"+y
	//toggleCal(el)
	//if (this.station!='') {sid='&sid='+this.station;}
	//if (this.selection!='') {lc='&lc='+this.selection;}
	//document.location.href='default.asp?pid='+this.pageId+'&gid='+this.geoId+sid+'&la='+this.langId+lc+'&nDate='+d+"/"+(m+1)+"/"+y
	
	if(String(d).length==1){d='0'+d}
	m+=1;
	if(String(m).length==1){m='0'+m}
	var dt = String(y)+String(m)+String(d);
	toggleCal(el);
	document.getElementById("currentDateField").innerHTML =d+"/"+m+"/"+y;
	retrieveFrontpage(''+dt+'');
}
function toggleCal(el)
{
	//cal = eval(el + "Cal");
	cal = document.getElementById(el + "Cal");
	cal.style.display=(cal.style.display=="none"?"":"none");
	if(cal.style.display=="")
	{
		redrawCal(this.Month, this.Year, el)
	}
}

function redrawCal(m, y, el)
{
	Month = m;
	Year = y;
	PrevMonth = m-1;
	if(PrevMonth<0)		// ie year changed
	{
		PrevYear = y-1;
		PrevMonth=11;
	}
	else
		PrevYear = y-1;
	NextMonth = m+1;
	if(NextMonth>11)	// ie year changed
	{
		NextYear = y+1;
		NextMonth = 0;
	}
	else
		NextYear = y+1;
	s1=drawCal(el);
	//cal = eval(el+"Cal");
	cal = document.getElementById(el + "Cal");
	cal.innerHTML = s1;
}

function createDateField(sName, Path, Value)
{
	document.write("<span id='" + sName + "Cal' class='Cal' style='position:absolute; z-index:1000; display:none'></span>");
	if(nobreak!=1){
		document.write("<div class=calImg><IMG class=fldDateDown id='" + sName + "Down' onClick=\"toggleCal('" + sName +"')\" title='Click to toggle calendar' src='" + Path + "calendar.gif' width='19' height='20'></div><br><br>");		
	}else{
		document.write("<div class=calImg><IMG class=fldDateDown id='" + sName + "Down' onClick=\"toggleCal('" + sName +"')\" title='Click to toggle calendar' src='" + Path + "calendar.gif' width='19' height='20'></div>");
	}
}


function drawCal(el)
{
s=""
s+="<table border=" + Border + " class=calTable cellpadding=" + Padding + " cellspacing=" + Spacing + " width=" + Width + ">"


s+="<tr class=calTitle >"

s+="<td align=center>"

// Prev Month Nav

monthToLink = PrevMonth;
if(PrevMonth==11)
	yearToLink = PrevYear
else
	yearToLink = Year

if ((monthToLink>=currentMonth-monthsBack && currentMonth!=0 && Year==currentYear) || ( monthToLink>11+currentMonth-monthsBack && Year==currentYear-1 )){
s+= "<a class=calNavLink href='javascript:redrawCal(" + monthToLink
s+="," + yearToLink + ",\"" + el + "\")' title='Previous Month'>"

if(LeftNav=="&lt;")
	s+=LeftNav
else
	s+="<img src='" + ImagePath + LeftNav + "' border=0>"

s+="</a>"
}
s+="</td>"

// Draw month & year
s+="<td colspan=4 align=center nowrap>"

s+=" <a title='Return to current month & year' class='calTitleLink' href='javascript:redrawCal(" + testDate.getMonth() + ","+ testDate.getYear() + ",\"" + el + "\")'>"
if(MonthType==0)
	s+=MonthShortNames[Month]
else
	s+=MonthFullNames[Month]
s+=" " + Year + "</a></td>"

// Next Month Nav

monthToLinkNext = NextMonth;
if(NextMonth==0)
	yearToLink = NextYear
else
	yearToLink = Year
s+="<td align=center>"
if ((monthToLinkNext<=currentMonth && currentMonth!=11 && Year==currentYear) || Year==currentYear-1){
s+="<a class=calNavLink href='javascript:redrawCal(" + monthToLinkNext
s+="," + yearToLink + ",\"" + el +"\")' title='Next Month'>"

if(RightNav=="&gt;")
	s+=RightNav
else
	s+="<img src='" + ImagePath + RightNav + "' border=0>"

s+="</a>";
}
s+="</td>";

// Draw Separator
s+="<td><a class=calNavLink href='javascript:emptyDate(\""+el+"\");'>x</a></td></tr>";


s+="<tr>"
if(DayType==0)	// small names (S,M,T etc)
	for(i=0; i<=6; i++)
		s+="<td class=calDayNames width='14%'>"+DaySmallNames[i]+"</td>"
else
  if(DayType==1)		// Short names (Sun, Mon, Tue, etc.)
	for(i=0; i<=6; i++)
		s+="<td class=calDayNames width='14%'>"+DayShortNames[i]+"</td>"
  else
	for(i=0; i<=6; i++)	// Full names (Sunday, Monday etc)
		s+="<td class=calDayNames width='14%'>"+DayFullNames[i]+"</td>"


currDay = 1
for(i=28; i<=31; i++)
{
	tempDay = new Date(Year, Month, i);
	if (tempDay.getMonth()==Month)
		intLastDay = i;
}

do
{
	s+="<tr>"
	for (i=0; i<=6; i++)
	{
		tempDay = new Date(Year, Month, currDay)
		if (tempDay.getDay()==i && tempDay.getMonth()==Month)
		{
			s+="<td class=calDay valign=top>"
			if(Month != currentMonth || (Month == currentMonth && currDay<=Value)){
				s+="<a href='javascript:putDate(\"" + el +"\"," + Month + "," + currDay + "," + Year + ")' class=calDayLink>"
			}
			s+=currDay
			if(Month != currentMonth || (Month == currentMonth && currDay<=Value)){
				s+="</a>"
			}
			s+="</td>"
			
			currDay = currDay + 1
			if(!Date(Month + "/" + currDay + "/" + Year))
				break;
		}
		else
			s+="<td class=calBlank>&nbsp;</td>"
	}
	tempDay2 = new Date(NextYear, NextMonth, 1)
	d = tempDay2.getDay()
	if (!Date(Month + "/" + currDay + "/" + Year) && d==1)
		for(j=d; j<=6; j++)
			s+="<td class=calBlank>&nbsp;</td>"

	s+="</tr>"
}
while (currDay < intLastDay+1)
return(s)
}

function DateField(n,b,p,s,w,v,l,r,mt,dt,ip, br, back)
{
	testDate=new Date();
	Month=testDate.getMonth();
	Year=testDate.getFullYear();
	currentMonth = Month;
	currentYear = Year;
	monthsBack=back;
	var PrevYear;
	var PrevMonth;
	var NextYear;
	var NextMonth;
	
	Name=n;
	Border=b;
	Padding=p;
	Spacing=s;
	Width=w;
	Value=v;
	LeftNav=l;
	RightNav=r;
	MonthType=mt;	// 0: short, 1: long
	DayType=dt;		// 0: small, 1: short, 2: long
	ImagePath=ip;
	nobreak = br;
		
		
	MonthShortNames = new Array("Ιαν", "Φεβ", "Μαρ", "Απρ", "Μάιος", "Ιουν", "Ιουλ", "Αυγ", "Σεπ", "Οκτ", "Νοε", "Δεκ");
	MonthFullNames =  new Array("Ιανουάριος", "Φεβρουάριος", "Μάρτιος", "Απρίλιος", "Μάιος", "Ιούνιος", "Ιούλιος", "Αύγουστος", "Σεπτέμβριος", "Οκτώβριος", "Νοέμβριος", "Δεκέμβριος");
	DaySmallNames = new Array("Κ", "Δ", "Τ", "Τ", "Π", "Π", "Σ");
	DayShortNames = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
	DayFullNames =  new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");

	this.drawCal=drawCal;
	this.redrawCal=redrawCal;
	this.toggleCal=toggleCal;
	this.putDate=putDate;
	this.createDateField=createDateField;
	
	createDateField(Name, ImagePath, Value);
	
}
