// JavaScript Document
//Contador de Caracteres
function vContar(form,name,vcount) {
  n = document.forms[form][name].value.length;
  t = vcount;
  if (n > t) {
    document.forms[form][name].value = document.forms[form][name].value.substring(0, t);
  }
  else {
    document.forms[form]['result'].value = t-n;
  }
}
//MENU DE SALTO
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//FUNCION PARA AGREGAR A FAVORITOS
function agregar(){
   if ((navigator.appName=="Microsoft Internet Explorer") && 
         (parseInt(navigator.appVersion)>=4)) {
      var url="http://www.yalpublicidad.com/"; 
      var titulo="YAL PUBLICIDAD - Diseño Grafico";
      window.external.AddFavorite(url,titulo);
   } else { 
      if(navigator.appName == "Netscape") 
         alert("Presione Crtl+D para agregar este sitio en sus Bookmarks"); 
   }
} 

//ABRIR VENTANA POPUP
function Abrir_windowsv(theURL,w,h) { 
var winName="VentanaV"
var windowprops ="top=100,left=100,toolbar=no,location=no,status=no, menubar=no,scrollbars=no, resizable=no,width=" + w + ",height=" + h;

window.open(theURL,winName,windowprops); 
} 

//ABRIR VENTANA POPUP
function Abrir_windowscroll(theURL2,w2,h2) { 
var winName2="mititulo"
var windowprops2 ="top=100,left=100,toolbar=yes,location=no,status=no, menubar=no,scrollbars=yes, resizable=no,width=" + w2 + ",height=" + h2;

window.open(theURL2,winName2,windowprops2); 
}

//Enviar Forma POPUP
function enviaForm(tbar,scrollb,w3,h3) {
//var windowp ="top=100,left=100,toolbar=" + tbar + ",location=no,status=no, menubar=no,scrollbars=" + scrollb + ", resizable=no,width=" + w3 + ",height=" + h3;

window.open('','winNombre','top=100,left=100,toolbar=' + tbar + ',location=no,status=no, menubar=no,scrollbars=' + scrollb + ', resizable=no,width=' + w3 + ',height=' + h3);
	document.mForm.target='winNombre';
	document.mForm.submit();
}

//FUNCION PARA INPUT DE FORMULARIOS
//******************************************************************************************************************
var v_state='false';
function onFocusField(field, value )
{
   if ( field.value == value || field.value == '')
   {
     field.value = '';
   }
}

function onBlurField(field, value )
{
   if ( field.value == '')
   {
     field.value = value;
   }
}

function onBlurF(field, value )
{
   if ( field.value == '')
   {
     field.value = value;
	 v_state='false';
   }
}
function onClickField() { v_state='true' }

function onMouseOverField(field, value )
{
   if ( field.value == value || field.value == '')
   {
     field.value = '';
   }
}

function onMouseOutField(field, value )
{
   if ( v_state=='false')
   {
     field.value = value;
   }
}
//-----------------------------------------------------------
function pch_blurlogin(state) {
  if (state=='load'){
    if (document.getElementById('loginname').value!=''){
      document.getElementById('pch_undiv').style.display='none';
    }
  }
  else if (state=='over'){
    if(document.getElementById('pch_undiv').style.display==''){
      document.getElementById('pch_undiv').style.display='none';
    }
  }
  else {
    if (document.getElementById('loginname').value==''){
      if (document.getElementById('login_focus').value!='true'){
        document.getElementById('pch_undiv').style.display='';
        if (!pch_loginnameDone){
          document.onmousemove = '';
        }
      }
    }
  }
}
function pch_blurpass(state) {
  if (state=='load'){
    if (document.getElementById('password').value!=''){
      document.getElementById('pch_pwdiv').style.display='none'; return true;
    }
  }
  else if (state=='over'){
    if(document.getElementById('pch_pwdiv').style.display==''){
      document.getElementById('pch_pwdiv').style.display='none';
    }
  }
  else{
    if (document.getElementById('password').value==''){
      if (document.getElementById('pass_focus').value!='true'){
        document.getElementById('pch_pwdiv').style.display='';
        pch_loginnameDone = false;
      }
    }
  }
}

function pchj_passwatch(){
  pchj_logClick();
  if ((pch_loginnameField.onfocus)&&(!pch_loginnameDone)) {
    document.onmousemove = pch_checkpass;
  }
}

function pchj_key_name(frm,e){
  var keycode;
  if (window.event) keycode = window.event.keyCode;
  else if (e) keycode = e.which;
  if (keycode == 13){pch_blurpass('load');}
}

function pchj_logClick() {pc_link_clicked=true;}
//******************************************************************************************************************


