var popUp; 


function OpenWindow(idForm,idControl,idName,postBack)
{	var aleatorio
	
	aleatorio = (Math.round((Math.random()*99999)+1))
	popUp = window.open(idForm + '?formname=' + document.forms[0].name + 
	'&Control=' + idControl + '&valor=' + document.forms[0].elements[idName].value + '&postBack=' + postBack,
	aleatorio,"top=100,left=150,height=400,width=700,status=yes,toolbar=no,menubar=no,resizable=yes" );
}

function AbrirVentana(idForm)
{	var aleatorio
	
	aleatorio = (Math.round((Math.random()*99999)+1))
	popUp = window.open(idForm,
	aleatorio,"top=100,left=150,height=415,width=700,status=yes,toolbar=no,scrollbars=yes,menubar=no,resizable=yes" );
}

function AbrirVentanaSmall(idForm)
{	var aleatorio
	
	aleatorio = (Math.round((Math.random()*99999)+1))
	popUp = window.open(idForm,
	aleatorio,"top=100,left=250,height=300,width=500,status=yes,toolbar=no,scrollbars=yes,menubar=no,resizable=yes" );
}

function AbrirVentanaPrincipal(idForm)
{	var aleatorio
	
	aleatorio = (Math.round((Math.random()*99999)+1))
	popUp = window.open(idForm,
	aleatorio,"top=0,left=0,height=652,width=1030,status=yes,toolbar=yes,menubar=yes,resizable=yes" );
}

function AbrirVentanaPrincipalX(idForm)
{	var aleatorio
	
	aleatorio = (Math.round((Math.random()*99999)+1))
	popUp = window.open(idForm,"Ventana1","top=0,left=0,height=652,width=1030,status=yes,toolbar=yes,menubar=yes,resizable=yes" );
}

function OpenWinSimple(sTipo,sUrl, iWidth, iHeight, iTop, iLeft)
{
	Args="width=" + iWidth + ",height=" + iHeight + ",resizable=yes,scrollbars=no,status=1,top=" + iTop + ",left=" + iLeft + ";"
	popUp=window.open(sUrl,sTipo,Args);
	if (popUp != null) {
		if (popUp.opener == null)
		popUp.opener = self;
	}
}

function OpenWindowLista(idForm,idName,idRecurso, postBack)
{	var aleatorio
	aleatorio = (Math.round((Math.random()*99999)+1)) 	
	popUp = window.open(idForm + '?formname=' + document.forms[0].name + 
	'&Control=' + idName + '&valor=' + document.forms[0].elements[idName].value + '&postBack=' + postBack + '&Recurso=' + idRecurso,
	aleatorio,"top=100,left=150,height=600,width=600,status=yes,toolbar=no,menubar=no,resizable=yes,scrollbars=yes" );
}

function SetValor(FormName,idControl, valor, postBack)
{
	eval('var theform = document.' + FormName + ';');
	popUp.close();
	theform.elements["hidControl"].value = idControl;
	theform.elements["hidValor"].value = valor;
	if (postBack)
		__doPostBack('btnRecargar','');
}		

function OpenWindowForSelect(idForm,idName,postBack)
{	var aleatorio
	
	aleatorio = (Math.round((Math.random()*99999)+1)) 		
	popUp = window.open(idForm + '?formname=' + document.forms[0].name + 
	'&Control=' + idName + '&valor=' + document.forms[0].elements[idName].value + '&postBack=' + postBack,
	aleatorio,"top=150,left=250,height=250,width=220,status=yes,toolbar=no,menubar=no,resizable=no" );
}


function SetValorForSelect(FormName,idControl, valor, postBack)
{
	eval('var theform = document.' + FormName + ';');
	popUp.close();
	theform.elements[idControl].value = valor;		
	if (postBack)
		__doPostBack('btnRecargar','');
}	

function SetValorForLista(FormName,idControl, valor, postBack)
{
	eval('var theform = document.' + FormName + ';');
	popUp.close();
	theform.elements[idControl].value = valor;	
	theform.elements["hidControl"].value = idControl
		if (postBack)
		__doPostBack('btnRecargar','');
}	

/*function OpenWindowLista(idForm,idName,idRecurso, postBack)
{	var aleatorio
	
	aleatorio = (Math.round((Math.random()*99999)+1)) 	
	popUp = window.open(idForm + '?formname=' + document.forms[0].name + 
	'&Control=' + idName + '&valor=' + document.forms[0].elements[idName].value + '&postBack=' + postBack + '&Recurso=' + idRecurso,
	aleatorio,"top=100,left=150,height=450,width=600,status=yes,toolbar=no,menubar=no,resizable=yes" );
}*/

function OpenForm(idForm,idControl, iWidth, iHeight, iTop, iLeft,postBack)
{	var aleatorio
	
	aleatorio = (Math.round((Math.random()*99999)+1)) 	
	Args="width=" + iWidth + ",height=" + iHeight + ",resizable=yes,scrollbars=no,status=yes,top=" + iTop + ",left=" + iLeft 
	Url='?formname=' + document.forms[0].name + '&Control=' + idControl + '&Valor=' + document.forms[0].elements[idControl].value + '&PostBack=' + postBack 	
	popUp = window.open(idForm + Url, aleatorio,Args);	
}


function OpenWindowListaValores(idForm,idName,idRecurso,idColumnas, postBack)
{	var aleatorio
	
	aleatorio = (Math.round((Math.random()*99999)+1)) 	
	popUp = window.open(idForm + '?formname=' + document.forms[0].name + 
	'&Control=' + idName + '&valor=' + document.forms[0].elements[idName].value + '&postBack=' + postBack + '&Recurso=' + idRecurso + '&Columnas=' + idColumnas,
	aleatorio,"top=100,left=150,height=350,width=500,status=yes,toolbar=no,menubar=no,resizable=yes" );
}

function CloseWindow()
            {
                self.close();
            }
            
function MostrarOcultar(id) {
 var disp = document.all(id).style.display;

 if(disp != "none" || disp == "") {
   document.all(id).style.display = "none";
  }
 else {
   document.all(id).style.display = "block";
  }
}

function ConfirmSubmit(valor)
	{
	var agree=confirm(valor);
	if (agree)
		return true ;
	else
		return false ;
	}
	
	
function SelectAllCheckboxes(spanChk){
	var xState=spanChk.checked;
	var theBox=spanChk;
	
		elm=theBox.form.elements;
		for(i=0;i<elm.length;i++)
		if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
			{
			if(elm[i].checked!=xState)
			elm[i].click();
			}
	}


function HighlightRow(chkB)	{
	
	var xState=chkB.checked;
		
	if(xState)
		{chkB.parentElement.parentElement.style.backgroundColor='CadetBlue'//'lightcoral';  // grdEmployees.SelectedItemStyle.BackColor
		 chkB.parentElement.parentElement.style.color='white'; // grdEmployees.SelectedItemStyle.ForeColor
		}else 
		{chkB.parentElement.parentElement.style.backgroundColor='white'; //grdEmployees.ItemStyle.BackColor
		 chkB.parentElement.parentElement.style.color='black'; //grdEmployees.ItemStyle.ForeColor
		}
	}
	
	
	
		

