﻿<!--

function valid_search()
{

if(q.value.length < 1) 
  { 
   return false;   }

return true;  
} 

//------------------
function mygetyear()
{
	y = getYear(Date())
	return y;
}

//-------------------
function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }


//-------------------------------
function jnewaccount() 
{
  var at="@";
  var dot=".";
  var str=document.form_na.email.value;
  var lat=str.indexOf(at);
  var lstr=str.length;
  var ldot=str.indexOf(dot);  
  var hid=document.form_na.hid.value;
 
   if (str.indexOf(at)==-1){
		   alert("¶κυρο E-mail ");
		   return false;
		}
   if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("¶κυρο E-mail ");
		   return false;
		}

   if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("¶κυρο E-mail ");
		    return false;
		}


  if (document.form_na.passwd.value.length < 5)
	{alert("Το password πρέπει να έχει τουλάχιστον 5 χαρακτήρες");
	   return false;
	}
	
  if (document.form_na.passwd.value != document.form_na.passwd2.value )
	{alert("Δεν ταιριάζουν τα password");
	   return false;
	}

if (hid == 1)
     { alert("Το email που πληκτρολογήσταε είναι ήδη καταχωρημένο");
	    return false; 
	 } 
else  
  return true;    
	
/*	
   if (document.form_na.fname.value.length < 3  || document.form_na.lname.value.length < 3   )
	{alert("Το όνομά σας πρέπει να έχει περισσότερους από 3 χαρακτήρες");
	   return false;
	}	

  if (document.form_na.address.value.length < 5)
	{alert("Η διεύθυνση πρέπει να έχει τουλάχιστον 5 χαρακτήρες");
	   return false;
	}

  if (document.form_na.city.value.length < 5)
	{alert("Η πόλη πρέπει να έχει τουλάχιστον 5 χαρακτήρες");
	   return false;
	}

  if ( !IsNumeric(document.form_na.tk.value) )
   { alert("Πληκτρολογήστε μόνο ψηφία για ταχυδρομικό κώδικα ");
     return false;
   }
    if ( document.form_na.tk.value.length < 5 )
   { alert("Πληκτρολογήστε 5 ψηφία για Τ.Κ. ");
     return false;
   } 

  if ( document.form_na.tel.value.length > 0 )
	 if (!IsNumeric(document.form_na.tel.value)   ) {
		     alert("Πληκτρολογήστε μόνο ψηφία για τηλέφωνο");
             return false; 
	 }
  
  
   if ( document.form_na.fax.value.length < 10 &&  document.form_na.fax.value.length > 1)
   { 
     alert("Ο αριθμός του FAX πρέπει να περιέχει τουλάχιστον 10 ψηφία");
     return false;
   } 
   
 
   if ( !IsNumeric(document.form_na.afm.value) && document.form_na.afm.value.length > 0 )
   { alert("Πληκτρολογήστε μόνο ψηφία για ΑΦΜ");
     return false;
   }
    if ( document.form_na.afm.value.length < 9 && document.form_na.afm.value.length > 0  )
   { alert("Πληκτρολογήστε 9 ψηφία για ΑΦΜ");
     return false;
   } 

  if ( document.form_na.doy.value.length < 3 && document.form_na.doy.value.length > 0  )
   { alert("Λίγοι χαρακτήρες για το πεδίο ΔΟΥ ");
     return false;
   } 
  */ 
  
}

