﻿
/*
 function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
 
function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}
*/

function Popup(Url) 
{
	var w = 580, h = 440;

	if (document.all || document.layers) {
		
		w = screen.availWidth;
		h = screen.availHeight;
	}

	var popW = 640, popH = 380;
	//var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	
	var leftPos =0, topPos = 0;
	return window.open(Url,'','Height=' + h + ', Width=' + w + ',top=' + topPos + ',left=' + leftPos + ',scrollbars=yes, status=yes, resizable=yes')
	
	//return window.open(Url,'','Height=' + popH + ', Width=' + popW + ',top=' + topPos + ',left=' + leftPos + ',scrollbars=yes, status=yes, resizable=yes')
	
}

function PopupDesplazada(Url, desplLeft, desplTop) 
{
	var w = 580, h = 440;

	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}

	var popW = 640, popH = 380;
	var leftPos = ((w-popW)/2) + desplLeft, topPos = ((h-popH)/2) + desplTop ;
	window.open(Url,'','Height=' + popH + ', Width=' + popW + ',top=' + topPos + ',left=' + leftPos + ',scrollbars=yes,status=yes, resizable=yes')
}

function CheckAll()
{
	for(var i=0;i<document.Form1.elements.length;i++)
	{
		if(document.Form1.elements[i].type == "checkbox")
		{
			if(document.Form1.elements[i].id != "chkTodos")
			{
		    	if(document.Form1.elements[i].checked)
					document.Form1.elements[i].checked = false;
        		else
					document.Form1.elements[i].checked = true;
			}
		}
	}
}

function Popup2(Url,popW,popH) 
{
	var w = 580, h = 440;

	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}

	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	return window.open(Url,'','Height=' + popH + ', Width=' + popW + ',top=' + topPos + ',left=' + leftPos + ',scrollbars=yes, status=yes, resizable=yes')
	//window.showModelessDialog(Url,'','Height=' + popH + ', Width=' + popW + ',top=' + topPos + ',left=' + leftPos + ',scrollbars=yes')
}

function selectitem(id, name)
{

	var idtag = 'window.opener.document.getElementById(\'txt'+varname+'ID\').value='+id;
	var nametag = 'window.opener.document.getElementById(\'txt'+varname+'\').value=\''+name+'\'';	

	// Lo siguiente se esta usando para tildar los Remembers en CollectDetailsABM.aspx
	if (window.opener.document.getElementById('chkRemember' + varname) != null) {
		eval('window.opener.document.getElementById(\'chkRemember' + varname + '\').disabled = false;');
		eval('window.opener.document.getElementById(\'chkRemember' + varname + '\').checked = true;');}
		
	eval(idtag);
	eval(nametag);		
	window.close();
}

function selectitemAndSubmit(id, name)
{

	var idtag = 'window.opener.document.getElementById(\'txt'+varname+'ID\').value='+id;
	var nametag = 'window.opener.document.getElementById(\'txt'+varname+'\').value=\''+name+'\'';	
	eval(idtag);
	eval(nametag);	
	window.opener.document.forms[0].submit();
	window.close();
}
function Clear(ctlName)
{
	//disableControl('txt' + ctlName , false);
	readOnlyControl('txt' + ctlName, false);
	document.getElementById('txt' + ctlName).value			= '';
	document.getElementById('txt' + ctlName + 'ID').value	= '';	
}

function readOnlyControl(controlID, bReadOnly)
{
	var obj = document.getElementById(controlID);
	obj.readOnly = bReadOnly;
}

function selectitemUC(id, name)
{
	var idtag = 'window.opener.document.getElementById(\''+varname+'ID\').value='+id;
	var nametag = 'window.opener.document.getElementById(\''+varname+'\').value=\''+name+'\'';	
	var wd = window.opener;
	eval(idtag);
	eval(nametag);	
	window.close();
}

function selectitemUCAndSubmit(id, name)
{
	var idtag = 'window.opener.document.getElementById(\''+varname+'ID\').value='+id;
	var nametag = 'window.opener.document.getElementById(\''+varname+'\').value=\''+name+'\'';	
	var wd = window.opener;
	eval(idtag);
	eval(nametag);	
	window.opener.document.forms[0].submit();
	window.close();
}

function ClearAndSubmit(ctlName)
{
	//disableControl('txt' + ctlName , false);
	readOnlyControl('txt' + ctlName, false);
	document.getElementById('txt' + ctlName).value			= '';
	document.getElementById('txt' + ctlName + 'ID').value	= '';	
	window.document.forms[0].submit();
}
function CloseAndRedirect(Url)
{	
	var x =	'window.opener.location.href =\'' + Url + '\'';
	var y = 'window.close()';
	eval(x);
	eval(y);
}
function ClearUC(ctlName)
{
	//disableControl(ctlName , false);
	readOnlyControl(ctlName, false);
	var idTag = 'document.getElementById(\''+ctlName+'ID\').value=""';
	var nametag = 'document.getElementById(\''+ctlName+'\').value=""';
	eval(idTag);
	eval(nametag);
}


