/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function toggleDiv(temp)
{
    document.getElementById("errorMessageTag").innerHTML="";
    if(temp == 1 && document.getElementById("FileTypeId").value == 'Def'){
        alert("Please select an option first.");
    }
    else if (temp == 1 && document.getElementById("FileTypeId").value == 'Upload'){
        document.getElementById("UploadDiv").style.display='block';
        document.getElementById("SelectDiv").style.display='none';
    }
    else if(temp == 1 && document.getElementById("FileTypeId").value == 'Download'){
        document.getElementById("DownloadDiv").style.display='block';
        document.getElementById("SelectDiv").style.display='none';
    }
    else if(temp==2 ){
        document.getElementById("DownloadDiv").style.display='none';
        document.getElementById("SelectDiv").style.display='block';
    }
    else if(temp==3 ){
        document.getElementById("UploadDiv").style.display='none';
        document.getElementById("SelectDiv").style.display='block';
    }
}


 function sendFileToServer(id)
{
    if(id==1){
        var fileName= document.getElementById("fileChooser").value
        var fileNameSplit=fileName.split('.');
        if(fileNameSplit[1]!="csv"){
            alert("please choose .csv file only");
            return;
        }
        else{
            document.forms[0].submit();
            var formUploadMultiPart = document.getElementById("MicroFileIdUpload");
            formUploadMultiPart.action = '/PacsApplication/MicroFileProcesssingServlet';
            formUploadMultiPart.submit();
        }
    }
    else if(id === 2)
    {
        var agent = document.getElementById('agentId').value;  
        
        if (agent === "") {
            alert("Please select Agent before Download.");
            return false;
        }
        var formDownloadNormal = document.getElementById("MicroFileIdDownload");
        formDownloadNormal.action = '/PacsApplication/MicroFileProcesssingServlet';
        formDownloadNormal.submit();

    }
}