// This date is used throughout to determine today's date.

    var scwDateNow = new Date(Date.parse(new Date().toDateString()));

//------------------------------------------------------------------------------
// Customisation section
//------------------------------------------------------------------------------

    // Set the date format
    //var scwShortDateFormat = "d/M/yyyy"; //European 
    //var scwShortDateFormat = "M/d/yyyy"; //American 
    
    // Set the bounds for the calendar here...
    // If you want the year to roll forward you can use something like this...
    //      var scwBaseYear = scwDateNow.getFullYear()-5;
    // alternatively, hard code a date like this...
    //      var scwBaseYear = 1990;

    var scwBaseYear        = scwDateNow.getFullYear();

    // How many years do want to be valid and to show in the drop-down list?

    var scwPastYears;
    var scwDropDownYears;
    try
    {
        scwDropDownYears = ASPscwDropDownYears;
        scwPastYears = ASPscwPastYears;
    }
    catch(e)
    {
        scwDropDownYears= 2;
        scwPastYears = 0;
    }
    
    scwBaseYear = scwBaseYear - scwPastYears;

    // All language dependent changes can be made here...

    var scwToday               = 'Today:',
        scwInvalidDateMsg      = 'The entered date is invalid.\n',
        scwOutOfRangeMsg       = 'The entered date is out of range.',
        scwDoesNotExistMsg     = 'The entered date does not exist.',
        scwInvalidAlert        = ['Invalid date (',') ignored.'],
        scwDateDisablingError  = ['Error ',' is not a Date object.'],
        scwRangeDisablingError = ['Error ',' should consist of two elements.'];         
    var scwArrWeekInits,scwArrMonthNames;  
    var Prefix;
  
    try{
        Prefix=ASPPrefix;scwShortDatePattern=ASPscwShortDatePattern;scwArrWeekInits=ASPscwArrWeekInits;scwArrMonthNames=ASPscwArrMonthNames;
    }
    catch(e){
        Prefix="Default_";scwShortDatePattern="d/M/yyy";scwArrWeekInits = ['S','M','T','W','T','F','S'];scwArrMonthNames = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];            
    }

    var scwWeekStart       =    1;
    // Set the allowed date delimiters here...
    // E.g. To set the rising slash, hyphen, full-stop (aka stop or point)
    //      and comma as delimiters use
    //              var scwArrDelimiters   = ['/','-','.',','];
    var scwArrDelimiters   = ['/','-','.',','];
    var scwZindex          = 1;
    var scwBlnStrict       = false;
    var scwEnabledDay      = [true, true, true, true, true, true, true,true, true, true, true, true, true, true,true, true, true, true, true, true, true,true, true, true, true, true, true, true, true, true, true, true, true, true, true,true, true, true, true, true, true, true];
    var scwDisabledDates   = new Array();
    var scwActiveToday = true;
    var scwOutOfRangeDisable = true;
    var scwClickToHide = false;
    var scwAllowPastSelection = true;
    
    try{
        scwAllowPastSelection=ASPscwAllowPastSelection;
    }
    catch(e){
        scwAllowPastSelection=false;
    }

    // Blend the colours into your page here...
    var scwHighlightText,scwHighlightBackground,scwWeekendBackground,scwWeekendText;
    var scwExMonthText,scwExMonthBackground,scwCellText,scwCellBackground,scwTodayBorder;
    var scwInDateText,scwInDateBackground,scwDisabledDayText,scwDisabledDayBackground,scwWeekBackground;
   
   //Use default color in case that ASP.NET has not register the appropriate scripts correctly   
    try
    {  
        scwHighlightText = ASPscwHighlightText;scwHighlightBackground = ASPscwHighlightBackground;        
        scwWeekendText = ASPscwWeekendText;scwWeekendBackground = ASPscwWeekendBackground;
        scwExMonthText = ASPscwExMonthText;scwExMonthBackground = ASPscwExMonthBackground;        
        scwCellText = ASPscwCellText;scwCellBackground= ASPscwCellBackground;scwWeekBackground=ASPscwWeekBackground;
        scwInDateText = ASPscwCellText;scwInDateBackground = ASPscwInDateBackground;scwTodayBorder=ASPscwTodayBorder;
        scwDisabledDayText = ASPscwDisabledDayText;scwDisabledDayBackground = ASPscwDisabledDayBackground;        
    }
    catch(e)
    {        
        scwHighlightText = '#013369';scwHighlightBackground = '#FFB01C';
        scwWeekendText = '#013369';scwWeekendBackground = '#CDE5FD';scwExMonthText = '#999999';
        scwExMonthBackground = '#CCCCCC';scwCellText = '#013369';scwCellBackground= '#CDE5FD';
        scwInDateText = '#FFFFFF';scwInDateBackground = '#FFB01C';scwDisabledDayText = '#993333';
        scwDisabledDayBackground = '#D0D0D0',scwWeekBackground='#F1F5FA',scwTodayBorder='#999999';
    }    


    function scwInputFormat(scwArrInput,scwEleValue)
        {var scwArrSeed = new Array();

         scwBlnFullInputDate = false;

         switch (scwArrInput.length)
            {case 1:
                {// Year only entry
                 scwArrSeed[0] = parseInt(scwArrInput[0],10);   // Year
                 scwArrSeed[1] = '6';                           // Month
                 scwArrSeed[2] = 1;                             // Day
                 break;
                }
             case 2:
                {// Year and Month entry
                 scwArrSeed[0] = parseInt(scwArrInput[1],10);   // Year
                 scwArrSeed[1] = scwArrInput[0];                // Month
                 scwArrSeed[2] = 1;                             // Day
                 break;
                }
             case 3:
                {
                    //alert("scwInputFormat");
                    if(scwShortDatePattern=="M/d/yyyy")
                    {
                        // for Month, Day and Year entry use...
                        scwArrSeed[0] = parseInt(scwArrInput[2],10);  // Year
                        scwArrSeed[1] = scwArrInput[0];               // Month
                        scwArrSeed[2] = parseInt(scwArrInput[1],10);  // Day
                    }
                    else
                    {
                        // Day Month and Year entry
                        scwArrSeed[0] = parseInt(scwArrInput[2],10);   // Year
                        scwArrSeed[1] = scwArrInput[1];                // Month
                        scwArrSeed[2] = parseInt(scwArrInput[0],10);   // Day
                    }

                    scwBlnFullInputDate = true;
                 break;
                }
             default:
                {// A stuff-up has led to more than three elements in the date.
                 scwArrSeed[0] = 0;     // Year
                 scwArrSeed[1] = 0;     // Month
                 scwArrSeed[2] = 0;     // Day
                }
            }

         // Apply validation and report failures

         if (scwExpValYear.exec(scwArrSeed[0])  == null ||
             scwExpValMonth.exec(scwArrSeed[1]) == null ||
             scwExpValDay.exec(scwArrSeed[2])   == null)
             {alert(scwInvalidDateMsg  +
                    scwInvalidAlert[0] + scwEleValue + scwInvalidAlert[1]);
              scwBlnFullInputDate = false;
              scwArrSeed[0] = scwBaseYear + Math.floor(scwDropDownYears/2); // Year
              scwArrSeed[1] = '6';     // Month 
              scwArrSeed[2] = 1;       // Day
             }
         return scwArrSeed;
        }

    function scwDisplayFormat(scwDisplayDate) 
        {// The format of the display of today's date at the foot of the
         // calendar...
         

            //alert("scwDisplayFormat");
            if(scwShortDatePattern=="M/d/yyyy")
            {
                // for Month, Day and Year output use...
                document.write(scwDisplayDate.getMonth() + '-' +
                    scwDisplayDate.getDate() + '-' +
                    scwDisplayDate.getFullYear()
                    );
            }
            else
            {
                // Day Month and Year display 
                document.write(scwDisplayDate.getDate() + '/' +
                            scwDisplayDate.getMonth() + '/' +
                            scwDisplayDate.getFullYear()
                           ); 
            }
        }
        
