﻿// JScript File
//Initialize Replace all method
String.prototype.ReplaceAll = function (stringToFind, stringToReplace) {
    var temp = this;
    var index = temp.indexOf(stringToFind);
    while (index != -1) {
        temp = temp.replace(stringToFind, stringToReplace);
        index = temp.indexOf(stringToFind);
    }
    return temp;
}

function GlossaryTooltip(divID, spanID, vis, shortDesc) {
    var docElement;
    docElement = document.getElementById(divID);
    if (docElement) {
        docElement.style.display = vis ? "inline" : "none";
        docElement.style.visibility = vis ? "visible" : "hidden";
    }

    if (shortDesc != 'Nothing') document.getElementById(spanID).innerHTML = shortDesc.ReplaceAll("~", "'");
    return false;
}

function showDefn(spanID, defnTxt) {
    var glossaryDesc;
    var temp = new Array();
    temp = defnTxt.split('%20');
    temp = temp.join(' ');
    defnTxt = temp;
    temp = defnTxt.split('%#');
    temp = temp.join('\'');
    defnTxt = temp;
    temp = defnTxt.split('%^');
    temp = temp.join('"');
    defnTxt = temp;
    temp = defnTxt.split('&#60;');
    temp = temp.join('<');
    defnTxt = temp;
    temp = defnTxt.split('&#62;');
    glossaryDesc = temp.join('>');
    document.getElementById(spanID).innerHTML = glossaryDesc;
}

