
leng_texto1="Las contraseñas ingresadas no son iguales";
leng_texto2="Las contraseñas deben tener por lo menos 4 caracteres de largo.";
leng_texto3="Debe seleccionar por lo menos una opción para hacer la busqueda";
leng_texto4="Debe seleccionar una opción para hacer la busqueda";
leng_texto5="Debe ingresar este campo para continuar";
leng_texto6="Numero ingresado incorrecto";
leng_texto7="Formato de email inválido";
leng_texto8="El formato no es del tipo moneda";
leng_texto9=". Ingrese para continuar";

// CODIGO DE ROLLOVER DE COLOR DE CELDAS

function cOvr(src) {
if (!src.contains(event.fromElement)) {
src.style.cursor = 'hand';
}
}

function cOut(src) {
if (!src.contains(event.toElement)) {
src.style.cursor = 'default';
}
}

function mOvr(src,clrOver) {
if (!src.contains(event.fromElement)) {
src.style.cursor = 'hand';
src.bgColor = clrOver;
}
}

function mOut(src,clrIn) {
if (!src.contains(event.toElement)) {
src.style.cursor = 'default';
src.bgColor = clrIn;
}
}

function mClk(src) {
if(event.srcElement.tagName=='TD'){
src.children.tags('A')[0].click();
}
}
// FIN DE ROLLOVER CELDAS
function buscaren() {
	var sel=false
	var formb= document.forms["b"]
	var query= escape (formb.query.value)
	for (var i=0;i < formb.b.length ; i++ )
	{
		if (formb.b[i].checked)	{ 
			sel= true
			break	}
	}
	if (sel)
	{
			openwin (formb.b[i].value + query, "600", "400", 1)
	}

}

//drag drop function for IE 4+//////
/////////////////////////////////
var dragapproved=false
var layername
var lastbox

function initializedragie(layername){
iex=event.clientX;
iey=event.clientY;
tempx=layername.style.pixelLeft;
tempy=layername.style.pixelTop;

dragapproved=true;
// metodo ejecutado onmousemove 
document.onmousemove=function (){
if (dragapproved){
	layername.style.pixelLeft=tempx+event.clientX-iex;
	layername.style.pixelTop=tempy+event.clientY-iey;

//     ^  Now works with multiple windows
 return false;
	}
}
}

if (document.all){
document.onmouseup=new Function("dragapproved=false")
}

////drag drop functions end here//////

function hidebox(layername){
if (document.all)
layername.style.visibility="hidden"
else if (document.layers)
document.eval("layername").visibility="hide"
}
function showbox(layername){
// closes the last window before opening the next
if (lastbox){
	hidebox(lastbox)
	}
	lastbox=layername;
	//end of closing, now open the next window
if (document.all)
layername.style.visibility="visible"
else if (document.layers)
document.eval("layername").visibility="visible"
}

//// end of drag drop ////

//drag drop function for NS 4////
/////////////////////////////////
var dragswitch=0
var nsx
var nsy
var nstemp

function drag_dropns(layername){
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}

function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
if (dragswitch==1){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
}

function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}
  
// Open a centered window  ////////
////////////////////////////////
function openwin(url,w,h,scroll)
{
scrwidth=screen.width;scrheight=screen.height;
leftmargin = (scrwidth - w)/2;topmargin = (scrheight - h)/2;
props = "left=" + leftmargin + ",";props = props + "top=" + topmargin + ",";props = props + "width=" + w+ ",";props = props + "height=" + h+ ",";
var windowprops= "left=" + leftmargin +",top=" + topmargin +",width="+w+",height="+h+",resizable=1,menubar=1,location=no,fullscreen=0,scrollbars="+ scroll;
popup=window.open(url,'pop',windowprops);
popup.focus();
}

function openwin2(url,w,h,scroll)
{
scrwidth=screen.width;scrheight=screen.height;
leftmargin = (scrwidth - w)/2;topmargin = (scrheight - h)/2;
props = "left=" + leftmargin + ",";props = props + "top=" + topmargin + ",";props = props + "width=" + w+ ",";props = props + "height=" + h+ ",";
var windowprops= "left=" + leftmargin +",top=" + topmargin +",width="+w+",height="+h+",resizable=0,location=no,fullscreen=0,scrollbars="+ scroll;
popup=window.open(url,'pop2',windowprops);
popup.focus();
}

function openwin_user(name,url,w,h,scroll)
{
scrwidth=screen.width;scrheight=screen.height;
leftmargin = (scrwidth - w)/2;topmargin = (scrheight - h)/2;
props = "left=" + leftmargin + ",";props = props + "top=" + topmargin + ",";props = props + "width=" + w+ ",";props = props + "height=" + h+ ",";
var windowprops= "left=" + leftmargin +",top=" + topmargin +",width="+w+",height="+h+",resizable=1,location=no,fullscreen=0,scrollbars="+ scroll;
popup=window.open(url,name,windowprops);
popup.focus();
}

