<!--
//created 27/1/2005
//Author Fragoulopoulos Andreas for TANEA Web site

//Javascript 1.2

function check_photos()
{
  url_str = "http://"+location.host;
  ln = url_str.length;
  for(i=0; i<document.images.length; i++) {

     if (document.images[i].width > 654 && document.images[i].src.substring(0,ln+7) == url_str+"/data/D") {
     
        logos = 654/document.images[i].width;
        document.images[i].width = document.images[i].width*logos;
        document.images[i].height = document.images[i].height*logos;
     }
  }
}

function showpage(pg)
{ 
  document.SearchForm.curpage.value = pg;
  document.SearchForm.submit();
}


function copy_fields(tmpForm, SearchForm)
{
   if (tmpForm['code']) {
      SearchForm['code'].value = tmpForm['code'].value;
      SearchForm['title'].value = tmpForm['title'].value;
      SearchForm['tmhma'].value = tmpForm['tmhma'].options[tmpForm['tmhma'].selectedIndex].value;
   }
   SearchForm['author'].value = tmpForm['author'].value;
   SearchForm['freetext'].value = tmpForm['freetext'].value;
   
   SearchForm['period'].value = tmpForm['period'].value;
     if (SearchForm['period'].value == '0')
     {
         SearchForm['datefrom'].value = tmpForm['DD1'].value+'/'+tmpForm['MM1'].value+'/'+tmpForm['YYYY1'].value;
         SearchForm['dateto'].value = tmpForm['DD2'].value+'/'+tmpForm['MM2'].value+'/'+tmpForm['YYYY2'].value;
     }
   SearchForm.submit();  
}


//CALENDAR FUNCTIONS

var day_num = new Array("01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31");
var month_num = new Array("01","02","03","04","05","06","07","08","09","10","11","12");
var months = new Array("Ιανουαρίου", "Φεβρουαρίου", "Μαρτίου", "Απριλίου", "Μαϊου",  "Ιουνίου",
                     "Ιουλίου", "Αυγούστου", "Σεπτεμβρίου", "Οκτωβρίου","Νοεμβρίου", "Δεκεμβρίου");



function leapYear(year)
{
   if (((year % 4 == 0) && year % 100 != 0) || year % 400 == 0) {
      return true;
   }
   return false;
}

function num_of_Days_In(month,year)
{

   if (month == 3 || month == 5 || month == 8 || month == 10) return 30;
   else if ((month == 1) && leapYear(year)) return 29;
   else if (month == 1) return 28;
   else return 31;
}

function changeDays(change_flag, date_form, elm_num)
{ 
  if(date_form.period)
      date_form.period.selectedIndex = date_form.period.options.length-1;
 
  dd = eval(date_form.elements["DD"+elm_num]);
  mm = eval(date_form.elements["MM"+elm_num]);
  yyyy = eval(date_form.elements["YYYY"+elm_num]);
  
  month = mm.selectedIndex;
  year = yyyy.options[yyyy.selectedIndex].value;

// the numb serves as a Day change flag so we won't calculate the num_of_Days_In(month,year) again
  if (change_flag)
  {
    numofDays = num_of_Days_In(month,year);
    dd.options.length = numofDays;

    for (i=27; i<numofDays; i++)
    {
       dd.options[i].text = day_num[i];
       dd.options[i].value = day_num[i];
    }
  }
}

function str_to_date(indate) //format DD/MM/YYYY returns date object
{
  var tmp_arr = new Array();
  tmp_arr = indate.split("/");
  dd = parseInt(tmp_arr[0]);
  mm = parseInt(tmp_arr[1]);
  yyyy = parseInt(tmp_arr[2]);
  newdate = new Date(yyyy, mm-1, dd);
  return newdate;
}

function setDateElm(elm, newdate, date_form)
{
  dd = eval(date_form.elements["DD"+elm]);
  mm = eval(date_form.elements["MM"+elm]);
  yyyy = eval(date_form.elements["YYYY"+elm]);

  year_str = newdate.getFullYear();
  month_str = newdate.getMonth();
  
  for  (i=0; i<yyyy.options.length; i++) {
       if (yyyy.options[i].value == year_str) {
          yyyy.selectedIndex = i;
       }
  }
  mm.selectedIndex = month_str;
  numofDays = num_of_Days_In( month_str, year_str);

  dd.options.length = numofDays;

  for (i=27; i<numofDays; i++)
  {
     dd.options[i].text = day_num[i];
     dd.options[i].value = day_num[i];
  }
  dd.selectedIndex = newdate.getDate() - 1;
  
}


function SetDates(mindate, maxdate, frm)
{
  elm = frm.elements["period"];
  diff = elm.options[elm.selectedIndex].value;

  max_date_obj = str_to_date(maxdate);
  min_date_obj = str_to_date(mindate);

  if (diff > 0) {
     min_date_obj = new Date();
     min_date_obj.setDate(max_date_obj.getDate()-(diff-1));
  }
    
  setDateElm(1, min_date_obj, frm);
  setDateElm(2, max_date_obj, frm);

}

//--> 
