
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 filtro para hacer la busqueda";
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=0,location=no,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,scrollbars="+ scroll;
popup=window.open(url,'pop2',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(pCampo,pCampo2)
{
	if (pCampo.value != pCampo2.value) { 
		alert(leng_texto1);
		pCampo2.focus();
		pCampo2.select();
		return false;
	}
	else
	{
		if (pCampo.value.length<4)
		{
			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(pCampo)
{
	if (pCampo.selectedIndex ==0) { 
		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(pCampo)
{
	if (IsEmpty(pCampo)) { 
		alert(leng_texto5);
		pCampo.focus();
		pCampo.select();
		return false;
	}
	else
	{
		return true;
	}
}

function ValidoNumero(pCampo)
{
	if (!IsNumber(pCampo)) { 
		alert(leng_texto6);
		pCampo.focus();
		pCampo.select();
		return false;
	}
	else
	{
		return true;
	}
}

function ValidoEmail(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){
		   alert(leng_texto7)
		   pCampo.focus();
		   pCampo.select();
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert(leng_texto7)
		    pCampo.focus();
		    pCampo.select();
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert(leng_texto7)
		    pCampo.focus();
		    pCampo.select();
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert(leng_texto7)
		    pCampo.focus();
		    pCampo.select();
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert(leng_texto7)
		    pCampo.focus();
		    pCampo.select();
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert(leng_texto7)
		    pCampo.focus();
		    pCampo.select();
		    return false
		 }

 		 return true					
	}

function ValidoMoneda(pCampo)
{
	if (!IsReal(pCampo)) { 
		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();
}