function HideDiv() {

        document.getElementById("ctl00_MainContent_MessageDiv").style.visibility = "hidden";

        document.getElementById("ctl00_MainContent_MessageDiv").style.display = "none";
    }


    function OpenMessagePopupFromEmailRequest(messagectl,emailidctl,subject,date) {
        var modalPopupBehavior = $find('programmaticMessageModalPopupBehavior');
        document.getElementById("ctl00_MainContent_RequestUserCtl_MailInfoDiv").innerHTML = document.getElementById(messagectl).innerHTML;
        document.getElementById("ctl00_MainContent_RequestUserCtl_EmailServiceIdCtl").value = document.getElementById(emailidctl).value;
        document.getElementById("ctl00_MainContent_RequestUserCtl_PopupTitleCtl").innerHTML = subject;
        document.getElementById("ctl00_MainContent_RequestUserCtl_DateLbl").innerHTML = date;
        modalPopupBehavior.show();



    }
    function OpenMessagePopupFromSearchRequest(searchidctl,date, keyword,phone,vatno,ipaddress,domain,page,Province,Town ) {
        var modalPopupBehavior = $find('MessageModalPopupBehavior');
        document.getElementById("ctl00_MainContent_SearchUserCtl_KeywordLbl").innerHTML = keyword;
        document.getElementById("ctl00_MainContent_SearchUserCtl_SearchTrackIdCtl").value = document.getElementById(searchidctl).value;
        document.getElementById("ctl00_MainContent_SearchUserCtl_DateLbl").innerHTML = date;
        document.getElementById("ctl00_MainContent_SearchUserCtl_PhoneLbl").innerHTML = phone;
        document.getElementById("ctl00_MainContent_SearchUserCtl_VATLbl").innerHTML = vatno;
        document.getElementById("ctl00_MainContent_SearchUserCtl_IPLbl").innerHTML = ipaddress;
        document.getElementById("ctl00_MainContent_SearchUserCtl_DomainLbl").innerHTML = domain;
        document.getElementById("ctl00_MainContent_SearchUserCtl_PageLbl").innerHTML = page;
        document.getElementById("ctl00_MainContent_SearchUserCtl_ProvinceLbl").innerHTML = Province;
        document.getElementById("ctl00_MainContent_SearchUserCtl_TownLbl").innerHTML = Town;
        modalPopupBehavior.show();



    }
    function BackGroundChange(ctlid) {

        document.getElementById(ctlid).style.backgroundColor = "#FDB509";


    }
    function BackGroundReset(ctlid) {
        document.getElementById(ctlid).style.backgroundColor = "White";

    }
    function ShowChangepasswordDiv() {
        var div = document.getElementById("ctl00_MainContent_ChangePasswordDiv");
        div.style.visibility = "visible";
        div.style.display = "block";
    }

    function PasswordCancel() {

        var div = document.getElementById("ctl00_MainContent_ChangePasswordDiv");
        div.style.visibility = "hidden";
        div.style.display = "none";
        return false;

    }
    function closeMessage() {

        document.getElementById("ctl00_MainContent_PwdChangedMsgDiv").style.visibility = 'hidden';
        document.getElementById("ctl00_MainContent_PwdChangedMsgDiv").style.display = 'none';
    }
    function showlogindiv() {
        document.getElementById("logindiv").style.visibility = "visible";
        document.getElementById("logindiv").style.display = "block";
        document.getElementById("symfirstdiv").style.visibility = "hidden";
        document.getElementById("symfirstdiv").style.display = "none";
        return false;
    }
    function showlogindivbyinfo() {
        document.getElementById("Sympathiserinfo").style.visibility = "hidden";
        document.getElementById("Sympathiserinfo").style.display = "none";
        document.getElementById("SympathiserloginDiv").style.visibility = "visible";
        document.getElementById("SympathiserloginDiv").style.display = "block";
        document.getElementById("logindiv").style.visibility = "visible";
        document.getElementById("logindiv").style.display = "block";
        document.getElementById("symfirstdiv").style.visibility = "hidden";
        document.getElementById("symfirstdiv").style.display = "none";
        document.getElementById("SympathiserErrorDiv").style.visibility = "hidden";
        document.getElementById("SympathiserErrorDiv").style.display = "none";
        return false;
    }
    function Showadv() {
        document.getElementById("AdvantagesDiv").style.display = "block";
        document.getElementById("WinDescDiv").style.display = "none";
        document.getElementById("SuperwinnerDiv").style.display = "none";
        return false;
    }
    function SuperWindivclose() {
        document.getElementById("SuperwinnerDiv").style.display = "none";
        return false;
    }
    function Windivclose() {
        document.getElementById("WinDescDiv").style.display = "none";
        return false;
    }
    function advclose() {
        document.getElementById("AdvantagesDiv").style.display = "none";
        return false;
    }
    function ShowWindiv() {
        document.getElementById("WinDescDiv").style.display = "block";
        document.getElementById("AdvantagesDiv").style.display = "none";
        document.getElementById("SuperwinnerDiv").style.display = "none";
        return false;
    }
    function ShowSuperWindiv() {
        document.getElementById("SuperwinnerDiv").style.display = "block";
        document.getElementById("AdvantagesDiv").style.display = "none";
        document.getElementById("WinDescDiv").style.display = "none";
        return false;
    }
    
    function hidelsyminfo() {
        document.getElementById("SympathiserErrorDiv").style.visibility = "hidden";
        document.getElementById("SympathiserErrorDiv").style.display = "none";
        document.getElementById("Sympathiserinfo").style.visibility = "hidden";
        document.getElementById("Sympathiserinfo").style.display = "none";
        document.getElementById("SympathiserErrorDiv").style.visibility = "hidden";
        document.getElementById("SympathiserErrorDiv").style.display = "none";
//        document.getElementById("WinDescDiv").style.display = "none";
//        document.getElementById("SuperwinnerDiv").style.display = "none";
        document.getElementById("AdvantagesDiv").style.display = "block";
        return false;
    }
    function hidelsymlogindiv() {
        document.getElementById("SympathiserErrorDiv").style.visibility = "hidden";
        document.getElementById("SympathiserErrorDiv").style.display = "none";
    document.getElementById("SympathiserloginDiv").style.visibility = "hidden";
        document.getElementById("SympathiserloginDiv").style.display = "none";
        return false;
    }
    function showsympathiserinfoDiv() {
        document.getElementById("Sympathiserinfo").style.visibility = "visible";
        document.getElementById("Sympathiserinfo").style.display = "block";
        document.getElementById("SympathiserloginDiv").style.visibility = "hidden";
        document.getElementById("SympathiserloginDiv").style.display = "none";
        return false;
    }
    function SympathiserTooltip(divID, Type) {
       
        var docElement;
        docElement = document.getElementById(divID);
        if (docElement) {

            if (Type == "Show") {
               
                docElement.style.display = "block";
                docElement.style.visibility = "visible";
            }
            else {
                docElement.style.display = "none";
                docElement.style.visibility = "hidden";
            }

        }
        document.getElementById("logindiv").style.visibility = "hidden";
        document.getElementById("logindiv").style.display = "none";
        document.getElementById("SympathiserErrorDiv").style.visibility = "hidden";
        document.getElementById("SympathiserErrorDiv").style.display = "none";
        document.getElementById("symfirstdiv").style.visibility = "visible";
        document.getElementById("symfirstdiv").style.display = "block";
        return false;
    }

    function ShowPopup(url) {       

        window.open(url, 'popup', 'height=720,width=690,left=50,top=50,location=no,titlebar=no,toolbar=no,menubar=no,scrollbars=yes,resizable=no,dialog=yes');
    }
