
<!-- 

var rowPhoneID = 0;
var rowAddressID = 2; // la incremento porq la pantalla tiene dos direciones por ingresar
var rowOnlineID = 0;
var rowContactID = 0;

/*******************************************************
*
********************************************************/
function openSelectState(path, windowID, select_name)
{ 
	select = document.getElementById('address_country' + select_name);

	var country = select.options[select.selectedIndex].value;

	if (country == "-1")
	{
		alert("Para seleccionar una provincia debe seleccionar previamente un pais");
	}
	else
	{
		var atributos = "toolbar=no, location=no, directories=no, status=no, menubar=no, width=600, height=400, scrollbars=yes,resizable=no";
		popup_ventana = window.open(path + country + "/" + select_name,"PopupSelectState" + windowID ,atributos);
		popup_ventana.focus();	
	
	}

}

/*******************************************************
*
********************************************************/
function printState(state_id, state_name, ctrl)
{


	var name  = opener.document.getElementById('address_state_name' + ctrl);
	var id  = opener.document.getElementById('address_state_id' + ctrl);
	
	var title_no_item  = opener.document.getElementById('title_no_item');
	var city_name  = opener.document.getElementById('address_city_name' + ctrl);
	var city_id  = opener.document.getElementById('address_city_id' + ctrl);

	if (id.value != state_id)
	{	
		name.value = state_name;
		id.value = state_id;
		city_name.value = title_no_item.innerHTML;
		city_id.value = '-1';
	}
	window.close();
	opener.focus();

}

/*******************************************************
*
********************************************************/
function openSelectCity(path, windowID, ctrl)
{ 
	var state = document.getElementById('address_state_id' + ctrl);
	

	if (state.value == "-1" || state.value == "")
	{
		alert("Para seleccionar una ciudad debe seleccionar previamente una provincia");
	}
	else
	{
		var atributos = "toolbar=no, location=no, directories=no, status=no, menubar=no, width=600, height=400, scrollbars=yes,resizable=no";
		popup_ventana = window.open(path + state.value + "/" + ctrl,"PopupSelectCity" + windowID ,atributos);
		popup_ventana.focus();	
	
	}

}

/*******************************************************
*
********************************************************/
function printCity(city_id, city_name, ctrl)
{
	var name  = opener.document.getElementById('address_city_name' + ctrl);
	var id  = opener.document.getElementById('address_city_id' + ctrl);
	name.value = city_name;
	id.value = city_id;
	window.close();
	opener.focus();
}

/*******************************************************
*
********************************************************/
function nullStateCity(ctrl)
{
	var select  = document.getElementById('address_country' + ctrl);
	var state_id  = document.getElementById('address_state_id' + ctrl);
	var state_name  = document.getElementById('address_state_name' + ctrl);
	var city_id  = document.getElementById('address_city_id' + ctrl);
	var city_name  = document.getElementById('address_city_name' + ctrl);
	var title_no_item  = document.getElementById('title_no_item');
		
	state_id.value = '-1';
	state_name.value = title_no_item.innerHTML;
	city_id.value = '-1';
	city_name.value = title_no_item.innerHTML;
}

/*******************************************************
*
********************************************************/
function enabledButton(txt,btn)
{
	txt = document.getElementById(txt);
	btn = document.getElementById(btn);
	if (trim(txt.value) == "")
	{	btn.disabled = true;	} 
	else
	{	btn.disabled = false;	}

}

/*******************************************************
*
********************************************************/
function trim(str){

   return str.replace(/^\s*|\s*$/g,"");
}

/*******************************************************
*
********************************************************/
function laodPopup(path, width, height)
{
	var atributos = "toolbar=no,location=no,directories=no,status=no,menubar=no,width=" + width + ",height=" + height + ",scrollbars=yes,resizable=no";
	//var atributos = '';
	popup_ventana = window.open(path, 'UpdateCom', atributos);
	popup_ventana.focus();
	
}

