function WindowOpen(szURL,szTarget,szOptions)
{
   var wnd;

   if ( szOptions == undefined )
   {
      szOptions = "";
   }

   if ( szOptions.indexOf("resizable") == -1)
   {
      szOptions += ",resizable=1";
   }

   /* Se abre la ventana */
   wnd = window.open(szURL,szTarget,szOptions);

   /* Se pasa el foco */
   try
   {
      wnd.focus();
   }

   /* Si falla, se cierra, se vuelve a abrir y se le pasa el foco */
   catch(e)
   {
      wnd.close();
      wnd = window.open(szURL,szTarget,szOptions);
      wnd.focus();
   }
}

function setCookie (doc,name, value, days)
{ 
   var expdate = new Date(); 

   if ( !days )
   {
      days = 1;
   }

   expdate.setTime(expdate.getTime() + days*24*60*60*1000); 

   doc.cookie = name + "=" + escape(value) + "; expires=" + expdate.toGMTString(); 

} 


function getCookie (doc,name)
{
   var dc = doc.cookie;
   var cname = name + "=";
   var clen = dc.length;
   var cbegin = 0;

   while (cbegin < clen)
   { 
      var vbegin = cbegin + cname.length;

      if (dc.substring(cbegin, vbegin) == cname)
      { 
         var vend = dc.indexOf (";", vbegin);
         if (vend == -1) vend = clen;
         return unescape(dc.substring(vbegin, vend));
      }

      cbegin = dc.indexOf(" ", cbegin) + 1;

      if (cbegin== 0)
      {
         break;
      }
   }
   return null;
}

function Reposition(
szTable,
szCellContents,
nExtraWidth,
nExtraHeight) 
{
   var MSEX=document.all;

   if ( MSEX )
   {
      return;
   }

   if ( nExtraWidth == undefined )
   {
      nExtraWidth = 0;
   }

   if ( nExtraHeight == undefined )
   {
      nExtraHeight = 0;
   }

   nWidthWindow = (MSEX)?document.body.clientWidth:window.innerWidth;
   nHeightWindow = (MSEX)?document.body.clientHeight:window.innerHeight;

   try
   {
      document.getElementById(szTable).width = nWidthWindow - nExtraWidth;
   }
   catch(e){}

   try
   {
      document.getElementById(szCellContents).height = nHeightWindow - nExtraHeight;
   }
   catch(e){}
}

function ChangeView (
szControlName)
{

   var ctl = document.getElementById(szControlName);

   if ( ctl.style.display == "none" )
   {
      ctl.style.display = "block";
   }
   else
   {
      ctl.style.display = "none";
   }
	
   return false;
}

function SubmitEnter(oEvento, oFormulario)
{
   var iAscii; 

   if (oEvento.keyCode) 
   {
      iAscii = oEvento.keyCode; 
   }
   else if (oEvento.which) 
   {
      iAscii = oEvento.which; 
   }
   else 
   {
      return false;
   }

   if (iAscii == 13) 
   {
      oFormulario.submit();
   }

   return true;
}
function showDivAddUsur(nDiv,imgName)
{
	var imgPlus = "images/Plus.ico";
	var imgMinus = "images/Minus.ico";
	if (document.getElementById('div_' + nDiv).style.display == 'none')
	{
		document.getElementById('div_'+nDiv).style.display = 'block';
		document.images[imgName].src = imgMinus;
	}
	else
	{
		document.getElementById('div_'+nDiv).style.display = 'none';	
		document.images[imgName].src = imgPlus;
	}
}