// JavaScript Document
////////////////////////////Ejecuta Editar, Enviar, Borrar
function DoActiong(action)
{
        if (action=='borrar')
        {
                var IsChecked=0;

                document.catalogo.valor.value='@';
                for (var i=0;i<document.catalogo.elements.length;i++)
                {

                        var e = document.catalogo.elements[i];
                        if ((e.checked) && (e.type=='checkbox'))
                        {
                                IsChecked++;
                                document.catalogo.valor.value += document.catalogo.elements[i].value+'@';
                        }

                }
                if(IsChecked == 0)
                {
                        alert("Favor de seleccionar un registro");
                }
                else
                {
                        document.catalogo.accion.value = action;
                        document.catalogo.contador.value = IsChecked;
                        document.catalogo.submit();
                }
        }
        if (action=='enviar')
        {
                var IsChecked=0;

                document.mandar.valor.value='@';
                for (var i=0;i<document.catalogo.elements.length;i++)
                {

                        var e = document.catalogo.elements[i];
                        if ((e.checked) && (e.type=='checkbox'))
                        {
                                IsChecked++;
                                document.mandar.valor.value += document.catalogo.elements[i].value+'@';
                        }

                }
                if(IsChecked == 0)
                {
                        alert("Favor de seleccionar un registro");
                }
                else
                {
                        document.mandar.accion.value = action;
                        document.mandar.contador.value = IsChecked;
                        document.mandar.submit();
                }
        }
        if (action=='editar')
        {
                var IsChecked=0;

                for (var i=0;i<document.catalogo.elements.length;i++)
                {

                        var e = document.catalogo.elements[i];
                        if ((e.checked) && (e.type=='checkbox'))
                        {
                                IsChecked++;
                                document.edit_reg.valor.value = document.catalogo.elements[i].value;
                        }

                }
                if(IsChecked == 0)
                {
                        alert("Favor de seleccionar un registro");
                }
                if(IsChecked > 1)
                {
                        alert("Favor de seleccionar solo un registro");
                }
                if(IsChecked == 1)
                {
                        document.edit_reg.submit();
                }
        }
}

////////////////////////////////////Revisar fechas
	function revisa_fecha(TXT)
	{
		if(TXT.value!="")
		{
			 if( checkField( TXT, isDate, false ))
			 {
				longitud(TXT);	
				revisa_mes(TXT);
			}
		}
	}

///////////////////////////Revisión de formularios
var digits = "0123456789"; var lowercaseLetters = " .,-abcdefghijklmnopqrstuvwxyzáéíóúñü.%&";        var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚÑ"; var whitespace = " \t\n\r";        var phoneChars = "()-+ "; var dateChars = "/"; var mMessage = "Error: no puede dejar este espacio vacio"; var pPrompt = "Error: "; var pAlphanumeric = "ingrese un texto que contenga solo letras y/o numeros"; var pAlphabetic   = "ingrese un texto que contenga solo letras"; var pInteger = "ingrese un numero entero"; var pNumber = "ingrese un numero"; var pPhoneNumber = "ingrese un número de teléfono"; var pDate = "ingrese una fecha"; var pEmail = "ingrese una dirección de correo electrónico válida"; var pName = "ingrese un texto que contenga solo letras, numeros o espacios";

