﻿var DocopenObj = null;
function ClearText(obj)
{ obj.value = ""; }
//Call for event start
function OpenDoc(obj) {
    if (obj) {
        var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
        var i = obj.getAttribute("v");
        if (isIE) {
            obj.blur();
            if (obj.getAttribute("id").indexOf("a") >= 0) {
                //Title is clicked (do nothing)
            }
            else { //snippets block is clicked
                document.getElementById("a" + i).click();
                return;
            }
        }
        var url = "";
        if (obj.getAttribute("url")) {
            url = obj.getAttribute("url");
        }
        else {
            url = obj.getAttribute("href");
        }
        if (isIE && DocopenObj) {
            //Since IE has a bug and it give JS error on window.open when PDF document is already opened in a popup and then
            //user tries to open some other document
            //DocopenObj = window.open("", 'windoc', 'resizable=yes');
            //DocopenObj.close();
        }
        DocopenObj = window.open(url, 'windoc', 'resizable=yes,scrollbars=yes,menubar=1,titlebar=yes,toolbar=yes,location=yes,status=yes');
        DocopenObj.focus();
        var sourceName = ""
        if (obj.getAttribute("source")) {
            sourceName = obj.getAttribute("source");
        }
        FireCall("opendoc±" + sourceName + "±" + url);
        return false;
    }
}
function OpenDoc1(id, sourceName, url) {
    var i = id.replace("a", "");
    i = i.replace("b", "");
    if (id.indexOf("a") >= 0) {
        //Title is clicked (do nothing)
    }
    else {  //snippets block is clicked
        document.getElementById("a" + i).click();
        return;
    }
    if (DocopenObj) {
        //Since IE has a bug and it give JS error on window.open when PDF document is already opened in a popup and then
        //user tries to open some other document
        //DocopenObj = window.open("", 'windoc', 'resizable=yes');
        //DocopenObj.close();
    }
    DocopenObj = window.open(url, 'windoc', 'resizable=yes,scrollbars=yes,menubar=1,titlebar=yes,toolbar=yes,location=yes,status=yes');
    DocopenObj.focus();
    FireCall("opendoc±" + sourceName + "±" + url);
}
function OpenDocSpecial(obj) {
    if (obj) {
        window.open(obj.href, 'windoc', 'resizable=yes,scrollbars=yes,menubar=1,titlebar=yes,toolbar=yes,location=yes,status=yes').focus();
        var sourceName = ""
        if (obj.getAttribute("source")) {
            sourceName = obj.getAttribute("source");
        }
        FireCall("opendoc±" + sourceName + "±" + obj.href);
        return false;
    }
}
function FireCall(arg) {
    CollectInput_RG(arg);
}
function PagingCall(obj, arg) {
    arg = arg + "±" + obj.href;
    try {
        window.status = "Processing......";
        window.document.body.style.cursor = 'progress';
    }
    catch (ex)
    { }
    FireCall(arg);
    return false;
}
function ReceiveServerData_RG(rValue) {
    if (rValue.indexOf("done") == -1)
    { window.location.href = rValue; }
}
//Call for event end

//Call for special result start
function BindSpecialResult(arg) {
    if (document.getElementById("trSpecialResultProcess")) {
        document.getElementById("trSpecialResultProcess").style.display = '';
    }
    if (document.getElementById("trSpecialResultMain")) {
        document.getElementById("trSpecialResultMain").style.display = 'none';
    }
    if (document.getElementById("trSpecialBanner")) {
        document.getElementById("trSpecialBanner").style.display = 'none';
    }
    CollectInput_SR(arg);
}
function ReceiveServerData_SR(rValue) {
    if (rValue.indexOf('ñÑ') != -1) {
        window.location.href = rValue.substring(2);
        return;
    }
    else {
        var arrVal = rValue.split("±")
        if (arrVal.length > 1) {
            if (arrVal[0] == 1) {
                if (document.getElementById("trSpecialBannerArea")) {
                    document.getElementById("trSpecialBannerArea").innerHTML = arrVal[1];
                    if (document.getElementById("trSpecialResultProcess")) {
                        document.getElementById("trSpecialResultProcess").style.display = 'none';
                    }
                    if (document.getElementById("trSpecialBanner")) {
                        document.getElementById("trSpecialBanner").style.display = '';
                    }
                    if (document.getElementById("trSpecialResultMain")) {
                        document.getElementById("trSpecialResultMain").style.display = 'none';
                    }
                }
            }
            else {
                if (document.getElementById("specialResultArea")) {
                    document.getElementById("specialResultArea").innerHTML = arrVal[1];
                    if (document.getElementById("trSpecialResultProcess")) {
                        document.getElementById("trSpecialResultProcess").style.display = 'none';
                    }
                    if (document.getElementById("trSpecialResultMain")) {
                        document.getElementById("trSpecialResultMain").style.display = '';
                    }
                    if (document.getElementById("trSpecialBanner")) {
                        document.getElementById("trSpecialBanner").style.display = 'none';
                    }
                }
            }
        }

    }
}
//Call for special result end

function roll_over(img_name, img_src) {
    img_name.src = img_src;
}

function ClearText(e, obj) {
    var aryKeyCodes = ['9', '20', '13', '16', '36', '45', '35', '33', '34', '15', '17', '18', '37', '39']; //Tab,caps lock,enter,shift, home, insert, end, pageup, pagedown, control, leftarrow, rightarrow      
    for (var ii = 0; ii < aryKeyCodes.length; ii++) {
        if (aryKeyCodes[ii] == e.keyCode) return;
    }
    if (obj.className == "inp_searchG")
    { obj.value = ""; obj.className = "inp_search"; }
}

function SetCursorToTextStart(textControlID) {
    var text = document.getElementById(textControlID);
    if (text.className == "inp_searchG") {
        if (text != null && text.value.length > 0) {
            if (text.createTextRange) {
                var range = text.createTextRange();
                range.moveStart('character', 0);
                range.collapse();
                range.select();
            }
            else if (text.setSelectionRange) {
                var textLength = text.value.length;
                text.setSelectionRange(textLength, 0);
            }
        }
    }
}
function VLink(docid) {
    var sp = document.getElementById('sp_' + docid);
    sp.className = "visitedLnk";
}
function doHover(ctrl) {
    ctrl.className = "tdGen tdMouseHover";
}
function doMouseOut(ctrl) {
    ctrl.className = "tdGen";
  }
function ApplyStrike(cName, prfix, val) {
  var getvalue = cName.getAttribute("keyVal")
  var objDel = document.getElementById(prfix + getvalue);
  if (objDel) {
    if (val == true) {
      objDel.className = "strikeTextHover";
    }
    else {
      objDel.className = "strikeText";
    }
  }
}
function NodeClicked(arg) {
  try { window.status = "Processing......"; window.document.body.style.cursor = 'progress'; }
  catch (ex) { }
  CollectInput_SN(arg);
}