function DateAdd(timeU,byMany,dateObj) {
	var millisecond=1;
	var second=millisecond*1000;
	var minute=second*60;
	var hour=minute*60;
	var day=hour*24;
	var year=day*365;

	var newDate;
	var dVal=dateObj.valueOf();
	switch(timeU) {
		case "ms": newDate=new Date(dVal+millisecond*byMany); break;
		case "s": newDate=new Date(dVal+second*byMany); break;
		case "mi": newDate=new Date(dVal+minute*byMany); break;
		case "h": newDate=new Date(dVal+hour*byMany); break;
		case "d": newDate=new Date(dVal+day*byMany); break;
		case "y": newDate=new Date(dVal+year*byMany); break;
	}
	return newDate;
}

function scwFireEvent(element,event)
{
    if (document.createEventObject){
        // dispatch for IE
        var evt = document.createEventObject();
        return element.fireEvent('on'+event,evt)
    }
    else{
        // dispatch for firefox + others
        var evt = document.createEvent("HTMLEvents");
        evt.initEvent(event, true, true ); // event type,bubbling,cancelable
        return !element.dispatchEvent(evt);
    }
}

function scwSetOutput(scwOutputDate)
{
    var new_value;
    var old_value; 
    old_value = scwTargetEle.value;
    if(scwShortDatePattern=="M/d/yyyy")
    {
        new_value = (scwOutputDate.getMonth()+1) + '/' + scwOutputDate.getDate() + '/' + scwOutputDate.getFullYear();
    }
    else
    { 	
        new_value = scwOutputDate.getDate() + '/' + (scwOutputDate.getMonth()+1) + '/' + scwOutputDate.getFullYear();
    }  
    scwTargetEle.value = new_value;
   
    
    //var fD;var datesForward=1;var tD;try{fD=ASPfD;tD=ASPtD;datesForward=ASPdatesForward;}catch(e){}  
    if(LinkedCalendards)
    {
        for (i in LinkedCalendards)
        {
            if(scwTargetEle.id==i)
            {
                var targ = document.getElementById(LinkedCalendards[i][1]);
                if(targ)
                {
                    var els = targ.getElementsByTagName('INPUT');
                    if(els.length>0)
                    {
                        var step;
                        step = parseInt(LinkedCalendards[i][0],10);
                        var OutTomor = DateAdd("d",step,scwOutputDate);
                        if(scwShortDatePattern=="M/d/yyyy")
                        {
                            els[0].value = (OutTomor.getMonth()+1) + '/' + OutTomor.getDate() + '/' + OutTomor.getFullYear();
                        }
                        else{ 	
                            els[0].value = OutTomor.getDate() + '/' + (OutTomor.getMonth()+1) + '/' + OutTomor.getFullYear();
                        }
                    }
                }
                break;
            }            
        }
    }    
    
    //######################Fire the on change event
    if(old_value!=new_value)
    {
        try
        {
           scwFireEvent(scwTargetEle,"change");
        }catch(e){}        
    }
     //######################Fire the on change event - END
    
    scwHide();
}