function ChequearTodos(chkbox, frm, value)
{
	for (var i=0;i < document.forms[frm].elements.length;i++)
	{
		var elemento = document.forms[frm].elements[i];
		if (elemento.type == "checkbox" && elemento.name == chkbox)
		{
			elemento.checked = value;
		}
	}
}

/*******************************************************
*
********************************************************/
function enabledDate (prefix)
{
	//alert(prefix);
	day = document.getElementById (prefix + 'Day');
	month = document.getElementById (prefix + 'Month');
	year = document.getElementById (prefix + 'Year');
	chk = document.getElementById (prefix + 'Check');

	day.disabled = chk.checked;
	month.disabled = chk.checked;
	year.disabled = chk.checked;	
	
}

/*******************************************************
*
********************************************************/
function setID(frm)
{
	for (var i=0;i<document.forms[frm].elements.length; i++)
	{
		if (document.forms[frm].elements[i].id == "")
		{
			document.forms[frm].elements[i].id = document.forms[frm].elements[i].name;
		}
	}
}


/*******************************************************
*
********************************************************/
function selectRadio(frm, radio)
{
	for (var i=0;i < document.forms[frm].elements.length;i++)
	{
		var elemento = document.forms[frm].elements[i];
		
		if (elemento.type == "radio" && elemento.id == radio)
		{
			elemento.checked = true;
		}
	}
}


function showDiv(div, selector)
{
	div = document.getElementById (div);
	selector = document.getElementById (selector);
	if(div.style.visibility == 'visible')
	{	div.style.visibility = 'hidden';
		selector.disabled = true;
	}
	else
	{	div.style.visibility = 'visible';
		selector.disabled = false;
	}
}

function seleccionarTodos(cbo, value)
{
	cbo = document.getElementById(cbo);
	for (var i=0;i < cbo.options.length;i++)
	{
			cbo.options[i].selected = value;
	}
}

function addEmail(table)
{
	table = document.getElementById (table);
	rowID = document.getElementById ('rowID');
	webdir = document.getElementById ('webdir');
	
	rowID.value++;
	var id = rowID.value;
	
	table.insertRow(-1);
	var row = table.rows[table.rows.length - 1];
	row.id = id;
	
	//-------------------------------------------------------------------
	
	//inserto la celda donde va el ID
	row.insertCell(row.cells.length);
	var cell = row.cells[row.cells.length - 1];
	cell.innerHTML = "<span class='texto'>E-mail:</span>";
	cell.align = "right";
	//cell.innerHTML = "E-mail:";
	
	//-------------------------------------------------------------------
	
	//inserto la celda con el txt de email
	row.insertCell(row.cells.length);
	var cell = row.cells[row.cells.length - 1];
	var inputEmail = document.createElement("input");
	inputEmail.name = 'email[]';
	inputEmail.type = 'text';
	inputEmail.value = "";
	inputEmail.size = '30';
	cell.appendChild(inputEmail);

	//-------------------------------------------------------------------
	
	//inserto el link quitar
	row.insertCell(row.cells.length);
	var cell = row.cells[row.cells.length - 1];
	cell.align = 'center';
	//cell.innerHTML = '';
	var link = document.createElement("A");
	link.innerHTML='<img src="' + webdir.value + '/images/delete.gif" width="16" height="16" border="0" alter="Borrar">';	
	link.href = "javascript:removeRowTable('" + table.id + "','" + id + "')";
	cell.appendChild(link);	

}

/*******************************************************
*
********************************************************/
function removeRowTable(table, row)
{
	var table = document.getElementById(table);
	var row = document.getElementById(row);
	for (var i = table.rows.length-1; i>=0; i--) 
	{
	  	if (eval(table.rows[i].id) == eval(row.id))
		{	  	
			table.deleteRow(i);		
			i = -1;
		}
	}

}//end function

