<!--
//Created by Andreas Fragoulopoulos
//For Nomos & Fysh website
//16-11-2002

function Submit()
{
 inform = document.forms[0];
 if (trimEdges(inform.freetext.value) != '')
    inform.submit();
}

function isValidEmail(str)
{
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function submitNewsLetter(language)
{
 var complete=true;
  var mailAlert=false;

   if((document.NewsLetter.firstname.value=="") || (document.NewsLetter.firstname.value==null))
    {
		if ( language == 1 )
		{
	    	window.alert("Παρακαλώ συμπληρώστε το Όνομά σας!");
		}
		else
		{
			window.alert("Please fill in your First Name!");
		}
	    complete=false;
	    mailAlert=true;
    }

	if((document.NewsLetter.lastname.value=="") || (document.NewsLetter.lastname.value==null))
	  {
	    if ( mailAlert==false)
		{
		  if ( language == 1 )
		  {
	      	window.alert("Παρακαλώ συμπληρώστε το Επώνυμό σας!");
		  }
		  else
		  {
			window.alert("Please fill in your Last Name!");
	      }
	      mailAlert=true;
		}
		complete=false;
	  }

 if(isValidEmail(document.NewsLetter.email.value)==false)
  {
      if ( mailAlert==false )
       {
	     if ( language == 1 )
		 {
          window.alert("Παρακαλώ συμπληρώστε το E-mail σας!");
		 }
		 else
		 {
		  window.alert("Please fill in you E-mail Address!");
		 }
		  mailAlert=true;
       }
       complete=false;
   }

  return complete;

}


function showpage(pg)
{ 
  inform = document.forms[1];
  inform.curpage.value = pg;
  inform.submit();
}

function showinfo(current,e,txt)
{
   if (document.layers) // Netscape 4.0+
   {
      theString = "<DIV NOWRAP CLASS='ttip'>"+txt+"</DIV>";
      document.info.document.write(theString);
      document.info.document.close();
      document.info.left = e.pageX+5;
      document.info.top = e.pageY+5;
      document.info.visibility = "show";
   }
   else
   {
      if (document.getElementById) // Netscape 6.0+ and Internet Explorer 5.0+
      {
         elm = document.getElementById("info");
//         elmd=document.getElementById(current.id)
         elm.innerHTML = txt;
         if(document.all) // for IE5+ only
         {
            elm.style.pixelTop=(document.body.scrollTop + event.clientY) + 5
            elm.style.pixelLeft=(document.body.scrollLeft + event.clientX) + 5
         }
         else
         {  // NS6 only
            elm.style.top=e.pageY+5
            elm.style.left=e.pageX+5 
         }
         elm.style.visibility = "visible"
      }
   }
}

function hideinfo(){
if (document.layers) // Netscape 4.0+
   {
    document.info.visibility = "hidden";
   }
else
  {
   if(document.getElementById) // Netscape 6.0+ and Internet Explorer 5.0+
     {
      elm = document.getElementById("info");
      elm.style.visibility = "hidden";
     }
  } 
}

function isDigit(val) {
   var digits = "1234567890";
   for (var i=0; i < val.length; i++) {
	if (digits.indexOf(val.charAt(i)) == -1)
	{ return false; }
   }
   return true;
}

function checkdate(dateStr)
{
   var valid = true;
   if (dateStr != '')
   { 
     date_arr = new Array();
     date_arr = dateStr.split('-'); 
     if (date_arr.length < 3)
     {
        alert('Παρακαλούμε εισάγετε την ημερομηνία με τη μορφή ΗΗ-ΜΜ-ΕΤΟΣ ή αφήστε το πεδίο κενό'); 
        valid = false;
     }
   }
   else
       {  valid = false;  }
   
   if (valid)
   {
     for (i=0; i<date_arr.length; i++)
     {
       if (! isDigit(date_arr[i]))
       {  valid = false;  }
       if (i == 0 || i == 1) //day or month
       {
         if (date_arr[i].length < 1 || date_arr[i].length > 2)
            {  valid = false;  }
         else
         {
           if (date_arr[i].length == 1) //make two digit format
             { date_arr[i] = '0'+date_arr[i];  }
         }
       }
       else
       { 
         if (date_arr[i].length != 4)
             { valid = false;  }
       }
     }    
   } 
   
   if (valid)
      return date_arr.join('-');
   else
      return '';
}

function checkSelected(Obj)
{

   var selected = false;
   for (j=0; j<Obj.options.length; j++)  
   {
      if (Obj.options[j].selected == true) 
      {
         selected = true;
         break;
      }
   }
   return (selected);
   
}

function checkEmail(strMail)    {

var intEnd = strMail.length;

  if (intEnd < 5)
      return false;

  if (strMail.indexOf("@") == -1)
      return false;

  if (strMail.indexOf("@") == 0)
      return false;

  if (strMail.indexOf("@") == intEnd-1)
      return false;

  if (strMail.indexOf(".") == -1)
      return false;

  if (strMail.indexOf(".") == 0)
	  return false;

  if (strMail.indexOf(".") == intEnd-1)
      return false;

  return true;
}


function checkdata(inform)
{
  
  if (inform.name == 'Search')
  {
     inform.datefrom.value = checkdate(inform.datefrom.value);
     inform.dateto.value = checkdate(inform.dateto.value);
  
     if (inform.freetext.value == '' && inform.freekey.value == '' &&
         !checkSelected(inform.keyword) && inform.freeauthor.value == '' &&
         !checkSelected(inform.author) && inform.datefrom.value == '' &&
         inform.dateto.value == '')
     {
       return (false); 
     }
     else
     {
       return (true);
     }
  }
 
  else if (inform.name == 'Contact')
  { 
     var errors = '';
  clearSpaces(inform);
     
     if (inform.fullname.value == '')
       { errors += ' - ' + 'το Όνοματεπώνυμο\n'; }
     if (inform.job.value == '')
       { errors += ' - ' + 'το Επάγγελμα\n'; }
     if ((inform.email.value == '') || !(checkEmail(inform.email.value))) 
       { errors += ' - ' + 'το Εmail\n'; }
     if (inform.message.value == '') 
       { errors += ' - ' + 'το Μήνυμα\n'; }
       
     if (errors)
     {
        alert('Παρακαλώ συμπληρώστε :\n' + errors);
        return (false);
     }
     else 
        { return (true); }
  }

 else if (inform.name == 'Review')
 {
     var errors = '';
  clearSpaces(inform);
     
     if (inform.fullname.value == '')
       { errors += ' - ' + 'το Όνοματεπώνυμο\n'; }
     if ((inform.email.value == '') || !(checkEmail(inform.email.value))) 
       { errors += ' - ' + 'το Εmail\n'; }
     if (inform.message.value == '') 
       { errors += ' - ' + 'το Μήνυμα\n'; }
     if (inform.message.value.length >1000) 
       { errors += ' - ' + 'το Μήνυμα πρέπει να είναι μικρότερο από 1000 χαρακτήρες.\n'; }
       
     if (errors)
     {
        alert('Παρακαλώ συμπληρώστε :\n' + errors);
        return (false);
     }
     else 
        { return (true); }
 }
}


function Clear(inform, Obj_name)
{
   for(i=0; i<inform.length; i++) 
   {  
      var Obj = inform.elements[i];
      if (Obj.name == Obj_name)
      {
         if (Obj.type == 'text' || Obj.type == 'textarea') 
         {
            Obj.value = "";
         }
         if (Obj.type == 'select-one' || Obj.type == 'select-multiple')
         {
            for (j=0; j<Obj.options.length; j++) 
            {
               Obj.options[j].selected = false; 
            }
         }
         if (Obj.type == 'radio' || Obj.type == 'checkbox')
         {
            Obj.checked = false; 
         }
      }
   }
}


function clearSpaces(inform)
{
  for (i=0; i<inform.elements.length; i++) 
  {
    if (inform.elements[i].type == 'text' || inform.elements[i].type == 'textarea') 
    { inform.elements[i].value =  trimEdges(inform.elements[i].value); }
  }

}

function ResetMultiChoice(choice)
{
   if (document.Search.elements[choice])
   {
      var i;
      if (!choice)
         return;
      for (i=0; i<document.Search.elements[choice].length; i++)
          document.Search.elements[choice].options[i].selected = false;
   }
}


//Erases Chars at Left of string
function Ltrim(inStr, remStr) {
 
var trimChar = (remStr == null) ? " " : remStr;
 if (inStr != '')  {
     var startPosition = 0;
     while (startPosition<inStr.length && inStr.charAt(startPosition) == trimChar)
            startPosition++;
     inStr = inStr.substring(startPosition,inStr.length)
 }
 return (inStr);
}

//Erases Chars at Right of string
function Rtrim(inStr, remStr) {
 
var trimChar = (remStr == null) ? " " : remStr;
 if (inStr != '')  {
     var endPosition = inStr.length-1;
     while (endPosition>= 0 && inStr.charAt(endPosition) == trimChar)
            endPosition--;
     inStr = inStr.substring(0, endPosition+1)
 }
 return (inStr);
}

//Erases Chars at both string ends
function trimEdges(inStr, remStr) {
  
  inStr = Ltrim(inStr, remStr);
  inStr = Rtrim(inStr, remStr);
  return(inStr);
}

function printpage(winname, strPageName, strQString) {
try {
        var execstr = "var "+winname+" = window.open('"+strPageName + "?" + strQString+"', '"+winname+"', 'scrollbars=yes,resizable=yes,toolbar=no,statusbar=no,width=680,height=700');";
	eval (execstr);
	eval(winname+".focus();");
	eval(winname+".print();");
} catch(error) {}
}
//--> 
