var shower_vert = null;
var jcProgBar = null;

window.addEvent('domready', function(){
	 shower_vert = new Fx.Slide('prop_form_box', {mode: 'vertical' , duration: 2000}).slideOut();
	 jcProgBar = new Fx.Slide('jcProgBar', {mode: 'vertical' , duration: 1});

	shower_vert.hide();
	jcProgBar.hide();
});
function jcPublish(publish, table)
{
    var rows = Array();
    for(var i=0; i<=50; i++)
    {
        try 
        {
            var element = document.getElementById("cb" + i);
            if(element.checked)
            {
                 rows.push(element.value);
                 element.checked = false;
            }
        } 
        catch(e)
        {
        }
    }
    document.getElementById("checkMain").checked = false; 
    pBar();
  
    xajax_jcPublishList(rows, table, publish);
}
function jcDelete(table)
{
    var rows = Array();
    for(var i=0; i<=50; i++)
    {
        try 
        {
            var element = document.getElementById("cb" + i);
            
            if(element.checked)
            {
                rows.push(element.value);
                element.checked = false;
                new Effect.BlindUp("row_" + element.value);
            }
        } 
        catch(e)
        {
        }
    }
    document.getElementById("checkMain").checked = false;
   
    xajax_jcDeleteList(rows, table); 
    pBar();
}
function jcEdit()
{
    var rows = Array();
    for(var i=0; i<=50; i++)
    {
        try 
        {
            var element = document.getElementById("cb" + i);
            if(element.checked)
            {
                 rows.push(element.value);
                 element.checked = false;
            }
        } 
        catch(e)
        {
        }
    }
    document.getElementById("checkMain").checked = false; 
    
    if(!rows)
    {
        alert('Check something!');
        return;
    }
    pBar();
    xajax_jcEditFile(rows);
}
function chmEdit()
{
    var rows = Array();
    for(var i=0; i<=50; i++)
    {
        try 
        {
            var element = document.getElementById("cb" + i);
            if(element.checked)
            {
                 rows.push(element.value);
                 element.checked = false;
            }
        } 
        catch(e)
        {
        }
    }
    document.getElementById("checkMain").checked = false; 
    
    if(!rows)
    {
        alert('Check something!');
        return;
    }
    pBar();
    xajax_chmEditFile(rows);
}
function loaudFirstDate()
{
    var rows = Array();
    rows.push(document.getElementById("cb1").value);
    
    if(!rows)
    {
        alert('Check something!');
        return;
    }
    xajax_jcEditFile(rows);
}



function chmBar()
{
	 showerChmode.slideIn();
}
function chmBarHiden()
{
	 showerChmode.slideOut();
}
function pBar()
{
	
	 jcProgBar.slideIn();
}
function pBarHiden()
{
	 jcProgBar.slideOut();
}

function pBarIn()
{
	pBarHiden();
	shower_vert.slideIn();
}
function pBarOut()
{

	shower_vert.slideOut();
}

function subForm()
{
}
function subClose()
{
}
function listAdmin()
{
    new Effect.BlindDown('jcAdminList');
}
function listAdminClose()
{
    new Effect.BlindUp('jcAdminList');
}
function editItem( id  ) {
    var f = document.adminForm;
    cb = eval( 'f.' + id );
    if (cb) {
        for (i = 0; true; i++) {
            cbx = eval('f.cb'+i);
            if (!cbx) break;
            cbx.checked = false;
        } // for
        cb.checked = true;
        f.boxchecked.value = 1;
        jcEdit();
    }
    return false;
}
function editChm( id  ) {
    var f = document.adminForm;
    cb = eval( 'f.' + id );
    if (cb) {
        for (i = 0; true; i++) {
            cbx = eval('f.cb'+i);
            if (!cbx) break;
            cbx.checked = false;
        } // for
        cb.checked = true;
        f.boxchecked.value = 1;
        chmEdit();
    }
    return false;
}
function formatFloat(id)
{
    var cur = document.getElementById(id).value;
    reg = /[^\d\.]+/;
    cur = cur.replace(',', '.');
    cur = cur.replace('..', '.');
    cur = cur.replace(reg, '');
    document.getElementById(id).value = cur;
}
function changeIcon(id, file)
{
    var img = document.getElementById('icon_' + id);
    img.src = 'components/com_jxplorer/images/icons/68/' + file;
    var hid = document.getElementById('hid_icon_' + id);
    hid.value = file;
}
function jxCopyMove()
{ 
    var rows = Array();
    for(var i=0; i<=50; i++)
    {
        try 
        {
            var element = document.getElementById("cb" + i);
            if(element.checked)
            {
                 rows.push(element.value);
                 element.checked = false;
            }
        } 
        catch(e)
        {
        }
    }
    document.getElementById("checkMain").checked = false; 
    
    if(!rows)
    {
        alert('Check something!');
        return;
    }
    pBar();
    var direct = document.getElementById("directory");
    xajax_jxLoadList(rows, direct.value); 
   
}