// End of customisation section
    var scwTargetEle,
        scwSaveText,
        scwSaveBackground,
        scwMonthSum         = 0,
        scwBlnFullInputDate = false,
        scwStartDate        = new Date(),
        scwSeedDate         = new Date(),
        scwWeekStart        = scwWeekStart%7;
    var scwExpDelimiters    = new RegExp('[\\'+scwArrDelimiters.join('\\')+']','g');
    var scwExpValDay    = /^(0?[1-9]|[1-2]\d|3[0-1])$/,
        scwExpValMonth  = new RegExp("^(0?[1-9]|1[0-2]|"        +
                                     scwArrMonthNames.join("|") +
                                     ")$","i"),
        scwExpValYear   = /^(\d{1,2}|\d{4})$/;

    function showCal(scwEle,scwSourceEle)    {scwShow(scwEle,scwSourceEle);}    
    function scwShow(scwEle,scwSourceEle)
        {
         scwSeedDate = scwDateNow;
         scwEle.value = scwEle.value.replace(/^\s+/,'').replace(/\s+$/,'');

         if (scwEle.value.length==0)
            {
             scwBlnFullInputDate=false;
             if ((new Date(scwBaseYear+scwDropDownYears-1,11,31))<scwSeedDate ||
                 (new Date(scwBaseYear,0,1))                     >scwSeedDate
                )
                {scwSeedDate = new Date(scwBaseYear +
                                        Math.floor(scwDropDownYears / 2), 5, 1);
                }
            }
         else
            {
             scwArrSeedDate =
                 scwInputFormat(scwEle.value.split(scwExpDelimiters),
                                scwEle.value);
             if (scwArrSeedDate[0]<100)
                scwArrSeedDate[0] += (scwArrSeedDate[0]>50)?1900:2000;

             if (scwArrSeedDate[1].search(/\d+/)!=0)
                {month = scwArrMonthNames.join('|').toUpperCase().
                            search(scwArrSeedDate[1].substr(0,3).toUpperCase());
                 scwArrSeedDate[1] = Math.floor(month/4)+1;
                }

             scwSeedDate = new Date(scwArrSeedDate[0],scwArrSeedDate[1]-1,scwArrSeedDate[2]);
            }
         if (isNaN(scwSeedDate))
            {alert( scwInvalidDateMsg +
                    scwInvalidAlert[0] + scwEle.value +
                    scwInvalidAlert[1]);
             scwSeedDate = new Date(scwBaseYear +
                    Math.floor(scwDropDownYears/2),5,1);
             scwBlnFullInputDate=false;
            }
         else
            {
             if ((new Date(scwBaseYear,0,1)) > scwSeedDate)
                {if (scwBlnStrict) alert(scwOutOfRangeMsg);
                 scwSeedDate = new Date(scwBaseYear,0,1);
                 scwBlnFullInputDate=false;
                }
             else
                {if ((new Date(scwBaseYear+scwDropDownYears-1,11,31))<scwSeedDate)
                    {if (scwBlnStrict) alert(scwOutOfRangeMsg);
                     scwSeedDate = new Date(scwBaseYear + Math.floor(scwDropDownYears)-1,11,1);
                     scwBlnFullInputDate=false;
                    }
                 else
                    {if (scwBlnStrict && scwBlnFullInputDate &&
                          (scwSeedDate.getDate()      != scwArrSeedDate[2] ||
                           (scwSeedDate.getMonth()+1) != scwArrSeedDate[1] ||
                           scwSeedDate.getFullYear()  != scwArrSeedDate[0])
                        )
                        {alert(scwDoesNotExistMsg);
                         scwSeedDate = new Date(scwSeedDate.getFullYear(),scwSeedDate.getMonth()-1,1);
                         scwBlnFullInputDate=false;
                        }
                    }
                }
            }

         for (var i=0;i<scwDisabledDates.length;i++)
            {if (!((typeof scwDisabledDates[i]      == 'object') &&
                   (scwDisabledDates[i].constructor == Date)))
                {if ((typeof scwDisabledDates[i]      == 'object') &&
                     (scwDisabledDates[i].constructor == Array))
                    {var scwPass = true;

                     if (scwDisabledDates[i].length !=2)
                        {alert(scwRangeDisablingError[0] + scwDisabledDates[i] + scwRangeDisablingError[1]);
                         scwPass = false;
                        }
                     else
                        {for (var j=0;j<scwDisabledDates[i].length;j++)
                            {if (!((typeof scwDisabledDates[i][j]      == 'object') &&
                                   (scwDisabledDates[i][j].constructor == Date)))
                                {alert(scwDateDisablingError[0] + scwDisabledDates[i][j] +
                                       scwDateDisablingError[1]);
                                 scwPass = false;
                                }
                            }
                        }

                     if (scwPass && (scwDisabledDates[i][0] > scwDisabledDates[i][1]))
                        {scwDisabledDates[i].reverse();}
                    }
                 else
                    {alert(scwDateDisablingError[0] + scwDisabledDates[i] +
                           scwDateDisablingError[1]);}
                }
            }
         
         scwMonthSum =  12*(scwSeedDate.getFullYear()-scwBaseYear)+
                            scwSeedDate.getMonth();         
         document.getElementById('scwYears').options.selectedIndex =
            Math.floor(scwMonthSum/12);
         
         document.getElementById('scwMonths').options.selectedIndex=
            (scwMonthSum%12);

         // Position the calendar box


         var offsetTop = parseInt(scwEle.offsetTop ,10) +
                          parseInt(scwEle.offsetHeight,10),
             offsetLeft = parseInt(scwEle.offsetLeft,10);

         scwTargetEle=scwEle;

        try
        {
            do 
            {
             scwEle=scwEle.offsetParent;
             offsetTop +=parseInt(scwEle.offsetTop,10);
             offsetLeft+=parseInt(scwEle.offsetLeft,10);
            }
            while (scwEle.tagName!='BODY');
        }
        catch(e){}        

         document.getElementById('scw').style.top =offsetTop +'px';
         document.getElementById('scw').style.left=offsetLeft+'px';
         if (document.getElementById('scwIframe'))
            {
                document.getElementById('scwIframe').style.top=offsetTop +'px';
                document.getElementById('scwIframe').style.left=offsetLeft+'px';
                document.getElementById('scwIframe').style.width=(document.getElementById('scw').offsetWidth-2)+'px';                
                document.getElementById('scwIframe').style.height=(document.getElementById('scw').offsetHeight-2)+'px';                
                //document.getElementById('scwIframe').style.display='';
                document.getElementById('scwIframe').style.visibility='visible';             
            }

         scwShowMonth(0);
         //document.getElementById('scw').style.display='';
         document.getElementById('scw').style.visibility='visible';
        document.getElementById('scwMonths').style.visibility='visible';  
        document.getElementById('scwYears').style.visibility='visible';    
         
         scwCancelPropagation(scwSourceEle);
        }

    function scwCellOutput(scwEvt)
    {
        var scwEle = eventTrigger(scwEvt),scwOutputDate = new Date(scwStartDate);
        if (scwEle.nodeType==3) scwEle=scwEle.parentNode;
        scwOutputDate.setDate(scwStartDate.getDate() + parseInt(scwEle.id.substr(8),10));
        scwSetOutput(scwOutputDate);
    }