function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function getSelectedCheckbox(buttonGroup) {
   // Go through all the check boxes. return an array of all the ones
   // that are selected (their position numbers). if no boxes were checked,
   // returned array will be empty (length will be zero)
   var retArr = new Array();
   var lastElement = 0;
   if (buttonGroup[0]) { // if the button group is an array (one check box is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            retArr.length = lastElement;
            retArr[lastElement] = i;
            lastElement++;
         }
      }
   } else { // There is only one check box (it's not an array)
      if (buttonGroup.checked) { // if the one check box is checked
         retArr.length = lastElement;
         retArr[lastElement] = 0; // return zero as the only array value
      }
   }
   return retArr;
} // Ends the "getSelectedCheckbox" function

function Trim(s) 
{
  // Remove leading spaces and carriage returns
  
  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
  {
    s = s.substring(1,s.length);
  }

  // Remove trailing spaces and carriage returns

  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function ValidarPasswords(sysframe,posicion,pCampo,pCampo2)
{
	if (pCampo.value != pCampo2.value) { 
		if (document.getElementById(sysframe+"-ico_menu_"+posicion).src.indexOf('ico_menu.png')!=-1)
		{
			CambioEstado(sysframe,posicion);
		}
		alert(leng_texto1);
		pCampo2.focus();
		pCampo2.select();
		return false;
	}
	else
	{
		if (pCampo.value.length<4)
		{
			if (document.getElementById(sysframe+"-ico_menu_"+posicion).src.indexOf('ico_menu.png')!=-1)
			{
				CambioEstado(sysframe,posicion);
			}
			alert(leng_texto2);
			pCampo.focus();
			pCampo.select();
			return false;
		}
		else
		{
			return true;
		}
	}
}

function ValidoChecks(pCampo,pDesc)
{
if (getSelectedCheckbox(pCampo)=="") { 
		alert(leng_texto3 + pDesc + '--');
		return false;
	}
	else
	{
		return true;
	}
}

function ValidoRadios(pCampo,pDesc)
{
	if (getSelectedRadio(pCampo)=="") { 
		alert(leng_texto4 + pDesc + leng_texto9);
		return false;
	}
	else
	{
		return true;
	}
}

function ValidoSelect(sysframe,posicion,pCampo)
{
	if (pCampo.selectedIndex ==0) { 
		if (document.getElementById(sysframe+"-ico_menu_"+posicion).src.indexOf('ico_menu.png')!=-1)
		{
			CambioEstado(sysframe,posicion);
		}
		alert(leng_texto5);
		pCampo.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function ValidoFecha(pCampo,pDesc)
{
	if (IsEmpty(pCampo)) { 
		alert(leng_texto4 + pDesc + leng_texto9);
		return false;
	}
	else
	{
		return true;
	}
}

function ValidoRequerido(sysframe,posicion,pCampo)
{
	if (IsEmpty(pCampo)) { 
		if (document.getElementById(sysframe+"-ico_menu_"+posicion).src.indexOf('ico_menu.png')!=-1)
		{
			CambioEstado(sysframe,posicion);
		}
		alert(leng_texto5);
		pCampo.focus();
		pCampo.select();
		return false;
	}
	else
	{
		return true;
	}
}

function ValidoNumero(sysframe,posicion,pCampo)
{
	if (!IsNumber(pCampo)) { 
		if (document.getElementById(sysframe+"-ico_menu_"+posicion).src.indexOf('ico_menu.png')!=-1)
		{
			CambioEstado(sysframe,posicion);
		}
		alert(leng_texto6);
		pCampo.focus();
		pCampo.select();
		return false;
	}
	else
	{
		return true;
	}
}

function ValidoEmail(sysframe,posicion,pCampo) {

		str=pCampo.value;
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		
		if (str=='') { return true;}
		if (str.indexOf(at)==-1){
		   alert(leng_texto7)
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			if (document.getElementById(sysframe+"-ico_menu_"+posicion).src.indexOf('ico_menu.png')!=-1)
			{
				CambioEstado(sysframe,posicion);
			}
		   alert(leng_texto7)
		   pCampo.focus();
		   pCampo.select();
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			if (document.getElementById(sysframe+"-ico_menu_"+posicion).src.indexOf('ico_menu.png')!=-1)
			{
				CambioEstado(sysframe,posicion);
			}
		    alert(leng_texto7)
		    pCampo.focus();
		    pCampo.select();
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert(leng_texto7)
			if (document.getElementById(sysframe+"-ico_menu_"+posicion).src.indexOf('ico_menu.png')!=-1)
			{
				CambioEstado(sysframe,posicion);
			}
		    pCampo.focus();
		    pCampo.select();
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			if (document.getElementById(sysframe+"-ico_menu_"+posicion).src.indexOf('ico_menu.png')!=-1)
			{
				CambioEstado(sysframe,posicion);
			}
		    alert(leng_texto7)
		    pCampo.focus();
		    pCampo.select();
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert(leng_texto7)
			if (document.getElementById(sysframe+"-ico_menu_"+posicion).src.indexOf('ico_menu.png')!=-1)
			{
				CambioEstado(sysframe,posicion);
			}
		    pCampo.focus();
		    pCampo.select();
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert(leng_texto7)
			if (document.getElementById(sysframe+"-ico_menu_"+posicion).src.indexOf('ico_menu.png')!=-1)
			{
				CambioEstado(sysframe,posicion);
			}
		    pCampo.focus();
		    pCampo.select();
		    return false
		 }

 		 return true					
	}

function ValidoMoneda(sysframe,posicion,pCampo)
{
	if (!IsReal(pCampo)) { 
		if (document.getElementById(sysframe+"-ico_menu_"+posicion).src.indexOf('ico_menu.png')!=-1)
		{
			CambioEstado(sysframe,posicion);
		}
		alert(leng_texto8);
		pCampo.focus();
		pCampo.select();
		return false;
	}
	else
	{
		return true;
	}
}


function IsEmpty(aTextField) {
   if ((aTextField.value.length==0) ||
   (aTextField.value==null) || Trim(aTextField.value).length==0) {
      return true;
   }
   else { return false; }
}

function IsNumber(field)
{
if(!(field.value == Math.ceil(field.value))) {
	return false;
 }
 else
 {
	return true;
 }
}

function IsReal(field) {
 if(isNaN(field.value)) {
	return false;
 }
 else
 {
	 return true;
 }
}

function AbrirVent() {
var da1 = (document.all) ? 1 : 0;
var pr1 = (window.print) ? 1 : 0;
var mac1 = (navigator.userAgent.indexOf("Mac") != -1);
var vpf;
if (pr1) {
	vpf = open("excel.aspx", "Despleg","toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=740,height=400");
}
else {
	vpf = open("excel.aspx", "Despleg","toolbar=yes,menubar=yes,location=no,scrollbars=yes,resizable=yes,width=740,height=400");
}
       vpf.focus();
       //vpf.document.open();
	   /*vpf.document.writeln("<html>");
	   vpf.document.writeln("<head>");
	   vpf.document.writeln("<title>Reporte en Excel</title>");
	   vpf.document.writeln("<meta name='Content-Type' content='application/vnd.ms-excel;charset=iso-8859-1'>");
	   vpf.document.writeln("<meta name='vs_targetSchema' content='http://schemas.microsoft.com/intellisense/ie5'>");
	   vpf.document.writeln("<meta name='Content-Disposition' content='attachment;filename=reporte.xls'>");
	   vpf.document.writeln("<style type=text/css>");
	   vpf.document.writeln("          <!--");
	   vpf.document.writeln("		 td {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-style: normal; text-decoration: none}");
	   vpf.document.writeln("");
	   vpf.document.writeln("		 -->");
	   vpf.document.writeln("         </style>");
       vpf.document.writeln("</head>");
	   vpf.document.writeln("<body bgcolor=#FFFFFF leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>");*/
	   vpf.Form1.Valores.value=lblTabla.innerHTML;
       //vpf.document.close();
}

var posant=1;
function CambioEstado(sysframe,posicion)
{
	if ((posant!=posicion)) 
	{
		//alert("si");
		//alert(document.getElementById("ico_menu_"+posant).src);
		if (document.getElementById(sysframe+"-ico_menu_"+posant).src.indexOf('ico_menu.png')!=-1)
		{
			CambioEstado2(sysframe,posant);
		}
		CambioEstado2(sysframe,posicion)
		posant=posicion;
		
	}
	
}
function CambioEstado2(sysframe,posicion)
{
	if (document.getElementById(sysframe+"-ico_menu_"+posicion)) CambioImagenMenu(sysframe,posicion);
	for (i=1;i<50;i++)
	{
		if (document.getElementById(sysframe+"-menu_"+posicion+'_'+i))
		{
			CambioEstadoMenu(sysframe+"-menu_"+posicion+'_'+i);	
		}
	}
}

function CambioEstadoMenu(valor)
{
	if (document.getElementById(valor).style.display=="none")
	{
		document.getElementById(valor).style.display="block";
	}
	else
	{
		document.getElementById(valor).style.display="none";
	}
}

function CambioImagenMenu(sysframe,posicion)
{
	seba=document.getElementById(sysframe+"-ico_menu_"+posicion);
	if (seba.src.indexOf('ico_menu.png')!=-1)
	{
		seba.src='images/ico_menu2.png';
		//document.getElementById(sysframe+"-barra1_menu_"+posicion).className='abm_reg9';
		document.getElementById(sysframe+"-barra2_menu_"+posicion).className='abm_reg9';
		//document.getElementById(sysframe+"-barra3_menu_"+posicion).className='abm_reg9';
	}
	else
	{
		seba.src='images/ico_menu.png';
		//document.getElementById(sysframe+"-barra1_menu_"+posicion).className='abm_reg10';
		document.getElementById(sysframe+"-barra2_menu_"+posicion).className='abm_reg10';
		//document.getElementById(sysframe+"-barra3_menu_"+posicion).className='abm_reg10';
	}
}

			var selectedCountyArray = new Array();


			function setAsuntos(myState,Campo)
			{
				/* this function checks the selected state and populates 
				the counties based on that state.  It checks the selected counties 
				array for each value and if it is in that array, it is skipped since 
				you should not be able to add duplicate state-county combinations 
				*/
				
				if (Campo.indexOf(",") > -1)
				{
					var Valores=Campo.split(",");
					var part_num=0;
					while (part_num < Valores.length)
					 {
					  //alert(Valores[part_num]);
					  CambioComboRelacionado(myState,Valores[part_num]);
					  part_num+=1;
					  }
				}
				else
				{
					CambioComboRelacionado(myState,Campo);
				}


			}//end function

		function CambioComboRelacionado(myState,Campo)
		{
				var countyField = document.getElementById("f_"+Campo);
				countyField.length = 0;
				
				if (myState.selectedIndex == -1) 
				{//no state chosen
					countyField.length = 1;
					countyField.options[0].value="";
					countyField.options[0].text="Seleccionar un item...";
				}
				else
				{
					//get the associated county array
					document.getElementById("f_"+Campo).length=0;
					if(window["state"+Campo+"_Desc_Array" + myState.options[myState.selectedIndex].value]!= undefined)
					{
						var myStateArray = eval("state"+Campo+"_Desc_Array" + myState.options[myState.selectedIndex].value);
						var myStateArray2 = eval("state"+Campo+"_Valores_Array" + myState.options[myState.selectedIndex].value);
						//make the selectedcounty array a string for easier searching
						var selectedCounties = selectedCountyArray.toString();
						
						var count = 0;
						countyField.length++;
						count++;
						for (var i=0; i<myStateArray.length; i++)
						{
							if (selectedCounties.indexOf(myState.options[myState.selectedIndex].value + "->" + myStateArray[i]) == -1)
							{//not selected, so display it
								countyField.length++;
								countyField[count].value = myStateArray2[i];
								countyField[count].text = myStateArray[i];
								count++;
							}
						}
						if (count==2) 
						{
							countyField.selectedIndex=1;
						}
					}

				}
		}


p_posant='';
p_posant2='';
idestado=0;
function showestados(sys_frame,pos,opcion,valor,event)
{
	/*
	pBox=document.getElementById(sys_frame+"_cuadro"+valor);
	if(pBox)
	{
		pcuadro=pBox;
		idestado=opcion;
		pcuadro.style.left=document.body.scrollLeft+event.clientX-event.offsetX-3;
		pcuadro.style.top=document.body.scrollTop+event.clientY-event.offsetY+18;
		pcuadro.width=110;
		if (p_posant!=pos)
		{
			pcuadro.style.display="block";
		}
		else
		{
			if (pcuadro.style.display!="block")
			{
				pcuadro.style.display="block";
			}
			else
			{
				pcuadro.style.display="none";
			}
		}
		p_posant=pos;
	}
	*/
	idestado=opcion;
	pos_x=document.body.scrollLeft+event.clientX;
	//document.getElementById('d_'+nombre+'_'+pos).style.top=document.body.scrollTop+event.clientY-event.offsetY+16;
	pos_y=document.body.scrollTop+event.clientY+16
	//alert(event.clientY);
	document.getElementById(sys_frame+'_cuadro'+valor).style.left=pos_x;
	document.getElementById(sys_frame+'_cuadro'+valor).style.top=pos_y;
	document.getElementById(sys_frame+'_cuadro'+valor).width=110;
	if (p_posant!=pos)
	{
		document.getElementById(sys_frame+'_cuadro'+valor).style.display="";
	}
		if (document.getElementById(sys_frame+'_cuadro'+valor).style.display!="")
		{
			document.getElementById(sys_frame+'_cuadro'+valor).style.display="";
		}
		else
		{
			document.getElementById(sys_frame+'_cuadro'+valor).style.display="block";
		}
	p_posant=pos;

}


function showdetail(pos,nombre,event)
{
	//document.getElementById('d_'+nombre+'_'+pos).style.left=document.body.scrollLeft+event.clientX-event.offsetX-3-191;
	//document.getElementById('d_'+nombre+'_'+pos).style.top=document.body.scrollTop+event.clientY-event.offsetY+18-144;
	//alert(document.getElementById('d_'+nombre+'_'+pos).style.display);
	pos_x=document.body.scrollLeft+event.clientX;
	//document.getElementById('d_'+nombre+'_'+pos).style.top=document.body.scrollTop+event.clientY-event.offsetY+16;
	pos_y=document.body.scrollTop+event.clientY+16
	//alert(event.clientY);
	document.getElementById('d_'+nombre+'_'+pos).style.left=pos_x;
	document.getElementById('d_'+nombre+'_'+pos).style.top=pos_y;
	document.getElementById('d_'+nombre+'_'+pos).width=250;
	document.getElementById('d_'+nombre+'_'+pos).height=80;
	/*if (p_posant2!=pos)
	{
		document.getElementById('d_'+nombre+'_'+pos).style.display="";
	}*/
	//else
	//{
		if (document.getElementById('d_'+nombre+'_'+pos).style.display!="")
		{
			document.getElementById('d_'+nombre+'_'+pos).style.display="";
		}
		else
		{
			document.getElementById('d_'+nombre+'_'+pos).style.display="block";
		}
	//}
	p_posant2=pos;
}


function showdetail_cal(pos,nombre)
{
	pos_x=document.body.scrollLeft+event.clientX+0;
	pos_y=document.body.scrollTop+event.clientY-(document.getElementById('d_'+nombre+'_'+pos).clientHeight);
	
	document.getElementById('d_'+nombre+'_'+pos).style.left=pos_x;
	document.getElementById('d_'+nombre+'_'+pos).style.top=pos_y;
	document.getElementById('d_'+nombre+'_'+pos).width=250;
	//document.getElementById('d_'+nombre+'_'+pos).height=80;
	if (document.getElementById('d_'+nombre+'_'+pos).style.display!="")
	{
		document.getElementById('d_'+nombre+'_'+pos).style.display="";
	}
	else
	{
		document.getElementById('d_'+nombre+'_'+pos).style.display="block";
	}
}

function showdetail2(pos,nombre,event)
{
	//document.getElementById('d_'+nombre+'_'+pos).style.left=document.body.scrollLeft+event.clientX-event.offsetX-3-191;
	//document.getElementById('d_'+nombre+'_'+pos).style.top=document.body.scrollTop+event.clientY-event.offsetY+18-144;
	//alert(event.offsetX);
    //pos_x = event.offsetX?(event.offsetX):document.body.scrollLeft+event.clientX-document.getElementById('d_'+nombre+'_'+pos).offsetLeft;
    //pos_y = event.offsetY?(event.offsetY):document.body.scrollTop+event.clientY-document.getElementById('d_'+nombre+'_'+pos).offsetTop;
	//alert(pos_x);
	//document.getElementById('d_'+nombre+'_'+pos).style.left=document.body.scrollLeft+event.clientX-event.offsetX;
	pos_x=document.body.scrollLeft+event.clientX;
	//document.getElementById('d_'+nombre+'_'+pos).style.top=document.body.scrollTop+event.clientY-event.offsetY+16;
	pos_y=document.body.scrollTop+event.clientY+16
	//alert(event.clientY);
	document.getElementById('d_'+nombre+'_'+pos).style.left=pos_x;
	document.getElementById('d_'+nombre+'_'+pos).style.top=pos_y;
	document.getElementById('d_'+nombre+'_'+pos).width=200;
	document.getElementById('d_'+nombre+'_'+pos).height=20;
	if (p_posant2!=pos)
	{
		if (p_posant2!="")
		{
			document.getElementById('d_'+nombre+'_'+p_posant2).style.display="";
		}

	}
	//else
	//{
		if (document.getElementById('d_'+nombre+'_'+pos).style.display!="")
		{
			document.getElementById('d_'+nombre+'_'+pos).style.display="";
		}
		else
		{
			document.getElementById('d_'+nombre+'_'+pos).style.display="block";
		}
	//}
	
}

function showover(pos,nombre)
{
	//document.getElementById('d_'+nombre+'_'+pos).style.left=document.body.scrollLeft+event.clientX-event.offsetX-3-191;
	//document.getElementById('d_'+nombre+'_'+pos).style.top=document.body.scrollTop+event.clientY-event.offsetY+18-144;
	document.getElementById(nombre).style.left=document.body.scrollLeft+event.clientX-event.offsetX-41;
	document.getElementById(nombre).style.top=74;//document.body.scrollTop+event.clientY-event.offsetY+70;
	document.getElementById(nombre).width=250;
	document.getElementById(nombre).height=180;
	//if (p_posant2!=pos)
	//{
	//	document.getElementById(nombre).style.display="block";
	//}
	//else
	//{
		if (document.getElementById(nombre).style.display!="block")
		{
			document.getElementById(nombre).style.display="block";
		}
		else
		{
			document.getElementById(nombre).style.display="none";
		}
	//}
	//p_posant2=pos;
}

function hideestados()
{
	if(window["cuadro2"]!= null)
	{
		//cuadro2.style.display="none";
	}
}

function InStr(n, s1, s2){
	// Devuelve la posición de la primera ocurrencia de s2 en s1
	// Si se especifica n, se empezará a comprobar desde esa posición
	// Sino se especifica, los dos parámetros serán las cadenas
	var numargs=InStr.arguments.length;
	
	if(numargs<3)
		return n.indexOf(s1)+1;
	else
		return s1.indexOf(s2, n)+1;
}

function ChangeState(sys_frame,opc,idseccion,iditem,campo,page)
{
	hideestados();
	//document.location='index.php?idseccion='+idseccion+'&iditem='+iditem+'&s_opc='+opc+'&s_val='+idestado+'&Page='+page;
	Valor=document.URL;
	//alert(Valor);
	if (InStr(Valor, '&s_opc')>0)
	{
		//alert(Valor.substring(0,InStr(Valor, '&s_opc')-1));
		document.location=(Valor.substring(0,InStr(Valor, '&s_opc')-1))+'&s_opc='+opc+'&s_val='+idestado+'&field='+campo+'&Page='+page+'&sys_frame_cont='+sys_frame;
	}
	else
	{
		//alert("ok");
		document.location=Valor+'&s_opc='+opc+'&s_val='+idestado+'&field='+campo+'&sys_frame_cont='+sys_frame;
	}
	//alert(Valor.indexOf('&auto_filtro'));
}

function autoComplete (field, select, property, forcematch) {
	var found = false;
	for (var i = 0; i < select.options.length; i++) {
	if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
		found=true; break;
		}
	}
	if (found) { select.selectedIndex = i;}
	else { select.selectedIndex = -1; }
	if (field.createTextRange) {
		if (forcematch && !found) {
			field.value=field.value.substring(0,field.value.length-1); 
			return;
			}
		var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
		if (cursorKeys.indexOf(event.keyCode+";") == -1) {
			var r1 = field.createTextRange();
			var oldValue = r1.text;
			var newValue = found ? select.options[i][property] : oldValue;
			if (newValue != field.value) {
				field.value = newValue;
				var rNew = field.createTextRange();
				rNew.moveStart('character', oldValue.length) ;
				rNew.select();
				}
			}
		}
	}

function CalculoImporte(opc,campo1,campo2)
{
	switch(opc)
	{
		case 1:
			document.getElementById(campo2).value=Math.round((document.getElementById(campo1).value/sys_valor_hora)*100)/100;
			break;
		case 2:
			document.getElementById(campo1).value=(document.getElementById(campo2).value*sys_valor_hora);
			break;
	}
}

function replaceAll( str, from, to ) {
    var idx = str.indexOf( from );


    while ( idx > -1 ) {
        str = str.replace( from, to ); 
        idx = str.indexOf( from );
    }

    return str;
}

function NuevoEquivalencia(opcion)
{
	switch(opcion)
	{
		case 0:
			barra_materias.style.display="none";
			form_equivanlencias.style.display="block";
			break;
		case 1:
			barra_materias.style.display="block";
			form_equivanlencias.style.display="none";
			break;
	}
}

function NuevoCarrera(opcion)
{
	switch(opcion)
	{
		case 0:
			barra_carreras.style.display="none";
			form_carreras.style.display="block";
			break;
		case 1:
			barra_carreras.style.display="block";
			form_carreras.style.display="none";
			break;
	}
}

function NuevoMateria(opcion)
{
	switch(opcion)
	{
		case 0:
			barra_materias.style.display="none";
			form_materias.style.display="block";
			break;
		case 1:
			barra_materias.style.display="block";
			form_materias.style.display="none";
			break;
	}
}

function NuevoExamen(opcion)
{
	switch(opcion)
	{
		case 0:
			barra_examen.style.display="none";
			form_examen.style.display="block";
			break;
		case 1:
			barra_examen.style.display="block";
			form_examen.style.display="none";
			break;
	}
}


function NuevoMateriaAnterior(opcion)
{
	switch(opcion)
	{
		case 0:
			barra_materias.style.display="none";
			form_materias2.style.display="block";
			break;
		case 1:
			barra_materias.style.display="block";
			form_materias2.style.display="none";
			break;
	}
}

function NuevoArchivo(opcion)
{
	switch(opcion)
	{
		case 0:
			barra_archivos.style.display="none";
			form_archivo.style.display="block";
			break;
		case 1:
			barra_archivos.style.display="block";
			form_archivo.style.display="none";
			break;
	}
}

function NuevoDocumentacion(opcion)
{
	switch(opcion)
	{
		case 0:
			barra_documentacion.style.display="none";
			form_documentacion.style.display="block";
			break;
		case 1:
			barra_documentacion.style.display="block";
			form_documentacion.style.display="none";
			break;
	}
}

function NuevoComentario(opcion)
{
	switch(opcion)
	{
		case 0:
			barra_comentarios.style.display="none";
			form_comentarios.style.display="block";
			break;
		case 1:
			barra_comentarios.style.display="block";
			form_comentarios.style.display="none";
			break;
	}
}

function NuevoDomicilio(opcion)
{
	switch(opcion)
	{
		case 0:
			barra_contactos.style.display="none";
			form_domicilio.style.display="block";
			break;
		case 1:
			barra_contactos.style.display="block";
			form_domicilio.style.display="none";
			break;
	}
}
function NuevoTelefono(opcion)
{
	switch(opcion)
	{
		case 0:
			barra_contactos.style.display="none";
			form_telefono.style.display="block";
			break;
		case 1:
			barra_contactos.style.display="block";
			form_telefono.style.display="none";
			break;
	}
}

function BajaEstudiante(opcion)
{
	switch(opcion)
	{
		case 0:
			barra_baja.style.display="none";
			barra_baja1.style.display="block";
			barra_baja2.style.display="block";
			barra_baja3.style.display="block";
			break;
		case 1:
			barra_baja.style.display="block";
			barra_baja1.style.display="none";
			barra_baja2.style.display="none";
			barra_baja3.style.display="none";
			break;
	}
}

function NuevoEmail(opcion)
{
	switch(opcion)
	{
		case 0:
			barra_contactos.style.display="none";
			form_email.style.display="block";
			break;
		case 1:
			barra_contactos.style.display="block";
			form_email.style.display="none";
			break;
	}
}

function CancelarNota() {
pBox=document.getElementById("barra_nota");
pBox.style.display="none";
}

function EditarNota(campo,valor,fecha,idrelacion) {
	pBox=document.getElementById("barra_nota");
	pBox.style.display="block";
	document.formN.campo.value=campo;
	if (valor!=0)
	{
		document.formN.nota.value=valor;
	} else document.formN.nota.value="";
	document.formN.f_fecha1.value=fecha;
	document.formN.idrelacion.value=idrelacion;
}

function showNotas(pos) {
	pBox=document.getElementById("detalle1_"+pos);
	if (pBox.style.display!="block") pRes="block"; else pRes="none";
	pBox.style.display=pRes;
	pBox=document.getElementById("detalle2_"+pos);
	pBox.style.display=pRes;
	pBox=document.getElementById("detalle3_"+pos);
	if (pBox)
	{
		pBox.style.display=pRes;
	}
	/*pBox=document.getElementById("detalle4_"+pos);
	pBox.style.display=pRes; */

}

function CambioDocumento(opcion) {
	switch(opcion) {
		case "1":
		case "2":
		case "3":
			//Factura
			documento3.style.display="block";
			documento4.style.display="block";
			documento5.style.display="none";
			documento6.style.display="none";
			break;
		case "4":
			//Recibo
			documento3.style.display="none";
			documento4.style.display="none";
			documento5.style.display="block";
			documento6.style.display="block";
			break;
	}
}

cant_items=0;
var Productos=new Array();
var Descripciones=new Array();
var Cantidades=new Array();
var Precios=new Array();

function NewItem() {
	//pValor=document.getElementById("precio_"+document.formX.idproducto.value);
	//document.formX.precio.value=pValor.value;
	if(document.formX.cantidad.value==0) {
		alert("Debe ingresar la cantidad para continuar");
		return;
	}
	if(document.formX.precio.value==0) {
		alert("Debe ingresar el precio unitario para continuar");
		return;
	}
	if(document.formX.idproducto.value==0) {
	if(document.formX.desc_item.value=="") {
		alert("Debe ingresar la descripción del item para continuar");
		return;
	}

	} else {
	}
	cant_items++;
	Productos[cant_items]=document.formX.idproducto.value;
	if (document.formX.idproducto.value!=0)
	{
		Descripciones[cant_items]=document.formX.idproducto.options[document.formX.idproducto.selectedIndex].text;
	} else {
		Descripciones[cant_items]=document.formX.desc_item.value;
	}
	Cantidades[cant_items]=document.formX.cantidad.value;
	Precios[cant_items]=document.formX.precio.value;
	DibujoItems();
	document.formX.cantidad.value=1;
	document.formX.idproducto.selectedIndex=0;
	document.formX.desc_item.value="";
	document.formX.precio.value="";
}

var Medios=new Array();
var Importes=new Array();
var Bancos=new Array();
var Numeros=new Array();
var Emisiones=new Array();
var Depositos=new Array();
var Tarjetas=new Array();
var Cupones=new Array();
var Autorizaciones=new Array();

function NewMedio() {
	cant_items++;
	Medios[cant_items]=document.formX.idmedio.value;
	Descripciones[cant_items]=document.formX.idmedio.options[document.formX.idmedio.selectedIndex].text;
	Importes[cant_items]=document.formX.importe.value;
	Bancos[cant_items]=document.formX.idbanco.value;
	Numeros[cant_items]=document.formX.nro_comprobante.value;
	Emisiones[cant_items]=document.formX.f_fecha2.value;
	Depositos[cant_items]=document.formX.f_fecha3.value;
	Tarjetas[cant_items]=document.formX.nro_tarjeta.value;
	Cupones[cant_items]=document.formX.nro_cupon.value;
	Autorizaciones[cant_items]=document.formX.nro_autorizacion.value;

	DibujoCobros();

}

function DibujoCobros() {
	contenido_items.innerHTML="";
	Salida="<table width='100%'>";
	Total=0;
	for (i=1;i<=cant_items ;i++ )
	{
		if (Medios[i]>0)
		{
		Salida+="<tr>";
		Salida+="<td height=20>"+Descripciones[i]+"</td>";
		Salida+="<td align=right>"+(Importes[i]*1).toFixed(2)+"</td>";
		Salida+="<td width='1%'><a href='javascript:DelCobro("+i+");'><img src='ico/deletecell.png' border=0></a></td>";
		Salida+="</tr>";
		Total+=(Importes[i]*1);
		}
	}
	Salida+="</table>";
	total_cobros.innerHTML=Total.toFixed(2)+" $";
	contenido_items.innerHTML=Salida;
}

function DelCobro(pos) {
	Medios[pos]=0;
	DibujoCobros();
}
function CambioProducto(valor) {
	if (valor!=0)
	{
		pValor=document.getElementById("precio_"+valor);
		document.formX.precio.value=pValor.value;
		document.formX.desc_item.value="";
		document.formX.desc_item.disabled=true;
		//document.formX.precio.disabled=true;
	} else {
		document.formX.desc_item.disabled=false;
		//document.formX.precio.disabled=false;
	}
}


function CambioProducto2(valor) {
	if (valor!=0)
	{
		pValor=document.getElementById("precio2_"+valor);
		document.formC.precio.value=pValor.value;
	}
}

function DelItem(pos) {
	Cantidades[pos]=0;
	DibujoItems();
}

function DibujoItems() {
	contenido_items.innerHTML="";
	Salida="<table width='100%'>";
	Total=0;
	for (i=1;i<=cant_items ;i++ )
	{
		if (Cantidades[i]>0)
		{
		Salida+="<tr>";
		Salida+="<td height=20>"+Descripciones[i]+"</td>";
		Salida+="<td>"+Cantidades[i]+"</td>";
		Salida+="<td align=right>"+(Precios[i]*1).toFixed(2)+"</td>";
		Salida+="<td align=right>"+(Cantidades[i]*Precios[i]).toFixed(2)+"</td>";
		Salida+="<td width='1%'><a href='javascript:DelItem("+i+");'><img src='ico/deletecell.png' border=0></a></td>";
		Salida+="</tr>";
		Total+=Cantidades[i]*Precios[i];
		}
	}
	Salida+="</table>";
	total_items.innerHTML=Total.toFixed(2)+" $";
	contenido_items.innerHTML=Salida;
}

function ConfirmoDoc(){
	if (!document.formX.is_imprimir.checked && document.formX.nro_documento_tmp.value=='')
	{
		alert("Debe ingresar el número de comprobante para continuar");
		document.formX.nro_documento_tmp.focus();
		return;
	}
	if (document.formX.f_fecha1.value=="")
	{
		alert("Debe ingresar la fecha para continuar");
		return;
	}
	if (document.formX.iddocumento.value==0)
	{
		alert("Debe ingresar el tipo de documento para continuar");
		return;
	}

	if (document.formX.iddocumento.value!=4) {
		if (cant_items==0)
		{
			alert("Debe ingresar items al documento para continuar");
			return;
		}
		strtemp1="";
		strtemp2="";
		strtemp3="";
		strtemp4="";
		for (i=1;i<=cant_items ;i++ )
		{
			if (Cantidades[i]>0)
			{
				if (strtemp1) strtemp1+=",";
				strtemp1+=Productos[i];
				if (strtemp2) strtemp2+=",";
				strtemp2+=Descripciones[i];
				if (strtemp3) strtemp3+=",";
				strtemp3+=Cantidades[i];
				if (strtemp4) strtemp4+=",";
				strtemp4+=Precios[i];
			}
		}
		document.formX.productos.value=strtemp1;
		document.formX.descripciones.value=strtemp2;
		document.formX.cantidades.value=strtemp3;
		document.formX.precios.value=strtemp4;
		document.formX.submit();
	}
	if (document.formX.iddocumento.value==4) {
		if (cant_items==0)
		{
			alert("Debe ingresar items al documento para continuar");
			return;
		}
		strtemp1="";
		strtemp2="";
		strtemp3="";
		strtemp4="";
		strtemp5="";
		strtemp6="";
		strtemp7="";
		strtemp8="";
		strtemp9="";
		strtemp10="";
		pos=0;
		for (i=1;i<=cant_items ;i++ )
		{
			if (Medios[i]>0)
			{
				pos++;
				if (pos>1) strtemp1+=",";
				strtemp1+=Medios[i];
				if (pos>1) strtemp2+=",";
				strtemp2+=Descripciones[i];
				if (pos>1) strtemp3+=",";
				strtemp3+=Importes[i];
				if (pos>1) strtemp4+=",";
				strtemp4+=Bancos[i];
				if (pos>1) strtemp5+=",";
				strtemp5+=Numeros[i];
				if (pos>1) strtemp6+=",";
				strtemp6+=Emisiones[i];
				if (pos>1) strtemp7+=",";
				strtemp7+=Depositos[i];
				if (pos>1) strtemp8+=",";
				strtemp8+=Tarjetas[i];
				if (pos>1) strtemp9+=",";
				strtemp9+=Cupones[i];
				if (pos>1) strtemp10+=",";
				strtemp10+=Autorizaciones[i];
			}
		}
		document.formX.medios.value=strtemp1;
		document.formX.descripciones.value=strtemp2;
		document.formX.importes.value=strtemp3;
		document.formX.bancos.value=strtemp4;
		document.formX.numeros.value=strtemp5;
		document.formX.emisiones.value=strtemp6;
		document.formX.depositos.value=strtemp7;
		document.formX.tarjetas.value=strtemp8;
		document.formX.cupones.value=strtemp9;
		document.formX.autorizaciones.value=strtemp10;
		document.formX.submit();
	}
}

function FormatoPassword() {
	var valor=document.formX.f_nro_documento.value;
	valor_tmp=0;
	for(i=0;i<valor.length;i++) {
		valor_tmp+=parseInt(valor.charAt(i));
	}
	document.formX.f_pass.value=valor_tmp;
	document.formX.f_pass_2.value=valor_tmp;
}