function isEmpty(s){return ((s == null) || (s.length == 0))}
function isWhitespace (s){var i;if (isEmpty(s)) return true;for (i = 0; i < s.length; i++){var c = s.charAt(i); if (whitespace.indexOf(c) == -1) return false;}        return true;}
function stripCharsInBag (s, bag){var i;var returnString = "";for (i = 0; i < s.length; i++){var c = s.charAt(i);        if (bag.indexOf(c) == -1) returnString += c;}return returnString;}
function stripCharsNotInBag (s, bag){var i;var returnString = "";for (i = 0; i < s.length; i++){ var c = s.charAt(i); if (bag.indexOf(c) != -1) returnString += c;}return returnString;}
function stripWhitespace (s){return stripCharsInBag (s, whitespace)}
function charInString (c, s){for (i = 0; i < s.length; i++){        if (s.charAt(i) == c) return true;}return false}
function stripInitialWhitespace (s){var i = 0;while ((i < s.length) && charInString (s.charAt(i), whitespace))i++; return s.substring (i, s.length);}
function isLetter (c){return( ( uppercaseLetters.indexOf( c ) != -1 ) ||( lowercaseLetters.indexOf( c ) != -1 ) )}
function isDigit (c){return ((c >= "0") && (c <= "9"))}
function isLetterOrDigit (c){return (isLetter(c) || isDigit(c))}
function isInteger (s){        var i;if (isEmpty(s)) if (isInteger.arguments.length == 1) return defaultEmptyOK; else return (isInteger.arguments[1] == true);        for (i = 0; i < s.length; i++) {var c = s.charAt(i); if( i != 0 ){if (!isDigit(c)) return false;} else { if (!isDigit(c) && (c != "-") || (c == "+")) return false;}}return true;}
function isNumber (s){var i;var dotAppeared;dotAppeared = false;if (isEmpty(s)) if (isNumber.arguments.length == 1) return defaultEmptyOK; else return (isNumber.arguments[1] == true);for (i = 0; i < s.length; i++){ var c = s.charAt(i);if( i != 0 ) {if ( c == "." ) {if( !dotAppeared ) dotAppeared = true;else        return false;}        else if (!isDigit(c)) return false;} else { if ( c == "." ) {if( !dotAppeared ) dotAppeared = true; else return false; } else if (!isDigit(c) && (c != "-") || (c == "+")) return false; } }return true;}
function isAlphabetic (s){var i; if (isEmpty(s)) if (isAlphabetic.arguments.length == 1) return defaultEmptyOK; else return (isAlphabetic.arguments[1] == true); for (i = 0; i < s.length; i++) { var c = s.charAt(i); if (!isLetter(c))        return false; } return true;}
function isAlphanumeric (s){var i; if (isEmpty(s)) if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK; else return (isAlphanumeric.arguments[1] == true); for (i = 0; i < s.length; i++){ var c = s.charAt(i); if (! (isLetter(c) || isDigit(c) ) ) return false;        } return true;}
function isName (s){if (isEmpty(s)) if (isName.arguments.length == 1) return defaultEmptyOK; else return (isAlphanumeric.arguments[1] == true); return( isAlphanumeric( stripCharsInBag( s, whitespace ) ) );}
function isPhoneNumber (s){ var modString; if (isEmpty(s)) if (isPhoneNumber.arguments.length == 1) return defaultEmptyOK; else return (isPhoneNumber.arguments[1] == true); modString = stripCharsInBag( s, phoneChars ); return (isInteger(modString))}
function isDate (s){ var modString; if (isEmpty(s)) if (isDate.arguments.length == 1) return defaultEmptyOK; else return (isDate.arguments[1] == true); modString = stripCharsInBag( s, dateChars ); return (isInteger(modString))}

function isEmail (s){ if (isEmpty(s))        if (isEmail.arguments.length == 1) return defaultEmptyOK; else return (isEmail.arguments[1] == true); if (isWhitespace(s)) return false; var i = 1; var sLength = s.length; while ((i < sLength) && (s.charAt(i) != "@")) { i++; } if ((i >= sLength) || (s.charAt(i) != "@")) return false; else i += 2; while ((i < sLength) && (s.charAt(i) != ".")) { i++; }  if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false; else return true;}
function statBar (s){ window.status = s}
function warnEmpty (theField){ theField.focus(); alert(mMessage); statBar(mMessage); return false;}
function warnInvalid (theField, s){ theField.focus(); theField.select(); alert(s); statBar(pPrompt + s); return false;}
function checkField (theField, theFunction, emptyOK, s){ var msg; if (checkField.arguments.length < 3) emptyOK = defaultEmptyOK; if (checkField.arguments.length == 4) { msg = s; } else        { if( theFunction == isAlphabetic ) msg = pAlphabetic; if( theFunction == isAlphanumeric ) msg = pAlphanumeric; if( theFunction == isInteger ) msg = pInteger; if( theFunction == isNumber ) msg = pNumber; if( theFunction == isEmail ) msg = pEmail; if( theFunction == isPhoneNumber ) msg = pPhoneNumber; if( theFunction == isDate ) msg = pDate; if( theFunction == isName ) msg = pName; } if ((emptyOK == true) && (isEmpty(theField.value))) return true; if ((emptyOK == false) && (isEmpty(theField.value))) return warnEmpty(theField); if (theFunction(theField.value) == true) return true; else return warnInvalid(theField,msg);}

