var pong;
function makeArray(n){
  this.length = n;
  for (i=1;i<=n;i++){
    this[i]=0;
  }
  return this;
}

// standard date display function with y2k compatibility
function displayDate() {
  var this_month = new makeArray(12);
  this_month[0]  = "January";
  this_month[1]  = "February";
  this_month[2]  = "March";
  this_month[3]  = "April";
  this_month[4]  = "May";
  this_month[5]  = "June";
  this_month[6]  = "July";
  this_month[7]  = "August";
  this_month[8]  = "September";
  this_month[9]  = "October";
  this_month[10] = "November";
  this_month[11] = "December";

  var this_day_e = new makeArray(7);
  this_day_e[0]  = "Sunday";
  this_day_e[1]  = "Monday";
  this_day_e[2]  = "Tuesday";
  this_day_e[3]  = "Wednesday";
  this_day_e[4]  = "Thursday";
  this_day_e[5]  = "Friday";
  this_day_e[6]  = "Saturday";

  var today = new Date();
  var day   = today.getDate();
  var month = today.getMonth();
  var year  = today.getYear();
  var dia = today.getDay();
    if (year < 1000) {
       year += 1900; }
  return( " " + this_day_e[dia] + ", " + this_month[month] + " " + day + ", " + year);
}



// JavaScript Document
//Funciones usadas en el formulario
function esInteger(e) {
var charCode
if (navigator.appName == "Netscape") // Veo si es Netscape o Explorer (mas adelante lo explicamos)
charCode = e.which // leo la tecla que ingreso
else
charCode = e.keyCode // leo la tecla que ingreso
status = charCode 
if (charCode > 31 && (charCode < 48 || charCode > 57)) { // Chequeamos que sea un numero comparandolo con los valores ASCII
alert("This field only accepts numbers");
return false;
}
return true;
}


//para controlar tamaño del texto del campo de texto

function textolargo(texto,actual,maxim) {
if (texto.value.length>maxim){
 event.keyCode=0;
 texto.value=texto.value.substring(0,maxim);
 alert("You have now typed in  "+maxim+" characters");
 return false;
}
 return true;
}


//apartado Recomendar
function comprobar() {
vacio = "";
if (document.form.tunombre.value == "") {
vacio += "\n     -  Your name is missing";
}
if (document.form.nombredestinatario.value == "") {
vacio += "\n     -  The addressee’s name is missing";
}
if (document.form.tuemail.value == "") {
//vacio += "\n     -  Falta tu dirección de correo"; no hacemos nada
}
else if ((document.form.tuemail.value.indexOf('@') == -1) || 
(document.form.tuemail.value.indexOf('.') == -1)) {
vacio += "\n     -  The e-mail address is incorrect";
}
if (document.form.emaildestinatario.value == "") {
vacio += "\n     -  The addressee’s e-mail address is missing";
}
else if ((document.form.emaildestinatario.value.indexOf('@') == -1) || 
(document.form.emaildestinatario.value.indexOf('.') == -1)) {
vacio += "\n     -  The addressee’s e-mail address is incorrect";
}
if (vacio != "") {
vacio ="_____________________________________________\n" +
"Data incorrect or incomplete:\n" +
vacio + "\n_____________________________________________" +
"\nPlease modify or complete the data inserted";
alert(vacio);
return false;
}
else {
return true;//document.forms[0].submit();//form.submit();
}
}

//Formulario envio solo telefono
function checkFieldstelefono() {
vacio = "";
if (document.form2.nombre2.value == "") {
vacio += "\n     -  Please insert a contact name";
}
if (document.form2.telefonofijo.value == "") {
vacio += "\n     -  Insert a telephone number";
}
if (vacio != "") {
vacio ="_____________________________________________\n" +
"Data incorrect or incomplete:\n" +
vacio + "\n_____________________________________________" +
"\nPlease modify or complete the data inserted";
alert(vacio);
return false;
}
else {
return true;//document.forms[0].submit();//form.submit();
}
}

//Formularios
function checkFields() {
vacio = "";
if (document.form.nombre.value == "") {
vacio += "\n     -  Please insert a contact name";
}
if (document.form.email.value == "" && document.form.telefono.value == "" && document.form.otrotelefono.value == "") {
vacio += "\n     -  Please insert an e-mail address or contact telephone number";
}
if (document.form.telefono.value == "") {
//vacio += "\n     -  Escriba un teléfono de contacto";
}
if (document.form.email.value == ""){
//de momento no hacemos nada
}
else if ((document.form.email.value.indexOf('@') == -1) || 
(document.form.email.value.indexOf('.') == -1)) {
vacio += "\n     -  The e-mail address is incorrect";
}
if(document.form.consulta.value == "") {
vacio += "\n     -  Please indicate the information you require (comments)";
}
if (vacio != "") {
vacio ="_____________________________________________\n" +
"Data incorrect or incomplete:\n" +
vacio + "\n_____________________________________________" +
"\nPlease modify or complete the data inserted";
alert(vacio);
return false;
}

else {
if(document.form.empresa.value == "") {
document.form.empresa.value = "Not indicated";
}
if(document.form.email.value == "") {
document.form.email.value = "No@indicado.com";
}
if(document.form.telefono.value == "") {
document.form.telefono.value = "Not indicated";
}
if(document.form.otrotelefono.value == "") {
document.form.otrotelefono.value = "Not indicated";
}
if(document.form.website.value == "") {
document.form.website.value = "Not indicated";
}
//if(document.form.tipo.value == "") {
//document.form.tipo.value = "No indicado";
//}
if(document.forms.length > 9){
if(document.form.palabras.value == "") {
document.form.palabras.value = "Not indicated";
}
if(document.form.plazo.value == "") {
document.form.plazo.value = "Not indicated";
}
if (document.form.idiomas.value == ""){
document.form.idiomas.value = "Not indicated";
}
}
return true;//document.forms[0].submit();//form.submit();
}
}