function scwCancelPropagation(scwSourceEle)
{
    if (typeof event=='undefined')
    {
        try{
        scwSourceEle.parentNode.addEventListener("click",scwStopPropagation,false);
        }catch(e){}
    }
    else   
    {
        try{event.cancelBubble = true;}catch(e){}
    }
}

function scwStopPropagation(scwEvt)
{
    if (typeof event=='undefined')
        scwEvt.stopPropagation();
    else 
        scwEvt.cancelBubble = true;
}

function scwHighlight(e)
{
    var scwEle = eventTrigger(e);
    if (scwEle.nodeType==3) scwEle=scwEle.parentNode;
    scwSaveText=scwEle.style.color;
    scwSaveBackground=scwEle.style.backgroundColor;
    scwEle.style.color=scwHighlightText;
    scwEle.style.backgroundColor=scwHighlightBackground;
    return true;
}

function scwUnhighlight(e)
{
    var scwEle = eventTrigger(e);
    if (scwEle.nodeType==3) scwEle =scwEle.parentNode;
    scwEle.style.backgroundColor =scwSaveBackground;
    scwEle.style.color=scwSaveText;
    return true;
}
function eventTrigger(e)
{
    if (!e) e = event;
    return e.target||e.srcElement;
}

function scwCancel(e)
{
    if (scwClickToHide) scwHide();
    scwStopPropagation(e);
}