////////////////////////////////Fechas

		function longitud(TXT)
		{
            var cadena1;
            cadena1 = TXT.value;

            if (cadena1.length<10)
            {
				alert("La fecha no es correcta"); 	
				TXT.focus();
				bandf = false;
			}
			else
			{
				bandf = true;
			}
		}

        function revisa(TXT)
        {
			var cadena1;
			cadena1 = TXT.value;

			if (cadena1.length==2)
			{
				TXT.value = cadena1.substring(0,2) + "/";
			}
			if (cadena1.length==5)
			{
				TXT.value = cadena1.substring(0,5) + "/";
			}
        }

        function revisa_mes(TXT)
        {
                cadena1 = TXT.value;

                if (cadena1.length==10)
                {
		                if (cadena1.substring(3,5)>12)
        		        {
                		    alert ("Es incorrecto el mes");
		                    TXT.value = cadena1.substring(0,2) + "/";
							bandf = false;
							TXT.focus();
						}
						else
						{
							bandf = true;
						}

                        if (cadena1.substring(3,5)==01 || cadena1.substring(3,5)==03 || cadena1.substring(3,5)==05 || cadena1.substring(3,5)==07 || cadena1.substring(3,5)==08 || cadena1.substring(3,5)==10 || cadena1.substring(3,5)==12)
                        {
                                if (cadena1.substring(0,2)>31)
                                {
                                        alert ("Es incorrecto el dia");
										TXT.value = "";
//                                        TXT.value = cadena1.substring(0,7) + "-";
										bandf = false;
										TXT.focus();
								}
								else
								{
										bandf = true;
								}
                        }
                        if (cadena1.substring(3,5)==04 || cadena1.substring(3,5)==06 || cadena1.substring(3,5)==09 || cadena1.substring(3,5)==11)
                        {
                                if (cadena1.substring(0,2)>30)
                                {
                                        alert ("Es incorrecto el dia");
										TXT.value = "";
//                                        TXT.value = cadena1.substring(0,7) + "/";
										bandf = false;
										TXT.focus();
								}
								else
								{
										bandf = true;
								}
                        }
                        if (cadena1.substring(3,5)==02)
                        {
						        var var1 = new Number(cadena1.substring(7,10));
								var div = (var1 - 1996)/4;
								var absol = Math.floor(div);
								if(div - absol==0)
								{
	                                if (cadena1.substring(0,2)>29)
    	                            {
                                        alert ("Es incorrecto el dia");
										TXT.value = "";
//                                        TXT.value = cadena1.substring(0,7) + "/";
										bandf = false;
										TXT.focus();
									}
									else
									{
										bandf = true;
									}
								}
								else
								{	
            	                    if (cadena1.substring(0,2)>28)
                	                {
                                        alert ("Es incorrecto el dia");
										TXT.value = "";
//                                        TXT.value = cadena1.substring(0,7) + "/";
										bandf = false;
										TXT.focus();
									}
									else
									{
										bandf = true;
									}
								}
                        }
                }
        }

///////////////////////////////////////////////menu auxiliar

function MM_reloadPage(init) {  //reloads the window if Nav4 resized

  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {

    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}

  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();

}


MM_reloadPage(true);


function MM_findObj(n, d) { //v4.0

  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 && document.getElementById) x=document.getElementById(n); return x;

}

function MM_showHideLayers() { //v3.0

  var i,p,v,obj,args=MM_showHideLayers.arguments;

  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];

    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }

    obj.visibility=v; }

}

///////////////////////////////////////////////bordes en la forma para cambio de color

function obscuro(TXT)
{
	if(document.alta.color.value==0)
	{
		TXT.className = 'field1';
	}
	else
	{
		document.alta.color.value=0;
		TXT.className = 'field2';
	}	
}

function claro(TXT)
{
	TXT.className = 'field';
}


///////////////////////////////////////////poder utilizar el enter como tab