//FUNCION PARA SWF
function embedFlash(ubicacion,pelicula,ancho,alto){
	  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ancho+'" height="'+alto+'" >');
		document.write('<param name="movie" value="'+ubicacion+pelicula+'.swf" />');
		document.write('<param name="quality" value="high" />');
		document.write('<param name="wmode" value="transparent" />');
		document.write('<embed src="'+ubicacion+pelicula+'.swf" width="'+ancho+'" height="'+alto+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>');
	  document.write('</object>');
}

//VALIDAR RENOVACIÓN DE DOMINIO
function vValidarRenovacion() {
	var x=document.frenovar.periodo;
	/*if(x.options[x.selectedIndex].index == 1){
		document.frenovar.importe.value = ;
	}else{
		document.frenovar.cuentayal.value = "";
	}*/	
	var imp=document.frenovar.monto.value * x.options[x.selectedIndex].value;
	var igv=imp * 0.19;
	if (document.frenovar.igv.checked){
		document.frenovar.importe.value = imp + igv;
	}else{
		document.frenovar.importe.value = imp;
	}
}

function vValRenovacion(){
	if (document.frenovar.operacion.value==''){
		alert('Por favor ingrese el numero de operación');
		document.frenovar.operacion.focus();
		return false;
	}
	if (document.frenovar.fecha.value==''){
		alert('Por favor ingrese la fecha de depósito');
		document.frenovar.fecha.focus();
		return false;
	}
	if (document.frenovar.importe.value=='0'){
		alert('Por favor seleccione el periodo de renovación el cual debe coincidir con el importe entregado de depósito');
		document.frenovar.importe.focus();
		return false;
	}
	return true	
}

//VALIDAR FORMULARIO DE COTIZACION
function vValidarCotizacion() {
	if (document.fcotizar.ancho.value == '') {
		alert('Por favor ingrese el ancho en metros ejm 1.20');
		document.fcotizar.ancho.focus();
		return false;
	}
	if (document.fcotizar.alto.value == '') {
		alert('Por favor ingrese el alto en metros 0.50');
		document.fcotizar.alto.focus();
		return false;
	}
	return true;
}
//FUNCION PARA VALIDAR BUSCADOR DE DOMINIO
function vBuscarDominio() {
  if (document.frm.domain.value == '' | document.frm.domain.value == 'Nombre sin extensión' | document.frm.domain.value == 'Enter name without extension') {
    alert('Por favor ingrese un nombre de dominio válido.');
    document.frm.domain.focus();
    return false;
    }
	
	/*window.open('','myWin','toolbar=yes,location=no,status=no,menubar=no,scrollbars=yes, resizable=no,width=650,height=450');
	document.dominio.target='myWin';
	document.dominio.submit();*/
  return true;
}

//FUNCION PARA VALIDAR FORMULARIO DE LOGIN
function vLogin() {
  if (document.login.usuario.value == '') {
    alert('Por favor ingrese su ID de Cliente.');
    document.login.usuario.focus();
    return false;
    }
	
   if (document.login.password.value == '') {
    alert('Por favor ingrese su clave.');
    document.login.password.focus();
    return false;
    }
  return true;
}

//VALIDAR COMPRA DE HOSTING

function ValidarCompra() {
	if (document.comprarhost.empresa.value==''){
		alert('Por favor ingrese su nombre completo o nombre de su empresa seguido de su nombre completo');
		document.comprarhost.empresa.focus();
		return false;
	}
	
	if (document.comprarhost.numdoc.value==''){
		alert('Por favor ingrese el número de su DNI o RUC');
		document.comprarhost.numdoc.focus();
		return false;
	}
	
	if (document.comprarhost.direccion.value==''){
		alert('Por favor ingrese su domicilio');
		document.comprarhost.direccion.focus();
		return false;
	}
	
	if (document.comprarhost.ciudad.value==''){
		alert('Por favor ingrese su ciudad');
		document.comprarhost.ciudad.focus();
		return false;
	}
	
	if (document.comprarhost.telefono.value==''){
		alert('Por favor ingrese su Teléfono');
		document.comprarhost.telefono.focus();
		return false;
	}
	
	if (document.comprarhost.attach.value==''){
		alert('Por favor adjunte su Voucher Escaneado.');
		document.comprarhost.attach.focus();
		return false;
	}
	if (document.comprarhost.contrato.checked==false){
		alert('Por favor acepte el Contrato.');
		document.comprarhost.contrato.focus();
		return false;
	}
	return true;
} 

