function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}

function checkNumber(val) {
  var strPass = val.value;
  var strLength = strPass.length;
  var lchar = val.value.charAt((strLength) - 1);
  var cCode = CalcKeyCode(lchar);


  if (cCode < 48 || cCode > 57 ) {
    var myNumber = val.value.substring(0, (strLength) - 1);
    val.value = myNumber;
  }
  return false;
}


function clear_field(field,name)
{
		if(field.value==name){
			field.value="";
		}
}

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 check_send()
{

	if(document.abonare.name.value=="" || document.abonare.name.value=="Nume & Prenume") {
		alert("Va rugam introduceti numele pentru a continua.");
		document.abonare.name.focus();
		return false;
	}
	


	if(document.abonare.city.value=="0") {
		alert("Va rugam introduceti orasul in care locuiti pentru a continua.");
		document.abonare.city.focus();
		return false;
	}


	if(document.abonare.mobile.value=="" || document.abonare.mobile.value=="Telefon mobil") {
		alert("Va rugam introduceti numarul de telefon pentru a continua.");
		document.abonare.mobile.focus();
		return false;
	}
	
	if(document.abonare.mobile.value.length!=10) {
			alert("Va rugam introduceti corect numarul de telefon. \n\n 072X XXX XXX (Cosmote, Orange, Vodafone, Zapp) ");
			document.abonare.mobile.focus();
			return false;
	}
	
	document.abonare.submit();
	
}

function check_order(){
		if (document.order_form.name.value=="" || document.order_form.name.value=="-") {
			alert("Va rugam sa completati campul <Nume>.");
			document.order_form.name.focus();
			return false;
		}

		if (document.order_form.email.value=="" || document.order_form.email.value=="-") {
			alert("Va rugam sa completati campul <E-mail>.");
			document.order_form.email.focus();
			return false;
		}
		
		if (document.order_form.adr.value=="" || document.order_form.adr.value=="-") {
			alert("Va rugam sa completati campul <Adresa>.");
			document.order_form.adr.focus();
			return false;
		}
		
		if (document.order_form.city.value=="" || document.order_form.city.value=="-") {
			alert("Va rugam sa completati campul <Oras>.");
			document.order_form.city.focus();
			return false;
		}
		
		if (document.order_form.p_code.value=="" || document.order_form.p_code.value=="-") {
			alert("Va rugam sa completati campul <Cod postal>.");
			document.order_form.p_code.focus();
			return false;
		}

		if (document.order_form.cod_f.value=="" || document.order_form.cod_f.value=="-") {
			alert("Va rugam sa completati campul <Cod fiscal / CNP>.");
			document.order_form.cod_f.focus();
			return false;
		}
		
		if (document.order_form.code_2.value!="572") {
			alert("Va rugam introduceti numarul <572> in campul <Cod>.");
			document.order_form.code_2.focus();
			return false;
		}		

		return true;
}