/*nextfield = "box1"; 
netscape  = ""; 
ver       = navigator.appVersion; 
len       = ver.length; 
 
for( iln = 0; iln < len; iln++ ) { 
	if( ver.charAt( iln ) == "(" ) { 
		break; 
	} 
} 
netscape = ( ver.charAt( iln+1 ).toUpperCase() != "C" ); 
 
	// handle the keypress 
function keyDown( DnEvents ) { 
 
		// determine whether Netscape or Internet Explorer 
	k = ( netscape ) ? DnEvents.which : window.event.keyCode; 
 
		// enter key pressed 
	if ( k == 13 ) { 
		if ( nextfield == 'done' ) { 
				// submit, we finished all fields 
			return true; 
		} else { 
				// we are not done yet, send focus to next box 
			eval( 'document.' + nextfield + '.focus()' ); 
			return false; 
		} 
	} 
} 
 
	// work together to analyze keystrokes 
document.onkeydown = keyDown; 
 
if ( netscape ) { 
	document.captureEvents( Event.KEYDOWN|Event.KEYUP ); 
} */


///////////////////////////////////////////cambio de color en TR

	ie = document.all?1:0
	var frm = document.catalogo;

	function CCA(CB)
	{
			if (CB.checked) 
			{
				hL(CB);
			}
			else 
			{
				if (ie)
				{					
					dL(CB);
				}
				else 
				{
					Data = CB.name.split(/:/);
					dL(CB);
				}
			}
	}

	function hL(E)
	{
			if (ie)
			{
					while (E.tagName!="TR")
					{E=E.parentElement;}
			}
			else
			{
					while (E.tagName!="TR")
					{E=E.parentNode;}
			}
			E.className = "row2";
	}
	
	function dL(E)
	{
			if (ie)
			{
					while (E.tagName!="TR")
					{E=E.parentElement;}
			}
			else
			{
					while (E.tagName!="TR")
					{E=E.parentNode;}
			}
			E.className = "row1";
	}
	
////////////////////////////////////////////////////////////////Ordenamiento

if (document.ELEMENT_NODE == null) 
{
	document.ELEMENT_NODE = 1;
  	document.TEXT_NODE = 3;
}

function getTextValue(el) 
{
	var i;
  	var s;
  	
	s = "";
  	for (i = 0; i < el.childNodes.length; i++)
    if (el.childNodes[i].nodeType == document.TEXT_NODE)
    s += el.childNodes[i].nodeValue;
    else if (el.childNodes[i].nodeType == document.ELEMENT_NODE &&
    el.childNodes[i].tagName == "BR")
    s += " ";
    else
    s += getTextValue(el.childNodes[i]);
	return normalizeString(s);
}

function compareValues(v1, v2) 
{
	var f1, f2;

  	f1 = parseFloat(v1);
  	f2 = parseFloat(v2);
  	if (!isNaN(f1) && !isNaN(f2)) 
	{
    	v1 = f1;
    	v2 = f2;
  	}

  	if (v1 == v2)
    return 0;
  	if (v1 > v2)
    return 1
  	return -1;
}

var whtSpEnds = new RegExp("^\\s*|\\s*$", "g");
var whtSpMult = new RegExp("\\s\\s+", "g");

function normalizeString(s) 
{
	s = s.replace(whtSpMult, " "); 
  	s = s.replace(whtSpEnds, ""); 

  	return s;
}

function cambioimagen_chica(referenciaimagen,cambiopor)
{
	document.images[referenciaimagen].width = 0;
	document.images[referenciaimagen].src = eval(cambiopor + ".src")
}

function cambioimagen(referenciaimagen,cambiopor)
{
	document.images[referenciaimagen].width = 11;
	document.images[referenciaimagen].src = eval(cambiopor + ".src")
}
dibujo1 = new Image(108,27);
dibujo1.src = "../../pix/orden_DESC.gif";
dibujo2 = new Image(108,27);
dibujo2.src = "../../pix/orden_ASC.gif";
dibujo3 = new Image(108,27);
dibujo3.src = "../../pix/blanco.gif";