function PopupOnTop(Url, obj) 
{
	var w = 580, h = 440;

	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}

	var popW = 640, popH = 380;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
			
	if (obj != null){
		if (obj.closed == false) {
			obj.focus();
			return obj;
		}											
	}
			
	return window.showModelessDialog(Url,'','dialogHeight: ' + popH + 'px; dialogWidth: ' + popW + 'px; dialogTop: ' + topPos + 'px; dialogLeft: ' + leftPos + 'px;center: Yes; help: No; resizable: Yes; status: No;');
}


function selectAssignor(id, name, emi)
{	//utilizado en AddSearchOwner.aspx -> para asignar el owner al seleccionarlo 
	var idtag = 'window.opener.document.getElementById(\''+varname+'ID\').value='+id;
	var nametag = 'window.opener.document.getElementById(\''+varname+'\').value=\''+name+'\'';	
	
	if(emi=="N")
	{
		//var notEmiTag = 'window.opener.document.getElementById(\''+varname+'NotEMI\').style.display=\'inline\'';
		//var notEmitag = 'window.opener.document.getElementById(\''+varname+'NotEMI\').style.display=\'inline\'';
		//var emitag = 'window.opener.document.getElementById(\''+varname+'NotEMI\').style.display=\'none\'';		
	}
	else
	{
		//var notEmitag = 'window.opener.document.getElementById(\''+varname+'NotEMI\').style.display=\'none\'';
		//var emitag = 'window.opener.document.getElementById(\''+varname+'NotEMI\').style.display=\'inline\'';		
	}
		
	var f = window.opener.document.getElementById("Form1");
	eval(idtag);
	eval(nametag);	
	//eval(emitag);
	//eval(notEmitag);
	f.submit();
	window.close();
}

function copyValueAndClearID(controlIdFrom, controlIdTo)
{
	var obj1 = document.getElementById(controlIdFrom);
	var obj2 = document.getElementById(controlIdTo);
	obj2.value = obj1.value;
	var idTag = 'document.getElementById(\''+controlIdTo+'ID\').value=""';
	eval(idTag);
}

/*
funcion:				readOnlyControl
objetivo:				dejar o no como sóo lectura un control 
parametro controlID:	id en el client browser del control
parametro bReadOnly:	true o false, según corresponda
*/
function readOnlyControl(controlID, bReadOnly)
{
	var obj = document.getElementById(controlID);
	obj.readOnly = bReadOnly;
}

/*
funcion:				copyValue
objetivo:				copia el value de un objeto en el value de otro
parametro controlIdFrom:id en el client browser del control desde donde quiero copiar
parametro controlIdTo:	id en el client browser del control a donde quiero copiar
*/

function copyValue(controlIdFrom, controlIdTo)
{
	var obj1 = document.getElementById(controlIdFrom);
	var obj2 = document.getElementById(controlIdTo);
	obj2.value = obj1.value;
}

/*
funcion:				disableControl
objetivo:				Habilitar o deshabilitar un control 
parametro controlID:	id en el client browser del control
parametro bDisabled:	true o false, según se quiera habilitar o deshabilitar 
*/
function disableControl(controlID, bDisabled)
{
	var obj = document.getElementById(controlID);
	if(bDisabled==true)
		obj.disabled = true;
     else
		obj.disabled = false;
}


function selectRelease(idRelease, idUsageWork, submit)
{

	var idReleaseTag = 'window.opener.document.getElementById(\'' + fieldRelease + '\').value='+idRelease;
	var idUsageWorkTag = 'window.opener.document.getElementById(\'' + fieldUsageWork + '\').value=\''+idUsageWork+'\'';	
	
	if (window.opener.document.getElementById(ctlCheckBox) != null) {
		eval('window.opener.document.getElementById(ctlCheckBox).disabled = false;');
		eval('window.opener.document.getElementById(ctlCheckBox).checked = true;');}
	
	eval(idReleaseTag);
	eval(idUsageWorkTag);
	if (submit == true)
		window.opener.document.forms[0].submit();
	window.close();
}

function selectOwnerShowAdvertence(id, name)
{

	var idtag = 'window.opener.document.getElementById(\'txt'+varname+'ID\').value='+id;
	var nametag = 'window.opener.document.getElementById(\'txt'+varname+'\').value=\''+name+'\'';	
	eval(idtag);
	eval(nametag);	
	var wd = window.opener;
	if(wd.AfterOwnerChange!=null)
		eval(wd.AfterOwnerChange());
	window.close();
}

