function openCenteredWindow(url, name, width, height, features) {
  if(screen.width){
	  var winl = (screen.width-width)/2;
	  var wint = (screen.height-height)/2;
  } else {
		winl = 0;
		wint =0;
  }
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + height + ',';
  settings += 'width=' + width + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(url, name, settings);
  win.window.focus();
}

function openCenteredWindowJustScroll(url, name, width, height)
{
	var features = 'scrollbars=yes,toolbars=no,statusbar=no';
	openCenteredWindow(url, name, width, height, features);
}

function openCenteredWindowAlone(url, name, width, height)
{
	var features = 'scrollbars=no,toolbars=no,statusbar=no';
	openCenteredWindow(url, name, width, height, features);
}

function redirect(url)
{
	window.location.href = url;
}

function find(id,container)
{
	var p,i,obj;
	
	//si no pasaron un contenedor uso document
	if(!container)
		container = document;
	
	//si hay un signo de pregunta despues del id el container es un frame
	if( ( p = id.indexOf("?") )>0 && parent.frames.length )
	{
    container = parent.frames[id.substring(p+1)].document;
    id = id.substring(0,p);
	}
	
	//si no lo encuentro directamente en el container uso all
  if( !( obj = container[id] ) && container.all )
  	obj = container.all[id];
  
  //si no lo encontre lo busco entre los forms usando el id como nombre
  for ( i=0; !obj && i < container.forms.length; i++ )
  	obj = container.forms[i][id];
  
  //si no lo encontre lo busco en los layers
  for( i=0; !obj && container.layers && i < container.layers.length; i++ )
  	obj = find( id, container.layers[i].document );
  
  //si no lo encontre me fijo si puedo usar getElementById
  if( !obj && container.getElementById )
  	obj = container.getElementById(id);
  
  return obj;
}

function replace(id_hide,id_show)
{
	display(id_show,true);
	display(id_hide,false);
}

function display(id,mode)
{
	find(id).style.display = mode ? "" : "none";
}

function visible(id,mode)
{
	find(id).style.visibility = mode ? "" : "hidden";
}

function switchFieldClass(field, active) {
	if (field.className == "FieldError") return;
	field.className = active ? "FieldsOver" : "Fields";
}

function ir(url)
{
	if( window.location.href )
		window.location.href = url;
	else if( window.location )
		window.location = url;
}

function paginainicio( obj, page )
{
	if(obj.setHomePage)
	{
		obj.style.behavior = 'url(#default#homepage)';
		obj.setHomePage(page);
	}
	else
	{
		alert("Lo sentimos, su navegador no soporta esta accion.");
	}
}

function favoritos( title, url )
{
	if (window.sidebar)
	{ // Mozilla Firefox Bookmark
		window.sidebar.addPanel( title, url, "" );
	}
	else if( window.external )
	{ // IE Favorite
		window.external.AddFavorite( url, title );
	}
	else
	{
		alert("Lo sentimos, su navegador no soporta esta accion.");
	}
}