//-------------------------------
function validate_edit_account() 
{
  
  if (document.form_na.passwd.value.length < 5)
	{alert("Το password πρέπει να έχει τουλάχιστον 5 χαρακτήρες");
	   return false;
	}
/*	
  if (document.form_na.passwd.value != document.form_na.passwd2.value )
	{alert("Δεν ταιριάζουν τα password");
	   return false;
	}
*/	
   if (document.form_na.fname.value.length < 3  || document.form_na.lname.value.length < 3   )
	{alert("Το όνομά σας πρέπει να έχει περισσότερους από 3 χαρακτήρες");
	   return false;
	}	

  if (document.form_na.address.value.length < 5)
	{alert("Η διεύθυνση πρέπει να έχει τουλάχιστον 5 χαρακτήρες");
	   return false;
	}

  if (document.form_na.city.value.length < 5)
	{alert("Η πόλη πρέπει να έχει τουλάχιστον 5 χαρακτήρες");
	   return false;
	}

  if ( !IsNumeric(document.form_na.tk.value) )
   { alert("Πληκτρολογήστε μόνο ψηφία για ταχυδρομικό κώδικα ");
     return false;
   }
    if ( document.form_na.tk.value.length < 5 )
   { alert("Πληκτρολογήστε 5 ψηφία για Τ.Κ. ");
     return false;
   } 

  if ( !IsNumeric(document.form_na.tel.value) )
   { alert("Πληκτρολογήστε μόνο ψηφία για τηλέφωνο");
     return false;
   }
    if ( document.form_na.tel.value.length < 10 )
   { alert("Ο αριθμός τηλεφώνου πρέπει να περιέχει τουλάχιστον 10 ψηφία");
     return false;
   } 
   
  
   if ( document.form_na.fax.value.length < 10 &&  document.form_na.fax.value.length > 1)
   { 
     alert("Ο αριθμός του FAX πρέπει να περιέχει τουλάχιστον 10 ψηφία");
     return false;
   } 
   
 
   if ( !IsNumeric(document.form_na.afm.value) )
   { alert("Πληκτρολογήστε μόνο ψηφία για ΑΦΜ");
     return false;
   }
    if ( document.form_na.afm.value.length < 9 )
   { alert("Πληκτρολογήστε 9 ψηφία για ΑΦΜ");
     return false;
   } 

  if ( document.form_na.doy.value.length < 3 )
   { alert("Λίγοι χαρακτήρες για το πεδίο ΔΟΥ ");
     return false;
   } 
   
  	 
  return true;    
}
//-----------------------
function validate_products()
{
  var dd= document.form_new_product;	 
  var price = dd.products_price.value;


  if (dd.products_name.value.length < 1) {
	  alert('Μη έγκυρο όνομα');
	  return false; }
 
  if (!IsNumeric(price) || price.length < 1 ) {
      alert('Πληκτρολογείστε την τιμή του προϊόντος  ');
	  return false; }
  
  
  rtoStore();
  	  

}


//---------------------------
function checkempty() {

var obj = document. getElementById("qq");

if (obj.value == "") {
   return false;
}
return true;
}

//------------------
function openwindow(myfile)
{
	
window.open(myfile, 'foto', 'width=820,height=620,scrollbars=no');	
}

//-------------
function be_download()
{
var be_name = document.f_down_be.be_name.value;
var be_email=document.f_down_be.be_email.value;
var be_tel=document.f_down_be.be_tel.value;
	

if ( !IsNumeric(be_tel) )
  { 
  alert("Στο πεδίο τηλέφωνο πρέπει να υπάρχουν μόνο αριθμοί.");
   return false;
  }

if (be_name.length < 5 || be_email.length < 8 || be_tel.length < 10)
   {
	 alert("Λίγοι χαρακτήρες για το ονομ/μο ή το email ή το τηλεφωνικό νούμερο.");
	 return false;
   }

 document.f_down_be.flag1.value = 1;
 return true;  
   
}

//----------------------------
// transer cost eval
function eval_trans_cost()
{
  //var dd=document.thisform;
  
  var total_ammount= parseFloat(document.getElementById("total_ammount").value);
  var total_weight = parseFloat(document.getElementById("total_weight").value);
  var destination=parseInt(document.getElementById("destination").value);
  var is_active_stable=document.getElementById("is_active_stable").value;
  var is_active_dorean=document.getElementById("is_active_dorean").value;
  var is_active_weight=document.getElementById("is_active_weight").value;
  var is_active_kila=document.getElementById("is_active_kila").value;
  
  var num_loop=0;
  var limit_ammount=0;
  var total_cost=0;
  var total_order=total_ammount;
  var tmp=0;
  var tmp_weight=0;
  var i=0;
  var from_weight=new Array();
  var to_weight=new Array();


  if (destination != 0)
  {

   if (is_active_weight == 'y')
      {
		
		num_loop=parseInt(document.getElementById("num_loop").value);		    
		for (i=0; i<num_loop; i++)
		  {
			from_weight[i]= parseFloat(document.getElementById("weight_from_weight_"+i).value);		     
			to_weight[i]= parseFloat(document.getElementById("weight_to_weight_"+i).value);		     
			if (total_weight > from_weight[i] && total_weight <= to_weight[i] )
			   {tmp=i;  /*alert(total_weight+'--'+from_weight[i]+'--'+to_weight[i]); */ }
  	      } // end for

	     if (destination == 1)
		   total_cost=parseFloat(document.getElementById("weight_cost_gr_main_"+tmp).value);
		 else if (destination == 2)  
		   total_cost=parseFloat(document.getElementById("weight_cost_gr_island_"+tmp).value);		
		   
   	  } // end if weight

  if (is_active_kila == 'y')
      {
		num_loop=parseInt(document.getElementById("num_loop").value);		    
		for (i=0; i<num_loop; i++)
		  {
			from_weight[i]= parseFloat(document.getElementById("weight_from_weight_"+i).value);		     
			if (total_weight > from_weight[i] )
			   { tmp_weight = total_weight - from_weight[i];
			     tmp=i;  /*alert(total_weight+'--'+from_weight[i]+'--'+to_weight[i]); */ }
  	      } // end for

	     if (destination == 1)
		    total_cost=Math.round(parseFloat(document.getElementById("weight_cost_gr_main_"+tmp).value)*tmp_weight*100)/100;
		 else if (destination == 2)  
		    total_cost=Math.round(parseFloat(document.getElementById("weight_cost_gr_island_"+tmp).value)*tmp_weight*100)/100;		
		   
		   
   	  } // end if weight

    if (is_active_stable == 'y')
      {
	     if (destination == 1)
		   total_cost=parseFloat(document.getElementById("stable_cost_gr_main").value);
		 else if (destination == 2)  
		   total_cost=parseFloat(document.getElementById("stable_cost_gr_island").value);		 
   	  } // end if stable

    if (is_active_dorean == 'y')
      {
      limit_ammount=parseFloat(document.getElementById("dorean_limit_ammount").value);
	   if (total_ammount >= limit_ammount )
	    {
		  total_cost=0;
	     /*if (destination == 1)
		    total_cost=parseFloat(document.getElementById("dorean_cost_gr_main").value);
		  else if (destination == 2)  
		   total_cost=parseFloat(document.getElementById("dorean_cost_gr_island").value);		 
		 */  
		 alert(total_amount);
		}
		   
	 } // end if dorean



  } //end if destination

  
  total_order=total_ammount+total_cost;
  total_order=total_order.toFixed(2);

  document.getElementById("trans_cost").innerHTML=total_cost;
  document.getElementById("total_order").innerHTML=total_order;

  document.getElementById("trans_cost_price").value=total_cost;
  document.getElementById("total_order_price").value=total_order;

	
}