function selectitemAndSubmit(id, name)
{

	var idtag = 'window.opener.document.getElementById(\'txt'+varname+'ID\').value='+id;
	var nametag = 'window.opener.document.getElementById(\'txt'+varname+'\').value=\''+name+'\'';	
	eval(idtag);
	eval(nametag);	
	window.opener.document.forms[0].submit();
	window.close();
}

function PopupWithStatusMenuBar(Url) 
{
	var w = 580, h = 440;

	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}

	var popW = 640, popH = 380;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	window.open(Url,'','Height=' + popH + ', Width=' + popW + ',top=' + topPos + ',left=' + leftPos + ',scrollbars=yes,status=yes, resizable=yes')
	//window.showModelessDialog(Url,'','Height=' + popH + ', Width=' + popW + ',top=' + topPos + ',left=' + leftPos + ',scrollbars=yes')
}

function PopupWithStatusMenuBarDespl(Url, desplLeft, desplTop) 
{
	var w = 580, h = 440;

	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}

	var popW = 640, popH = 380;
	var leftPos = ((w-popW)/2) + desplLeft, topPos = ((h-popH)/2) + desplTop ;
	window.open(Url,'','Height=' + popH + ', Width=' + popW + ',top=' + topPos + ',left=' + leftPos + ',scrollbars=yes,status=yes, resizable=yes')
	//window.showModelessDialog(Url,'','Height=' + popH + ', Width=' + popW + ',top=' + topPos + ',left=' + leftPos + ',scrollbars=yes')
}

function PopupModal(Url) 
{
	var w = 580, h = 440;

	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}

	var popW = 640, popH = 380;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	//window.open(Url,'','Height=' + popH + ', Width=' + popW + ',top=' + topPos + ',left=' + leftPos + ',scrollbars=yes, status=yes, resizable=yes')
	window.showModalDialog(Url,'','Height=' + popH + ', Width=' + popW + ',top=' + topPos + ',left=' + leftPos + ',scrollbars=yes')
}


function PopupAgreement(Url) 
{
	var w = 780, h = 580;

	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}

	var popW = 780, popH = 580;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	window.open(Url,'','Height=' + popH + ', Width=' + popW + ',top=' + topPos + ',left=' + leftPos + ',scrollbars=yes, status=yes, resizable=yes')
}


function selectwork(id, name)
{
	
	var idtag = 'window.opener.document.getElementById(\'txt'+varname+'ID\').value='+id;
	var nametag = 'window.opener.document.getElementById(\'txt'+varname+'\').value=\''+name+'\'';
	if(workId==id)
	{
		alert("You can't select the same work");
		return false;
	}
		
	eval(idtag);
	eval(nametag);	
	window.close();
}



// Funciones para el manejo del menu ----------------------

function AutoShowHide(show)
{			
	if (parent != null)
	{
	  if (parent.frames[0] != null)
	  {
	    if (parent.frames[0].document.getElementById('chkAutoHide') != null)
		{
		  if (parent.frames[0].document.getElementById('chkAutoHide').checked == true)	
		  {
			if (show == 'show')
				SizeToMax();
			else						
				SizeToMin();
		  }
	    }				
      }
    }
}

function SizeToMin()
{	
	if (parent.frames[0].document.getElementById('DivFlecha') != null &&
		parent.frames[0].document.getElementById('DivFlecha2') != null &&
		parent.frames[0].document.getElementById('hdnLastSize') != null)
	{
		if (top.document.body.cols != "10,*")
		{
			parent.frames[0].document.getElementById('DivFlecha').style.display='';	
			parent.frames[0].document.getElementById('DivFlecha2').style.display='none';
			parent.frames[0].document.getElementById('hdnLastSize').value=top.document.body.cols;		
			top.document.body.cols = "10,*"
		}	
	}
}
function SizeToMax()
{	
	if (parent.frames[0].document.getElementById('DivFlecha') != null &&
		parent.frames[0].document.getElementById('DivFlecha2') != null &&
		parent.frames[0].document.getElementById('hdnLastSize') != null)
	{
		if (top.document.body.cols == "10,*")
		{
			parent.frames[0].document.getElementById('DivFlecha2').style.display='';		
			parent.frames[0].document.getElementById('DivFlecha').style.display='none';		
			top.document.body.cols = parent.frames[0].document.getElementById('hdnLastSize').value; 
		}	
	}
}
// Fin Funciones para el manejo del menu ----------------------


