function ocular_selects(){
	selec = document.getElementsByTagName('SELECT');	
	var gko = navigator.userAgent.toLowerCase();
	if (gko.indexOf('gecko')==-1)
		for(i=0;i<selec.length;i++)
			selec[i].style.visibility='hidden';//hacemos el setAttribute normalmente	
}

function mostrar_selects(){
	selec = document.getElementsByTagName('SELECT');	
	var gko = navigator.userAgent.toLowerCase();
	if (gko.indexOf('gecko')==-1)
		for(i=0;i<selec.length;i++)		
			selec[i].style.visibility='visible';//hacemos el setAttribute normalmente
}

//precarga de imagenes
image1 = new Image();
image1.src = "imagenes/b_inicio_on.jpg";
image2 = new Image();
image2.src = "imagenes/b_dominios_on.jpg";
image3 = new Image();
image3.src = "imagenes/b_hospedaje_on.jpg";
image4 = new Image();
image4.src = "imagenes/b_presencia_on.jpg";
image5 = new Image();
image5.src = "imagenes/b_portafolio_on.jpg";
image6 = new Image();
image6.src = "imagenes/b_contacto_on.jpg";
image7 = new Image();
image7.src = "imagenes/b_ayuda_on.jpg";
image8 = new Image();
image8.src = "imagenes/tab_on.gif";
image9 = new Image();
image9.src = "imagenes/tagactual.gif";
image10 = new Image();
image10.src = "imagenes/tab_off.gif";
image11 = new Image();
image11.src = "imagenes/titulo_peq.jpg";
image12 = new Image();
image12.src = "imagenes/moneda_bs_on.jpg";
image13 = new Image();
image13.src = "imagenes/moneda_usd_on.jpg";
image14 = new Image();
image14.src = "imagenes/moneda_eur_on.jpg";
image15 = new Image();
image15.src = "imagenes/moneda_eur2_on.jpg";
image16 = new Image();
image16.src = "imagenes/moneda_eur3_on.jpg";
image17 = new Image();
image17.src = "imagenes/moneda_usd2_on.jpg";
image18 = new Image();
image18.src = "imagenes/moneda_bs2_on.jpg";
image19 = new Image();
image19.src = "imagenes/hospedaje_linux_on.jpg";
image20 = new Image();
image20.src = "imagenes/hospedaje_windows_on.jpg";

var j = new Array(0,0,0,0,0,0,0);
var ap = new Array(7);
var desap = new Array(7);
var botones = new Array('dominios','hospedaje','presencia','portafolio','contacto','ayuda');

//inicializacion de submenus
function ubicarSubmenus() {
	for (y=0;y<botones.length;y++) {
		document.getElementById('sm_'+botones[y]).style.MozOpacity=0;
		document.getElementById('sm_'+botones[y]).style.filter = 'alpha(opacity=0)';
		document.getElementById('sm_'+botones[y]).style.top='123px';
		document.getElementById('sm_'+botones[y]).style.zIndex='100';
	}
	document.getElementById('sm_dominios').style.left='99px';
	document.getElementById('sm_hospedaje').style.left='204px';
	document.getElementById('sm_presencia').style.left='341px';
	document.getElementById('sm_portafolio').style.left='470px';
	document.getElementById('sm_contacto').style.left='567px';
	document.getElementById('sm_ayuda').style.left='603px';
}

//efecto de imagenes en menu
function cambiarImg(imagen,xm) {
	imagenURL='imagenes/b_'+imagen+'_on.jpg';
	document.getElementById(imagen).src=imagenURL;
	if (xm!=-1) {
		abrirSubmenu('sm_'+imagen,xm);
	}
}
function devolverImg(imagen,xm) {
	clearInterval(desap[xm]);
	imagenURL='imagenes/b_'+imagen+'_off.jpg';
	document.getElementById(imagen).src=imagenURL;
	if (xm!=-1) {
		cerrarSubmenu('sm_'+imagen,xm);
	}
}

function abrirSubmenu(seccion,xm) {
	clearInterval(desap[xm]);
	document.getElementById(seccion).style.visibility='visible';
	document.getElementById(seccion).style.zIndex='100';
	ap[xm]=setInterval('aparecer("'+seccion+'","'+xm+'")',1);
}
function aparecer(seccion,xm){
		document.getElementById(seccion).style.MozOpacity=j[xm]/100;
		document.getElementById(seccion).style.filter = 'alpha(opacity='+j[xm]+')';
		document.getElementById(seccion).style.zIndex='100';
		j[xm]=j[xm]+20;
		if (j[xm]>=85) {  
			clearInterval(ap[xm]);
		}
}
function desaparecer(seccion,xm){
		document.getElementById(seccion).style.MozOpacity=j[xm]/100;
		document.getElementById(seccion).style.filter = 'alpha(opacity='+j[xm]+')';
		j[xm]=j[xm]-20;
		if (j[xm]<=0) {  clearInterval(desap[xm]); document.getElementById(seccion).style.visibility='hidden'; }
}
function cerrarSubmenu(seccion,xm) {
	clearInterval(ap[xm]);
	desap[xm]=setInterval('desaparecer("'+seccion+'","'+xm+'")',1);
}