//////////////////////////////////////////////////////7Reportes

	function agregar_a()
	{
        if(document.alta.no_seleccionados.selectedIndex >= 0)
        {
                var no_seleccionados = document.alta.no_seleccionados;
                var seleccionados= document.alta.seleccionados;
                var selectedValue = "";
                var selectedText = "";
                var bandera = 0;

                for (var i=0;i<document.alta.seleccionados.length;i++)
                {
                        if(document.alta.seleccionados.options[i].value==document.alta.no_seleccionados.options[no_seleccionados.selectedIndex].value)
                        {
                                bandera=1;
                        }
                }
                if(bandera==0)
                {
						var sel = document.alta.no_seleccionados.selectedIndex;
                        selectedValue = document.alta.no_seleccionados.options[no_seleccionados.selectedIndex].value;
                        selectedText = document.alta.no_seleccionados.options[no_seleccionados.selectedIndex].text;
                        document.alta.seleccionados.options[seleccionados.length] = new Option(selectedText,selectedValue);
						document.alta.no_seleccionados.options[document.alta.no_seleccionados.selectedIndex] = null;
						
						document.alta.no_seleccionados.selectedIndex = sel;
						if(document.alta.no_seleccionados.length == sel)
						{
							document.alta.no_seleccionados.selectedIndex = sel-1;
						}
                }
				if(document.alta.no_seleccionados.length == 0)
				{
					document.alta.agregar.disabled = true;
				}
				document.alta.quitar.disabled = false;
        }
        else
        {		
				alert("Favor de seleccionar el registro que se desea agregar");
                document.alta.no_seleccionados.focus();
        }
	}

function quitar_a()
	{
        if(document.alta.seleccionados.selectedIndex >= 0)
        {
                var seleccionados = document.alta.seleccionados;
                var no_seleccionados= document.alta.no_seleccionados;
                var selectedValue = "";
                var selectedText = "";
                var bandera = 0;

                for (var i=0;i<document.alta.no_seleccionados.length;i++)
                {
                        if(document.alta.no_seleccionados.options[i].value==document.alta.seleccionados.options[seleccionados.selectedIndex].value)
                        {
                                bandera=1;
                        }
                }
                if(bandera==0)
                {
						var sel = document.alta.seleccionados.selectedIndex;
                        selectedValue = document.alta.seleccionados.options[seleccionados.selectedIndex].value;
                        selectedText = document.alta.seleccionados.options[seleccionados.selectedIndex].text;
                        document.alta.no_seleccionados.options[no_seleccionados.length] = new Option(selectedText,selectedValue);
						document.alta.seleccionados.options[document.alta.seleccionados.selectedIndex] = null;

						document.alta.seleccionados.selectedIndex = sel;
						if(document.alta.seleccionados.length == sel)
						{
							document.alta.seleccionados.selectedIndex = sel-1;
						}
                }
				if(document.alta.seleccionados.length == 0)
				{
					document.alta.quitar.disabled = true;
				}
				document.alta.agregar.disabled = false;
        }
        else
        {
				alert("Favor de seleccionar el registro que se desea quitar");
                document.alta.seleccionados.focus();
        }
	}