//Funciones Modulo Presupuestos
function CuadroCostosA(Costo,Proveedor,Moneda,Cantidad,Markup,Bonificacion,PrecioVta,Tipo)
{
	var nametag1 = 'window.opener.document.getElementById(\'txtCosto\').value='+Costo;
	var nametag2 = 'window.opener.document.getElementById(\'txtProveedorID\').value='+Proveedor;
	var nametag3 = 'window.opener.document.getElementById(\'TxtTipoPrecio\').value="' + Tipo  + '"';
	var nametag4 = 'window.opener.document.getElementById(\'txtMonedaID\').value='+Moneda;
	//var nametag5 = 'window.opener.document.getElementById(\'txtCantidad\').value='+Cantidad;
	var nametag6 = 'window.opener.document.getElementById(\'TxtMarkupPorc\').value='+Markup;
	var nametag7 = 'window.opener.document.getElementById(\'TxtBonificacionPorc\').value='+Bonificacion;
	var nametag8 = 'window.opener.document.getElementById(\'txtPrecio\').value='+PrecioVta;
	var nametag9 = 'window.opener.document.getElementById(\'txtVieneDeCC\').value=1';
	
	eval(nametag1);	
	eval(nametag2);	
	eval(nametag3);	
	eval(nametag4);	
	//eval(nametag5);	
	eval(nametag6);	
	eval(nametag7);	
	eval(nametag8);	
	eval(nametag3);	
	
	window.opener.document.forms[0].submit();
	window.close();
}
function CuadroCostosB(Costo,Proveedor,Moneda,Tipo)
{
	var nametag1 = 'window.opener.document.getElementById(\'txtCosto\').value='+Costo;
	var nametag2 = 'window.opener.document.getElementById(\'txtProveedorID\').value='+Proveedor;
	var nametag3 = 'window.opener.document.getElementById(\'TxtTipoPrecio\').value="' + Tipo  + '"';
	var nametag4 = 'window.opener.document.getElementById(\'txtVieneDeCC\').value=1';
	var nametag5 = 'window.opener.document.getElementById(\'txtMonedaID\').value='+Moneda;

	eval(nametag1);	
	eval(nametag2);	
	eval(nametag3);	
	eval(nametag4);	
	eval(nametag5);
	window.opener.document.forms[0].submit();
	window.close();
}
function CuadroCostosC(Costo,Proveedor,Moneda,Markup,Bonificacion,PrecioVta,Tipo)
{
 	var nametag1 = 'window.opener.document.getElementById(\'txtCosto\').value='+Costo;
	var nametag2 = 'window.opener.document.getElementById(\'txtProveedorID\').value='+Proveedor;
	var nametag3 = 'window.opener.document.getElementById(\'TxtTipoPrecio\').value="' + Tipo + '"';
	var nametag4 = 'window.opener.document.getElementById(\'txtMonedaID\').value='+Moneda;
	var nametag5 = 'window.opener.document.getElementById(\'TxtMarkupPorc\').value='+Markup;
	var nametag6 = 'window.opener.document.getElementById(\'TxtBonificacionPorc\').value='+Bonificacion;
	var nametag7 = 'window.opener.document.getElementById(\'txtPrecio\').value='+PrecioVta;
	var nametag8 = 'window.opener.document.getElementById(\'txtVieneDeCC\').value=1';
	
	eval(nametag1);	
	eval(nametag2);	
	eval(nametag3);	
	eval(nametag4);	
	eval(nametag5);	
	eval(nametag6);	
	eval(nametag7);	
	eval(nametag8);	
	
	window.opener.document.forms[0].submit();
	window.close();
}

function CuadroCostosEsp()
{
	var Costo = document.getElementById('txtCE').value;
	var Proveedor1 = document.getElementById('cboProveedor');
	Proveedor = Proveedor1.options[Proveedor1.selectedIndex].value;
	var Moneda1 = document.getElementById('cboMoneda');
	var Moneda = Moneda1.options[Moneda1.selectedIndex].value;
	var Tipo
	
	if (document.getElementById('rbEsp').checked==true)
	{	 
	 Tipo = 'E' ;
	}
	else
	{	 
	 Tipo = 'C' ;
	}
	
	var nametag1 = 'window.opener.document.getElementById(\'txtCosto\').value='+Costo;
	var nametag2 = 'window.opener.document.getElementById(\'txtProveedorID\').value='+Proveedor;
	var nametag3 = 'window.opener.document.getElementById(\'TxtTipoPrecio\').value="'+Tipo+'"';
	var nametag4 = 'window.opener.document.getElementById(\'txtMonedaID\').value='+Moneda;
	var nametag5 = 'window.opener.document.getElementById(\'txtVieneDeCC\').value=1';
	
	eval(nametag1);	
	eval(nametag2);	
	eval(nametag3);	
	eval(nametag4);	
	eval(nametag5);	
	
	window.opener.document.forms[0].submit();
	window.close();
}

function Open(Url) 
{
	return window.location.href = Url ;
}


function volver(cant_pags) {
    window.history.go(cant_pags*(-1));
}
        
function ResetScroll() {
    document.getElementById('yCoordHolder').value = 0;
    document.getElementById('xCoordHolder').value = 0;
}

// FIn Funciones Modulo Presupuestos