//ventana de efectos mouseover
function ventanita(texto,id) {
	var x=findPos(document.getElementById(id))[0]+20;
	var y=findPos(document.getElementById(id))[1]+15;
	document.getElementById("tablaVentanita").style.position="absolute";
	document.getElementById("tablaVentanita").style.top=y+'px';
	document.getElementById("tablaVentanita").style.left=x+'px';
	document.getElementById("txtVentanita").innerHTML=texto;
	document.getElementById("tablaVentanita").style.display='';
}
function cerrarVentanita() {
	document.getElementById('tablaVentanita').style.display='none';
	document.getElementById("txtVentanita").style.marginTop='0px';
}
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	//alert(curleft+","+curtop);
	return [curleft,curtop];
}

function efectoTagsOn(esto){
	//alert(esto.className);
	if (esto.className=='tagoff'){ esto.className='tagon'; }
}
function efectoTagsOff(esto){
	//alert(esto.className);
	if (esto.className=='tagon'){ esto.className='tagoff'; }
}
function efectoTagsClick(esto){
	//alert(esto.className);
	uno=document.getElementById('divDom1');
	elotro=document.getElementById('divDom2');
	uno.className='tagoff';
	elotro.className='tagoff';
	esto.className='tagactual';
}
function efectoTagsClick2(esto){
	//alert(esto.className);
	uno=document.getElementById('divHosp1');
	elotro=document.getElementById('divHosp2');
	uno.className='tagoff';
	elotro.className='tagoff';
	esto.className='tagactual';
}
//funcion para manejar el cambio de planes en la seccion de hospedaje
function masplanes() {
	var imag=document.getElementById('plan1').src.split("/");
	imagen=imag[imag.length-1];
	if (imagen=='planf020.gif'){
		document.getElementById('plan1').src='imagenes/planf400.gif';
		document.getElementById('plan2').src='imagenes/planf650.gif';
		document.getElementById('plan3').src='imagenes/planw050.gif';
		document.getElementById('plan4').src='imagenes/planw100.gif';
		
		document.getElementById('link_plan1').href='hospedaje_web.php?plan=F400';
		document.getElementById('link_plan2').href='hospedaje_web.php?plan=F650';
		document.getElementById('link_plan3').href='hospedaje_web.php?windows&plan=W050';
		document.getElementById('link_plan4').href='hospedaje_web.php?windows&plan=W100';
	} else {
		document.getElementById('plan1').src='imagenes/planf020.gif';
		document.getElementById('plan2').src='imagenes/planf040.gif';
		document.getElementById('plan3').src='imagenes/planf100.gif';
		document.getElementById('plan4').src='imagenes/planf200.gif';
		
		document.getElementById('link_plan1').href='hospedaje_web.php?plan=F020';
		document.getElementById('link_plan2').href='hospedaje_web.php?plan=F040';
		document.getElementById('link_plan3').href='hospedaje_web.php?plan=F100';
		document.getElementById('link_plan4').href='hospedaje_web.php?plan=F200';
	}
}
var u=60;
function cambiarImagenes(p) {
	desaparecerP=setInterval('fadeOut("'+p+'")',1);
}
function fadeOut(p) {
	document.getElementById('imgP1').style.MozOpacity=u/100;
	document.getElementById('imgP1').style.filter = 'alpha(opacity='+u+')';
	document.getElementById('imgP2').style.MozOpacity=u/100;
	document.getElementById('imgP2').style.filter = 'alpha(opacity='+u+')';
	document.getElementById('imgP3').style.MozOpacity=u/100;
	document.getElementById('imgP3').style.filter = 'alpha(opacity='+u+')';
	u=u-2;
	if (u<=0) {  
		clearInterval(desaparecerP);
		if (p==1) {
		document.getElementById('imgP1').src='portafolio/abby.jpg';
		document.getElementById('imgP2').src='portafolio/aventura.jpg';
		document.getElementById('imgP3').src='portafolio/lascabanas.jpg';
		} else {
		document.getElementById('imgP1').src='portafolio/weldox.jpg';
		document.getElementById('imgP2').src='portafolio/malibu.jpg';
		document.getElementById('imgP3').src='portafolio/jrpart.jpg';	
		}
		aparecerP=setInterval('fadeIn("'+p+'")',1);
	}
}
function fadeIn(p) {
	document.getElementById('imgP1').style.MozOpacity=u/100;
	document.getElementById('imgP1').style.filter = 'alpha(opacity='+u+')';
	document.getElementById('imgP2').style.MozOpacity=u/100;
	document.getElementById('imgP2').style.filter = 'alpha(opacity='+u+')';
	document.getElementById('imgP3').style.MozOpacity=u/100;
	document.getElementById('imgP3').style.filter = 'alpha(opacity='+u+')';
	u=u+2;
	if (u>=60) {  
			clearInterval(aparecerP);
			if (p==1) {
			document.getElementById('masP').href='javascript:cambiarImagenes(0);';
			} else {
			document.getElementById('masP').href='javascript:cambiarImagenes(1);';		
			}
	}
}
function menosOpaco(elemento) {
	elemento.style.MozOpacity=1;
	elemento.style.filter = 'alpha(opacity=100)';
}
function masOpaco(elemento) {
	elemento.style.MozOpacity=0.6;
	elemento.style.filter = 'alpha(opacity=60)';
}
function scrollear(paonde) {
	y=document.getElementById("txtVentanita").style.marginTop;
	y=y.replace("px","");
	y=parseInt(y);
	alto=document.getElementById("txtVentanita").offsetHeight;
	if ((paonde=='up')&&(y>68-alto)) { y=y-5; }
	if ((paonde=='down')&&(y<=-5)) { y=y+5; }
	document.getElementById("txtVentanita").style.marginTop=y+"px";
}
function monedaOn() {
	if (document.getElementById("moneda").alt=='Bs') {
			document.getElementById("moneda").src='imagenes/moneda_bs_on.jpg';
	}
	if (document.getElementById("moneda").alt=='USD') {
			document.getElementById("moneda").src='imagenes/moneda_usd_on.jpg';
	}
	if (document.getElementById("moneda").alt=='Eur') {
			document.getElementById("moneda").src='imagenes/moneda_eur_on.jpg';
	}
	document.getElementById("monedaOpciones").style.visibility='visible';
}
function monedaOff() {
	if (document.getElementById("moneda").alt=='Bs') {
			document.getElementById("moneda").src='imagenes/moneda_bs_off.jpg';
	}
	if (document.getElementById("moneda").alt=='USD') {
			document.getElementById("moneda").src='imagenes/moneda_usd_off.jpg';
	}
	if (document.getElementById("moneda").alt=='Eur') {
			document.getElementById("moneda").src='imagenes/moneda_eur_off.jpg';
	}
	document.getElementById("monedaOpciones").style.visibility='hidden';
}
function mantenerVisible() {
	document.getElementById("monedaOpciones").style.visibility='visible';
}
function hacerInvisible() {
	document.getElementById("monedaOpciones").style.visibility='hidden';
}
function prender(imagen,pos){
	if ((imagen=='eur')&&(pos=='arriba')) {
		document.getElementById("monedaArriba").src='imagenes/moneda_eur2_on.jpg';
	}
	if ((imagen=='eur')&&(pos=='abajo')) {
		document.getElementById("monedaAbajo").src='imagenes/moneda_eur3_on.jpg';
	}
	if (imagen=='usd') {
		document.getElementById("monedaAbajo").src='imagenes/moneda_usd2_on.jpg';
	}
	if (imagen=='bs') {
		document.getElementById("monedaArriba").src='imagenes/moneda_bs2_on.jpg';
	}
}
function apagar(imagen,pos){
	if ((imagen=='eur')&&(pos=='arriba')) {
		document.getElementById("monedaArriba").src='imagenes/moneda_eur2_off.jpg';
	}
	if ((imagen=='eur')&&(pos=='abajo')) {
		document.getElementById("monedaAbajo").src='imagenes/moneda_eur3_off.jpg';
	}
	if (imagen=='usd') {
		document.getElementById("monedaAbajo").src='imagenes/moneda_usd2_off.jpg';
	}
	if (imagen=='bs') {
		document.getElementById("monedaArriba").src='imagenes/moneda_bs2_off.jpg';
	}
}
function mas(cual) {
	if (document.getElementById(cual).style.display=='none') {
		document.getElementById(cual).style.display='';
		document.getElementById('desp_'+cual).innerHTML='<img src="imagenes/replegar.gif" alt="replegar">&nbsp;[<a href="javascript:mas(\''+cual+'\');">replegar</a>]';
	} else { 
		document.getElementById(cual).style.display='none';
		document.getElementById('desp_'+cual).innerHTML='<img src="imagenes/desplegar.gif" alt="desplegar">&nbsp;[<a href="javascript:mas(\''+cual+'\');">desplegar</a>]';
	}
}