function isVisibleDiv(div, selector)
{
	var div = document.getElementById (div);
	var selector = document.getElementById (selector);
	if(div.style.visibility == 'hidden')
	{	selector.disabled = true;
	}
	else
	{	selector.disabled = false;
	}
}

/** Habilitar o deshabilitar los selectores de genero y foto segun la opcion 
 *	seleccionada en el selector de tipos de usuario
 */

//tipos de usuarios
var SIN_PERFIL = 1;
var CON_PERFIL = 2;
var ACT_1MES = 3;
var ACT_3MES = 4;

function isVisibleGenero(tipo, genero)
{
	var tipo = document.getElementById (tipo);
	var genero = document.getElementById (genero);
	//alert(tipo.options[tipo.selectedIndex].value);
	if(tipo.options[tipo.selectedIndex].value == SIN_PERFIL)
	{	genero.disabled = true;
	}
	else
	{	genero.disabled = false;
	}
}

function enabledSelectors()
{
	var tipo = document.getElementById ('tipo');
	var genero = document.getElementById ('genero');
	var foto = document.getElementById ('foto');
	//alert(tipo.options[tipo.selectedIndex].value);
	if(tipo.options[tipo.selectedIndex].value == SIN_PERFIL)
	{	genero.disabled = true;
		foto.disabled = true;
	}
	else
	{	genero.disabled = false;
		foto.disabled = false;
	}
}

/** Agrega el perfil pasado a la tabla pasada que se encuentra en opener
 *
 */
function addProfile(table, id, name)
{
	//var delete_title = document.getElementById('title_delete');
	var table = opener.document.getElementById(table);
	var webdir = document.getElementById ('webdir');

	if (!inTable(table,id,0))
	{
		table.insertRow(-1);
		var row = table.rows[table.rows.length - 1];
		row.id = id;
		
		//-------------------------------------------------------------------

		//inserto la celda donde va el ID => columna que sirve para validacion
		row.insertCell(row.cells.length);
		var cell = row.cells[row.cells.length - 1];
		cell.innerHTML = id;
		cell.style.display = 'none';
		
		//-------------------------------------------------------------------

		//inserto la celda con el innerHTML de nombre + txt de id del perfil
		row.insertCell(row.cells.length);
		var cell = row.cells[row.cells.length - 1];
		
		//inserto el link (a view) con el nombre del perfil
		//cell.align = 'left';
		var linkView = opener.document.createElement("A");
		linkView.innerHTML = name;
		linkView.className = "texto4";
		linkView.href = webdir.value + '/perfil/perfil/ver/' + id; 
		linkView.target = "_blank";
		cell.appendChild(linkView);	
		
		
		var inputID = opener.document.createElement("input");
		inputID.name = 'perfilesID[]';
		inputID.type = 'text';
		inputID.value = id;
		inputID.style.display = 'none';
		//inputID.size = '30';
		cell.appendChild(inputID);

		//-------------------------------------------------------------------
		
		//inserto el link quitar
		row.insertCell(row.cells.length);
		var cell = row.cells[row.cells.length - 1];
		cell.align = 'center';
		//cell.innerHTML = '';
		var linkDelete = opener.document.createElement("A");
		linkDelete.innerHTML='<img src="' + webdir.value + '/images/delete.gif" width="16" height="16" border="0" alter="Quitar" title="Quitar">';	
		linkDelete.href = "javascript:removeRowTable('" + table.id + "','" + id + "')";
		cell.appendChild(linkDelete);	

	}


}


/*******************************************************
*
********************************************************/
function inTable(table, text, cellPos)
{
	for (var i = table.rows.length-1;i>=0;i--) 
	{
		//alert("tabla: " + table.rows[i].cells[cellPos].innerHTML + " - text pasado: " + text);
		if (trim(table.rows[i].cells[cellPos].innerHTML.toLowerCase()) ==  trim(text.toLowerCase()))
		{
			alert("El item seleccionado ya se encuentra en la lista");
			return true;
		}

	}
	return false;

}//end function


//-->