function AbrirPagina(Ruta,Ventana,Propiedades) {
	window.open(Ruta,Ventana,Propiedades);
}

function AsigNom(Nombre){
	window.name = Nombre;
}

function mStatus(msj){ window.status = msj; }

function aActivar(valor){
	var d = document;
	var v = d.getElementById(valor);
	var w = d.getElementById('Bordado');
	var x = d.getElementById('Estampado');
	var y = d.getElementById('largo');

	if((!w.checked)&&(!x.checked)){
		alert('Debe Seleccionar Un Tipo');
		v.checked = !x.checked;
	}

	if (valor=='Bordado'){
		y.disabled = !w.checked;
		y = d.getElementById('ancho');
		y.disabled = !w.checked;
	}
	if (valor=='Estampado'){
		y = d.getElementById('colores');
		y.disabled = !x.checked;	
	}
}

function ValidarForma(){
	var d = document;
	var campos = ValidarForma.arguments;
	var arg, x, err;
	
	err = '';

	x = d.getElementById(campos[1]); if (x.value<campos[0]){ err+= '* La Cantidad debe ser Mayor o Igual a '+campos[0]+'. \n'; }
	if (campos.length>2) {
		x = d.getElementById("Bordado"); if(x.checked){
		if (campos.length>2) { x = d.getElementById(campos[2]); if (x.value==''){ err+= '* Debe Ingresar el Largo del Bordado. \n'; } }
		if (campos.length>3) { x = d.getElementById(campos[3]); if (x.value==''){ err+= '* Debe Ingresar el Ancho del Bordado. \n'; } } }
		if (campos.length>4) { x = d.getElementById("Estampado"); if(x.checked){
		x = d.getElementById(campos[4]); if (x.value==''){ err+= '* Debe Ingresar Los Colores del Estampado. \n'; } } }
	}
	if (err!=''){ alert('Se Han Producido los Siguientes Errores: \n\n'+err); form2.action = ''; }
}

function ValidarCarro(){
	var d = document;
	var campos = ValidarCarro.arguments;
	var arg, x, err;
	
	err = '';

	x = d.getElementById(campos[2]); if (x.value<campos[1]){ err+= '* La Cantidad debe ser Mayor o Igual a '+campos[1]+'. \n'; }
	if (err!=''){ alert('Se Han Producido los Siguientes Errores: \n\n'+err); }
	else {
		x = d.getElementById(campos[2]);
		AbrirPagina(campos[0]+"&idp="+campos[3]+"&valor="+x.value,'Index');
		}
}

function pPreguntar(vinculo){
	if (confirm("¿Está seguro que desea eliminar este articulo?")){
		AbrirPagina(vinculo,'Index');
	}
}

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.title; 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 += '- Requerido '+nm+'.\n'; }
  } if (errors) alert('Se produjeron los siguientes Errores:\n'+errors);
  document.MM_returnValue = (errors == '');
}