// JavaScript Document

//valida formulario

function valida_envia(){
	//valido el nombre
	if (document.getElementById("fvalida").nombre.value.length==0){
		alert("Por favor, escriba su nombre.")
		document.getElementById("fvalida").nombre.focus()
		return 0;
	}

	if (document.getElementById("fvalida").telefono.value.length==0){
		alert("Por favor, escriba su teléfono.")
		document.getElementById("fvalida").telefono.focus()
		return 0;
	}
	
		if (document.getElementById("fvalida").motivo.value.length==0){
		alert("Por favor, escriba su motivo de contacto.")
		document.getElementById("fvalida").motivo.focus()
		return 0;
	}
	
	
	
//el formulario se envia

	document.getElementById("fvalida").submit();
}


// desactivar seleccion de texto

function disableselect(e)
{
   return false
}
function reEnable()
{
   return true
}
//if IE4+
document.onselectstart=new Function ("return false")
//if NS6
if (window.sidebar)
{
   document.onmousedown=disableselect
   document.onclick=reEnable
}

// desactivar boton derecho
var mensaje = "[Copyright © 2004-2010 LIMPIEZAS BERNI]";
function derecho(e)
{
if (navigator.appName == 'Netscape' && e.which == 3)
alert(mensaje);
else if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2)
alert(mensaje);
}
document.onmousedown = derecho;

// Archivo en formulario
var numero = 0;

// Funciones comunes
c= function (tag) { // Crea un elemento
   return document.createElement(tag);
}
d = function (id) { // Retorna un elemento en base al id
   return document.getElementById(id);
}
e = function (evt) { // Retorna el evento
   return (!evt) ? event : evt;
}
f = function (evt) { // Retorna el objeto que genera el evento
   return evt.srcElement ?  evt.srcElement : evt.target;
}

addField = function () {
   container = d('files');
   
   span = c('SPAN');
   span.className = 'file';
   span.id = 'file' + (++numero);

   field = c('INPUT');   
   field.name = 'archivos[]';
   field.type = 'file';
   
   a = c('A');
   a.name = span.id;
   a.href = '#';
   a.onclick = removeField;
   a.innerHTML = 'Quitar';

   span.appendChild(field);
   span.appendChild(a);
   container.appendChild(span);
}
removeField = function (evt) {
   lnk = f(e(evt));
   span = d(lnk.name);
   span.parentNode.removeChild(span);
}
// Fin Archivo en formulario

