<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function muestraCorfo(valor) {
	campo = MM_findObj('corfito')
	if (valor == 2) {
		
		campo.style.display = ""
	} else {
		campo.style.display = "none"
	}
	
}
function copiaClipboard(meintext) {
	if (window.clipboardData) 
   {
   
   // the IE-manier
   window.clipboardData.setData("Text", meintext);
   
   // waarschijnlijk niet de beste manier om Moz/NS te detecteren;
   // het is mij echter onbekend vanaf welke versie dit precies werkt:
   }
   else if (window.netscape) 
   { 
   
   // dit is belangrijk maar staat nergens duidelijk vermeld:
   netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
   
   // maak een interface naar het clipboard
   var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
   if (!clip) return;
   
   // maak een transferable
   var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
   if (!trans) return;
   
   // specificeer wat voor soort data we op willen halen; text in dit geval
   trans.addDataFlavor('text/unicode');
   
   // om de data uit de transferable te halen hebben we 2 nieuwe objecten nodig   om het in op te slaan
   var str = new Object();
   var len = new Object();
   
   var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
   
   var copytext=meintext;
   
   str.data=copytext;
   
   trans.setTransferData("text/unicode",str,copytext.length*2);
   
   var clipid=Components.interfaces.nsIClipboard;
   
   if (!clip) return false;
   
   clip.setData(trans,null,clipid.kGlobalClipboard);
   
   }
   alert("Following info was copied to your clipboard:\n\n" + meintext);
   return false;
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function actInterprete(valor) {
	inte = MM_findObj('inte')
	inter = MM_findObj('interprete')
	if (valor == 1) {
		inte.style.display = ""
	} else {
		inte.style.display = "none"
		inter.value = ""
	}
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_checkPlugin(plgIn, theURL, altURL, autoGo) { //v4.0
  var ok=false; document.MM_returnValue = false;
  with (navigator) if (appName.indexOf('Microsoft')==-1 || (plugins && plugins.length)) {
    ok=(plugins && plugins[plgIn]);
  } else if (appVersion.indexOf('3.1')==-1) { //not Netscape or Win3.1
    if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
    else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
    else ok=autoGo; }
  if (!ok) theURL=altURL; if (theURL) window.location=theURL;
}
function muestra (campo){
	elCampo = MM_findObj(campo)
	elCampo.style.display = ""
}
function oculta (campo){
	elCampo = MM_findObj(campo)
	elCampo.style.display = "none"
}
function mo (campo) {
	elCampo = MM_findObj(campo)
	if (elCampo.style.display == "") {
		elCampo.style.display = "none"
	}
	else if (elCampo.style.display == "none") {
		elCampo.style.display = ""
	}
}
function desactRut(pais) {
	if (pais != "Chile") {
		campo = MM_findObj('rut')
		campo.value = "0"
		campo.style.display = "none"
		campo2 = MM_findObj('rutText')
		campo2.style.display = "none"
	} else{
		campo = MM_findObj('rut')
		campo.value = ""
		campo.style.display = ""
		campo2 = MM_findObj('rutText')
		campo2.style.display = ""
	}
}
function number_format(a, b, c, d) {
 a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
 e = a + '';
 f = e.split('.');
 if (!f[0]) {
  f[0] = '0';
 }
 if (!f[1]) {
  f[1] = '';
 }
 if (f[1].length < b) {
  g = f[1];
  for (i=f[1].length + 1; i <= b; i++) {
   g += '0';
  }
  f[1] = g;
 }
 if(d != '' && f[0].length > 3) {
  h = f[0];
  f[0] = '';
  for(j = 3; j < h.length; j+=3) {
   i = h.slice(h.length - j, h.length - j + 3);
   f[0] = d + i +  f[0] + '';
  }
  j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
  f[0] = j + f[0];
 }
 c = (b <= 0) ? '' : c;
 return f[0] + c + f[1];
}

function setSubtotal(minim, maxim) {
	var elTotal = 0;
	for (i=minim;i<=maxim;i++) {
		elValor = MM_findObj('h_'+i)
		laCant = MM_findObj('i_'+i)
		if (laCant != null && laCant.value != 0 && elValor != null && elValor.value != 0) {
		elTotal += elValor.value*laCant.value
		}
	}
	elCampo = MM_findObj('subtotal')
	elCampo.value = number_format(elTotal, 0, ',', '.')
	elCampo2 = MM_findObj('subtotal2')
	elCampo2.value = number_format(elTotal, 0, ',', '.')
}
function genCod (campo, long) {
	cod = ""
	RI_chars = Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
	RILong = RI_chars.length - 1
	if (long == "") {
		long = 12
	}
	for (i=0;i<long;i++) {
		pos = Math.round(RILong * Math.random())
		cod += RI_chars[pos]
	}
	elCampo = MM_findObj(campo)
	elCampo.value = cod
}
function genUser (nombre, apellido, usuario, long) {
	cod = ""
	elNombre = MM_findObj(nombre)
	elApellido = MM_findObj(apellido)
	i = Math.round(Math.random()*2)+2
	eln = elNombre.value.substr(0, i)
	i = Math.round(Math.random()*2)+2
	ela = elApellido.value.substr(0, i)
	n = Math.round(Math.random()*50)
	cod =  eln + ela + n
	elCampo = MM_findObj(usuario)
	elCampo.value = cod
}
function MM_validateForm() { //v4.0
  if (document.getElementById){
    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=document.getElementById(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 == '');
} }
//-->