var win= null;
function windowPopCenter(page,name,w,h,scroll){
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
settings='height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',toolbar=no,location=no,status=no,menubar=no,resizable=no,dependent=no'
win=window.open(page,name,settings)
            if( win != null ){
                if( stringMatch( navigator.appName.substring( 0, 8 ), "Netscape" ) ){
                    win.opener = self;
                }
                if( stringMatch( navigator.appName, "Netscape" ) &&
                    navigator.appVersion.substring( 0, 1 ) >= 3 ){
                    win.focus();
                }
                else if( stringMatch( navigator.appName, "Microsoft Internet Explorer" ) &&
                    navigator.appVersion.substring( 0, 1 ) >= 4 ){
                    win.focus();
                }
            }
}


function openWindow(name, url, w, h) {
  windowPopCenter(url,name,w,h,'no');
}

function stringMatch( x, y ){
if( x.length != y.length ){
                return false;
}
            for( var i = 0; i<x.length; i++ ){ if( x.charAt( i ) != y.charAt( i ) ){ return false; } } return true; } /* BEGIN: show info code for Netscape users */ var showInfo = 0; var infoMsg = ''; var infoWidth; var infoHeight; if(!window.event && window.captureEvents) { /* capture a CLICK event */ window.captureEvents(Event.CLICK); /* set event handlers */ window.onclick = onClickHandler; } function onClickHandler(e) { if( showInfo == 1 ){ var leftOffset = e.screenX; var heightOffset = e.screenY; openInfoWin( leftOffset, heightOffset ); showInfo = 0; } if( routeEvent(e) == false ){ return false; } else{ return true; } } /* END: show info code for Netscape users */ function doInfo( msg, w, h, rsc ){ infoMsg = msg; rscMsg = ''; if( rsc != null ){ rscMsg = rsc; } if( w != null && h != null ){ infoWidth = w; infoHeight = h; } else{ infoWidth = '220'; infoHeight = '120'; } if( stringMatch(navigator.appName, "Netscape") ){ /* Use even handler code for Netscape users */ showInfo = 1; } else if( stringMatch(navigator.appName, "Microsoft Internet Explorer") ){ leftOffset = window.event.screenX; heightOffset = window.event.screenY; var widthVariant = infoWidth/2; var heightVariant = infoHeight/2; leftOffset = leftOffset-widthVariant; heightOffset = heightOffset-heightVariant; openInfoWin( leftOffset, heightOffset ); } } function openInfoWin( x, y ){ var w = window.open('/roving/info.jsp?i='+escape(infoMsg)+'&r='+rscMsg, 'infoWin', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width='+infoWidth+',height='+infoHeight+',left='+x+',top='+y); /* close any already open info window that the user might've left open */ if( stringMatch(navigator.appName, "Microsoft Internet Explorer") ){ if( w.screenLeft > (x+10) || w.screenLeft < (x-10) || w.sreenTop > (y+10) || w.screeTop < (y-10) ){ w.close(); w = window.open('/roving/info.jsp?i='+escape(infoMsg)+'&r='+rscMsg, 'infoWin', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width='+infoWidth+',height='+infoHeight+',left='+x+',top='+y); } } else if( stringMatch(navigator.appName, "Netscape") ){ if( w.screenX > (x+10) || w.screenX < (x-10) || w.sreenY > (y+10) || w.sreenY < (y-10) ){ w.close(); w = window.open('/roving/info.jsp?i='+escape(infoMsg)+'&r='+rscMsg, 'infoWin', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+infoWidth+',height='+infoHeight+',left='+x+',top='+y); } } w.focus(); 
} 
  

// FUNCTION FOR RESIZED IMAGE POP UP
function PopupPic(sPicURL, root) { 
root = root + "";
if ((root == "undefined") || (root == "")) root = "";
win = window.open(root + "view_image.asp?picURL="+sPicURL, "", "resizable=0,HEIGHT=200,WIDTH=200");
            if( win != null ){
                if( stringMatch( navigator.appName.substring( 0, 8 ), "Netscape" ) ){
                    win.opener = self;
                }
                if( stringMatch( navigator.appName, "Netscape" ) &&
                    navigator.appVersion.substring( 0, 1 ) >= 3 ){
                    win.focus();
                }
                else if( stringMatch( navigator.appName, "Microsoft Internet Explorer" ) &&
                    navigator.appVersion.substring( 0, 1 ) >= 4 ){
                    win.focus();
                }
            }

}


function clearCombo(combo) {
   for (i = combo.options.length - 1; i >= 0; i-- ) {
     combo.options.remove(i);
   }
}
 
function addComboOption(combo, text, value, selected) {
   var oOption = document.createElement("OPTION");
   combo.options.add(oOption);
   oOption.innerText = text;
   oOption.value = value;
   oOption.selected = selected;
}

var errfound = false;
function error1(elem, text) {
	if (errfound) return;
	window.alert(text);
	elem.select();
	elem.focus();
	errfound = true;
}

function error2(elem, text) {
	if (errfound) return;
	window.alert(text);
	errfound = true;
}

function error3(elem, text) {
	if (errfound) return;
	window.alert(text);
	elem.focus();
	errfound = true;
}

function CheckEmail(correo)
{
  var re;
  re = /^\s+/g;
  correo = correo.replace(re, "");
  re = /\s+$/g;
  correo = correo.replace(re, "");

  var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

  if (!filter.test(correo)) {
    return false;
  }
  return true;
  
}

var chars = "abcdefghijklmnopqrstuvwxyz0123456789_-";

function checkFolderName(fldr) {
  fldr = fldr.toLowerCase();
  for (i = 0; i < fldr.length; i++) {
    if (chars.indexOf(fldr.charAt(i)) == -1) {
      return false;
    }
  }
  return true;
}


// only allow letters, alpha
function alpha(e) {
var k;
document.all ? k = e.keyCode : k = e.which;
return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8);
}

// *********************************************************
// 07-26-2005 New Show Hide - More Efficient (GMP)
// *********************************************************
var loaddef = "";
var resizedef = "";

// ----------------------------------
// cross-browser functions
var IE_all_cache = new Object();
function IE_getElementById(id) {
  if (IE_all_cache[id] == null) {
    IE_all_cache[id] = document.all[id];
  }
  return IE_all_cache[id];
}

if (document.all) {
  if (!document.getElementById) {
    document.getElementById = IE_getElementById;
  }
}

//-----------------------------------
// Browser detection

var agt = navigator.userAgent.toLowerCase();

var is_opera = (agt.indexOf("opera") != -1);
var is_ie = (agt.indexOf("msie") != -1) && document.all && !is_opera;
var is_ie5 = (agt.indexOf("msie 5") != -1) && document.all;

// ---------------------------------
// shelled functions for old javascript
function tog() {}

// ----------------------------------
// visibility functions

function tog() {
  // tog: toggle the visibility of html elements (arguments[1..]) from none to
  // arguments[0].  Return what should be returned in a javascript onevent().
  display = arguments[0];
  for( var i=1; i<arguments.length; i++ ) {    
    var x = document.getElementById(arguments[i]);
    if (x.style.display == "none" || x.style.display == "") {
      x.style.display = display;
    } else {
      x.style.display = "none";
    }
  } 

  var e = is_ie ? window.event : this;
  if (e) {
    if (is_ie) {
      e.cancelBubble = true;
      e.returnValue = false;
      return false;
    } else {
      return false;
    }
  }
}

function tog_data( idnum ) {
  x = tog( 'block', 'dheader_show_' + idnum, 'dheader_hide_' + idnum,
	   'dshow_' + idnum );
  
  return x;
}

function submit_form(formid) {
  if (dataCheck(document.getElementById(formid))) {
    document.getElementById(formid).submit();
  }  
}

function submit_refresh(formid) {
  document.getElementById('action') = 'refresh';
  document.getElementById(formid).submit();
}

function opener_refresh(refresh, formname) {
  if (formname == '') formname = 'addform';
  if (window.opener && refresh=='yes') {
    window.opener.document.getElementById('action').value='refresh';
    window.opener.document.getElementById(formname).submit();
  }
}