// JavaScript Document

// menu: muestra el menu
function menu(c)
{
	switch(c) {
	case 0:
	// Opciones del submenu Replicas
		rp0.style.display = 'inline';
		rp1.style.display = 'inline';
		break;
	case 1:
	// Opciones del submenu Usuarios
		us0.style.display = 'inline';
		us1.style.display = 'inline';
		us2.style.display = 'inline';
		break;
	case 2:
	// Opciones submenu Autoresponder
		ar0.style.display = 'inline';
		ar1.style.display = 'inline';
		ar2.style.display = 'inline';
		break;
	case 3:
	// Opciones del sub-submenu mensajes
		ar_msg0.style.display = 'inline';
		ar_msg1.style.display = 'inline';
		break;
	case 4:
	// Opciones del sub-submenu Prospectos
		ar_af0.style.display = 'inline';
		ar_af1.style.display = 'inline';
		ar_af2.style.display = 'inline';
		ar_af3.style.display = 'inline';
		ar_af4.style.display = 'inline';
		break;
	}
}

// alerta: alerta de confirmacion */
function alerta(c) 
{
	window.alert(c);
}

// selon: ilumina las celdas */
function selon(ctrl)
{
	ctrl.style.backgroundColor = '#CCCCCC';
}

// seloff: vuelve la celda al color original
function seloff(ctrl, origcolor)
{
	ctrl.style.backgroundColor = origcolor;
}

// selonoff: vuelve la celda al color original
function selonoff(selObj, origcolor)
{
	selObj.style.backgroundColor = origcolor;
}

// chkFirst: Devuelve false si itv es 0 y pos != 1
function chkFirst(c)
{
	if(document.frm.itv.value == 0) {
		window.alert(c);
		return false;
	}
	return true;
}

// checkitems: checkea las posiciones de los campos a importar
function checkitems(op, id1, id2, id3, id4, id5, id6, id7, id8, txt1, txt2)
{
	if (op.value < 1 || op.value > 9) {
		window.alert(txt1);
		op.value = '';
		op.focus;
		return;
	}

  var ids = new Array(id1, id2, id3, id4, id5, id6, id7, id8);
	
	for (var i=0; i < ids.length; i++) {
		if (op.value == ids[i].value) {
			window.alert(txt2);
			op.value = '';
			op.focus;
		  break;
		}
	}
}

// setdisab: habilita o desabilita una campo de texto
function setdisab(c)
{
	c.disabled = (c.disabled)? '' : 'disabled';
}

// showtr: muestra u oculta un tr
function showtr(obj)
{
	obj.style.display = (obj.style.display == 'inline') ? 'none' : 'inline';
}

// screen_height: toma el alto de la pantalla
function screen_height(obj)
{
	obj.height.value = window.screen.height;
	return true;
}

function findObj(n, d) { //v4.01
  var p,i,x;
  if(!d) d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) x=d.all[n]; 
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); 
  return x;
}

function showHideLayers() { //v6.0
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  	if ((obj=findObj(args[i]))!=null) { 
  		v=args[i+2];
    	if (obj.style) { 
    		obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
    	}
    obj.visibility=v; 
  	}
}

// Muestra el pop up de ayuda
function helpme(c, path)
{
  var url = path+'?op=help&theme='+c;
  var wp = 2*(screen.width/10);
  var hp = 2*(screen.height/10);
  var w = 6*(screen.width/10);
	var h = 6*(screen.height/10);
 	
	window.open(url, 'help', 'height='+h+', width='+w+', left='+wp+', top='+hp+', resizable=no, scrollbars=yes')
}

// Genera un link y redirige
function sel_domain(frame, sel, link) 
{
	frame.location = link + sel.options[sel.selectedIndex].value;	
}

var ns4 = (document.layers);
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);

function getObj( id )
{ 
	// Netscape 4
	if(ns4)
		return document.layers[id];
		
	// Explorer 4
	else if(ie4)
		return document.all[id];

	// W3C - Explorer 5+ and Netscape 6+
	else if(ie5 || ns6)
		return document.getElementById(id);
}

function show(id){
	// Netscape 4
	if(ns4){
		document.layers[id].visibility = "show";
	}
	// Explorer 4
	else if(ie4){
		document.all[id].style.visibility = "visible";
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if(ie5 || ns6){
		document.getElementById(id).style.visibility = "visible";
	}
}

function hide(id){
	// Netscape 4
	if(ns4){
		document.layers[id].visibility = "hide";
	}
	// Explorer 4
	else if(ie4){
		document.all[id].style.visibility = "hidden";
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if(ie5 || ns6){
		document.getElementById(id).style.visibility = "hidden";
	}
}

//Mantiene visible el Loading
function loadingPosition() 
{
	loading = getObj( "loading" );
	
	if ( loading.style.display != "none" )
		loading.style.top = ( documentTopPosition() + 1 ) + "px";
}

// JavaScript Document