/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
	function confirmarpaso2() {
		var resp;
		resp = confirm("\xbfEsta seguro de confirmar el registro?");
		if (resp==true){
			document.regestudio.submit();
		};
	}
	function cancelar(){
		var resp;

		resp = confirm('\xbfEsta seguro de cancelar el registro?');
		if (resp){
			window.location='http://www.pymesuruguay.com/index.php';
		}
	}
        function checklegal(ind){
            var chk = document.getElementById('chklegal');
            var conf = document.getElementById('siguiente');
            var marco = document.getElementById('marcolegal');
            var navegador = navigator.appName

            if (chk){
                if (ind==0){
                    chk.checked=true;
                    conf.disabled=false;
                    marco.style.borderColor='green';
                }else{
                    if (chk.checked){
                        conf.disabled=false;
                        marco.style.borderColor='green';
                    }else{
                        conf.disabled=true;
                        marco.style.borderColor='red';
                    }
                }
            }
        }
	function confirmarpaso1(cantr) {
            var resp;
            var i;
            var cantop=0;
            var valor;
            var depto = parseFloat(document.getElementById('dpto').value);
            var local = parseFloat(document.getElementById('selloc').value);
            var nloc = document.getElementById('nuevaloc').value;
            var mail = document.getElementById('mimail').value;
            var p;
            var errors='';

            resp = confirm('Atenci\xf3n: Se registrar\xe1 la empresa y podr\xe1 especificar tres productos en la siguiente pantalla \xbfEst\xe1 seguro de confirmar el registro?');
            if (resp){
                if ((document.regestudio.denominacion.value == '') || (document.regestudio.rsocial.value == '')) {
                    errors += 'Especifique Denominaci\xf3n y Raz\xf3n Social.\r\n';
                }
                if ((document.regestudio.ruc.value == '')){
                    errors += 'Especifique un ruc correctamente.\r\n';
                }
                if ((document.regestudio.usadm.value == '')){
                    errors += 'Especifique un nombre de usuario correctamente.\r\n';
                }
                p=mail.indexOf('@');
                if ((p<1) || (p==(mail.length-1))) {
                    errors += 'Especifique un e-mail correctamente.\r\n';
                }
                for (i=0;i<=cantr;i++){
                    if (typeof(eval('document.regestudio.op' + i))=='object'){
                        eval ('valor = document.regestudio.op' + i + '.checked;');
                        if (valor){
                            cantop = cantop+1;
                        }
                    }
                }
                if ((depto==999999)||(local==999999)||(((isNaN(local))||(local==0))&&(nloc==''))){
                    errors += 'Debe seleccionar Departamento y Localidad (o especificar una).\r\n';
                }else{
                    if (cantop >4){
                        errors += 'Atenci\xf3n no se permite participar en m\xe1s de 4 rubros. Gracias.\r\n';
                    }else{
                        if (cantop==0){
                            errors += 'Debe seleccionar un rubro por lo menos.\r\n';
                        }else{
                            if (nloc!=''){
                                document.regestudio.obs.value = document.regestudio.obs.value + ' Nueva Localidad:' + nloc;
                            }
                            if ((document.regestudio.code.value == '')){
                                errors += 'Por Favor ingrese c\xf3digo de verificaci\xf3n.\r\n';
                            }
                        }
                    }
                }
                if (errors!=''){
                    alert (errors);
                }else{
                    document.regestudio.submit();
                }
            }
        }
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
function confirmarCONTACTO(){
        var depto = parseFloat(document.getElementById('dpto').value);
        var local = parseFloat(document.getElementById('selloc').value);
        var nloc = document.getElementById('nuevaloc').value;
        var mail = document.contacto.email.value;
        var nombre = document.contacto.nombre.value;
        var comenta = document.contacto.comentario.value;
        var errors='';

        if (nombre==''){
            errors = errors + 'Debe especificar un nombre.\n';
        }
        p=mail.indexOf('@');
        if (p<1 || p==(mail.length-1)) {
            errors = errors + 'Debe especificar una direcci\xf3n de e-mail correcta.\n';
        }
        if ((depto==999999)||(local==999999)||(((isNaN(local))||(local==0))&&(nloc==''))){
            errors = errors + 'Debe seleccionar Departamento y Localidad (o especificar una).\n';
        }
        if (comenta==''){
            errors = errors + 'Debe especificar un comentario.\n';
        }
        if (errors!=''){
            alert (errors);
        }else{
            document.contacto.departamento.value = document.contacto.dpto.options[document.contacto.dpto.selectedIndex].text;
            if (document.contacto.nuevaloc.value!=''){
                document.contacto.localidad.value = document.contacto.nuevaloc.value;
            }else{
                document.contacto.localidad.value = document.contacto.selloc.options[document.contacto.selloc.selectedIndex].text;
            }
            document.contacto.submit();
        }
}

    function irA(intendencias){
		if (intendencias.options[intendencias.selectedIndex].value!=="") {
			window.open(intendencias.options[intendencias.selectedIndex].value);
		}
    }



