// JavaScript Document
// PRECARGA IMAGENES WEB:

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

/* CAMBIAR ESTADO INPUT */

function change_input1(id){
	if (document.getElementById(id).value == 'Buscar Productos'){ 
		document.getElementById(id).value = ''; 
	} 
	return false;
}

function reset_input1(id){
	if (document.getElementById(id).value==''){
		document.getElementById(id).value='Buscar Productos'; 
		return false;
	}			
}

function change_input2(id){
	if (document.getElementById(id).value == 'Ingresa tu email'){ 
		document.getElementById(id).value = ''; 
	} 
	return false;
}

function reset_input2(id){
	if (document.getElementById(id).value==''){
		document.getElementById(id).value='Ingresa tu email'; 
		return false;
	}			
}

// VALIDAR EMAIL BOLETIN:

function validarEmail(email) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email)) {
return (true);
} else {
alert("La dirección de email es incorrecta.");
document.frmofertas.txtemail.focus();
return (false);
}
}

function validarEmail2(mail) {
if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(mail)) {
alert("Dirección de email es incorrecta. ejemplo: minombre@hotmail.com");
document.frmboletin.txtemail2.focus();
return (false);
} 
else
return (true);
}

//VALIDAR FORM DE CONTACTOS:
function valida_frmcontacto(form) {
	if ((form.nombre.value == "") || (form.nombre.value== null)) {
	alert("Debe ingresar su nombre"); 
	form.nombre.focus();
	return false;
}
else 
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email.value)) { 
	alert("Dirección de correo no válida"); 
	form.email.focus(); 
	return (false);
}
else 
	if ((form.asunto.value == "") || (form.asunto.value== null)) {
	alert("Debe ingresar el asunto del mensaje"); 
	form.asunto.focus();
	return false;
}
else 
	if ((form.mensaje.value == "") || (form.mensaje.value== null)) {
	alert("Debe ingresar el mensaje a enviar"); 
	form.mensaje.focus();
	return false;
    } 
else 
return true;
}

//VALIDAR FORMULARIO REGPRODUCTOS:
function valida_frmproductos(forms) {
	if ((forms.nombre.value == "") || (forms.nombre.value== null)) {
	alert("Ingresar nombre del producto"); 
	forms.nombre.focus();
	return false;
}
else 
	if ((forms.precio.value == "") || (forms.precio.value== null)) {
	alert("Ingresar precio del producto"); 
	forms.precio.focus();
	return false;
}
else 
	if (forms.familia.selectedIndex==0){
       alert("Debe seleccionar una categoria")
       forms.familia.focus()
       return false;
} 
else 
	if (forms.subcatagorys.selectedIndex==0){
       alert("Debe seleccionar una subcategoria")
       forms.subcatagory.focus()
       return false;
    } 
else
	if ((forms.imagen.value == "") || (forms.imagen.value== null)) {
	alert("Seleccionar imagen del producto"); 
	forms.imagen.focus();
	return false;
}
else
	if ((forms.pclaves.value == "") || (forms.pclaves.value== null)) {
	alert("Ingresar palabras claves del producto"); 
	forms.pclaves.focus();
	return false;
}
else 
return true;
}

// FUNCION FILTRAR TIPO DE ARCHIVOS IMAGEN:
function control(f){
    var ext=['jpg','jpeg'];
    var v=f.value.split('.').pop().toLowerCase();
    for(var i=0,n;n=ext[i];i++){
        if(n.toLowerCase()==v)
            return
    }
    var t=f.cloneNode(true);
    t.value='';
    f.parentNode.replaceChild(t,f);
    alert("extension de archivo no valida");
	forms.imagen.focus();
}

//SLIDESHOW IMAGENES NOVEDADES:

var slides2=[]; //SLIDESHOW IMAGES
//configure the below images and descriptions to your own.
slides2[0] = ["images/banner_novedades1.jpg", "", "http://www.aproduservi.com.pe/pages/productos.asp?id=1&ids=42&nsub=Accesorios%20PC"];
slides2[1] = ["images/banner_novedades2.png", "", "http://www.aproduservi.com.pe/pages/detalle.asp?id=1&cat=Computadoras&ids=1&scat=PCs%20Aproduservi&idp=355"];
slides2[2] = ["images/banner_novedades3.jpg", "", "http://www.aproduservi.com.pe/pages/detalle.asp?id=8&cat=Multimedia&ids=55&scat=Proyectores&idp=342"];
/*slides2[3] = ["images/banner_novedades4.png", "", "http://www.aproduservi.com.pe/pages/p_recientes.asp?idp=446"];
slides2[4] = ["images/banner_novedades5.png", "", "http://www.aproduservi.com.pe/pages/p_recientes.asp?idp=447"];
*/
//optional properties for these images:
slides2.no_descriptions=1; //Use for no descriptions displayed for this slide show
slides2.width=510; //use to set width of widest image if dimensions vary
slides2.height=265; //use to set height of tallest image if dimensions vary
slides2.no_auto=0; //use to make show completely user operated (no play button, starts in stopped mode)
slides2.no_controls=1; //Use for a slide show with no controls
slides2.use_alt=1; //use for descriptions as images alt attributes
slides2.use_title=1; //use for descriptions as images title attributes
slides2.nofade=0; //use for no fade-in, fade-out effect for this show
slides2.border=0; //set border width for images
slides2.pause=1; //use for pause onmouseover
slides2.random=1; //set a random slide sequence on each page load

//TEXTO HTML PARPADEANTE
function parpadear() {
  var blink = document.all.tags("BLINK")
  for (var i=0; i < blink.length; i++)
    blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function empezar() {
  if (document.all)
    setInterval("parpadear()",1000)
}
window.onload = empezar;