function agregar_i()
	{
        if(document.alta.no_seleccionados_i.selectedIndex >= 0)
        {
                var no_seleccionados_i = document.alta.no_seleccionados_i;
                var seleccionados_i= document.alta.seleccionados_i;
                var selectedValue = "";
                var selectedText = "";
                var bandera = 0;

                for (var i=0;i<document.alta.seleccionados_i.length;i++)
                {
                        if(document.alta.seleccionados_i.options[i].value==document.alta.no_seleccionados_i.options[no_seleccionados_i.selectedIndex].value)
                        {
                                bandera=1;
                        }
                }
                if(bandera==0)
                {
                        selectedValue = document.alta.no_seleccionados_i.options[no_seleccionados_i.selectedIndex].value;
                        selectedText = document.alta.no_seleccionados_i.options[no_seleccionados_i.selectedIndex].text;
                        document.alta.seleccionados_i.options[seleccionados_i.length] = new Option(selectedText,selectedValue);
						document.alta.no_seleccionados_i.options[document.alta.no_seleccionados_i.selectedIndex] = null;
                }
				if(document.alta.no_seleccionados_i.length == 0)
				{
					document.alta.agregar_imp.disabled = true;
				}
				document.alta.quitar_imp.disabled = false;
        }
        else
        {		
				alert("Favor de seleccionar el registro que se desea agregar");
                document.alta.no_seleccionados_i.focus();
        }
	}

	function quitar_i()
	{
        if(document.alta.seleccionados_i.selectedIndex >= 0)
        {
                var seleccionados_i = document.alta.seleccionados_i;
                var no_seleccionados_i= document.alta.no_seleccionados_i;
                var selectedValue = "";
                var selectedText = "";
                var bandera = 0;

                for (var i=0;i<document.alta.no_seleccionados_i.length;i++)
                {
                        if(document.alta.no_seleccionados_i.options[i].value==document.alta.seleccionados_i.options[seleccionados_i.selectedIndex].value)
                        {
                                bandera=1;
                        }
                }
                if(bandera==0)
                {
                        selectedValue = document.alta.seleccionados_i.options[seleccionados_i.selectedIndex].value;
                        selectedText = document.alta.seleccionados_i.options[seleccionados_i.selectedIndex].text;
                        document.alta.no_seleccionados_i.options[no_seleccionados_i.length] = new Option(selectedText,selectedValue);
						document.alta.seleccionados_i.options[document.alta.seleccionados_i.selectedIndex] = null;
                }
				//alert (document.alta.no_seleccionados.length);
				if(document.alta.seleccionados_i.length == 0)
				{
					document.alta.quitar_imp.disabled = true;
				}
				document.alta.agregar_imp.disabled = false;
        }
        else
        {
				alert("Favor de seleccionar el registro que se desea quitar");
                document.alta.seleccionados_i.focus();
        }
	}

	function arriba_a()
	{
        if(document.alta.seleccionados.selectedIndex >= 0)
        {
	        var x = new Number(document.alta.seleccionados.selectedIndex);
			x = x - 1;
			if(x>=0)
			{
				var valuex = document.alta.seleccionados.options[document.alta.seleccionados.selectedIndex].value;
				var valuey = document.alta.seleccionados.options[document.alta.seleccionados.selectedIndex-1].value;
				
				var textx = document.alta.seleccionados.options[document.alta.seleccionados.selectedIndex].text;
				var texty = document.alta.seleccionados.options[document.alta.seleccionados.selectedIndex-1].text;
				
				document.alta.seleccionados.options[document.alta.seleccionados.selectedIndex].value = valuey;
				document.alta.seleccionados.options[document.alta.seleccionados.selectedIndex-1].value = valuex;
				
				document.alta.seleccionados.options[document.alta.seleccionados.selectedIndex].text = texty;
				document.alta.seleccionados.options[document.alta.seleccionados.selectedIndex-1].text = textx;				
				
				document.alta.seleccionados.selectedIndex = x;
			}
        }
	}

	function abajo_a()
	{
        if(document.alta.seleccionados.selectedIndex >= 0)
        {
	        var maxi = new Number(document.alta.seleccionados.length);
	        var x = new Number(document.alta.seleccionados.selectedIndex);
			maxi = maxi - 1;
			x = x + 1;
			if(x<=maxi)
			{
				var valuex = document.alta.seleccionados.options[document.alta.seleccionados.selectedIndex].value;
				var valuey = document.alta.seleccionados.options[document.alta.seleccionados.selectedIndex+1].value;
				
				var textx = document.alta.seleccionados.options[document.alta.seleccionados.selectedIndex].text;
				var texty = document.alta.seleccionados.options[document.alta.seleccionados.selectedIndex+1].text;
				
				document.alta.seleccionados.options[document.alta.seleccionados.selectedIndex].value = valuey;
				document.alta.seleccionados.options[document.alta.seleccionados.selectedIndex+1].value = valuex;

				
				document.alta.seleccionados.options[document.alta.seleccionados.selectedIndex].text = texty;
				document.alta.seleccionados.options[document.alta.seleccionados.selectedIndex+1].text = textx;				
				
				document.alta.seleccionados.selectedIndex = x;
			}
        }
	}

	function arriba_i()
	{
        if(document.alta.seleccionados_i.selectedIndex >= 0)
        {
	        var x = new Number(document.alta.seleccionados_i.selectedIndex);
			x = x - 1;
			if(x>=0)
			{
				var valuex = document.alta.seleccionados_i.options[document.alta.seleccionados_i.selectedIndex].value;
				var valuey = document.alta.seleccionados_i.options[document.alta.seleccionados_i.selectedIndex-1].value;
				
				var textx = document.alta.seleccionados_i.options[document.alta.seleccionados_i.selectedIndex].text;
				var texty = document.alta.seleccionados_i.options[document.alta.seleccionados_i.selectedIndex-1].text;
				
				document.alta.seleccionados_i.options[document.alta.seleccionados_i.selectedIndex].value = valuey;
				document.alta.seleccionados_i.options[document.alta.seleccionados_i.selectedIndex-1].value = valuex;
				
				document.alta.seleccionados_i.options[document.alta.seleccionados_i.selectedIndex].text = texty;
				document.alta.seleccionados_i.options[document.alta.seleccionados_i.selectedIndex-1].text = textx;				
				
				document.alta.seleccionados_i.selectedIndex = x;
			}
        }
	}

	function abajo_i()
	{
        if(document.alta.seleccionados_i.selectedIndex >= 0)
        {
	        var maxi = new Number(document.alta.seleccionados_i.length);
	        var x = new Number(document.alta.seleccionados_i.selectedIndex);
			maxi = maxi - 1;
			x = x + 1;
			if(x<=maxi)
			{
				var valuex = document.alta.seleccionados_i.options[document.alta.seleccionados_i.selectedIndex].value;
				var valuey = document.alta.seleccionados_i.options[document.alta.seleccionados_i.selectedIndex+1].value;
				
				var textx = document.alta.seleccionados_i.options[document.alta.seleccionados_i.selectedIndex].text;
				var texty = document.alta.seleccionados_i.options[document.alta.seleccionados_i.selectedIndex+1].text;
				
				document.alta.seleccionados_i.options[document.alta.seleccionados_i.selectedIndex].value = valuey;
				document.alta.seleccionados_i.options[document.alta.seleccionados_i.selectedIndex+1].value = valuex;
				
				document.alta.seleccionados_i.options[document.alta.seleccionados_i.selectedIndex].text = texty;
				document.alta.seleccionados_i.options[document.alta.seleccionados_i.selectedIndex+1].text = textx;
				
				document.alta.seleccionados_i.selectedIndex = x;
			}
        }
	}

