function confirma_bor(msg) {
    return confirm('¿Está seguro que desea eliminar '+msg+'?');
}

function popup(mylink, windowname, width, height) {
   if (! window.focus) return true;
   var href;
   if (typeof(mylink) == 'string') href=mylink;
   else href=mylink.href;
   window.open(href, windowname, 'width='+width+',height='+height+',scrollbars=yes');
   return false;
}

function msnOPEN(email,obj,texto) {
   var browser=navigator.appName;
   var version=parseFloat(navigator.appVersion);
   if (browser=="Microsoft Internet Explorer" && version>=4){
      var el=document.getElementById(obj);
	  if (texto==null) texto=email;
	  el.innerHTML=texto+"<br><a href='#' onclick='location.href="+'"msnim:chat?contact=soporte@eqs.com.ve"'+"'><img src='images/msn2.png' height=20 border=0 alt='Abre una ventana de Windows Live Messenger'></a>";
   }
}


function chkNumeric(objName) {
   var checkOK = "0123456789";
   var checkStr = objName;
   var allValid = true;
   var decPoints = 0;
   var allNum = "";
   if (checkStr.value=="") return false;
   else {
      for (i = 0;  i < checkStr.value.length;  i++) {
          ch = checkStr.value.charAt(i);
          for (j = 0;  j < checkOK.length;  j++)
              if (ch == checkOK.charAt(j))
                 break;
              if (j == checkOK.length) {
                 allValid = false;
                 break;
              }
              if (ch != ",")
                 allNum += ch;
      }
      if (!allValid)
          objName.value=objName.value.substr(0,objName.value.length-1);
   }
}

function chkNumeric2(objName) {
   var checkOK = ".0123456789";
   var checkStr = objName;
   var allValid = true;
   var decPoints = 0;
   var allNum = "";
   if (checkStr.value=="") return false;
   else {
      for (i = 0;  i < checkStr.value.length;  i++) {
          ch = checkStr.value.charAt(i);
          for (j = 0;  j < checkOK.length;  j++)
              if (ch == checkOK.charAt(j))
                 break;
              if (j == checkOK.length) {
                 allValid = false;
                 break;
              }
              if (ch != ",")
                 allNum += ch;
      }
      if (!allValid)
          objName.value=objName.value.substr(0,objName.value.length-1);
      else {  // solo pone 2 decimales
         if (objName.value.substr(objName.value.length-1,1)==".") return false;
         n=eval(objName.value);
//         n=(Math.floor(n*100))/100;
         objName.value=n;
      }
   }
}

function replace(string,text,by) {
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

function textCounter(field,cntfield,maxlimit) {
   if (field.value.length > maxlimit)
       field.value = field.value.substring(0, maxlimit);
   else
       cntfield.value = maxlimit - field.value.length;
}


function switchMenu(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != "none" ) {
		el.style.display = 'none';
	}
	else {

		el.style.display = '';
	}
}

function switchMenu2(obj) {
	var alldivs=document.getElementsByTagName("div");
	for (var i=0; i<alldivs.length; i++){
            if (alldivs[i].id.substr(0,8)=="inneradm")
		alldivs[i].style.display="none";
	}
        switchMenu(obj);
}

var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
   page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
   try {
       page_request = new ActiveXObject("Msxml2.XMLHTTP")
   } 
   catch (e){
     try{
        page_request = new ActiveXObject("Microsoft.XMLHTTP")
     }
     catch (e){}
     }
   }
else
   return false
   page_request.onreadystatechange=function(){
   loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
   bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
   page_request.open('GET', url+bustcacheparameter, true)
   page_request.send(null)
}

function ajaxpage2(url){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
   page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
   try {
       page_request = new ActiveXObject("Msxml2.XMLHTTP")
   } 
   catch (e){
     try{
        page_request = new ActiveXObject("Microsoft.XMLHTTP")
     }
     catch (e){}
     }
   }
else
   return false
   page_request.onreadystatechange=function(){
   if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) {
	  return true
   }
}
if (bustcachevar) //if bust caching of external page
   bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
   page_request.open('GET', url+bustcacheparameter, true)
   page_request.send(null)
}

function loadpage(page_request, containerid){
   if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) {
		var scs=page_request.responseText;
        document.getElementById(containerid).innerHTML=scs;
        var capa = document.getElementById('loadingdiv');
        //document.getElementById(containerid).removeChild(capa);
   }
   else {
        if (document.getElementById('loadingdiv')==null) {
           var newdiv = document.createElement("div");
           newdiv.setAttribute('id', 'loadingdiv');
		   newdiv.setAttribute('style','position:absolute;top:1px;left:1px;z-index:999;');
           newdiv.innerHTML = '<table cellspacing=5 cellpadding=5 class="waitBox"><tr align=center valign=center><td><b>espera un momento...</b></td></tr></table>';
           document.getElementById(containerid).appendChild(newdiv);
   		   document.getElementById('loadingdiv').className="loading";
		}
   } 
}


function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}

String.prototype.htmlEntities = function () {
   return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
};

function rescatar_script(texto) { 
   var p1=texto.split("<script",2); 
   if (p1[1]) { 
      var p2=p1[1].split(">",2); 
      var p3=p2[1].split("</script",2) 
      if (p3[0] && p3[0]!='') eval(p3[0]);
         texto=p1[0]+p3[1]; 
      texto=rescatar_script(texto); 
   } 
return texto; 
} 

function encode_utf8(s) {
  return unescape(encodeURIComponent(s));
}