//VALIDAR FORMULARIO DE AGENDAR VISITA
function vAgendarVisita() {
	if (document.comprarhost.nombre.value==''){
		alert('Por favor ingrese su nombre completo o nombre de su empresa seguido de su nombre completo');
		document.comprarhost.nombre.focus();
		return false;
	}
	
	if (document.comprarhost.dni.value==''){
		alert('Por favor ingrese el número de su D.N.I.');
		document.comprarhost.dni.focus();
		return false;
	}
	
	if (document.comprarhost.telefono.value==''){
		alert('Por favor ingrese su Teléfono');
		document.comprarhost.telefono.focus();
		return false;
	}
	
	if (document.comprarhost.email.value==''){
		alert('Por favor su Email.');
		document.comprarhost.email.focus();
		return false;
	}
	
	if (document.comprarhost.lugarcita.value==''){
		alert('Por favor ingrese la dirección completa donde se realizará nuestra visita');
		document.comprarhost.lugarcita.focus();
		return false;
	}
	return true;
} 	 

//VALIDAR FORMULARIO DE AGENDAR VISITA
function vComprar() {
	if (document.comprar.empresa.value==''){
		alert('Por favor ingrese el nombre de su Razon Social');
		document.comprar.empresa.focus();
		return false;
	}
	
	if (document.comprar.nombre.value==''){
		alert('Por favor ingrese su nombre completo');
		document.comprar.nombre.focus();
		return false;
	}
	
	if (document.comprar.dni.value==''){
		alert('Por favor ingrese el número de su D.N.I.');
		document.comprar.dni.focus();
		return false;
	}
	
	if (document.comprar.telefono.value==''){
		alert('Por favor ingrese su Teléfono');
		document.comprar.telefono.focus();
		return false;
	}
	
	if (document.comprar.email.value==''){
		alert('Por favor su Email.');
		document.comprar.email.focus();
		return false;
	}
	
	if (document.comprar.direccion.value==''){
		alert('Por favor ingrese la dirección');
		document.comprar.direccion.focus();
		return false;
	}
	return true;
} 	 

/*function fnSetFocusComprar()
{
	document.comprar.empresa.focus();
	document.comprar.total.value=document.comprar.precioservicio.value;
	
	var x=document.comprar.precioservicio;
	var Total=document.comprar.total.value
	
	document.comprar.subtotal.value = Total/1.19
	document.comprar.igv.value = document.comprar.total.value - document.comprar.subtotal.value

	 if(x.options[x.selectedIndex].index == 1){
		document.comprar.servicio.value = "Papeleria";
	} else if (x.options[x.selectedIndex].index == 2){
		document.comprar.servicio.value = "Logotipo Empresarial";
	} else if (x.options[x.selectedIndex].index == 3){
		document.comprar.servicio.value = "Logotipo Corporativo";
	} else if (x.options[x.selectedIndex].index == 4){
		document.comprar.servicio.value = "Sistema de Datos";
	} else if (x.options[x.selectedIndex].index == 5){
		document.comprar.servicio.value = "Diseño Web Corporativo";
	} else if (x.options[x.selectedIndex].index == 6){
		document.comprar.servicio.value = "Diseño Web en Flash";
	} else if (x.options[x.selectedIndex].index == 7){
		document.comprar.servicio.value = "Diseño Web Informativo";
	} else if (x.options[x.selectedIndex].index == 8){
		document.comprar.servicio.value = "Diseño Web Personal";
	} else if (x.options[x.selectedIndex].index == 9){
		document.comprar.servicio.value = "Diagramación de Revistas 36 Pag.";
	} else {
		document.comprar.servicio.value = "No ha seleccionado ningún servicio";
	} 
	
	 if(x.options[x.selectedIndex].index == 2){
		document.comprar.password.maxLength = 6;
		document.comprar.password.readOnly = true;
	}
	else{
		document.comprar.password.value = "";
		document.comprar.password.maxLength = 4;
		document.comprar.password.readOnly = true;
	} 

} */

//VALIDAR FORMULARIO DE REGISTRO DE COMPRA
function vRegistrar() {
	if (document.comprar.nombre.value==''){
		alert('Por favor ingrese su nombre completo');
		document.comprar.nombre.focus();
		return false;
	}
	
	if (document.comprar.numdoc.value==''){
		alert('Por favor ingrese el número de su documento.');
		document.comprar.numdoc.focus();
		return false;
	}
	
	if (document.comprar.telefono.value==''){
		alert('Por favor ingrese su Teléfono');
		document.comprar.telefono.focus();
		return false;
	}
	
	if (document.comprar.email.value==''){
		alert('Por favor su Email.');
		document.comprar.email.focus();
		return false;
	}
	
	if (document.comprar.direccion.value==''){
		alert('Por favor ingrese la dirección');
		document.comprar.direccion.focus();
		return false;
	}
	if (document.comprar.ciudad.value==''){
		alert('Por favor ingrese su ciudad');
		document.comprar.ciudad.focus();
		return false;
	}
	if (document.comprar.departamento.value==''){
		alert('Por favor ingrese su departamento');
		document.comprar.departamento.focus();
		return false;
	}
	if (document.comprar.codigopostal.value==''){
		alert('Por favor ingrese su código postal');
		document.comprar.codigopostal.focus();
		return false;
	}
	return true;
}