function alerta(id,titulo,contenido,cerrar,ancho) {
	x=findPos(document.getElementById(id))[0]+40;
	y=findPos(document.getElementById(id))[1]+20;
	document.getElementById("titulo_vent_alert").innerHTML=titulo;
	document.getElementById("contenVentanita").innerHTML=contenido;
	document.getElementById("cerrar_img").innerHTML="<img src=\"imagenes/cerrar_ventana.jpg\" alt=\"cerrar\" width=\"16\" height=\"15\" id=\"img_cerrar\" hspace=\"5\" onClick=\"cierra_alerta('"+cerrar+"');\" style=\"cursor:hand;\">";
	document.getElementById("boton_cerrar").innerHTML="<input type=\"button\" class=\"boton\" name=\"aceptar\" id=\"aceptar\" value=\"Aceptar\" onClick=\"cierra_alerta('"+cerrar+"');\">";
	document.getElementById("ventana_error").style.width=ancho+'px';
	document.getElementById("ventana_error").style.position="absolute";	
	document.getElementById("ventana_error").style.top=y+'px';
	document.getElementById("ventana_error").style.left=x+'px';
	document.getElementById("ventana_error").style.display='';
}
function cierra_alerta(id_foco){
	document.getElementById("ventana_error").style.display='none';
	document.getElementById(id_foco).focus();
}