//-----------------
// function $(strId){ return document.getelementbyid(strId); }

//---------------------
function display_payment_text(xvalue)
{

if (xvalue == 2)
  {
    document.getElementById("doseis_visible").style.display = 'block';
    document.getElementById("banks_visible").style.display = 'none';
    document.getElementById("antikatavoli_visible").style.display = 'none';
	document.getElementById("paypal_visible").style.display = 'none';	
  }
if (xvalue == 1)
  {
	document.getElementById("doseis_visible").style.display = 'none';
    document.getElementById("banks_visible").style.display = 'block';
	document.getElementById("antikatavoli_visible").style.display = 'none';
	document.getElementById("paypal_visible").style.display = 'none';	
}
if (xvalue == 3)
  {
    document.getElementById("doseis_visible").style.display = 'none';
    document.getElementById("banks_visible").style.display = 'none';
	document.getElementById("antikatavoli_visible").style.display = 'block';
	document.getElementById("paypal_visible").style.display = 'none';
} 

if (xvalue == 4)
  {
    document.getElementById("doseis_visible").style.display = 'none';
    document.getElementById("banks_visible").style.display = 'none';
	document.getElementById("antikatavoli_visible").style.display = 'none';
	document.getElementById("paypal_visible").style.display = 'block';
	
  } 
  
}


//-------------------------------
function validate_order() 
{
  var f = document.f_order;
  var tmp = false;
 
  for (var i=0; i < f.payment_method.length; i++)
   {
   if (f.payment_method[i].checked)
      {
      var tmp = true;
      }
   }
 
 if (tmp == false)
    {
	  alert("Επιλέξτε μέθοδο πληρωμής.");
	  return false;
	}

 if (f.h_name.value == "")
    {
	  alert("Το πεδίο του ονόματος δεν μπορεί να είναι κενό");
	  return false;
	}

 if (f.h_surname.value == "")
    {
	  alert("Το πεδίο του επωνύμου δεν μπορεί να είναι κενό");
	  return false;
	}

 if (f.h_city.value == "")
    {
	  alert("Το πεδίο της πόλης δεν μπορεί να είναι κενό");
	  return false;
	}

if (f.h_address.value == "")
    {
	  alert("Το πεδίο της διεύθυνσης δεν μπορεί να είναι κενό");
	  return false;
	}

if (f.h_tel.value == "")
    {
	  alert("Το πεδίο του τηλεφώνου δεν μπορεί να είναι κενό");
	  return false;
	}

if (f.check_used_rules.checked == false)
    {
	  alert("Πρέπει να τσεκάρετε ότι αποδέχεστε τους όρους χρήσης.");
	  return false;
	}


  return true;
}

//---------------
function show_pr_foto(fotoname)
{
	 
 document.getElementById("show_pr_foto").innerHTML= "<img src='"+fotoname+"' width='180' />";
	
}


// -->

