﻿// JScript File
function IsMicrosoft() {
    if (navigator.appName.indexOf("Microsoft") !=-1) {
        return true;
    } else {
        return false;
    }
}

function doUpdate(sAct,sArg)
{

    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
       
        var oInputs = document.getElementsByTagName("input")
        var oCmd;
        for(var i=0;i<oInputs.length;i++){
            if(oInputs[i].id.indexOf("cmdDoUpdate")>=0){
                oCmd = oInputs[i]; break;
            }
        }
        
        if( oCmd != null){ 
            theForm.__EVENTTARGET.value = sAct;
            theForm.__EVENTARGUMENT.value = sArg;
            oCmd.click();
        }
    }
}

function SetTableRowOver(oRow,bSetOver)
{
    var sCurrClass = oRow.className;
    var sNewClass = "";
    if(bSetOver){
        sNewClass = sCurrClass+" RowOver";
    }else{
        var sClass = oRow.className.split(" ");
        sNewClass = sClass[0];
    }
    oRow.className = sNewClass;
}

/// Img ///
function ImgOver(oImg){
    oImg.src = oImg.src.replace("_n","_r");
}
function ImgOut(oImg){
    oImg.src = oImg.src.replace("_r","_n");
}

function ChooseItem(sItem, em)
{
    var hSelected = document.getElementById("hdnSelectedItems");
    if (em.checked)
        hSelected.value = hSelected.value + sItem + ";"
    else
        hSelected.value = hSelected.value.replace(sItem + ";", "");
    //alert(hSelected.value);
}
/// Command Bar ///
function CmdSave(){
    if(document.getElementById("hdnSelectedItems").value==''){
        alert('Please mark the items that you wish to save');
        return;
    }
    var oWin = window.open("ANTPrint.aspx?Action=Save&Items=" + document.getElementById("hdnSelectedItems").value,"Save");
    oWin.focus();
    oWin.document.execCommand("saveAs",true,".html");
    oWin.close();
    //oWin.save();
}

//&Items=" + document.getElementById("hdnSelectedItems")

function CmdPrint(){
    if(document.getElementById("hdnSelectedItems").value==''){
        alert('Please mark the items that you wish to print');
        return;
    }
    var oWin = window.open("ANTPrint.aspx?Action=Print&Items=" + document.getElementById("hdnSelectedItems").value,"Print");
    oWin.focus();
    oWin.print();
}
function CmdExcel(){
    if(document.getElementById("hdnSelectedItems").value==''){
        alert('Please mark the items that you wish to export to Excel');
        return;
    }
    window.location= "ANTPrint.aspx?Action=Excel&Items=" + document.getElementById("hdnSelectedItems").value;
}
function CmdBack2List(){
    //debugger;
    if(IsItemShow()){
        var oIframe = GetItemIframe();
        if(oIframe != null){
            oIframe.src = "";
        }
        __doPostBack("Back2List","");
    }
//    window.history.back();    
}

function CmdItemPrev(){
    if(IsItemShow()){
        var oIframe = GetItemIframe();
        if(oIframe != null){
            oIframe.src = "";
        }
        __doPostBack("ItemPrev","");
    }
}
function CmdItemNext(){
    if(IsItemShow()){
        var oIframe = GetItemIframe();
        if(oIframe != null){
            oIframe.src = "";
        }
        __doPostBack("ItemNext","");
    }
}
function CmdDocZoom(){
    if(IsItemShow()){
        var oIframe = GetItemIframe();
        if(oIframe != null){
            window.open(oIframe.src,"Zoom")
        }
    }
}
function GetItemIframe()
{
    return document.getElementById("ctl00_ContentPlaceHolder1_ANTPubItemUc1_frmHtmFile");
}
function IsItemShow(){
    var oTest = document.getElementById("Item_Data");
    if(oTest != null){
        return true;
    }else{
        return false;
    }
}
function testMenuItem(id,url)
{
    if(url != ""){
        window.location = url;
    }else{
        //doUpdate("LoadSubject",id);
        window.location = "ANTSearchItems.aspx?Subject="+id;
    }
}

function OpenHelp()
{
    var sFeatures="dialogHeight: " + 640 + "px;";
	window.showModalDialog("LookupHelp.htm","",sFeatures);
	
}

function AdjustBoxHeight(LeftBox, CenterBox, RightBox)
{
        var centerCol = window.document.getElementById(CenterBox);
        var leftCol = window.document.getElementById(LeftBox);
        var rightCol = window.document.getElementById(RightBox);
        if (centerCol != null && leftCol != null && rightCol != null){
            var hCenterCol = centerCol.offsetHeight;
            var hLeftCol = leftCol.offsetHeight;
            var hRightCol = rightCol.offsetHeight;
            var maxHeight = Math.max(hCenterCol, Math.max(hLeftCol, hRightCol));
            centerCol.style.height = maxHeight + 'px';
            leftCol.style.height = maxHeight + 'px';
            rightCol.style.height = maxHeight + 'px';
        }   
}