function scwHide()
{
    //document.getElementById('scw').style.display='none';
    document.getElementById('scw').style.visibility='hidden';   
    document.getElementById('scwMonths').style.visibility='hidden';  
    document.getElementById('scwYears').style.visibility='hidden';        
    if (document.getElementById('scwIframe'))
    {
        //document.getElementById('scwIframe').style.display='none';
        document.getElementById('scwIframe').style.visibility='hidden';        
    }
}

function scwShowMonth(scwBias)
{
    var TsoukiDate = new Date();
    var scwShowDate  = new Date(Date.parse(new Date().toDateString()));
    scwSelYears  = document.getElementById('scwYears');
    scwSelMonths = document.getElementById('scwMonths');
    if (scwSelYears.options.selectedIndex>-1)
    {
        scwMonthSum=12*(scwSelYears.options.selectedIndex)+scwBias;
        if (scwSelMonths.options.selectedIndex>-1)
        {
            scwMonthSum+=scwSelMonths.options.selectedIndex;
        }
    }
    else
    {
        if (scwSelMonths.options.selectedIndex>-1)
        {
            scwMonthSum+=scwSelMonths.options.selectedIndex;
        }
    }

    scwShowDate.setFullYear(scwBaseYear + Math.floor(scwMonthSum/12),
                         (scwMonthSum%12),1);

    if ((12*parseInt((scwShowDate.getFullYear()-scwBaseYear),10)) +
     parseInt(scwShowDate.getMonth(),10) < (12*scwDropDownYears)    &&
     (12*parseInt((scwShowDate.getFullYear()-scwBaseYear),10)) +
     parseInt(scwShowDate.getMonth(),10) > -1)
    {
        scwSelYears.options.selectedIndex=Math.floor(scwMonthSum/12);
        scwSelMonths.options.selectedIndex=(scwMonthSum%12);
        scwCurMonth = scwShowDate.getMonth();
        scwShowDate.setDate((((scwShowDate.getDay()-scwWeekStart)<0)?-6:1) + scwWeekStart-scwShowDate.getDay());
        scwStartDate = new Date(scwShowDate);

        var scwCells = document.getElementById('scwCells');

        for (i=0;i<scwCells.childNodes.length;i++)
        {
            var scwRows = scwCells.childNodes[i];
            if (scwRows.nodeType==1 && scwRows.tagName=='TR')
            {
                for (j=0;j<scwRows.childNodes.length;j++)
                {
                    var scwCols = scwRows.childNodes[j];
                    if (scwCols.nodeType==1 && scwCols.tagName=='TD')
                    {
                        scwRows.childNodes[j].innerHTML=scwShowDate.getDate();

                        var scwCellStyle=scwRows.childNodes[j].style,
                         scwDisabled = (scwOutOfRangeDisable &&
                                         (scwShowDate < (new Date(scwBaseYear,0,1)) ||
                                          scwShowDate > (new Date(scwBaseYear+scwDropDownYears-1,11,31))
                                         ))?true:false;

                        for (var k=0;k<scwDisabledDates.length;k++) 
                        {
                            if ((typeof scwDisabledDates[k] == 'object')  &&
                             (scwDisabledDates[k].constructor == Date) &&
                             scwShowDate.valueOf() == scwDisabledDates[k].valueOf())
                            {
                                scwDisabled = true;
                            }
                            else
                            {
                                if ((typeof scwDisabledDates[k] == 'object') &&
                                     (scwDisabledDates[k].constructor == Array) &&
                                     scwShowDate.valueOf() >= scwDisabledDates[k][0].valueOf() &&
                                     scwShowDate.valueOf() <= scwDisabledDates[k][1].valueOf())
                                {
                                    scwDisabled = true;
                                }
                            }
                        }                        

                        if (scwDisabled || !scwEnabledDay[j+(7*((i*scwCells.childNodes.length)/6))]) 
                        {
                            //alert(scwShowDate + " 1");
                            scwRows.childNodes[j].onclick     =null;
                            scwRows.childNodes[j].onmouseover =null;
                            scwRows.childNodes[j].onmouseout  =null;
                            scwRows.childNodes[j].style.cursor='default';
                            scwCellStyle.color = scwDisabledDayText;
                            scwCellStyle.backgroundColor= scwDisabledDayBackground;
                        }
                        else
                        {
                            if(TsoukiDate.toDateString()==scwShowDate.toDateString())
                            {
                                scwCellStyle.border='1px solid ' + scwTodayBorder;
                            }     
                            else
                            {
                                scwCellStyle.border='none';
                            } 
                            scwRows.childNodes[j].onclick      = scwCellOutput;
                            scwRows.childNodes[j].onmouseover  = scwHighlight;
                            scwRows.childNodes[j].onmouseout   = scwUnhighlight;
                            scwRows.childNodes[j].style.cursor = (document.getElementById('scwIframe'))?'hand':'pointer';                                                                 
                        
                            
                            if (scwShowDate.getMonth()!=scwCurMonth)
                            {        
                                //Diaforetikos minas apo afton pou deixnei to calendar                        
                                //alert(scwShowDate + " 2");
                                if(TsoukiDate>scwShowDate)
                                {
                                    if(!scwAllowPastSelection)
                                    {
                                        scwRows.childNodes[j].onclick=null;
                                        scwRows.childNodes[j].style.cursor='default';
                                    }
                                    else
                                    {
                                        scwRows.childNodes[j].onclick=scwCellOutput;
                                        scwRows.childNodes[j].style.cursor='pointer';
                                    }                                    
                                }
                                else
                                {
                                    scwRows.childNodes[j].onclick =scwCellOutput;
                                    scwRows.childNodes[j].style.cursor='pointer';
                                }
                                scwRows.childNodes[j].onmouseover =null;
                                scwRows.childNodes[j].onmouseout  =null;
                                
                                scwCellStyle.color=scwExMonthText;
                                scwCellStyle.backgroundColor=scwExMonthBackground;
                            }
                            else if (scwBlnFullInputDate &&
                                  scwShowDate.toDateString()==
                                  scwSeedDate.toDateString())
                            {
                                //Epilegmeni imerominia  
                                if(TsoukiDate>scwShowDate && TsoukiDate.toDateString()!=scwShowDate.toDateString())
                                {     
                                    //An h hmerominia pou fortvnoume einai sto parelthon   
                                    scwRows.childNodes[j].onclick     = scwCellOutput;
                                    scwRows.childNodes[j].onmouseover = null;
                                    scwRows.childNodes[j].onmouseout  = null;
                                    scwRows.childNodes[j].style.cursor='default';
                                    scwCellStyle.color=scwInDateText;
                                    scwCellStyle.backgroundColor=scwInDateBackground;
                                }
                                else
                                {
                                    //An h hmerominia pou fortvnoume einai sto mellon   
                                    scwCellStyle.color=scwInDateText;
                                    scwCellStyle.backgroundColor=scwInDateBackground;
                                } 
                            }
                            else if (scwShowDate.getDay()%6==0)
                            {
                                //An einai Kiriaki tou idiou mina                                
                                if(TsoukiDate>scwShowDate && 
                                    TsoukiDate.toDateString()!= scwShowDate.toDateString())
                                {
                                    //An h hmerominia pou fortvnoume einai sto parelthon 
                                    
                                    //alert(scwShowDate + " 4");
                                    
                                    if(!scwAllowPastSelection)
                                    {
                                        scwRows.childNodes[j].onclick=null;
                                        scwRows.childNodes[j].style.cursor='default';
                                    }
                                    else
                                    {
                                        scwRows.childNodes[j].onclick=scwCellOutput;
                                        scwRows.childNodes[j].style.cursor='pointer';
                                    }
                              
                                    scwRows.childNodes[j].onmouseover =null;
                                    scwRows.childNodes[j].onmouseout  =null;                                  
                                    scwCellStyle.color = scwExMonthText;
                                    scwCellStyle.backgroundColor=scwExMonthBackground;
                                }
                                else
                                {
                                    //An h hmerominia pou fortvnoume einai sto mellon  
                                    scwCellStyle.color=scwWeekendText;
                                    scwCellStyle.backgroundColor=scwWeekendBackground;
                                }   
                            }
                            else
                            {
                                //Idios minas me ton trexon tou calendar
                                //Den einai savatokiriako
                                //Den einai h epilegmeni imerominia
                                if(TsoukiDate>scwShowDate && TsoukiDate.toDateString()!=scwShowDate.toDateString())
                                {
                                    //alert(scwShowDate + " 5");
                                    if(!scwAllowPastSelection)
                                    {
                                        scwRows.childNodes[j].onclick=null;
                                        scwRows.childNodes[j].style.cursor='default';
                                    }
                                    else
                                    {
                                        scwRows.childNodes[j].onclick=scwCellOutput;
                                        scwRows.childNodes[j].style.cursor='pointer';
                                    }                
                                    scwRows.childNodes[j].onmouseover =null;
                                    scwRows.childNodes[j].onmouseout  =null;                            
                                    scwCellStyle.color=scwExMonthText;
                                    scwCellStyle.backgroundColor=scwExMonthBackground;
                                }
                                else
                                {
                                    //An h hmerominia pou fortvnoume einai sto mellon  
                                    scwCellStyle.color=scwCellText;
                                    scwCellStyle.backgroundColor=scwCellBackground;
                                }
                            }                            
                                          
                        }
                        scwShowDate.setDate(scwShowDate.getDate()+1);
                        }
                    }
                }
            }
        }
    }

    document.write(
     "<!--[if IE]><iframe class='" + Prefix + "scw' src='javascript:false' id='scwIframe' name='scwIframe' frameborder='0'></iframe><![endif]-->" +
     "<table id='scw' class='" + Prefix + "scw'>" +
       "<tr class='" + Prefix + "scw'><td class='" + Prefix + "scw'>" +
           "<table class='" + Prefix + "scwHead' id='scwHead' " +
                    "cellspacing='0' cellpadding='0' width='100%'>" +
            "<tr class='" + Prefix + "scwHead'><td class='" + Prefix + "scwHead'>" +
                    "<input class='" + Prefix + "scwHead' type='button' value='<' onclick='scwShowMonth(-1);' />" + 
                "</td><td class='" + Prefix + "scwHead'><select id='scwMonths' class='" + Prefix + "scwHead' " +
                            "onChange='scwShowMonth(0);'>");

    for (i=0;i<scwArrMonthNames.length;i++)
        document.write("<option>" + scwArrMonthNames[i] + "</option>");
    document.write("</select></td><td class='" + Prefix + "scwHead'>" + 
                    "<select id='scwYears' class='" + Prefix + "scwHead' onChange='scwShowMonth(0);'>");

    for (i=0;i<scwDropDownYears;i++)
        document.write("<option>" + (scwBaseYear+i) + "</option>");

    document.write( "</select></td><td class='" + Prefix + "scwHead'>" +
                    "<input class='" + Prefix + "scwHead' type='button' value='>' onclick='scwShowMonth(1);' /></td>" +
                "</tr></table></td></tr>" +
          "<tr class='" + Prefix + "scw'>" +
            "<td class='" + Prefix + "scw'>" +
              "<table class='" + Prefix + "scwCells' cellpadding='0' cellspacing='0' align='center'>" +
                "<thead class='" + Prefix + "scwWeek'>" +
                  "<tr class='" + Prefix + "scwWeek'>");

    for (i=0;i<scwArrWeekInits.length;i++)
        document.write( "<td class='" + Prefix + "scwWeek' id='scwWeekInit" + i + "'>" +
                          scwArrWeekInits[(i+scwWeekStart)%scwArrWeekInits.length] +
                        "</td>");

    document.write("</tr></thead><tbody class='" + Prefix + "scwCells' id='scwCells'>");

    for (i=0;i<6;i++)
        {document.write("<tr class='" + Prefix + "scwCells'>");
         for (j=0;j<7;j++)
            {document.write("<td class='" + Prefix + "scwCells' id='scwCell_" + (j+(i*7)) + "'></td>");}
            document.write("</tr>");
        }
    document.write("</tbody>"); 
    document.write("</table></td></tr></table>");

    if (document.addEventListener)
        {document.addEventListener('click',scwHide, false);
         document.getElementById('scw').addEventListener('click',scwCancel,false);
         document.getElementById('scwHead').addEventListener('click',scwStopPropagation,false);
         document.getElementById('scwCells').addEventListener('click',scwStopPropagation,false);
        }
    else
        {document.attachEvent('onclick',scwHide);
         document.getElementById('scw').attachEvent('onclick',scwCancel);
         document.getElementById('scwHead').attachEvent('onclick',scwStopPropagation);
         document.getElementById('scwCells').attachEvent('onclick',scwStopPropagation);
        }