	
	function MM_expandirMenu(e)
	{
		if (e.style.display == "")
		{
			e.style.display="none";
		} else {
			e.style.display="";
		}
	}
	
	function MM_restaurarImagen() { //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 MM_cargarImagenes() { //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_cargarImagenes.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 MM_buscarObj(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_buscarObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}
	
	function MM_cambiarImagen() { //v3.0
	  var i,j=0,x,a=MM_cambiarImagen.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_buscarObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
		
	function DisplayStatusMsg(msgStr)
	{
		status=msgStr;
		document.MM_returnValue = true;
	}
	
	
	function OpenNewWindow(rScript, rHeight, rWidth, rLeft, rTop, fResizable)
	{
		
		window.open(rScript, "", "height="+rHeight+",width="+rWidth+",screenX=15,left="+rLeft+",screenY=15,top="+rTop+",channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable="+fResizable+",scrollbars=1,status=0,toolbar=0,titlebar=0");
		return true;
	}
	
	
// **************************** FUNCION PARA LA UTILIZACION DE MASCARAS ****************************	
var cuit = new Array(2,8,1)
var dni = new Array(1,3,3,3,3)
function mascara(d,sep,pat,nums){
if(d.valant != d.value){
	val = d.value
	largo = val.length
	val = val.split(sep)
	val2 = ''
	for(r=0;r<val.length;r++){
		val2 += val[r]	
	}
	if(nums){
		for(z=0;z<val2.length;z++){
			if(isNaN(val2.charAt(z))){
				letra = new RegExp(val2.charAt(z),"g")
				val2 = val2.replace(letra,"")
			}
		}
	}
	val = ''
	val3 = new Array()
	for(s=0; s<pat.length; s++){
		val3[s] = val2.substring(0,pat[s])
		val2 = val2.substr(pat[s])
	}
	for(q=0;q<val3.length; q++){
		if(q ==0){
			val = val3[q]
		}
		else{
			if(val3[q] != ""){
				val += sep + val3[q]
				}
		}
	}
	d.value = val
	d.valant = val
	}
}

// -----------------------------FUNCION PARA EFECTO FADE ----------------------------------------


function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;
 
    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}
 
//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}
 
function shiftOpacity(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
    if(document.getElementById(id).style.opacity == 100) {
        opacity(id, 100, 0, millisec);
    } else {
        opacity(id, 0, 100, millisec);
    }
}

// ------------------------------------------------- FUNCIÓN PARA VALIDAR UN CUIT, COMPLETO -------------------------------------------------

//////////////////// Funcion que valida el ingreso de SOLAMENTE NUMEROS impidiendo el ingreso de LETRAS Y SIMBOLOS ESPECIALES By Guillote.//////////
function valida_solo_numeros(e) { 
    tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==8){
	 return true;
	 }
	 else{
    patron = /\d/; // Solo acepta números
	//patron = /\w/; // En este caso aceptaría números y letras
	//patron = /\D/; // En este caso no aceptaría números
	//patron =/[A-Za-zñÑ\s]/; // Con la tecla ñ y Ñ incluidas..
    te = String.fromCharCode(tecla);
    return patron.test(te);
	}
}
//////////////////////////////////////////////// valida_CUIT //////////////////////////////////////////////
function valida_CUIT(){
var vec= new Array(10);
var permitidos = new Array(4);
var cuite;
var cuit = Form1.cuit.value;
var dosdigitos_cuit;
dosdigitos_cuit = cuit.substring(0,2); 
// Cargo en un vector los prefijos de cuit permitidos.
permitidos[0] = "20";
permitidos[1] = "27";
permitidos[2] = "30";
permitidos[3] = "33";
permitidos.toString();
dosdigitos_cuit.toString();

if(dosdigitos_cuit != permitidos[0] && dosdigitos_cuit != permitidos[1] && dosdigitos_cuit != permitidos[2]  && dosdigitos_cuit != permitidos[3]){
	alert("Formato de CUIT/CUIL invalido");
	return true;
}

esCuit=false;
cuit_rearmado="";
errors = '';
for (i=0; i < cuit.length; i++) { 
caracter=cuit.charAt( i);
if ( caracter.charCodeAt(0) >= 48 && caracter.charCodeAt(0) <= 57 ) {
cuit_rearmado +=caracter;
}
}
cuite=cuit_rearmado;
if ( cuite.length != 11) { // si no estan todos los digitos
esCuit=false;
errors = 'Cuit <11 ';
alert( "CUIT Menor a 11 Caracteres" );
return true;
} else {
x=i=dv=0;
// Multiplico los dígitos.
vec[0] = cuite.charAt( 0) * 5;
vec[1] = cuite.charAt( 1) * 4;
vec[2] = cuite.charAt( 2) * 3;
vec[3] = cuite.charAt( 3) * 2;
vec[4] = cuite.charAt( 4) * 7;
vec[5] = cuite.charAt( 5) * 6;
vec[6] = cuite.charAt( 6) * 5;
vec[7] = cuite.charAt( 7) * 4;
vec[8] = cuite.charAt( 8) * 3;
vec[9] = cuite.charAt( 9) * 2;

// Suma cada uno de los resultados para validar CUIT
for( i = 0;i<=9; i++) {
x += vec[i];
}
dv = (11 - (x % 11)) % 11;
if ( dv == cuite.charAt( 10) ) { 
esCuit=true;
} 
}
if ( !esCuit ) {
alert( "CUIT Invalido" );
document.Form1.cuit.focus();
errors = 'El CUIT/CUIL ingresado no es valido.';
return (false)
}
else{Form1.submit();}
}

