function PosicionarFocusCrearSeccio()
{
    var ctl = document.getElementById('FormulariDadesSeccio_Titol_CaixaText');

    if (ctl != null)
    {
        ctl.focus();
        ctl.select();
    }
}

function SortirRecarregar(sParametre)
{ 
   var tempArbre = window.opener.iFrame.FrameArbre.location.href;
   window.opener.iFrame.FrameArbre.location = tempArbre.substring(0,window.opener.iFrame.FrameArbre.location.href.indexOf("?")) + "?IdCategoria=" + sParametre;
   window.close();
}

function SortirRecarregarEliminar(sParametre)
{ 
   var tempArbre = window.opener.iFrame.FrameArbre.location.href;
   window.opener.iFrame.FrameArbre.location = tempArbre.substring(0,window.opener.iFrame.FrameArbre.location.href.indexOf("?")) + "?IdCategoria=" + sParametre;
   
   var tempDades = window.opener.iFrame.FrameDades.location.href;
   if (!sParametre) {
        window.opener.iFrame.FrameDades.location.reload();
    } else {
         if (window.opener.iFrame.FrameDades.location.href.indexOf("?") >= 0) {
            window.opener.iFrame.FrameDades.location = tempDades.substring(0,window.opener.iFrame.FrameDades.location.href.indexOf("?")) + "?IdCategoria" + sParametre;
        } else {
            window.opener.iFrame.FrameDades.location = window.opener.iFrame.FrameDades.location + "?IdCategoria" + sParametre;
        }
    }
    
   window.close();
}

function Recarregar(oFrame, sParametres) {
    if (!sParametres) {
        oFrame.location.reload();
    } else {
         if (oFrame.location.href.indexOf("?") >= 0) {
            oFrame.location = oFrame.location + "&" + sParametres;
        } else {
            oFrame.location = oFrame.location + "?" + sParametres;
        }
    }
}

function RecarregarDadesVenciments(sParametres) {
   var temp  = '/Venciments/LlistatVenciments.aspx'
   if (!sParametres) {
        window.parent.frames[1].location = temp;
    } else {
        window.parent.frames[1].location = temp + "?" + sParametres;
      }
}

function RecarregarDadesVencimentsAdministracio(sParametres) {
   var temp  = '/Administracio/Venciments/LlistatVenciments.aspx'
   if (!sParametres) {
        window.parent.frames[1].location = temp;
    } else {
        window.parent.frames[1].location = temp + "?" + sParametres;
      }
}

function RecarregarDadesCategoria(sParametres) {
   var temp  = '/Administracio/Categories/Dades.aspx'
   if (!sParametres) {
        window.parent.frames[1].location = temp;
    } else {
        window.parent.frames[1].location = temp + "?" + sParametres;
      }
}

function RecarregarDadesArbre(sParametres) {
   var temp = window.parent.frames[0].location.href;
   
   if (!sParametres) {
   	
        window.parent.frames[0].location.reload();
    } else {
         if (window.parent.frames[0].location.href.indexOf("?") >= 0) {
            window.parent.frames[0].location = temp.substring(0,window.parent.frames[0].location.href.indexOf("?")) + "?" + sParametres;
        } else {
            window.parent.frames[0].location = window.parent.frames[0].location + "?" + sParametres;
        }
    }
}




function DispararAccio(sAccio) {

   var IdCategoria;
   IdCategoria = window.parent.iFrame.FrameArbre.document.getElementById('ArbreCategories_Hidden').value;
   
   switch (sAccio) {
        case "Nou":
             ObrirFinestra('/Administracio/Categories/Crear.aspx?IdCategoria=' + IdCategoria, 'Categories', 500, 325, true, true, false, false);
             break;
                    
        case "Moure":
             ObrirFinestra('/Administracio/Categories/Moure.aspx?IdCategoria=' + IdCategoria, 'Categories', 450, 450, true, true, false, true);
             break;
                        
        case "Eliminar":
             ObrirFinestra('/Administracio/Categories/Eliminar.aspx?IdCategoria=' + IdCategoria, 'Categories', 675, 300, true, true, false, false);
             break;
                        
        case "Pujar":
             ObrirFinestra('/Administracio/Categories/Pujar.aspx?IdCategoria=' + IdCategoria, 'Categories', 450, 150, true, true, false, false);
             break;
                        
        case "Baixar":
             ObrirFinestra('/Administracio/Categories/Baixar.aspx?IdCategoria=' + IdCategoria, 'Categories', 450, 150, true, true, false, false);
             break;
                        
        default:
              //No cal fer res
              break;
    }
}