/***********************************************
* Textarea Maxlength script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function ismaxlength(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}

function showMenu(capa){
	hideMenu('Menu2');
	hideMenu('Menu3');
	hideMenu('Menu4');
	hideMenu('Menu5');
	mi_capa=document.getElementById(capa);
	mi_capa.style.visibility='visible';
}

function showAdvanced(capa){
	hideMenu('resulCOM');
	hideMenu('resulNET');
	mi_capa=document.getElementById(capa);
	mi_capa.style.visibility='visible';

	if(capa=="resulCOM"){
		changeBotoneraCOM();
	}
	if(capa=="resulNET"){
		changeBotoneraNET();
	}
}

function hideMenu(capa){
	mi_capa=document.getElementById(capa);
	mi_capa.style.visibility='hidden';
}
	
function hideAllMenu(){
	hideMenu('Menu2');
	hideMenu('Menu3');
	hideMenu('Menu4');
	hideMenu('Menu5');	
}

function enviarMailing(){
	document.datos.action="mailing.php";
	document.datos.submit();
}


function enviarIndustry(){
	if(document.datos.industry.value!=""){
		window.open("http://www.amazing43.com/forum/viewtopic.php?t="+document.datos.industry.value);
	}
}

function sendEmail(id_usuario){
	popup=window.open('emailUser.php?id_usuario='+id_usuario, 'ModelerSite', "status=no,toolbar=no,directories=no,menubar=no,location=no,resizable=yes,scrollbars=no,history=no,width=490,height=300,top=0,left=0");
}
function buscar()
{
	with(document.datos)
	{
		accion.value="BUSCAR";
		pagina.value = 1;
		submit();
	}
}

function GetParentTable(obj)
{
	objParent = obj.offsetParent;
    while( objParent.tagName != 'BODY')
    {
    	if(objParent.id.substr(0, 3) == "tbl")
			return objParent.id.substr(3);
		objParent = objParent.offsetParent;
	}
	return;
}

function verImagen(imagen)
{
	var w = window.open('verImagen.php?imagen=' + imagen, 'WinImagen', 'toolbars=no, scrollbars=yes');
}


function eliminarSeleccionados()
{
	with(document.datos)
	{
		if(confirm("¿Está seguro que desea eliminar los items seleccionados?"))
		{
			accion.value = "ELIMINAR";
			submit();
		}
	}
}

function ir(p)
{
	with(document.datos)
	{
		pagina.value = p;
		submit();
	}
}

function irCOM(p)
{
	with(document.datos)
	{
		paginaCOM.value = p;
		layerActivo.value = "resulCOM";
		submit();
	}
}

function SetRecordFocus(cId)
{
	document.getElementById(cId).style.backgroundColor = "#F5F5F5";
}

function UnSetRecordFocus(cId)
{
	document.getElementById(cId).style.backgroundColor = "white";
}

function ordenar(campo)
{
	with(document.datos)
	{
		if(orden_campo.value != campo)
		{
			orden_campo.value = campo;
			orden_direccion.value = "ASC";
		}
		else
		{
			if(orden_direccion.value == "ASC")
				orden_direccion.value = "DESC";
			else
				orden_direccion.value = "ASC";
		}
		
		submit();
		
	}
}

function Expand(cSectionName)
{
	document.getElementById("tbl" + cSectionName).style.display = "";
	document.getElementById("img" + cSectionName).src = "images/ButtonCollapse.gif";
}

function Collapse(cSectionName)
{
	document.getElementById("tbl" + cSectionName).style.display = "none";
	document.getElementById("img" + cSectionName).src = "images/ButtonExpand.gif";
}

function ExpandCollapse(cSectionName)
{
	if (document.getElementById("tbl" + cSectionName).style.display == "none")
		Expand(cSectionName);
	else
		Collapse(cSectionName);
}

function checkEmail(strEmail)
{
	return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(strEmail))
}

function SetFocus(elemFoco)
{
	try
	{
		//var oTable = GetParentTable(elemFoco);
		//if(oTable != "") Expand(oTable);
		elemFoco.focus();
	}
	catch(e)
	{
		alert(e.description);
	}
}
