﻿    var objShow = "ENCLAIMS";
    var objHidd = "JPCLAIMS";

    function ShowFDNewWindow(object)
    {
        window.open(object.src, "FD","width=500,height=550,stuts,resizable,scrollbars=yes");

        return false;
    }
    function ShowFDWindow(object)
    {
        window.open(object, "FD","width=500,height=550,stuts,resizable,scrollbars=yes");

        return false;
    }
    
    function ShowTiffImage(pSorce, pWidth, pHeight)
    {
        var objWin = window.open(pSorce, "Drawings","width=" + pWidth+ ",stuts,resizable,scrollbars=yes");
        objWin.moveTo(50, 50);
        objWin.resizeTo(pWidth, pHeight);
        objWin.focus();
                
        return false;
    }

    function ShowTiffImageWithIdx(patentNumber, imageIdx) 
    {
        var tempURL = "patn=" + patentNumber + "&idx=" + imageIdx;
        window.open("../DataView/ViewTiiffIamge.aspx?" + tempURL, "PDF", "width=820,height=800,stuts,resizable,scrollbars=yes");
        
        return false;
    }
 

	function ShowPopUpClaims(pPatn)
	{
        var newWin = null;
        var tempURL = "patn=" + pPatn;
        window.open("../DataView/ViewClaims2.aspx?" + tempURL, "Claims","width=820,height=800,stuts,resizable,scrollbars=yes");
        
	    return false;
	}
	
	
    function ShowKpaPDFFile(pPatn, kind)
    {
        var newWin = null;
        var tempURL = "Key=" + pPatn + "&Kd=" + kind;
        window.open("../DataView/ViewPDF.aspx?" + tempURL, "PDF","stuts,resizable,scrollbars=yes");
        
        return false;
    }

    function ShowPDFFile(pPatn)
    {
        var newWin = null;
        var tempURL = "Key=" + pPatn + "&Mode=I";
        window.open("../DataView/ViewPDF.aspx?" + tempURL, "PDF","stuts,resizable,scrollbars=yes");
        
        return false;
    }
    
    function ShowLegal(patn)
    {
        var newWin = null;
        var tempURL = "Key=" + patn;
        window.open("../DataView/ViewLegal.aspx?" + tempURL, "LegalStatus","stuts,resizable,scrollbars=yes");
        
        return false;
    }
    

    function ShowFullText(pPatn)
    {
        var newWin = null;
        var tempURL = "Key=" + pPatn;
        window.open("../DataView/FullText2.aspx?" + tempURL, "LinkFullText", "");
        return false;
    }
     function ShowCNFullText(pPatn, pCollection)
    {
        var newWin = null;
        var tempURL = "Key=" + pPatn + "&collection=" + pCollection;
  
        window.open("../DataView/ViewCNFullText.aspx?" + tempURL, "CNFULLTEXT","width=1020,height=670,stuts,resizable,scrollbars=yes");
        
        return false;
    }

    function ShowEpoPDFFile(patentNumber, collection, isd, kd) {
        var newWin = null;
        var tempURL = "patn=" + patentNumber + "&collection=" + collection + "&isd=" + isd + "&kd=" + kd;

        window.open("../DataView/ViewEpoPDF.aspx?" + tempURL, "EPOPDF", "stuts,resizable,scrollbars=yes");

        return false;
        
    }
   /*                                              *
    *               Client CallBack                */

    function ShowClientTable(strArgment , strKind)
    {
        var objResult = document.getElementById(strKind);
        if(objResult.innerHTML == "")
        {
            callBack(strArgment , strKind);
            ShowProcess();
        }
        else
            ShowSpan(strKind);
    }
    
	function DisplayCallBack(result, context)
	{
        var objResult = document.getElementById(context);
        
        if(context == "TRANSCLAIM")
            context = "CLAIM";
            
        var objResultS = document.getElementById(context+"S");
        var objResultC = document.getElementById(context+"C");

        if( objResult )
            objResult.innerHTML = result;

        if(objResultS)
            objResultS.style.display='None';
        if(objResultC)
            objResultC.style.display='inline';
        
        if(context == "CLAIM")
            ShowSelectedClaims(objShow, objHidd);    

        HiddenProcess();            
	}
	
	function ShowSpan(spanName)
	{
        var objResult = document.getElementById(spanName);
        var objResultS = document.getElementById(spanName+"S");
        var objResultC = document.getElementById(spanName+"C");
        
        if(objResult)
            objResult.style.display='block';

        if(objResultS)
            objResultS.style.display='None';
        if(objResultC)
            objResultC.style.display='inline';
	}
	function CloseSpan(spanName)
	{
        var objResult = document.getElementById(spanName);
        var objResultS = document.getElementById(spanName+"S");
        var objResultC = document.getElementById(spanName+"C");
        
        if(objResult)
            objResult.style.display='none';

        if(objResultS)
            objResultS.style.display='inline';
        if(objResultC)
            objResultC.style.display='None';
	}

	function ietruebody(){
        return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    }
	
	function ShowProcess()
	{
	    var objResult = document.getElementById("divProcess");

	    if(objResult)
	    {
	        objResult.style.display='inline';
	        objResult.style.top =  eval(ietruebody().scrollTop + 350) + "px"; 
	        objResult.style.left = eval(ietruebody().clientWidth/2 - 100) + "px";
        }
	}
	
	function HiddenProcess()
	{
	    var objResult = document.getElementById("divProcess");
	    
	    if(objResult)
	        objResult.style.display='None';
	}
	
	function ShowOrHiddenDiv(spanName)
	{
	    var objSPAN = document.getElementById(spanName);
	    var objIMAGE = document.getElementById(spanName+"Img");
	    
	    if(objSPAN)
	    {
	        if(objSPAN.style.display == "inline")
	        {
	            objSPAN.style.display = "none";
	            objIMAGE.src= "../Images/closed_aw.gif";
            }
	        else
	        {
	            objSPAN.style.display = "inline";
	            objIMAGE.src= "../Images/open_aw.gif";
            }
	    }
	}
	
	function ShowClaims(pShowSpan, pHiddenSpan, pArgment , pKind)
	{
	    ShowClientTable(pArgment , pKind);

        objShow = pShowSpan;
        objHidd = pHiddenSpan;
        ShowSelectedClaims(pShowSpan, pHiddenSpan)

    	return false;
	}
	
	function ShowSelectedClaims(pShowSpan, pHiddenSpan)
	{
	    var objShowSPAN = document.getElementById(pShowSpan);
	    var objHiddenSPAN = document.getElementById(pHiddenSpan);
        var objResultS = document.getElementById("CLAIMS");
        var objResultC = document.getElementById("CLAIMC");

        if(objResultS)
            objResultS.style.display = "none";
        if(objResultC)
            objResultC.style.display = "inline";

	    if(objShowSPAN )
            objShowSPAN.style.display = "inline";

	    if(objHiddenSPAN)
            objHiddenSPAN.style.display = "none";
	}
	
	function CloseSpanClaims()
	{
	    var objCLAIMSPAN = document.getElementById("CLAIM");
	    var objTRANSCLAIMSPAN = document.getElementById("TRANSCLAIM");
        var objResultS = document.getElementById("CLAIMS");
        var objResultC = document.getElementById("CLAIMC");

        if(objResultS)
            objResultS.style.display = "inline";
        if(objResultC)
            objResultC.style.display = "none";
        
        
	    if(objCLAIMSPAN)
            objCLAIMSPAN.style.display = "none";
	    if(objTRANSCLAIMSPAN)
            objTRANSCLAIMSPAN.style.display = "none";
	}


    var objTarget;
    var isToolTipRequired;

    function updateToolTip(who, targetId, code)
    {
        var behavior = $find('toolTipDP');

        objTarget = $get(targetId);
        isToolTipRequired = true;

        if (objTarget && behavior)
        {
            objTarget.style.display = "none";

            behavior.remove_populated(toolTip_populated);
            behavior.add_populated(toolTip_populated);
            behavior.populate(code);

            var p = Sys.UI.DomElement.getLocation(who);
            Sys.UI.DomElement.setLocation(objTarget, p.x, p.y + who.offsetHeight + 5);
        }
    }
    
    function hideToolTip(targetId)
    {
        var objTarget = $get(targetId);
        if (objTarget)
        {
            objTarget.style.display = "none";
        }
        
        isToolTipRequired = false;
    }
    
    function toolTip_populated()
    {
        if (objTarget)
        {
            if (objTarget.innerText && isToolTipRequired)
            {
                objTarget.style.display = "block";
            }
        }
    }
    
    var clmsRetrieved = false;
    var descRetrieved = false;
    var familyRetrieved = false;
    var drefRetrieved = false;
    var frefRetrieved = false;
    var orefRetrieved = false;
    var dcitRetrieved = false;
    var consultDocRetrieved = false;
    
    function checkGeneric(button, showText, hideText, targetId, alreadyRetrieved)
    {
        var retrieveData = false;
        var objTarget = $get(targetId);
        
        if (button.innerText == showText)
        {
            if (!alreadyRetrieved)
                retrieveData = true;
            else
            {
                button.innerText = hideText;
                objTarget.style.display = "block";
            }
        }
        else
        {
            button.innerText = showText;
            objTarget.style.display = "none";
        }
        
        return retrieveData;
    }
    
    function setClaims()
    {
        clmsRetrieved = true;
    }
    
    function checkClaims(button, showText, hideText)
    {
        var retrieveData = checkGeneric(button, showText, hideText, "ClaimsExpandableArea", clmsRetrieved);
        if (retrieveData)
            clmsRetrieved = true;
            
        return retrieveData;
    }
        
    function checkDescription(button, showText, hideText)
    {
        var retrieveData = checkGeneric(button, showText, hideText, "DescExpandableArea", descRetrieved);
        if (retrieveData)
            descRetrieved = true;
            
        return retrieveData;
    }
        
    function checkFamily(button, showText, hideText)
    {
        var retrieveData = checkGeneric(button, showText, hideText, "FamilyExpandableArea", familyRetrieved);
        if (retrieveData)
            familyRetrieved = true;
            
        return retrieveData;
    }
        
    function checkDref(button, showText, hideText)
    {
        var retrieveData = checkGeneric(button, showText, hideText, "DrefExpandableArea", drefRetrieved);
        if (retrieveData)
            drefRetrieved = true;
            
        return retrieveData;
    }
        
    function checkFref(button, showText, hideText)
    {
        var retrieveData = checkGeneric(button, showText, hideText, "FrefExpandableArea", frefRetrieved);
        if (retrieveData)
            frefRetrieved = true;
            
        return retrieveData;
    }
        
    function checkOref(button, showText, hideText)
    {
        var retrieveData = checkGeneric(button, showText, hideText, "OrefExpandableArea", orefRetrieved);
        if (retrieveData)
            orefRetrieved = true;
            
        return retrieveData;
    }
        
    function checkDcit(button, showText, hideText)
    {
        var retrieveData = checkGeneric(button, showText, hideText, "DcitExpandableArea", dcitRetrieved);
        if (retrieveData)
            dcitRetrieved = true;
            
        return retrieveData;
    }
        
    function checkConsultDoc(button, showText, hideText)
    {
        var retrieveData = checkGeneric(button, showText, hideText, "ConsultDocExpandableArea", consultDocRetrieved);
        if (retrieveData)
            consultDocRetrieved = true;
            
        return retrieveData;
    }
        
    function redirectFtermSearch(hiddenId, buttonUniqueId, ftermCode) {
        try {
            var hiddenObj = document.getElementById(hiddenId);
            hiddenObj.value = ftermCode;
            WebForm_DoPostBackWithOptions(
                new WebForm_PostBackOptions(
                    buttonUniqueId,
                    "",
                    false,
                    "",
                    "../Search/Result+.aspx",
                    false,
                    true)
            );
        }
        catch (e) {
            alert(e);
        }
    }





    function FtermSearch() {
        this.Fterm = "";
        this.HiddenId = "";
        this.ButtonUniqueId = "";
        this.ResourcePub = "当該技術分類(<b>{0}</b>)に含まれる公開件照会";
        this.ResourceReg = "当該技術分類(<b>{0}</b>)に含まれる登録件照会";

        this.ShowSelector = function(hiddenId, buttonUniqueId, ftermCode) {
            var position = $("#div" + ftermCode).position();
            var scrollBottom = $(document).scrollTop() + $(window).height();

            if ((position.top + 85) < scrollBottom)
                $("#divSelect").css({ "left": (position.left + 11) + "px", "top": (position.top + 20) + "px" });
            else
                $("#divSelect").css({ "left": (position.left + 11) + "px", "top": (position.top - 70) + "px" });

            $("#pubSearch").html(this.ResourcePub.replace('{0}', ftermCode));
            $("#regSearch").html(this.ResourceReg.replace('{0}', ftermCode));
            $("#divSelect").hide();
            $("#divSelect").slideDown("fast");

            this.HiddenId = hiddenId;
            this.ButtonUniqueId = buttonUniqueId;
            this.Fterm = ftermCode;
        }

        this.HideSelector = function() {
            $("#divSelect").hide();
        }

        this.GoSearch = function(kind) {

            var hiddenObj = document.getElementById(this.HiddenId);
            hiddenObj.value = this.Fterm + "," + kind;

            WebForm_DoPostBackWithOptions(
                new WebForm_PostBackOptions(
                    this.ButtonUniqueId,
                    "",
                    false,
                    "",
                    "../Search/Result+.aspx",
                    false,
                    true)
            );
        }
    }

    var _ftermSearch = new FtermSearch();
    function showFtermSearch(hiddenId, buttonUniqueId, ftermCode) {
        $(document).click(function() {
            $("#divSelect").hide();
        });
        $("#divSelect").click(function(event) {
            event.stopPropagation();
        });
        _ftermSearch.ShowSelector(hiddenId, buttonUniqueId, ftermCode);
    }

    function hideFtermSearch() {
        _ftermSearch.HideSelector();
    }

    function goFtermSearch(kind) {
        _ftermSearch.GoSearch(kind);
    }

    function showPatentMap(strPatn) {
        var newWin = null;
        var tempURL = "Key=" + strPatn;
        newWin = window.open("../DataView/ViewPatentMap.aspx?" + tempURL, "PatentMap", "status,resizable");

        return false;
    }

    
    
    
    
