window.defaultStatus='(C) 2007 DBMedios http://www.dbmedios.com'

var useFlash = navigator.mimeTypes &&
navigator.mimeTypes["application/x-shockwave-flash"] &&
navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
	
function opacity(id, opacStart, opacEnd, millisec, pagina) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    }
	
	setTimeout("window.location ='" + pagina + "'", ((timer-1) * speed));
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 

function fundido(id, tiempo, pagina) {

	document.getElementById(id).style.visibility = "visible";
	changeOpac(0, id);
	document.getElementById(id).style.zIndex = 10;
	opacity(id, 0, 100, tiempo, pagina);
}

function popup(ref,name,w,h,scroll) {
	
	var URLtoOpen = ref;
	var windowName = name;
	var popW = w, popH = h;
	var scrollB = 'no';
	if(scroll==1){scrollB='yes'};
	w = screen.availWidth;
	h = screen.availHeight;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	window.open(URLtoOpen, windowName,'width=' + popW + ',height=' + popH + ',scrollbars=' + scrollB + ',screenx=' +leftPos +',screeny=' +topPos +',top=' +topPos +',left=' +leftPos, +'location=no, toolbar=no, directories=no, menubar=no, resizable=no, fullscreen=0, status=no, channelmode=0');

}

function verify() {

	var fallo = 0;
	
	if(document.form_contacto.mail.value==""){document.getElementById('c7').style.visibility = "visible"; document.form_contacto.mail.focus(); fallo=1}else{document.getElementById('c7').style.visibility = "hidden";}
	if(comprueba_email(document.form_contacto.mail.value)==false){document.getElementById('c7b').style.visibility = "visible"; document.form_contacto.mail.focus(); fallo=1}else{document.getElementById('c7b').style.visibility = "hidden";}
	if(document.form_contacto.telefono.value==""){document.getElementById('c6').style.visibility = "visible"; document.form_contacto.telefono.focus(); fallo=1}else{document.getElementById('c6').style.visibility = "hidden";}
	if(isNaN(document.form_contacto.telefono.value)){document.getElementById('c6b').style.visibility = "visible"; document.form_contacto.telefono.focus(); fallo=1}else{document.getElementById('c6b').style.visibility = "hidden";}
	if(document.form_contacto.provincia.value==""){document.getElementById('c5').style.visibility = "visible"; document.form_contacto.provincia.focus(); fallo=1}else{document.getElementById('c5').style.visibility = "hidden";}
	if(document.form_contacto.poblacion.value==""){document.getElementById('c4').style.visibility = "visible"; document.form_contacto.poblacion.focus(); fallo=1}else{document.getElementById('c4').style.visibility = "hidden";}
	if(document.form_contacto.cp.value==""){document.getElementById('c3').style.visibility = "visible"; document.form_contacto.cp.focus(); fallo=1}else{document.getElementById('c3').style.visibility = "hidden";}
	if(isNaN(document.form_contacto.cp.value)||document.form_contacto.cp.value.length!=5){document.getElementById('c3b').style.visibility = "visible"; document.form_contacto.cp.focus(); fallo=1}else{document.getElementById('c3b').style.visibility = "hidden";}
	if(document.form_contacto.direccion.value==""){document.getElementById('c2').style.visibility = "visible"; document.form_contacto.direccion.focus(); fallo=1}else{document.getElementById('c2').style.visibility = "hidden";}
	if(document.form_contacto.contacto.value==""){document.getElementById('c1').style.visibility = "visible"; document.form_contacto.contacto.focus(); fallo=1}else{document.getElementById('c1').style.visibility = "hidden";}
	
	if(fallo==0){document.getElementById('c100').style.visibility = "hidden"; document.form_contacto.submit();}else{document.getElementById('c100').style.visibility = "visible";}
	
}


function comprueba_email(texto){

    var mailres = true;            
    var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-";
    var arroba = texto.indexOf("@",0);

    if ((texto.lastIndexOf("@")) != arroba) arroba = -1;
    
    var punto = texto.lastIndexOf(".");
                
     for (var contador = 0 ; contador < texto.length ; contador++){
        if (cadena.indexOf(texto.substr(contador, 1),0) == -1){
            mailres = false;
            break;
     	}
     }

    if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1))
     mailres = true;
    else {
     mailres = false;
	}
    
    return mailres;
} 