//////////////////////////Funcion para deshabilitar el back, ctrl + u , etc

		document.onkeydown = function(){
			if ((event.ctrlKey) && (event.keyCode == 85)){
			 window.event.returnValue = false;		
			}else if ((event.ctrlKey) && (event.keyCode == 78)) {
			 window.event.returnValue = false;
			}else if ((event.keyCode == 8)){
				if(document.hasFocus.type!="text")
				{
			 		window.event.returnValue = false;
				}
			}
		}


document.onclick = function (){
	if (event.srcElement.tagName == "A" && window.event.shiftKey) {
	 window.event.returnValue = false;
	}
}

/////////////////////////////función para abrir ventanas internas


var dragapproved=false
var minrestore=0
var initialwidth,initialheight,initialleft,initialtop
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function drag_drop(e){
if (ie5&&dragapproved&&event.button==1){
document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
}
}

function initializedrag(e){
offsetx=ie5? event.clientX : e.clientX
offsety=ie5? event.clientY : e.clientY
document.getElementById("dwindowcontent").style.display="none" //extra
tempx=parseInt(document.getElementById("dwindow").style.left)
tempy=parseInt(document.getElementById("dwindow").style.top)

dragapproved=true
document.getElementById("dwindow").onmousemove=drag_drop
}

function loadwindow(url,width,height, Left, Top){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
document.getElementById("dwindow").style.display=''
document.getElementById("dwindow").style.width=initialwidth=width+"px"
document.getElementById("dwindow").style.height=initialheight=height+"px"
document.getElementById("dwindow").style.left=initialleft= Left + "px"
document.getElementById("dwindow").style.top=initialtop= Top +"px"
document.getElementById("framec").src=url
}
}

function maximize(Height){
if (minrestore==0){
minrestore=1 //maximize window
document.getElementById("maxname").setAttribute("src","../../pix/restore.gif")
document.getElementById("dwindow").style.height= "0px"
}
else{
minrestore=0 //restore window
document.getElementById("maxname").setAttribute("src","../../pix/max.gif")
document.getElementById("dwindow").style.height=Height
top.Detalle.Alta1.framec.frames.document.all("framec").height='260px';
}

}
function closeit(){
document.getElementById("dwindow").style.display="none"
}

