function IsEmailValid(FormName,ElemName)
{
        var EmailOk  = true
        var Temp     = ElemName
        var AtSym    = Temp.value.indexOf('@')
        var Period   = Temp.value.lastIndexOf('.')
        var Space    = Temp.value.indexOf(' ')
        var Length   = Temp.value.length - 1   // Array is from 0 to length-1
        
        if ((AtSym < 1) ||                     // '@' cannot be in first position
            (Period <= AtSym+1) ||             // Must be at least one valid char btwn '@' and '.'
            (Period == Length ) ||             // Must be at least one valid char after '.'
            (Space  != -1))                    // No empty spaces permitted
           {  
              EmailOk = false              
           } else {
               EmailOk = true;
           }
        return EmailOk
}

function enviarLocal(){
  if ( Validar(document.puntocompras) ) {
      document.puntocompras.submit();
  }
}   

function esDigito (c)
{
	return ((c >= "0") && (c <= "9"));
}

function esEntero (s)
{
	var i=0;
    for (i = 0; i < s.length; i++)
	{   
		var c = s.charAt(i);
		if (!esDigito(c)) return false;
    }
    return true;
}

function Validar(f) {
var temp = "Complete los datos: ";
var flag = 0;
var cont = 0;
var i = 0;

//***************************
if (f.tienda.value==""){
       temp = temp+"Nombre de la tienda,"
       flag = 1;
}

if (f.url.value==""){
       temp = temp+"URL de la tienda,"
       flag = 1;
}

if (f.email.value==""){
       temp = temp+"Correo electrónico,"
       flag = 1;
} else {
	if (!IsEmailValid(f,f.email)) {
		temp = temp + "Correo electrónico inválido,"
		flag = 1;
	}
}

if (f.descripcion.value==""){
       temp = temp+"Descripción de la tienda,"
       flag = 1;
}


if (f.nombre.value==""){
       temp = temp+"Nombre de la persona contacto,"
       flag = 1;
}

if (f.telefono.value==""){
       temp = temp+"Teléfono,"
       flag = 1;
} else {
	if (!esEntero(f.telefono.value))
	{
		temp = temp + "Teléfono solo con campos numéricos,"
		flag = 1;
	}
}

for (i=0; i<4; i++){  
     if ( f.tipo[i].checked ){ 
          cont++;
     }
}
if ( cont==0 ) {
       temp = temp+"Ubicación (teléfono),";
       flag = 1;
}

if ( flag!=0 ){
   if (cont==10){
      alert(temp);
      return false;
   }else {
      alert(temp.substring(0,temp.length-1));
      return false;
   }
}else{
    return true;
}

}