function validaEmail(id){
   // #5
   valor = document.getElementById(id).value;
   correo = valor.indexOf('@');   
   band=true;
   if (correo != -1){
      email = valor.split('@');
      point = email[1].indexOf('.');
      punto = email[1].split('.');
      if (point != -1 && point!=''){
         if (punto[1].length<2 || punto[1].length>4){
            alerta(id,'ERROR:','El dominio de la dirección de email no es valido!<br><br>Ejemplo: mi_email@facilweb.net',id,300);			
            band=false;
         }
      }
      else{
         alerta(id,'ERROR:','Falta el dominio del email!<br><br>Ejemplo: mi_email@facilweb.net',id,300);		 
         band=false;
      }
   }
   else{
		alerta(id,'ERROR:','El email es incorrecto!<br><br>Ejemplo: mi_email@facilweb.net',id,300);
		band=false;	   
   }
   if (band==true) return true;
   else return false;
}

function validarDominio(valor){
	//return valor.match(/^([a-zA-Z0-9][a-zA-Z0-9\-]{3,})\.([a-zA-Z0-9]{2,4}(\.[a-zA-Z0-9]{2})?)$/) == true;
  if(valor.match(/^([a-zA-Z0-9][a-zA-Z0-9\-]{3,})\.([a-zA-Z0-9]{2,4}(\.[a-zA-Z0-9]{2})?)$/)){	 
   return (true)
  } else {
    return (false);
  }
}


function valida_dominio(valor){
  if(valor.match(/^([a-zA-Z0-9\-.]{3,100})$/)){	 
   return (true)
  } else {
    return (false);
  }
}

function valida_dominio_hospedaje(valor){
  if(valor.match(/^([a-zA-Z0-9\-.]{2,100})$/)){	 
   return (true)
  } else {
    return (false);
  }
}

function select_selected(nomb_sel,valor){
 select_tipo = document.getElementById(nomb_sel).getElementsByTagName('OPTION');  
   for (i=0; i<select_tipo.length; i++)
	    select_tipo[i].selected=(select_tipo[i].getAttribute('value')==valor.toString());   			
}

var nav4 = window.Event ? true : false;
function soloNum(evt){
// Version Original
//   var key = nav4 ? evt.which : evt.keyCode;
//   return (key <= 13 || (key >= 48 && key <= 57));

// Version que soporta IE 8.0
var e = event || evt; // for trans-browser compatibility
    var charCode = e.which || e.keyCode;

    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

    return true;

}

function solomoneda(evt,id_campo){     
   str=document.getElementById(id_campo).value;	

// var key = nav4 ? evt.which : evt.keyCode;   
//   if((key==46 || key==44) && str.match(',')==null){
//   	   document.getElementById(id_campo).value+=',';	  
//   }
//   return (key <= 13 || (key >= 48 && key <= 57));

var e = event || evt; // for trans-browser compatibility
    var charCode = e.which || e.keyCode;

    if ((charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 188 || charCode > 189)))
        return false;
		
   return true;

}

function val_dominio(evt){
   //var key = nav4 ? evt.which : evt.keyCode;
   //return (key <= 13 || (key >= 65 && key <= 90)||(key >= 97 && key <= 122)||(key >= 48 && key <= 57)||key==45);
    
	var e = event || evt; // for trans-browser compatibility
	var charCode = e.which || e.keyCode;
	//alert(charCode);
	if ((charCode < 46)||(charCode == 47)||((charCode > 57)&&(charCode < 65))||((charCode > 90)&&(charCode < 97))||((charCode > 122)&&(charCode < 127)))
	return false;

    return true;
}
