function RTL()
{
    document.getElementById("artBody").setAttribute("class", "RTL textArea");
    document.getElementById("artBody").setAttribute("className", "RTL textArea");
    document.getElementById("artTitle").setAttribute("class", "RTL textBox");
    document.getElementById("artTitle").setAttribute("className", "RTL textBox");
}

function LTR()
{
    document.getElementById("artBody").setAttribute("class", "textArea");
    document.getElementById("artBody").setAttribute("className", "textArea");
    document.getElementById("artTitle").setAttribute("class", "textBox");
    document.getElementById("artTitle").setAttribute("className", "textBox");
}

function checkall(chkArt)
{
    for (i = 0; i < chkArt.length; i++)
    {
        chkArt[i].checked = true;
    }
    return "Select all";
}

function uncheck(chkArt)
{
    for (i = 0; i < chkArt.length; i++)
    {
        chkArt[i].checked = false;
    }
    return "Select none";
}
function inverse(chkArt)
{
    for (i = 0; i < chkArt.length; i++)
    {
        if(chkArt[i].checked){chkArt[i].checked = false;}
        else{chkArt[i].checked = true;}
    }
    return "Select Inverse";
}
function confirmDelArt(name,ID,link)
{
    if (confirm("Are you sure you wish to delete article '" + name + "'?"))
    {
            location.replace("admin/delArt.php?get=" + link + "&delete=" + ID);
    }
}
function confirmDel(form,name,ID)
{
    if (confirm("Are you sure you wish to delete " + name + "?"))
    {
            location.replace(form + ".php?delete=" + ID);
    }
}

function confirmDelFile(fileName,artID,from,get)
{
    if (confirm("Are you sure you wish to delete " + fileName + "?"))
    {
            location.replace("articles.php?artID=" + artID + "&delFile=" + fileName + "&get=" + get + "&from=" + from);
    }
}

function confirmDelPic(fileName,artID)
{
    if (confirm("Are you sure you wish to delete " + fileName + "?"))
    {
            location.replace("art_pics.php?artID=" + artID + "&delFile=" + fileName);
    }
}

function editCategory(ID,Cat,Desc)
{
    var catID = document.forms[0].catID;
    catID.value = ID;
    var txtCat = document.forms[0].catName;
    txtCat.value = Cat;
    var txtDesc = document.forms[0].catDesc;
    txtDesc.value = Desc;
    var btnSubmit = document.forms[0].btnSubmit;
    btnSubmit.name = "btnEdit";
    btnSubmit.value = "Edit";
}

function editLanguage(ID,Lang,Dir)
{
    var langID = document.forms[0].langID;
    langID.value = ID;
    var langName = document.forms[0].langName;
    langName.value = Lang;
    var textDir = document.forms[0].textDir;
    textDir.value = Dir;
    var btnSubmit = document.forms[0].btnSubmit;
    btnSubmit.name = "btnEdit";
    btnSubmit.value = "Edit";
}

function editSource(ID,name,link,desc)
{
    var srcID = document.forms[0].srcID;
    srcID.value = ID;
    var srcName = document.forms[0].srcName;
    srcName.value = name;
    var srcLink = document.forms[0].srcLink;
    srcLink.value = link;
    var srcDesc = document.forms[0].srcDesc;
    srcDesc.value = desc;
    var btnSubmit = document.forms[0].btnSubmit;
    btnSubmit.name = "btnEdit";
    btnSubmit.value = "Edit";
}

function selArt(get, from)
{
    artID = document.forms[0].selArtID;
    location.replace('articles.php?artID=' + artID.options[artID.selectedIndex].value + '&get=' + get + '&from=' + from);
}

function selSrc(cat)
{
    src = document.getElementById("selnewspapers");
    if(cat)
        category = '&cat=' + cat;
    else
        category = '';
    location.replace('index.php?src=' + src.options[src.selectedIndex].value + category);
}

function enableDate()
{
    document.forms[1].selDayFrom.disabled = !document.forms[1].selDayFrom.disabled;
    document.forms[1].selMonthFrom.disabled = !document.forms[1].selMonthFrom.disabled;
    document.forms[1].selYearFrom.disabled = !document.forms[1].selYearFrom.disabled;

    document.forms[1].selDayTo.disabled = !document.forms[1].selDayTo.disabled;
    document.forms[1].selMonthTo.disabled = !document.forms[1].selMonthTo.disabled;
    document.forms[1].selYearTo.disabled = !document.forms[1].selYearTo.disabled;
}

function View(show,hide)
{
    document.getElementById(show).style.display="inline";
    document.getElementById(hide).style.display="none";
}

function showPic(show)
{
    i = 0;
    while(document.getElementById("artPIC[" + i + "]"))
    {
        if("artPIC[" + i + "]" == show)
        {
            document.getElementById("artPIC[" + i + "]").style.display="inline";
        }
        else
        {
            document.getElementById("artPIC[" + i + "]").style.display="none";
        }
        i++;
    }
}

function Send(ArtID)
{
    var email = window.prompt('E-mail address:','Example: www.name@host.ae');
    if(email)
    {
        var from = window.prompt('Your name:','');
        location.replace('show.php?artID=' + ArtID + '&send=true&from=' + from + '&email=' + email);
    }
}

function Print()
{
    document.getElementById("header").style.display = 'none';
    document.getElementById("tblLeft").style.display = 'none';
    document.getElementById("tblRight").style.display = 'none';
    document.getElementById("send_print").style.display = 'none';
    document.getElementById("showPic").style.display = 'none';
    document.getElementById("showText").style.display = 'none';
    document.getElementById("files").style.display = 'none';
    document.getElementById("art").style.borderWidth = '0';
    document.getElementById("art").style.width = '650';
    document.getElementById("tdArt").style.borderWidth = '0';
    print();
    document.getElementById("header").style.display = 'inline';
    document.getElementById("tblLeft").style.display = 'inline';
    document.getElementById("tblRight").style.display = 'inline';
    document.getElementById("send_print").style.display = 'inline';
    document.getElementById("showPic").style.display = 'inline';
    document.getElementById("showText").style.display = 'inline';
    document.getElementById("files").style.display = 'inline';
    document.getElementById("art").style.border = '1';
    document.getElementById("art").style.width = '80%';
    document.getElementById("tdArt").style.borderWidth = '1';
}