function stopdrag(){
dragapproved=false;
document.getElementById("dwindow").onmousemove=null;
document.getElementById("dwindowcontent").style.display="" //extra
}

///////////////////////////////////////sELECCIONAR TODO
	function seleccionar(CB)
	{
		if(CB.checked==true)
		{
			for (var i=0;i<document.catalogo.elements.length;i++)
		   	{
				var e = document.catalogo.elements[i];
           		if ((e.type=='checkbox') && (e.name=="a"))
		        {
    	        	e.checked=true;
					CCA(e);
				}
			}
		}
		else
		{
			for (var i=0;i<document.catalogo.elements.length;i++)
		   	{
				var e = document.catalogo.elements[i];
           		if ((e.type=='checkbox') && (e.name=="a"))
		        {
    	        	e.checked=false;
					CCA(e);
				}
			}		
		}
	}

////////////////////////////////////////7desplegar

	var plusImage = "../../pix/plus1.gif";
	var minusImage = "../../pix/minus1.gif";
	var imageTagPrefix = "img";
	var nodeSeparator = ".";
	var n = 1;

	ie = document.all?1:0
	var frm = document.catalogo;

	function intermedio(E)
	{
			while (E.tagName!="TR")
			{E=E.parentElement;}
			Collapse(E.id);
	}

	function Collapse(Node)
	{	
		objChildNode = document.getElementById(Node + nodeSeparator + n);
		
		objImg	= document.getElementById(imageTagPrefix + nodeSeparator + Node);
		
		if(objChildNode != null)
		{	
			if (objChildNode.style.display == "")
			{	
				if (objImg != null)objImg.src = plusImage;
				closeAllChilds(Node)
				return;
			}else 
			{	
				objChildNode.style.display = "";
				if (objImg != null)objImg.src = minusImage;
			}
			n = n + 1;
			Collapse(Node);
		}else n = 1;
	}

	function ExplicitCollapse(Node,p_direction)
	{	
		objChildNode = document.getElementById(Node + nodeSeparator + n);
		
		objImg	= document.getElementById(imageTagPrefix + nodeSeparator + Node);
		
		if(objChildNode != null)
		{	
			if (p_direction == "0")
			{	
				objChildNode.style.display = "none";
				if (objImg != null)objImg.src = plusImage;
				if(!closeAllChilds(objChildNode.id)) return false;
			}else 
			{	
				objChildNode.style.display = "";
				if (objImg != null)objImg.src = minusImage;
			}

			n = n + 1;
			ExplicitCollapse(Node,p_direction);
		}else n = 1;
	}

	function closeAllChilds(nNode)
	{	
		var tempNode,objTempNode,objNode,tempImg,objBody;
		objNode= document.getElementById(nNode);
		objTable = objNode.parentElement;
		var tagNm = objTable.tagName;
		if(tagNm.toUpperCase() == "TBODY")
		{	
			for(i=0;i<objTable.rows.length;i++)
			{	
				tempNode = objTable.rows[i].id;
				if (tempNode != nNode)
				{
					ja1 = tempNode.split(".");
					ja2 = nNode.split(".");
					var lon1 = ja1.length;
					var lon2 = ja2.length;
					if(lon1!=lon2)
					{
						if(tempNode.indexOf(nNode) >= 0)
						{	objTempNode	= document.getElementById(tempNode);
							tempImg		= document.getElementById(imageTagPrefix + nodeSeparator + tempNode);
							if (tempImg != null)tempImg.src = plusImage;
							objTempNode.style.display = "none";
						}
					}
				}
			}
		}else
		{	alert("Table Tag not found");
			return false;
		}
		return true;
	}

	function OpenNode(strNode,p_direction)
	{	var objNode;
		var arrNode = strNode.split(nodeSeparator);
		var str = "";
		for(i=0;i<arrNode.length;i++){
			if(str == "")
			{  str = arrNode[i];
			}else
			{
			   str = str + nodeSeparator + arrNode[i];
			}
			objNode = document.getElementById(str);
			if (objNode != null)
			{
				if (p_direction == "1")
				{
					ExplicitCollapse(str,p_direction);
				}else
				{
					Collapse(str);
				}
			}
			 
		}
	}