// ***************** SUPERCLASSES y Funciones comunes *************************************
function SC_Form() { // Superclass Form 
	this.Submit = function () {
    if (this.Validar()                                 && 
	    confirm('¿Confirma que desea grabar los datos?') ){ 
	    this.oForm.submit();
	  }
  }
}

function toChar(sString,iLength,chrFill) 
{
	var sString = new String(sString);
	var iStrLen = sString.length;
	var sTmp = '';
	
	if (iStrLen < iLength) 
	{
		for (n = iStrLen; n < iLength; n++) 
		{
			sString = sString + chrFill;
		}
	} else if (iStrLen > iLength) {
 		for (n = 1; n < iStrLen + 1; n++) 
		{
			sTmp = sTmp + sString.cahrAt(n);
		}
		sString = sTmp;
  	}
	return sString;
}

function highlightButton(s) {
  if ("INPUT" == event.srcElement.tagName)
    event.srcElement.className = s;
}

function sobre(src,color_entrada) {
  src.bgColor = color_entrada;
  src.style.cursor="default";
}

function Comu_Redir(oLoc) {
  var sDir = new String(oLoc);
  sDir1 = '/redsocial/intranet/html/comunicaciones/' + sDir.substring(sDir.lastIndexOf('/')+1, sDir.length);
  location = sDir1;
}

function charsLeft(oObj) {
   var iLen = oObj.value.length;
   if (iLen >= 500) {
   	 	oObj.value = oObj.value.substring(0,499);
	 	sStr = '(m&aacute;ximo 500 caracteres)';
   } else {
		 sStr = '(m&aacute;ximo 500 caracteres. Restan ' + eval(500 - iLen) + ')&nbsp;&nbsp;';
   }
   document.all.spnChars.innerHTML = sStr;
}

function isIE_5_6() { //v1.0
  if (document.getElementById) {
    return true;
  } else {
    return false;
  }
}

function getElementById_v4(sID, oDoc) { //v1.0
  // Alternativa a "document.getElementById()" que asegura compatibilidad con IE4.0+
  var iDL = oDoc.all.length;
  for (n = 0; n < iDL; n++) {
    if (oDoc.all[n].id == sID) {
      var oObj = oDoc.all[n];
      break;
    } else {
      var oObj = null;
    }
  }
  return oObj;
}

function ChgImg(name_obj, sSrc) { //v2.0
  if (isIE_5_6()) {
    var oImg = document.getElementById(name_obj);
  } else {
    var oImg = getElementById_v4(name_obj, document);
  }
  oImg.src = sSrc;
}

function GetElementInParent(id) { //v1.0
  if (isIE_5_6()) {
    return parent.document.getElementById(id);
  } else {
    return getElementById_v4(id, parent.document);
  }
}

function GetElementInIFrame(ElementID, iIFrame) { //v1.0
  var oIFrame = document.frames[iIFrame];
  if (isIE_5_6()) {
    var oImg = oIFrame.document.getElementById(ElementID);
  } else {
    var oImg = getElementById_v4(ElementID, oIFrame.document);
  }
  return oImg;
}

function InArray(aArray, sString) { //v1.0
  var iArrLen = aArray.length;
  for (n = 0; n < iArrLen - 1; n++) {
    var sElem = new String(aArray[n]);
    var iMatch = sElem.indexOf(sString);
    if (iMatch != -1) {
      return n;
      break;
    }
  }
  if (iMatch == -1) {
    return iMatch;
  }
}

function MsgEsperar() 
{
    var oDiv = document.getElementById('divProcesando');
    oDiv.innerHTML = '<table width="100%" border="5" bordercolor="#FFFFFF" cellspacing="0" cellpadding="0">'                                            +
                   '<tr><td>'   															+
                   '<table width="100%" border="0" cellspacing="0" cellpadding="5">'                                                                    +
                   '<tr align="center">'   														+
                   '<td><font size="4"><font face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF">Espere por favor...</font></font></td>'	+
                   '</tr><tr align="center">' 														+
                   '<td><img src="/redsocial/andar/imagenes/icons/progreso.gif" width="143" height="20" style="filter: FlipH"></td>'	 		+
                   '</tr></table></td></tr></table>';
    oDiv.style.visibility = 'visible';
}

function SetDiv() 
{
    return '<div id="divProcesando" style="position:absolute; width:316px; height:56px; z-index:1; left: 20px; top: 20px; background-color: #000000; layer-background-color: #333333; visibility: hidden;"></div>';
}

function highlightButton(sClassName) { //v1.0
    if (event.srcElement.tagName == 'INPUT')
	event.srcElement.className = sClassName;
}

function ChgBgColor(src, sColor) { //v1.0
  src.bgColor = sColor;
  src.style.cursor = "default";
}

function SetStatus(sInst, oObj) { //v1.0
  if (sInst == 'andar') {
    window.status='Andar - Obra Social de los Viajantes Vendedores de la República Argentina';
    oObj.onMouseOut = window.status='';
    return true;
  }
}

function hide_it() {
  Id = "loadmessage";
  if (document.all) {
    document.all[Id].style.visibility = "hidden";
  } else if (document.layers) {
    document.layers[Id].visibility = "hide";
  } else if (document.getElementById) {
    document.getElementById(Id).style.visibility = "hidden";
  }
}

function popup(popup_url,name,width,height) {
  size = 'width=' + width + ',height=' + height;
  newwindow=window.open(popup_url,name,'resizable=no,menubar=no,location=no,toolbar=no,status=no,scrollbars=auto,directories=no,'+size);
}

function popup1(popup_url,name,width,height) {
  size = 'width=' + width + ',height=' + height;
  newwindow=window.open(popup_url,name,'resizable=no,menubar=no,location=no,toolbar=no,status=no,scrollbars=yes,directories=no,'+size);
}

function popup2(popup_url,name,width,height) {
  size = 'width=' + width + ',height=' + height;
  var newwindow=window.open(popup_url,name,'resizable=no,menubar=no,location=no,toolbar=no,status=no,scrollbars=yes,directories=no,'+size);
  newwindow.moveTo(0,0)
}


function popup_plus(popup_url,name,width,height,s) {
  var size = 'width=' + width + ',height=' + height;
  var Wnd = window.open(popup_url,name,'resizable=no,menubar=no,location=no,toolbar=no,status=no,directories=no,scrollbars=' + s + ',' + size);
}

function JSEscribirFecha() { //v1.0
  var dia = new Array('Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sabado');
  var meses = new Array('Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre');
  var data = new Date();
  var index2 = data.getDay();
  var index = data.getMonth();
  var an = data.getYear();
  if (an<1000) {
    an = 1900 + an;
  }
  document.write('<font color="#DAE5EF">Impreso el ' + dia[index2] + ', ' + data.getDate() + ' de ' + meses[index] + ' de ' + an + '</font>');
}

function EscribirFecha_Ext(sColor, letras) { //v1.0
  dia = new Array ("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sabado");
  meses = new Array ("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
  data = new Date();
  index2 = data.getDay();
  index = data.getMonth();
  var nDia = data.getDate();
  var an=data.getYear();
  if (an<1000) {
    an = 1900+an;
  }
  if (letras == 0) {
    document.write('<font color="#' + sColor + '">' + nDia + '/' + index + '/' + data.getYear() + '</font>');
  } else if (letras == 1) {
    document.write('<font color="#' + sColor + '">' + dia[index2] + ', ' + data.getDate() + ' de ' + meses[index] + ' de ' + an + '</font>');
  }
}