﻿
var g_queryfilter_disable=false;
var g_queryfilter_click=false;
var g_queryfilter_status = false;
if(window.Event){// 修正Event的DOM
    /*
                                IE5        MacIE5        Mozilla        Konqueror2.2        Opera5
    event                        yes        yes            yes            yes                    yes
    event.returnValue            yes        yes            no            no                    no
    event.cancelBubble            yes        yes            no            no                    no
    event.srcElement            yes        yes            no            no                    no
    event.fromElement            yes        yes            no            no                    no
    
    */
    Event.prototype.__defineSetter__("returnValue",function(b){// 
        if(!b)this.preventDefault();
        return b;
        });
    Event.prototype.__defineSetter__("cancelBubble",function(b){// 设置或者检索当前事件句柄的层次冒泡
        if(b)this.stopPropagation();
        return b;
        });
    Event.prototype.__defineGetter__("srcElement",function(){
        var node=this.target;
        while(node!=null && node.nodeType!=null && node.nodeType!=1)node=node.parentNode;
        return node;
        });
    Event.prototype.__defineGetter__("fromElement",function(){// 返回鼠标移出的源节点
        var node;
        if(this.type=="mouseover")
            node=this.relatedTarget;
        else if(this.type=="mouseout")
            node=this.target;
        if(!node)return;
        while(node.nodeType!=1)node=node.parentNode;
        return node;
        });
    Event.prototype.__defineGetter__("toElement",function(){// 返回鼠标移入的源节点
        var node;
        if(this.type=="mouseout")
            node=this.relatedTarget;
        else if(this.type=="mouseover")
            node=this.target;
        if(!node)return;
        while(node.nodeType!=1)node=node.parentNode;
        return node;
        });
    Event.prototype.__defineGetter__("offsetX",function(){
        return this.layerX;
        });
    Event.prototype.__defineGetter__("offsetY",function(){
        return this.layerY;
        });
    }
if(window.Document){// 修正Document的DOM
    /*
                                IE5        MacIE5        Mozilla        Konqueror2.2        Opera5
    document.documentElement    yes        yes            yes            yes                    no
    document.activeElement        yes        null        no            no                    no
    
    */
    }
if(window.Node){// 修正Node的DOM
    /*
                                IE5        MacIE5        Mozilla        Konqueror2.2        Opera5
    Node.contains                yes        yes            no            no                    yes
    Node.replaceNode            yes        no            no            no                    no
    Node.removeNode                yes        no            no            no                    no
    Node.children                yes        yes            no            no                    no
    Node.hasChildNodes            yes        yes            yes            yes                    no
    Node.childNodes                yes        yes            yes            yes                    no
    Node.swapNode                yes        no            no            no                    no
    Node.currentStyle            yes        yes            no            no                    no
    
    */
    Node.prototype.replaceNode=function(Node){// 替换指定节点
        this.parentNode.replaceChild(Node,this);
        }
    Node.prototype.removeNode=function(removeChildren){// 删除指定节点
        if(removeChildren)
            return this.parentNode.removeChild(this);
        else{
            var range=document.createRange();
            range.selectNodeContents(this);
            return this.parentNode.replaceChild(range.extractContents(),this);
            }
        }
    Node.prototype.swapNode=function(Node){// 交换节点
        var nextSibling=this.nextSibling;
        var parentNode=this.parentNode;
        node.parentNode.replaceChild(this,Node);
        parentNode.insertBefore(node,nextSibling);
        }
    }
if(window.HTMLElement){
    HTMLElement.prototype.__defineGetter__("all",function(){
        var a=this.getElementsByTagName("*");
        var node=this;
        a.tags=function(sTagName){
            return node.getElementsByTagName(sTagName);
            }
        return a;
        });
    HTMLElement.prototype.__defineGetter__("parentElement",function(){
        if(this.parentNode==this.ownerDocument)return null;
        return this.parentNode;
        });
    HTMLElement.prototype.__defineGetter__("children",function(){
        var tmp=[];
        var j=0;
        var n;
        for(var i=0;i<this.childNodes.length;i++){
            n=this.childNodes[i];
            if(n.nodeType==1){
                tmp[j++]=n;
                if(n.name){
                    if(!tmp[n.name])
                        tmp[n.name]=[];
                    tmp[n.name][tmp[n.name].length]=n;
                    }
                if(n.id)
                    tmp[n.id]=n;
                }
            }
        return tmp;
        });
    HTMLElement.prototype.__defineGetter__("currentStyle", function(){
        return this.ownerDocument.defaultView.getComputedStyle(this,null);
        });
    HTMLElement.prototype.__defineSetter__("outerHTML",function(sHTML){
        var r=this.ownerDocument.createRange();
        r.setStartBefore(this);
        var df=r.createContextualFragment(sHTML);
        this.parentNode.replaceChild(df,this);
        return sHTML;
        });
    HTMLElement.prototype.__defineGetter__("outerHTML",function(){
        var attr;
        var attrs=this.attributes;
        var str="<"+this.tagName;
        for(var i=0;i<attrs.length;i++){
            attr=attrs[i];
            if(attr.specified)
                str+=" "+attr.name+'="'+attr.value+'"';
            }
        if(!this.canHaveChildren)
            return str+">";
        return str+">"+this.innerHTML+"</"+this.tagName+">";
        });
    HTMLElement.prototype.__defineGetter__("canHaveChildren",function(){
        switch(this.tagName.toLowerCase()){
            case "area":
            case "base":
            case "basefont":
            case "col":
            case "frame":
            case "hr":
            case "img":
            case "br":
            case "input":
            case "isindex":
            case "link":
            case "meta":
            case "param":
                return false;
            }
        return true;
        });

    HTMLElement.prototype.__defineSetter__("innerText",function(sText){
        var parsedText=document.createTextNode(sText);
        this.innerHTML=parsedText;
        return parsedText;
        });
    HTMLElement.prototype.__defineGetter__("innerText",function(){
        var r=this.ownerDocument.createRange();
        r.selectNodeContents(this);
        return r.toString();
        });
    HTMLElement.prototype.__defineSetter__("outerText",function(sText){
        var parsedText=document.createTextNode(sText);
        this.outerHTML=parsedText;
        return parsedText;
        });
    HTMLElement.prototype.__defineGetter__("outerText",function(){
        var r=this.ownerDocument.createRange();
        r.selectNodeContents(this);
        return r.toString();
        });
    HTMLElement.prototype.attachEvent=function(sType,fHandler){
        var shortTypeName=sType.replace(/on/,"");
        fHandler._ieEmuEventHandler=function(e){
            window.event=e;
            return fHandler();
            }
        this.addEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);
        }
    HTMLElement.prototype.detachEvent=function(sType,fHandler){
        var shortTypeName=sType.replace(/on/,"");
        if(typeof(fHandler._ieEmuEventHandler)=="function")
            this.removeEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);
        else
            this.removeEventListener(shortTypeName,fHandler,true);
        }
    HTMLElement.prototype.contains=function(Node){// 是否包含某节点
        do if(Node==this)return true;
        while(Node=Node.parentNode);
        return false;
        }
    HTMLElement.prototype.insertAdjacentElement=function(where,parsedNode){
        switch(where){
            case "beforeBegin":
                this.parentNode.insertBefore(parsedNode,this);
                break;
            case "afterBegin":
                this.insertBefore(parsedNode,this.firstChild);
                break;
            case "beforeEnd":
                this.appendChild(parsedNode);
                break;
            case "afterEnd":
                if(this.nextSibling)
                    this.parentNode.insertBefore(parsedNode,this.nextSibling);
                else
                    this.parentNode.appendChild(parsedNode);
                break;
            }
        }
    HTMLElement.prototype.insertAdjacentHTML=function(where,htmlStr){
        var r=this.ownerDocument.createRange();
        r.setStartBefore(this);
        var parsedHTML=r.createContextualFragment(htmlStr);
        this.insertAdjacentElement(where,parsedHTML);
        }
    HTMLElement.prototype.insertAdjacentText=function(where,txtStr){
        var parsedText=document.createTextNode(txtStr);
        this.insertAdjacentElement(where,parsedText);
        }
    HTMLElement.prototype.attachEvent=function(sType,fHandler){
        var shortTypeName=sType.replace(/on/,"");
        fHandler._ieEmuEventHandler=function(e){
            window.event=e;
            return fHandler();
            }
        this.addEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);
        }
    HTMLElement.prototype.detachEvent=function(sType,fHandler){
        var shortTypeName=sType.replace(/on/,"");
        if(typeof(fHandler._ieEmuEventHandler)=="function")
            this.removeEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);
        else
            this.removeEventListener(shortTypeName,fHandler,true);
        }
    }






function setCopyright()
{
	var copyright=dojo.byId('copyright-span');
    if(copyright!=null)
    {
		var now= new Date();
		var year=now.getFullYear();
		/*if(year<1900)
			year = year+1900;*/
		copyright.innerHTML="©"+year+" Patentics.com";
    }
}
/// Author: godsong 06.10.4
/// Help to perform "check/uncheck all" effectt
/// checkboxSwitch: domNode of checkbox marked as "check/uncheck all"
/// checkboxGroup:  domNodes of the checkboxes
function checkAll(checkboxSwitch, checkboxGroup)
{
    for (var i = 0;i < checkboxGroup.length; i++)
    {
        if (checkboxGroup[i].type == 'checkbox')
            checkboxGroup[i].checked = checkboxSwitch.checked;
    }
}

/// Author: godsong 06.10.4
/// Set the style of first parent div node to "display: none"
/// obj: current dom node
function hideParentDiv(obj)
{
    obj = obj.parentNode;
    while (obj && obj.tagName.toLowerCase() != 'div')
    {
        obj = obj.parentNode;
    }
    if (obj)
        obj.style.display = 'none';
}

function hideParentTr(obj)
{
    obj = obj.parentNode;
    while (obj && obj.tagName.toLowerCase() != 'tr')
    {
        obj = obj.parentNode;
    }
    if (obj)
        obj.style.display = 'none';
}

/// Author: godsong 06.10.5
/// Find the specific parent node
/// obj: current dom node
/// tag: parent node tag to look for
/// index: skip index - 1 matched node
/// return: the node found or null
function findParentNode(obj, tag, index)
{    
    for (var i = 0; obj && i < index; ++i)
    {
        do
        {
            obj = obj.parentNode;
            if(obj == null)
                return null;
        }
        while(obj.tagName != tag.toUpperCase())
    }
    if (i == index)
        return obj;
    else
        return null;
}

function isChildOf(childobj, parentobj)
{
    if(childobj == null || parentobj == null)
        return false;
    do
    {
        childobj = childobj.parentNode;
        if(childobj == null)
            return false;
        else if(childobj == parentobj)
            return true;
    }
    while(true)
}

function findSiblingBefore(obj, tag, index)
{    
    for (var i = 0; obj && i < index; ++i)
    {
        do
        {            
            obj = obj.previousSibling;
        }
        while (obj && obj.tagName != tag.toUpperCase())
    }
    if (i == index)
        return obj;
    else
        return null;
}

function findSiblingAfter(obj, tag, index)
{    
    for (var i = 0; obj && i < index; ++i)
    {
        do
        {
            obj = obj.nextSibling;
        }
        while (obj && obj.tagName != tag.toUpperCase())
    }
    if (i == index)
        return obj;
    else
        return null;
}

function getFormElementValue(form, name)
{
    var elems = form.elements;
    for (var i = 0; i < elems.length; ++i)
        if (elems[i].name == name && elems[i].checked)
            return elems[i].value;
    return c_sC;
}

function setFormElementValue(form, name, value)
{
    var elems = form.elements;
    for (var i = 0; i < elems.length; ++i)
        if (elems[i].name == name)
        {
            if (elems[i].type == "radio" || elems[i].type == "checkbox")
            {
                if (value != elems[i].value)
                    continue;
                else
                {
                    elems[i].checked = true;
                    break;
                }
            }
            else
                elems[i].value = value;
        }        
}

function bbimg(o)
{
	var zoom=parseInt(o.style.zoom, 10)||100;
	zoom+=event.wheelDelta/12;
	if (zoom>0) 
	{	
	    if(parseFloat(o.style.zoom)>parseFloat(zoom) || (o.width*parseInt(zoom)/100<document.body.clientWidth))
	        o.style.zoom=zoom+'%';
	}
	return false;
}

function showSlaveDiv(splitPaneId, masterPaneId, slavePaneId, slaveHeight, keepSlavePaneSize)
{
    var slave = dijit.byId(slavePaneId);
    if(slave == null)
    {
    	return;
    }
    var master = dijit.byId(masterPaneId);
    var main = dijit.byId(splitPaneId);
    if (!keepSlavePaneSize || slave.sizeShare * (100 - slaveHeight) < master.sizeShare * slaveHeight)
    {
        dijit.byId(masterPaneId).sizeShare = 100 - slaveHeight;
        dijit.byId(slavePaneId).sizeShare = slaveHeight;
        dijit.byId(splitPaneId).layout();    
        if(slaveHeight==100)
        {
            dojo.byId('slave-restore').style.display='';
            dojo.byId('slave-max').style.display='none';
        }  
        else
        {
            dojo.byId('slave-restore').style.display='none';
            dojo.byId('slave-max').style.display='';
        }
    }
}

//function selectTab(parentTabId, childTabId)
//{
//    var pTab = dijit.byId(parentTabId);
//    var cTab = dijit.byId(childTabId);
//    if(pTab != null && cTab != null)
//    {
//        pTab.selectTab(cTab, true);
//    }
//}

function textContentToSearch(node)
{
	var _result = "";
	if (node == null) { return _result; }
	for (var i = 0; i < node.childNodes.length; i++) {
		switch (node.childNodes[i].nodeType) {
			case 1: // ELEMENT_NODE
			case 5: // ENTITY_REFERENCE_NODE
				if (node.childNodes[i].tagName == "SUP" || node.childNodes[i].tagName == "SUB")
				{
					_result += " ";
					_result += textContentToSearch(node.childNodes[i]);
					_result += " ";
				}
				else
					_result += textContentToSearch(node.childNodes[i]);
				break;
			case 3: // TEXT_NODE
			case 2: // ATTRIBUTE_NODE
			case 4: // CDATA_SECTION_NODE
				_result += node.childNodes[i].nodeValue;
				break;
			default:
				break;
		}
	}
	return _result;
}

function getAdjacentText(startNode, endNode)
{
	var _result = '';
	if (!startNode && !endNode) { return _result; }
	var snode;
	if (!startNode)
	    snode = endNode.previousSibling;
	else
	    snode = startNode.nextSibling;
	var isEnd = false;
	while (!isEnd)
	{
		switch (snode.nodeType) {
			case 1: // ELEMENT_NODE
			case 5: // ENTITY_REFERENCE_NODE
				_result += textContentToSearch(snode);							
				break;
			case 3: // TEXT_NODE
			case 2: // ATTRIBUTE_NODE
			case 4: // CDATA_SECTION_NODE
				_result += snode.nodeValue;
				break;
			default:
				break;
		}
		snode = snode.nextSibling;
		if (!snode)
			isEnd = true;
	    else if (snode == endNode)
	        isEnd = true;
		else if (!endNode && snode.nodeType == 1 && snode.tagName == "BR")
			isEnd = true;
	}
	return _result;
}

function htmlEncode(strS)
{
	return(strS.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;").replace(/\r\n/g,"<br\/>"));
}

function htmlDecode(strS)
{
	return(strS.replace(/<br\/?>/ig,"\r\n").replace(/&nbsp;/ig," ").replace(/&gt;/ig,">").replace(/&lt;/ig,"<").replace(/&amp;/ig,"&"));
}

function isNullorEmpty(str)
{
    if(typeof(str)=='undefined')
        return true;
    if(!str)
        return true;
    return (str == null || str == 'undefined' || str == 'null');
}

function getElementByClassName(obj, tag, className)
{
    if(obj == null || isNullorEmpty(tag) || isNullorEmpty(className))
        return null;
}

function getNormalizedPN(pn)
{
    if(basic_search)
        return pn;
    var Normalized = getConfig(NORMALIZE_PN_CONFIG);
    if(!Normalized)
        return pn;
    if(isNullorEmpty(pn))
        return pn;
    pn = pn.replace(/,/g, "").replace(/US/, "");
    if(pn.indexOf('/') != -1)
        pn = pn.substring(0, pn.indexOf('/')) + pn.substring(pn.indexOf('/') + 1, pn.length);
    if(parseInt(pn) > 10000000 && parseInt(pn) < 200000000)
        pn = '200' + pn;
    return pn;
}

function getElementsByClassName(obj, tag, className)
{
    if(obj == null || isNullorEmpty(tag) || isNullorEmpty(className))
        return null;
    var objs = obj.getElementsByTagName(tag);
    if(objs.length == 0)
        return;
    for(var i = 0; i < objs.length; i++)
        if(objs[i].className.toLowerCase() == className.toLowerCase())
            return objs[i];
    return null;
}
StatisticsClass = {
    initGlobalVal: function () {
        StatisticsClass.initGlobalVal.apply(StatisticsClass, arguments);
    },
    onStatTypeChange:function(){
        StaticsClass.onStatTypeChange.applay(StatisticsClass, arguments);
    }
}
ClassView ={
    changeClassInfoType: function () {
        ClassView.changeClassInfoType.apply(ClassView, arguments);
	}
}
function getPatentNumIDI(pn, nodiffus)
{
    if(isNullorEmpty(pn))
        return -1;
    var Normalized = getConfig(NORMALIZE_PN_CONFIG);
    if(!Normalized)
    {
        if(pn.indexOf('CN') == 0 || pn.indexOf('CK') == 0 || (parseInt(pn) >= 200000000 && parseInt(pn) < 219000000))
            return 12;
        if(parseInt(pn)>450000000)
            return 128;
	    return 48;
    }    
    if(pn.indexOf('##') != -1 || pn.indexOf('%23%23') != -1) //document
        return 12;
    pn = pn.toUpperCase().replace(/'/g, '');
    if(pn.indexOf('RE') == 0)
        return 1;
    if(pn.indexOf('CN') == 0 || pn.indexOf('CK') == 0 || (parseInt(pn) >= 200000000 && parseInt(pn) < 220000000))
        return 12;
    if(pn.indexOf('EP') == 0 || (parseInt(pn) >= 10060000 && parseInt(pn) < 15000000))
        return 16+64;
    if(pn.indexOf('WO') == 0 || parseInt(pn) >= 15000000 && parseInt(pn) < 20000000)
        return 32+64;
    if((pn.indexOf('U') == 0 && pn.indexOf('US') != 0) || (parseInt(pn) >= 300000000 && parseInt(pn)<=10000000000))//added or 200x/xxxxxxx
        return -(128+12);
    if(nodiffus)
        return 3;
    else
    {
        if((pn.length == 11 && pn.substring(0, 3) == '200') || (parseInt(pn) > 10000000 && parseInt(pn) < 200000000))
            return 2;
        else if(parseInt(pn)>=220000000 && parseInt(pn)<300000000)
            return 64;
        else if(pn.charAt(0)>'0' && pn.charAt(0)<='9')
            return 1;
    }
    return 64;
}
function setDisplay(divobj,style)
{
    if(divobj!=null)
        divobj.style.display=style;
}
function setVisible(divobj,style)
{
    if(divobj!=null)
        divobj.style.visibility = style;
}
function setPageViewDisplay(view,refreshLoginState)
{
	if(g_pagetype=='i')
		return;
	if(dojo.isIE && window.external && isClient)
	{
		if(view!='search')
		{
			window.external.Sync(2);
			window.external.Sync(4);
		}
		else
		{
			var maintable= dojo.byId('querylist-queryresult-table-SEARCH-MASTER');
			var maintable2= dojo.byId('querylist-queryresult-table-SEARCH-SLAVE');
			var type=2;
			var type2=4;
			if(maintable!=null && maintable.style.display=='')
			{
				var trElements = maintable.getElementsByTagName('tr');
				if(trElements!=null && trElements.length>1)
					type=3;
			}
			window.external.Sync(type);
			if(maintable2!=null && maintable2.style.display=='')
			{
				var trElements = maintable2.getElementsByTagName('tr');
				if(trElements!=null && trElements.length>1)
					type2=5;
			}
			window.external.Sync(type2);
		}
	}
    commandDown();//字段组合
    toReadDown();
    g_currentView = view;
    if(g_currentView != 'search' && g_currentView != null)
        showSlaveDiv('index-right', 'index-master', 'index-slave', 0, false);
    if(dojo.byId('popupdiv-searchhelp') != null && dojo.byId('popupdiv-searchhelp').style.visibility == 'visible')
        dojo.byId('popupdiv-searchhelp').comObject.hidePopup();
    if(dojo.byId('search-popupdiv') != null)
        dojo.byId('search-popupdiv').style.visibility = 'hidden';
    if(dojo.byId('search-inputtipsdiv') != null)
        dojo.byId('search-inputtipsdiv').style.visibility = 'hidden';
    if(dojo.byId('popupdiv-highlightword') != null)
        dojo.byId('popupdiv-highlightword').style.visibility = 'hidden';
    if(dojo.byId('search-bookmark-popupdiv') != null)
        dojo.byId('search-bookmark-popupdiv').style.visibility = 'hidden';
    //if(dojo.byId('search-master-rotate-div') != null)
    //    dojo.byId('search-master-rotate-div').style.display = 'none';
    if(dojo.byId('popupdiv-importpatent') != null)
        dojo.byId('popupdiv-importpatent').style.visibility = 'hidden';
    if(Query_JS)
    {
        if(typeof('closeClipboardFigDiv')=='function')
            closeClipboardFigDiv();
        if(typeof('closeClipboardPNDiv')=='function')
            closeClipboardPNDiv();
    }
    var searchdiv = dojo.byId('search-master-querylist');
    var classdiv = dojo.byId('classinfo-div');
    var projectdiv = dojo.byId('project-projectlist');
    var helpdiv = dojo.byId('help-helpdiv');
    var statisticdiv = dojo.byId('statistic-statisticlist');
    var historydiv = dojo.byId('history-historylist');
    var historydiv_h = dojo.byId('history-div-historytype-h');
    var historydiv_b = dojo.byId('history-div-historytype-b');
    var historyunlogindiv = dojo.byId('history-historylist-unlogin');
    var analysisdiv = dojo.byId('document-documentlist');
    var logindiv = dojo.byId('login-form-div');
    var signupdiv = dojo.byId('signup-form-div');
    var clusterdiv  = dojo.byId('queryrelated-cluster-div');
    var clusterdiv_m = dojo.byId('queryrelated-cluster-div-SEARCH-MASTER');
    var clusterdiv_s = dojo.byId('queryrelated-cluster-div-SEARCH-SLAVE');
    var tempsubgetdiv = dojo.byId('search-master-subget');
    var querystatdiv = dojo.byId('querylist-queryresultstat-div-SEARCH-MASTER');
    var querystatdiv_s = dojo.byId('querylist-queryresultstat-div-SEARCH-SLAVE');
    var shadowdiv = dojo.byId('shadowDiv');
    var managediv = dojo.byId('management-div');
    var basicsearchdiv = dojo.byId('search-basicsearch-div');
    var uploaddocument = dojo.byId('doc_upload');
    var managediv = dojo.byId('management-div');
    setDisplay(uploaddocument,'none');
    setDisplay(searchdiv,'none');
    setDisplay(classdiv,'none');
    setDisplay(projectdiv,'none');
    setDisplay(helpdiv,'none');
    setDisplay(statisticdiv,'none');
    setDisplay(historydiv,'none');
    setDisplay(historydiv_h,'none');
    setDisplay(historydiv_b,'none');
    setDisplay(historyunlogindiv,'none');
    setDisplay(analysisdiv,'none');
    setDisplay(logindiv,'none');
    setDisplay(shadowdiv,'none');
    setDisplay(signupdiv,'none');
    setVisible(signupdiv,'hidden');
    setDisplay(clusterdiv,'none');
    setDisplay(clusterdiv_s,'none');
    setDisplay(clusterdiv_m,'none');
    setDisplay(managediv,'none');
    /*if(managediv)
    	setDisplay(managediv,'none');
    
    if(clusterdiv_m!=null)
        clusterdiv.style.display = 'none';*/
    setDisplay(tempsubgetdiv,'none');
    //advancedsearchdiv.style.display = 'none';
    var searchmenu = dojo.byId('header-menu-search');
    var classmenu = dojo.byId('header-menu-class');
    var statisticmenu = dojo.byId('header-menu-statistic');
    var analysismenu = dojo.byId('header-menu-analysis');
    var historymenu = dojo.byId('header-menu-history');
    var projectmenu = dojo.byId('header-menu-project');
    //var helpmenu = dojo.byId('header-menu-help');
    var managemenu = dojo.byId('header-menu-manage');
    searchmenu.innerHTML = c_sSearch;
    classmenu.innerHTML = c_sClass;
    statisticmenu.innerHTML = c_sStatistic;
    analysismenu.innerHTML = c_sAnalysis;
    historymenu.innerHTML = c_sHistory;
    projectmenu.innerHTML = c_sProject;
   // helpmenu.innerHTML = c_sHelp;
    managemenu.innerHTML = c_sManage;
    switch(g_currentView)
    {
        case 'search':
            /*if(querystatdiv != null)
                querystatdiv.style.display = 'none';
            if(querystatdiv_s != null)
                querystatdiv_s.style.display = 'none';*/
            searchmenu.innerHTML = '<b>' + c_sSearch + '</b>';
            searchdiv.style.display = '';
            if(basic_search)
                setDisplay(basicsearchdiv,'');
            break;
        case 'statistic':
            statisticmenu.innerHTML = '<b>' + c_sStatistic + '</b>';
            if (StatisticHTML_Load == false) {
                StatisticHTML_Load = true;
                AsyncLoad('statistic-statisticlist', 'statistic.htm', setPageView, arguments);
                return false;
            }
            if (StatisticStatisticlist_Load == false) {
                LoadStatisticsJsFile(setPageView, arguments);
                return false;
            }
            if (Query_JS == false) {
                LoadQueryJsFile(setPageView, arguments);
                return false;
            }
            if (StatisticInit == false) {
                initGlobalVal();
                StatisticInit = true;
            }
            if (statisticdiv == null)
                statisticdiv = dojo.byId('statistic-statisticlist');
            statisticdiv.style.display = '';
            var changetype = true;
            var searchtypevalue = dojo.byId('searchtype-span').typevalue;
            if ((searchtypevalue & 1) == 1)
                dojo.byId('statistic-type-select').value = 1;
            else if ((searchtypevalue & 2) == 2)
                dojo.byId('statistic-type-select').value = 2;
            else if ((searchtypevalue & 4) == 4)
                dojo.byId('statistic-type-select').value = 4;
            else if ((searchtypevalue & 8) == 8)
                dojo.byId('statistic-type-select').value = 8;
            else if ((searchtypevalue & 16) == 16)
                dojo.byId('statistic-type-select').value = 16;
            else if ((searchtypevalue & 32) == 32)
                dojo.byId('statistic-type-select').value = 32;
            else if ((searchtypevalue & 64) == 64)
                dojo.byId('statistic-type-select').value = 64;
            if (changetype)
                onStatTypeChange();
            break;
        case 'analysis':
            if (Query_JS == false) {
                LoadQueryJsFile(setPageViewDisplay, arguments);
                return false;
            }
            if (Document_JS == false) {
                LoadDocumentJsFile(setPageViewDisplay, arguments);
                return false;
            }
            analysismenu.innerHTML = '<b>' + c_sAnalysis + '</b>';
            analysisdiv.style.display = '';
            break;
        case 'history':
            if (History_JS == false) {
                LoadHistoryJsFile(setPageViewDisplay, arguments);
                return false;
            }
            if (HistoryHistorylist_Load == false) {
                HistoryHistorylist_Load = true;
                AsyncLoad('history-historylist', 'history.htm', setPageViewDisplay, arguments);
                return false;
            }
            if (Query_JS == false) {
                LoadQueryJsFile(setPageViewDisplay, arguments);
                return false;
            }

            if (HistoryHistorylist_Load) {
                historydiv_h = dojo.byId('history-div-historytype-h');
                historydiv_b = dojo.byId('history-div-historytype-b');
            }
            historymenu.innerHTML = '<b>' + c_sHistory + '</b>';
            historydiv.style.display = '';
            historydiv_h.style.display = '';
            break;
        case 'project':
            projectmenu.innerHTML = '<b>' + c_sProject + '</b>';
            projectdiv.style.display = '';
            break;
        case 'login':
            //logindiv.style.display = '';
            var dive = dojo.byId('login-result-div');
            var database_span='';
			if(basic_search!=null)
			    database_span=getDatabaseSpan();
            dive.innerHTML = database_span+g_loginSpan;
            dive.style.display = '';
            prepareLogin();
            break;
        case 'signup':
            if(SignupForm_Load==false)
            {
                dload('signup-form-div','signup.htm');            
                SignupForm_Load=true;
            }
            signupdiv.style.display = '';
            break;
        case 'help':
            helpmenu.innerHTML = '<b>' + c_sHelp + '</b>';
           // if(helpdiv==null)
            {
                //dload('help-helpdiv','help.htm');
               // helpdiv=dojo.byId('help-helpdiv');
            }
            helpdiv.style.display = '';
            break;
        case 'manage':
            LoadManageJsFile();
            managemenu.innerHTML = '<b>' + c_sManage +'</b>';
            managediv = dojo.byId('management-div');
            managediv.style.display='';
            break;
        case 'class':
            classmenu.innerHTML = '<b>' + c_sClass + '</b>';
            if (Class_JS == false) {
                LoadClassJsFile(setPageViewDisplay, arguments);
                return false;
            }
            if (Query_JS == false) {
                LoadQueryJsFile(setPageViewDisplay, arguments);
                return false;
            }
            if (Classinfo_Load == false) {
                classdiv.style.display = '';
                dojo.byId('classinfo-div').innerHTML = c_sLoading;
                Classinfo_Load = true;
                AsyncLoad('classinfo-div', 'class.htm', setPageViewDisplay, arguments);
                return false;
            }
            SetSystemDynamicDisplayByFuncArray('Class');
            classdiv.style.display = '';
            //ClassView.changeClassInfoType.apply(ClassView, arguments);
            changeClassInfoType();
            break;
        case null:
            break;
    }
    if(g_currentView != 'search')
        onSelectTypeChange(null);
    if (refreshLoginState)
        getUserLoginState();
}

function setPageView(view, refreshLoginState)
{
	if(view=='manage')
	{
		if(dojo.byId('searchrelated')!=null)
		{
			dojo.byId('searchrelated').style.display = 'none';
		}
		if(dojo.byId('managerelated')!=null)
		{
			dojo.byId('managerelated').style.display = '';
		}
		
	}else
	{
		//hideAllManageDiv();
			if(dojo.byId('searchrelated')!=null)
		  {
			   dojo.byId('searchrelated').style.display = '';
		  }
		  if(dojo.byId('managerelated')!=null)
			{
				dojo.byId('managerelated').style.display = 'none';
			}
	}
  if(view=='login')
    {
        prepareLogin();
        return;
    }
    if(!refreshLoginState && g_currentView != 'login')
        g_previousView = g_currentView;
    if(view == 'search')
    {
        /*if(dojo.byId('popupdiv-clipboardtoppn')!=null && g_ClipboardTopPNArray.length>0)
        {
            dojo.byId('popupdiv-clipboardtoppn').style.visibility='visible';
        }*/
    }
    var returnvalue = setPageViewDisplay(view, refreshLoginState);   
    if(view != 'search')
    {
       if(dojo.byId('popupdiv-clipboardtoppn')!=null )
        {
            dojo.byId('popupdiv-clipboardtoppn').style.visibility='hidden';
        }
        var state = { 
            pageview:view,
            back: function() { 
                setPageViewDisplay(this.pageview); 
                if(this.pageview == 'project' || this.pageview == 'history'||this.pageview == 'class')
                    getUserLoginState();
            }, 
            forward: function() { 
                setPageViewDisplay(this.pageview); 
                if(this.pageview == 'project' || this.pageview == 'history'||this.pageview == 'class')
                    getUserLoginState();
            }
        }; 
        //dojo.undo.browser.addToHistory(state); 
        dojo.back.addToHistory(state); 
    }
    if (refreshLoginState && returnvalue!=false)
        getUserLoginState();
}
function showhelp()
{
            var url = 'invokexml.do?sf=UserGet';
            var request = {
                url:url,
                handleAs:"text",
                load:function(response,ioArgs){                   
                    dojo.byId('help-helpdiv').innerHTML = XSLTtrans(response,c_sXslFileHelp);
                }
            };
            dojo.xhrGet(request);
                
            
}
function showmanage()
{
    var url = 'invokejson.do?sf=UserGet';
    var request = {
		url:c_sUserGet + '&random=' + Math.random(),
        handleAs:"json",
        load:function(response,ioArgs){
			if(response.Error!=null)
			{
				alert(response.Error);
			}     
			else
			{
				if(response.User.Id=='admin' || response.User.Level==2 || response.User.Level==1 || response.iType==1)
				{
					//dojo.byId('manage-managediv').innerHTML = XSLTtrans(response,c_sXslFileManage);
					dojo.byId('deluser-form').style.display='';
					dojo.byId('adduser-form').style.display='';
					dojo.byId('permission-div').style.display='';
					var trs = dojo.byId('usermanageContent-div').getElementsByTagName('tr');
					if(response.User.Id!='admin' && response.User.Level!=2 && response.User.Level!=1)
					{
						trs[0].style.display='none';
						trs[1].style.display='none';
					}
					else
					{
						trs[0].style.display='';
						trs[1].style.display='none';
						//permission_list();
					}
					if(response.User.Id!='admin' && response.User.Level!=2 && response.iType!=1)
					{
						trs[2].style.display='none';
					}
					else
					{
						trs[2].style.display='';
						showGroupList();
					}
				}
			}
			//
        }
    };
    dojo.xhrGet(request);            
}

function showAdvancedSearch()
{
            var url = 'invokexml.do?sf=UserGet';
            var request = {
            	url:url,
            	handleAs:"text",
              load:function(response,ioArgs){
                   
                    dojo.byId('search-advancedsearch-div').innerHTML = XSLTtrans(response,c_sXslFileAdvancedSearch);
                    
                }
              };
            dojo.xhrGet(request);
                
            
}
function showAdvancedInputSearch()
{
            var url = 'invokexml.do?sf=UserGet';
            var request = {
            	url:url,
            	handleAs:"text",
                load:function(response,ioArgs){                   
                    dojo.byId('search-advancedinput-div').innerHTML = XSLTtrans(response,c_sXslFileAdvancedInputSearch);                    
                }
             };
            dojo.xhrGet(request);
                
            
}

function showBooleanInputSearch()
{
    /* var url = 'invokexml.do?sf=UserGet';
            var request = {
            	url:url,
            	handleAs:"text",
              load:function(response,ioArgs){     
                   
                    dojo.byId('search-booleaninput-div').innerHTML = XSLTtrans(response,c_sXslFileBooleanInputSearch);
                    
                }
              };
            dojo.xhrGet(request);*/
}

function showNewUserSearch()
{
     var url = 'invokexml.do?sf=UserGet';
     var request = {
     	url:url,
     	handleAs:"text",
     	load:function(response,ioArgs){
     		dojo.byId('search-newuser-div').innerHTML = XSLTtrans(response,c_sXslFileNewUserSearch);
        }
      };
      dojo.xhrGet(request);
}

//function setQuickUserInfo(user)
//{
//    dojo.byId('search-userinfo-id').innerHTML = (user != null) ? user.User.Id : '';
//    dojo.byId('search-userinfo-name').innerHTML = (user != null) ? user.User.Name : '';
//    dojo.byId('search-userinfo-groupname').innerHTML = (user != null) ? user.User.UserGroup.Name : '';
//    dojo.byId('search-userinfo-maxproject').innerHTML = (user != null) ? user.User.MaxProject : '';
//    dojo.byId('search-userinfo-maxsubscription').innerHTML = (user != null) ? user.User.MaxSubscription : '';
//    dojo.byId('search-userinfo-maxpatent').innerHTML = (user != null) ? user.User.ProjectMaxPatent : '';
//    dojo.byId('search-userinfo-statmaxpatent').innerHTML = (user != null) ? user.User.StatMaxPatent : '';
//    dojo.byId('search-userinfo-lastlogindate').innerHTML = (user != null) ? user.User.LastLoginDate : '';
//    dojo.byId('search-userinfo-lastloginip').innerHTML = (user != null) ? user.User.LastLoginIP : '';
//}

function calculateOffset(field, attr) 
{
    var offset = 0;
	while(field)
	{
		offset += field[attr];
		field = field.offsetParent;
		
	}
    return offset;
}

function XSLTtrans(xmldata, xslfile)
{
    var xmlDoc;
    var xslDoc;

    // 判断浏览器的类型
    if(dojo.isSafari || (dojo.isWebKit && !(dojo.isSafari < 4)))
    {
        XMLDocument.prototype.load = function(filePath) 
        { 
            var xmlhttp = new XMLHttpRequest(); 
            xmlhttp.open("GET", filePath, false); 
            xmlhttp.setRequestHeader("Content-Type","text/xml"); 
            xmlhttp.send(null); 
            var newDOM = xmlhttp.responseXML; 
            if( newDOM ) 
            { 
              var newElt = this.importNode(newDOM.documentElement, true); 
              this.appendChild(newElt); 
              return true; 
            } 
        } 
        var parser = new DOMParser();
        xmlDoc = parser.parseFromString(xmldata, "text/xml");

        //load xsl file 
        var xsltDoc =  document.implementation.createDocument("", "", null); 
        xsltDoc.async = false; 
        xsltDoc.load(xslfile); 

        //build the relationship between xml file and xsl file 
        var xslt = new XSLTProcessor(); 
        xslt.importStylesheet(xsltDoc); 
        //set parameters 
        xslt.setParameter( null, 'testDom', xmlDoc); 
        //transform 
        var doc =  xslt.transformToFragment(xmlDoc, document); 
        //append the xml result to the main html file 
        var target=document.createElement('div');
        target.appendChild(doc); 
        return target.innerHTML;
    }
    else if(typeof window.ActiveXObject != 'undefined')
    {        
        // 支持IE浏览器
        xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
        xslDoc = new ActiveXObject('Microsoft.XMLDOM'); 
        //xmlDoc = new ActiveXObject('Msxml2.DOMDocument.6.0');
        //xslDoc = new ActiveXObject('Msxml2.DOMDocument.6.0'); 
        xmlDoc.async = false;
        xslDoc.async = false;    
        xmlDoc.loadXML(xmldata);
        xslDoc.load(xslfile);
        var result = xmlDoc.documentElement.transformNode(xslDoc); 
        return result;
    }
    else if(document.implementation && document.implementation.createDocument)
    {        
        // 支持Mozilla浏览器
        try
        {
            //xmlDoc = document.implementation.createDocument("", "", null);    
            //xmlDoc.async = false;
            //xmlDoc.load(url);
            var parser = new DOMParser();
            xmlDoc = parser.parseFromString(xmldata, "text/xml");
        }
        catch(e)
        {
            return "XML Document create error";
        }
        try
        {
            xslDoc = document.implementation.createDocument("", "", null);
            xslDoc.async = false;
            xslDoc.load(xslfile);
        }
        catch(e)
        {
            return "XSL Document load error";;
        }
        try
        {
            // 定义XSLTProcessor对象    
            var xsltProcessor = new XSLTProcessor();
            xsltProcessor.importStylesheet(xslDoc);
            var oResultFragment = xsltProcessor.transformToFragment(xmlDoc,document);
            var targetdiv = document.createElement('div');
            // 将解析过的文本输出到页面
            targetdiv.appendChild(oResultFragment);
            return targetdiv.innerHTML;
        }
        catch(e)
        {
             return "XSLT Transformation error";
        }    
    }
    else
    {
        return "Sorry, your browser does not support XSLT trnsformation. Please try IE 5.5+ or Firefox 1.5+";
    }
}

function strContainChinese(src)
{
    if(isNullorEmpty(src))
        return false;
    var tempsrc = src.replace(/[^\x00-\x80]/ig,"");
    return (src != tempsrc);
}

function onCheckboxImgMouseOver(obj)
{
    if(obj.src.indexOf('check.gif') != -1)
        obj.src = c_sImgPath+'img/check-active.gif';
}

function onCheckboxImgMouseOut(obj)
{
    if(obj.src.indexOf('check-active.gif') != -1)
        obj.src = c_sImgPath+'img/check.gif';
}

function isMSIE()
{
    if(navigator.userAgent.indexOf('MSIE'))
        return true;
    else
        return false;
}


function SetSystemInitDisplayByFuncArray()
{
    if(dojo.byId('search-master-database-radio')!=null)
    {
        dojo.byId('search-master-database-radio').style.display=(g_funcArray[140]==1 ? 'none':'');
    }
    
    for(var i=0;i<DatabaseCount;i++)
    {
        if(dojo.byId('searchtype-'+spanType[i])!=null)
        {
            dojo.byId('searchtype-'+spanType[i]).style.display = (g_funcArray[i] == 0 ? 'none' : '');
            dojo.byId('searchtype-'+spanType[i]+'-span').style.display = (g_funcArray[i] == 0 ? 'none' : '');
        }
    }
    
    if(dojo.byId('header-menu-home') != null)
    {
        dojo.byId('header-menu-home').style.display = (g_funcArray[15] == 0 ? 'none' : '');
        //dojo.byId('header-menu-sep1').style.display = (g_funcArray[15] == 0 ? 'none' : '');
    }
    if(dojo.byId('header-menu-search') != null)
    {
        dojo.byId('header-menu-sep1').style.display = ((g_funcArray[16] == 0 || g_funcArray[15] == 0)? 'none' : '');
        dojo.byId('header-menu-search').style.display = (g_funcArray[16] == 0 ? 'none' : '');
        //dojo.byId('header-menu-sep2').style.display = (g_funcArray[16] == 0 ? 'none' : '');
    }
    if(dojo.byId('header-menu-class') != null)
    {
        dojo.byId('header-menu-class').style.display = (g_funcArray[17] == 0 ? 'none' : '');
        dojo.byId('header-menu-sep2').style.display = (g_funcArray[17] == 0 ? 'none' : '');
    }
    if(dojo.byId('header-menu-statistic') != null)
    {
        dojo.byId('header-menu-statistic').style.display = (g_funcArray[18] == 0 ? 'none' : '');
        dojo.byId('header-menu-sep3').style.display = (g_funcArray[18] == 0 ? 'none' : '');
    }
    if(dojo.byId('header-menu-analysis') != null)
    {
        dojo.byId('header-menu-analysis').style.display = (g_funcArray[19] == 0 ? 'none' : '');
        dojo.byId('header-menu-sep4').style.display = (g_funcArray[19] == 0 ? 'none' : '');
    }
    if(dojo.byId('header-menu-history') != null)
    {
        dojo.byId('header-menu-history').style.display = (g_funcArray[20] == 0 ? 'none' : '');
        dojo.byId('header-menu-sep5').style.display = (g_funcArray[20] == 0 ? 'none' : '');
    }
    if(dojo.byId('header-menu-project') != null)
    {
        dojo.byId('header-menu-project').style.display = (g_funcArray[21] == 0 ? 'none' : '');
        dojo.byId('header-menu-sep6').style.display = (g_funcArray[21] == 0 ? 'none' : '');
        if(dojo.byId('popupdiv-clipboardpn-project')!=null)
            dojo.byId('popupdiv-clipboardpn-project').style.display = (g_funcArray[21] == 0 ? 'none' : '');
        if(dojo.byId('popupdiv-clipboardfig-project')!=null)
            dojo.byId('popupdiv-clipboardfig-project').style.display = (g_funcArray[21] == 0 ? 'none' : '');
    }
    
    if(dojo.byId('search-master-import-img') != null)
        dojo.byId('search-master-import-img').style.display = (g_funcArray[39] == 0 ? 'none' : '');
            
    if(dojo.byId('search-master-advancesearch-span') != null)
    {
//        dojo.byId('search-master-advancesearch-span').style.display = (g_funcArray[81] == 0 ? 'none' : '');
        dojo.byId('search-master-advancesearch-span').style.display = '';
    }
    if(dojo.byId('statistic-tab-td-Research') != null)
    {
        dojo.byId('statistic-tab-td-Research').style.display = (g_funcArray[115] == 0 ? 'none' : '');
        dojo.byId('statistic-tab-td-Research-next').style.display = (g_funcArray[115] == 0 ? 'none' : '');
    }
    if(dojo.byId('statistic-tab-td-Claims') != null)
    {
        dojo.byId('statistic-tab-td-Claims').style.display = (g_funcArray[116] == 0 ? 'none' : '');
        dojo.byId('statistic-tab-td-Claims-next').style.display = (g_funcArray[116] == 0 ? 'none' : '');
    }
    if(dojo.byId('statistic-tab-td-PDF') != null)
    {
        dojo.byId('statistic-tab-td-PDF').style.display = (g_funcArray[117] == 0 ? 'none' : '');
        dojo.byId('statistic-tab-td-PDF-next').style.display = (g_funcArray[117] == 0 ? 'none' : '');
    }
    if(dojo.byId('statistic-tab-td-Comment') != null)
        dojo.byId('statistic-tab-td-Comment').style.display = (g_funcArray[118] == 0 ? 'none' : '');
    if(dojo.byId('search-popupdiv-color-tr') != null)
        dojo.byId('search-popupdiv-color-tr').style.display = (g_funcArray[83] == 0 ? 'none' : '');
    if(dojo.byId('bbs-span')!=null)
    {
		dojo.byId('bbs-seperator-span').style.display=(g_funcArray[150] == 0 ? 'none' : '');
		dojo.byId('bbs-span').style.display=(g_funcArray[150] == 0 ? 'none' : '');
    }
    if(dojo.byId('fulltext-view-span-slave')!=null)
    {
		dojo.byId('fulltext-view-span-slave').style.display=(g_funcArray[142] == 0 ? 'none' : '');
    }
    if(dojo.byId('fulltext-view-span-master')!=null)
    {
		dojo.byId('fulltext-view-span-master').style.display=(g_funcArray[142] == 0 ? 'none' : '');
    }
    if(dijit!=null)
    {
        var menu = dijit.byId('contextmenu');
        if(menu != null)
        {
            var menuitemname=new Array('nsmenuitem','rsmenuitem','webmenuitem','ptmenuitem','clsmenuitem','cpmenuitem','pastemenuitem');
            for(var i = 130 ; i < 137; i++)
            {
                if(g_funcArray[i] == 0)
                {
	                var menuitem = dijit.byId(menuitemname[i-130]);
	                if(menuitem != null)
	                    menu.removeChild(menuitem);
                }
            }
        }
    }
    if(g_funcArray[61]==0)
        dojo.byId('search-master-addtocase-img').style.display='none';
    if(g_funcArray[62]==0)
        dojo.byId('search-slave-addtocase-img').style.display='none';
    /*if(dojo.byId('search-master-import-img')!=null)
        if(g_funcArray[104] == 1)
            dojo.byId('search-master-import-img').style.display = '';*/
    
}

function SetSystemDynamicDisplayByFuncArray(dynamicType, obj)
{
    if(dynamicType == 'QueryFulltext_SEARCH-MASTER' || dynamicType == 'QueryFulltext_SEARCH-SLAVE' || dynamicType == 'QueryFulltext_SEARCH-PATENT')
    {
            
        if(dojo.byId('search-input-topquery-span') != null)
            dojo.byId('search-input-topquery-span').style.display = (g_funcArray[38] == 0 ? 'none' : '');
        if(dojo.byId('search-input-topquery') != null)
            dojo.byId('search-input-topquery').style.display = (g_funcArray[38] == 0 ? 'none' : '');
        if(dojo.byId('search-input-topquery-button') != null)
            dojo.byId('search-input-topquery-button').style.display = (g_funcArray[38] == 0 ? 'none' : '');

        if(dynamicType == 'QueryFulltext_SEARCH-MASTER')
        {
            if(dojo.byId('queryfulltext_addtoproject_SEARCH-MASTER') != null)
                dojo.byId('queryfulltext_addtoproject_SEARCH-MASTER').style.display = (g_funcArray[30] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_querystat_SEARCH-MASTER') != null)
                dojo.byId('queryfulltext_querystat_SEARCH-MASTER').style.display = (g_funcArray[31] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_statdrawing_SEARCH-MASTER') != null)
                dojo.byId('queryfulltext_statdrawing_SEARCH-MASTER').style.display = (g_funcArray[32] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_clusterpatent_SEARCH-MASTER') != null)
                dojo.byId('queryfulltext_clusterpatent_SEARCH-MASTER').style.display = (g_funcArray[33] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_rotatesearch_SEARCH-MASTER') != null)
                dojo.byId('queryfulltext_rotatesearch_SEARCH-MASTER').style.display = (g_funcArray[34] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_exportpatent_SEARCH-MASTER') != null)
                dojo.byId('queryfulltext_exportpatent_SEARCH-MASTER').style.display = (g_funcArray[35] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_addtoclipboard_SEARCH-MASTER') != null)
                dojo.byId('queryfulltext_addtoclipboard_SEARCH-MASTER').style.display = (g_funcArray[36] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_addtoclipboard_SEARCH-MASTER') != null)
                dojo.byId('queryfulltext_addtoclipboard_SEARCH-MASTER').style.display = (g_funcArray[36] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_comparetoppatents_SEARCH-MASTER') != null)
                dojo.byId('queryfulltext_comparetoppatents_SEARCH-MASTER').style.display = (g_funcArray[41] == 0 ? 'none' : '');
            if(dojo.byId('doPatentMap_SEARCH-MASTER') != null)
                dojo.byId('doPatentMap_SEARCH-MASTER').style.display = (g_funcArray[40] == 0 ? 'none' : '');
        }
        else if(dynamicType == 'QueryFulltext_SEARCH-SLAVE')
        {
            if(dojo.byId('queryfulltext_addtoproject_SEARCH-SLAVE') != null)
                dojo.byId('queryfulltext_addtoproject_SEARCH-SLAVE').style.display = (g_funcArray[30] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_querystat_SEARCH-SLAVE') != null)
                dojo.byId('queryfulltext_querystat_SEARCH-SLAVE').style.display = (g_funcArray[31] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_statdrawing_SEARCH-SLAVE') != null)
                dojo.byId('queryfulltext_statdrawing_SEARCH-SLAVE').style.display = (g_funcArray[32] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_clusterpatent_SEARCH-SLAVE') != null)
                dojo.byId('queryfulltext_clusterpatent_SEARCH-SLAVE').style.display = (g_funcArray[33] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_rotatesearch_SEARCH-SLAVE') != null)
                dojo.byId('queryfulltext_rotatesearch_SEARCH-SLAVE').style.display = (g_funcArray[34] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_exportpatent_SEARCH-SLAVE') != null)
                dojo.byId('queryfulltext_exportpatent_SEARCH-SLAVE').style.display = (g_funcArray[35] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_addtoclipboard_SEARCH-SLAVE') != null)
                dojo.byId('queryfulltext_addtoclipboard_SEARCH-SLAVE').style.display = (g_funcArray[36] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_mail_SEARCH-SLAVE') != null)
                dojo.byId('queryfulltext_mail_SEARCH-SLAVE').style.display = (g_funcArray[37] == 0 ? 'none' : '');
            if(dojo.byId('doPatentMap_SEARCH-SLAVE') != null)
                dojo.byId('doPatentMap_SEARCH-SLAVE').style.display = (g_funcArray[40] == 0 ? 'none' : '');
        }
        else if(dynamicType == 'QueryFulltext_SEARCH-PATENT')
        {
            if(dojo.byId('queryfulltext_addtoproject_SEARCH-PATENT') != null)
                dojo.byId('queryfulltext_addtoproject_SEARCH-PATENT').style.display = (g_funcArray[30] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_querystat_SEARCH-PATENT') != null)
                dojo.byId('queryfulltext_querystat_SEARCH-PATENT').style.display = (g_funcArray[31] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_statdrawing_SEARCH-PATENT') != null)
                dojo.byId('queryfulltext_statdrawing_SEARCH-PATENT').style.display = (g_funcArray[32] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_clusterpatent_SEARCH-PATENT') != null)
                dojo.byId('queryfulltext_clusterpatent_SEARCH-PATENT').style.display = (g_funcArray[33] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_rotatesearch_SEARCH-PATENT') != null)
                dojo.byId('queryfulltext_rotatesearch_SEARCH-PATENT').style.display = (g_funcArray[34] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_exportpatent_SEARCH-PATENT') != null)
                dojo.byId('queryfulltext_exportpatent_SEARCH-PATENT').style.display = (g_funcArray[35] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_addtoclipboard_SEARCH-PATENT') != null)
                dojo.byId('queryfulltext_addtoclipboard_SEARCH-PATENT').style.display = (g_funcArray[36] == 0 ? 'none' : '');
            if(dojo.byId('queryfulltext_mail_SEARCH-PATENT') != null)
                dojo.byId('queryfulltext_mail_SEARCH-PATENT').style.display = (g_funcArray[37] == 0 ? 'none' : '');
            if(dojo.byId('doPatentMap_SEARCH-MASTER') != null)
                dojo.byId('doPatentMap_SEARCH-MASTER').style.display = (g_funcArray[40] == 0 ? 'none' : '');
        }
    }
    else if(dynamicType == 'QueryTab')
    {
        var imgs = obj.getElementsByTagName('img');
        for(var i=0;i<imgs.length;i++)
        {
            switch(imgs[i].name)
            {
                case 'refinebypn':
                {
                    if(g_funcArray[45] == 0)
                        imgs[i].style.display = 'none';
                    break;
                }
                case 'scoretoppn':
                {
                    if(g_funcArray[46] == 0)
                        imgs[i].style.display = 'none';
                    break;
                }
                case 'nrefinebypn':
                {
                    if(g_funcArray[47] == 0)
                        imgs[i].style.display = 'none';
                    break;
                }
                case 'settotop':
                {
                    if(g_funcArray[48] == 0)
                        imgs[i].style.display = 'none';
                    break;
                }
                case 'copypatent':
                {
                    if(g_funcArray[49] == 0)
                        imgs[i].style.display = 'none';
                    break;
                }
                case 'importpatent':
                {
                    if(g_funcArray[50] == 0)
                        imgs[i].style.display = 'none';
                    break;
                }
                case 'showpatent':
                {
                    if(g_funcArray[51] == 0)
                        imgs[i].style.display = 'none';
                    break;
                }
                
            }    
        }
    }
    else if(dynamicType == 'QueryRelated_SEARCH-MASTER')
    {
        if(dojo.byId('queryrelated_searchmaster_prev') != null)
            dojo.byId('queryrelated_searchmaster_prev').style.display = (g_funcArray[71] == 0 ? 'none' : '');
        if(dojo.byId('queryrelated_searchmaster_next') != null)
            dojo.byId('queryrelated_searchmaster_next').style.display = (g_funcArray[71] == 0 ? 'none' : '');
        if(dojo.byId('queryrelated_searchmaster_cluster') != null)
            dojo.byId('queryrelated_searchmaster_cluster').style.display = (g_funcArray[70] == 0 ? 'none' : '');
        if(dojo.byId('queryrelated_searchmaster_anlist') != null)
            dojo.byId('queryrelated_searchmaster_anlist').style.display = (g_funcArray[72] == 0 ? 'none' : '');
    }
    else if(dynamicType == 'QueryRelated_SEARCH-SLAVE')
    {
        if(dojo.byId('queryrelated_searchslave_prev') != null)
            dojo.byId('queryrelated_searchslave_prev').style.display = (g_funcArray[71] == 0 ? 'none' : '');
        if(dojo.byId('queryrelated_searchslave_next') != null)
            dojo.byId('queryrelated_searchslave_next').style.display = (g_funcArray[71] == 0 ? 'none' : '');
    }
    else if(dynamicType == 'UserLogin')
    {
        if(dojo.byId('search-master-searchfilter-span') != null)
        {
            dojo.byId('search-master-searchfilter-span').style.display = (g_funcArray[80] == 0 ? 'none' : '');
           /* if(g_funcArray[80] == 1)
                loadPreference();      */              
        }
        if(dojo.byId('project-quick-projectlist') != null)
        {
            dojo.byId('project-quick-projectlist').style.display = (g_funcArray[82] == 0 ? 'none' : '');
            if(g_funcArray[82] == 1)
            {
                loadQuickProject();
                initProjectIdColorPair();
            }
        }
        if(dojo.byId('bookmark-quick-bookmarklist') != null)
        {
            dojo.byId('bookmark-quick-bookmarklist').style.display = (g_funcArray[60] == 0 ? 'none' : '');
            if(g_funcArray[60] == 1)
                loadBookmarkCombobox('search-bookmark-select', null, 2);
        }
    }
    else if(dynamicType == 'Class')
    {
		if(dojo.byId('classinfo-type-span-1') != null)
		{
			dojo.byId('classinfo-type-span-1').style.display = (g_funcArray[84] == 0 ? 'none' : '');
		}
		if(dojo.byId('classinfo-type-span-2') != null)
		{
			dojo.byId('classinfo-type-span-2').style.display = (g_funcArray[85] == 0 ? 'none' : '');
		}
		if(dojo.byId('classinfo-type-span-3') != null)
		{
			dojo.byId('classinfo-type-span-3').style.display = (g_funcArray[86] == 0 ? 'none' : '');
		}
		if(dojo.byId('classinfo-type-span-4') != null)
		{
			dojo.byId('classinfo-type-span-4').style.display = (g_funcArray[88] == 0 ? 'none' : '');
		}
		if(dojo.byId('classinfo-type-span-5') != null)
		{
			dojo.byId('classinfo-type-span-5').style.display = (g_funcArray[87] == 0 ? 'none' : '');
		}          
    }
    else if(dynamicType == 'QueryTabTab')
    {
        var sdvalue = '';
        if(g_funcArray[90] == 1)
            sdvalue += 'b';
        if(g_funcArray[91] == 1)
            sdvalue += 'c';
        if(g_funcArray[92] == 1)
            sdvalue += 'm';
        if(g_funcArray[93] == 1)
            sdvalue += 'r';
        if(g_funcArray[94] == 1)
            sdvalue += 'u';
        if(g_funcArray[95] == 1)
            sdvalue += 'p';
        if(g_funcArray[96] == 1)
            sdvalue += 'f';
        if(g_funcArray[97] == 1)
            sdvalue += 'k';
        if(g_funcArray[98] == 1)
            sdvalue += 'x';
        if(g_funcArray[99] == 1)
            sdvalue += '1';
        if(g_funcArray[100] == 1)
            sdvalue += '2';
        if(g_funcArray[102] == 1)
            sdvalue += '3';
        if(g_funcArray[103] == 1)
            sdvalue += '4';
        if(g_funcArray[101] == 1)
            sdvalue += 'a';
        return sdvalue;
    }
    else if(dynamicType == 'ShowPatent')
    {
        if(g_funcArray[105] == 0)
            dojo.byId('showpatent-uspto-img').style.display = 'none';
        if(g_funcArray[106] == 0)
            dojo.byId('showpatent-printout-img').style.display = 'none';    
        if(g_funcArray[107] == 0)
            dojo.byId('showpatent-showclaims-img').style.display = 'none';
        if(g_funcArray[108] == 0)
            dojo.byId('showpatent-dopdf-img').style.display = 'none';
        if(g_funcArray[109] == 0)
            dojo.byId('showpatent-expandallcomment-img').style.display = 'none';
        if(g_funcArray[110] == 0)
            dojo.byId('showpatent-addtoproject-img').style.display = 'none';
        if(g_funcArray[120] == 0)
        {
		    var menu = dijit.byId('contextmenu');
	        var wrsmenuitem = dijit.byId('wrsmenuitem');
	        if(wrsmenuitem != null)
	            menu.removeChild(wrsmenuitem);
        }
        if(g_funcArray[121] == 0)
        {
		    var menu = dijit.byId('contextmenu');
	        var addcommentmenuitem = dijit.byId('addcommentmenuitem');
	        if(addcommentmenuitem != null)
	            menu.removeChild(addcommentmenuitem);
        }
        if(g_funcArray[122] == 0)
        {
		    var menu = dijit.byId('contextmenu');
	        var addnotemenuitem = dijit.byId('addnotemenuitem');
	        if(addnotemenuitem != null)
	            menu.removeChild(addnotemenuitem);
        }
        if(g_funcArray[123] == 0)
        {
		    var menu = dijit.byId('contextmenu');
	        var ptmenuitem = dijit.byId('ptmenuitem');
	        if(ptmenuitem != null)
	            menu.removeChild(ptmenuitem);
        }
    }
    else if(dynamicType == 'ProjectGet')
    {
        if(dojo.byId('projectupdate-newproject-color') != null)
            dojo.byId('projectupdate-newproject-color').style.display = (g_funcArray[83] == 0 ? 'none' : 'inline');
    }
}

//add by seedy
function prepareLogin(callbackFunc, callbackFuncArgsArray)
{
    var height = document.body.clientHeight;
    var width = document.body.clientWidth;
    var logindivwidth = 620;
    var logindivheight = 390;
    if(LoginForm_Load==false)
    {
        dload('login-form-div','login.htm');
        LoginForm_Load=true;
    }
    if(height<logindivheight)
    { 
      	logindivheight = height ;
      	dojo.byId('login-form-div').style.overflowY='scroll';
      	dojo.byId('login-form-div').style.height=logindivheight+'px';
    }
    else{
      	dojo.byId('login-form-div').style.overflowY='hidden';
      	dojo.byId('login-form-div').style.height=logindivheight+'px';
    }
    if(width<logindivwidth)
    { 
      	logindivwidth = width ;
      	dojo.byId('login-form-div').style.overflowX='scroll';
      	dojo.byId('login-form-div').style.width=logindivwidth+'px';
    }
    else{
      	dojo.byId('login-form-div').style.overflowX='hidden';
      	dojo.byId('login-form-div').style.width=logindivwidth+'px';
    }
    var left = (width - logindivwidth) / 2;
    var top = (height - logindivheight) / 2;
    if(left < 0)
        left = 0;
    if(top < 0)
        top = 0;
    dojo.byId('login-form-div').style.left = left + 'px';
    dojo.byId('login-form-div').style.top = top + 'px';
    dojo.byId('login-form-div-table1').style.display = '';
    dojo.byId('login-form-div-table2').style.display = 'none';
    dojo.byId('shadowDiv').style.display = '';
    dojo.byId('login-form-div').style.display = '';
    dojo.byId('login-form-div').style.visibility = 'visible';
    dojo.byId('shadowDiv').style.visibility = 'visible';
    
    funcBeforeLogin=callbackFunc;
    varsBeforeLoginArray = callbackFuncArgsArray;
    
    
}



function getUserLoginState2(callbackFunc,callbackFuncArgsArray)
{
var ret2 =false;
    var divf = dojo.byId('login-form-div');
    if(divf == null){
        callbackFunc(callbackFuncArgsArray);
        return;
    }
    var dive = dojo.byId('login-result-div');
    var url = c_sUserGet + '&it=1&random=' + Math.random();
    var request = {
        url:url,
        handleAs:"json",
        sync:true,
		load: function(ret, ioArgs){
			if(ret.Error != null) // error occurs
			{
				var database_span='';
			    if(basic_search!=null)
			        database_span=getDatabaseSpan();
			    dive.innerHTML = database_span+g_loginSpan;
			    setPageInitState(false);
			    alert(ret.Error);
			    prepareLogin(callbackFunc, callbackFuncArgsArray);
			}
			else if(ret.User != null) 
			{
			    divf.style.display = 'none';
			    dive.style.display = '';
			    
			    var database_span='';
			    if(basic_search!=null)
			        database_span=getDatabaseSpan();
			    dive.innerHTML = database_span+'<b><span class="querylist-a" onmouseout="onQueryTableMouseOut(this, &#39;a&#39;);" onmouseover="onQueryTableMouseOver(this, &#39;a&#39;);" onclick="prepareUpdateUserInfoCall()">' + ret.User.Name + '</span></b>&nbsp;<span class="header-menu-mouseover" onclick="doLogOff();">' + c_sSignOff + '</span>' + '&nbsp;' + g_versionSpan;
			     
			    //if(callbackFunc.name != 'doPatentMap1' && callbackFunc.name != 'addCurrentPagePN1' && callbackFunc.name != 'doExportSearchResults1' && callbackFunc.name != 'showProjectDiv3')
			    //    setPageInitState(true);
			    ret2 =  callbackFunc(callbackFuncArgsArray);
			}
			else if (ret.PD == 1)
			{
			    divf.style.display = 'none';
			    dive.style.display = '';
			    
			    var database_span='';
			    if(basic_search!=null)
			        database_span=getDatabaseSpan();
			    //dive.innerHTML = database_span+'<b><span class="querylist-a" onmouseout="onQueryTableMouseOut(this, &#39;a&#39;);" onmouseover="onQueryTableMouseOver(this, &#39;a&#39;);" onclick="prepareUpdateUserInfo()">' + ret.User.Name + '</span></b>&nbsp;<span class="header-menu-mouseover" onclick="doLogOff();">' + c_sSignOff + '</span>' + '&nbsp;' + g_versionSpan;
			     
			    //if(callbackFunc.name != 'doPatentMap1' && callbackFunc.name != 'addCurrentPagePN1' && callbackFunc.name != 'doExportSearchResults1' && callbackFunc.name != 'showProjectDiv3')
			    //    setPageInitState(true);
			     
			    ret2 =  callbackFunc(callbackFuncArgsArray);
			}
			else
			{
		        var database_span='';
			    if(basic_search!=null)
			        database_span=getDatabaseSpan();
			    dive.innerHTML = database_span+g_loginSpan;
			    if(!doLoginFormCookie())
			    {
			        prepareLogin(callbackFunc,callbackFuncArgsArray);
			    }
			}	    
		},
		error: function(error, ioArgs) { 
            var database_span='';
			if(basic_search!=null)
			    database_span=getDatabaseSpan();
		    dive.innerHTML = database_span+g_loginSpan;
		    setPageInitState(false);
		    alert(error.message);
		    prepareLogin(callbackFunc,callbackFuncsArray);
		}
	};         
    dojo.xhrGet(request);
    return ret2;
}


function pScrollIntoView(scroll,obj)
{
    if(scroll!=null && scroll.scrollTop!=null)
    {
        scroll.scrollTop = obj.offsetTop;
    }
}


function escapeRegExp(str){
	return str.replace(/\\/gm, "\\\\").replace(/([\f\b\n\t\r[\^$|?*+(){}])/gm, "\\$1"); // string
}

function HiddenQueryListIcon(typeArray)
{
    var type;
    if(typeArray.length==2 || typeArray.length==3)
        type = typeArray[0];
    else
        type = typeArray;
   if(dojo.byId('querylist-queryresultstat-div-'+type)!=null)
        dojo.byId('querylist-queryresultstat-div-'+type).style.display='none';
    if(dojo.byId('queryrelated-cluster-div-'+type)!=null)
        dojo.byId('queryrelated-cluster-div-'+type).style.display='none';
    if(dojo.byId('querylist-patentmap-div-'+type)!=null)
        dojo.byId('querylist-patentmap-div-'+type).style.display='none';
    if(dojo.byId('queryrelated-cluster-div-'+type)!=null)
        dojo.byId('queryrelated-cluster-div-'+type).style.display='none';
    if(type=='SEARCH-MASTER')
    {
        if(dojo.byId('querylist-queryresultchart-div-SEARCH-MASTER')!=null)
            dojo.byId('querylist-queryresultchart-div-SEARCH-MASTER').style.display='none';
        if(dojo.byId('search-master-rotate-div')!=null)
            dojo.byId('search-master-rotate-div').style.display = 'none';
    }
}


function belongToMxDataBase(pn)
{
    if(pn>=220000000 && pn<=255000000)
        return true;
    return false;
}
//seedy added 
function imgCheckboxOver(img)
{
    if(img!=null)
    {
        if(img.src.indexOf('img/cancel.gif')!=-1)
        {
            return;
        }else
        {
            img.src = c_sImgPath+'img/check-active.gif';
        }
        
    }
}

function imgCheckboxOut(img)
{
    if(img!=null)
    {
        if(img.src.indexOf('img/cancel.gif')!=-1)
        {
            return;
        }else
        {
            img.src = c_sImgPath+'img/check.gif';
        }
        
    }
}

function checkCheckboxImg(img)
{
    if(img!=null)
    {
        if(img.src.indexOf('img/check.gif')!= -1 || img.src.indexOf('img/check-active.gif')!=-1)
        {
            img.src = c_sImgPath+'img/cancel.gif';
        }else
        {
            img.src = c_sImgPath+'img/check.gif';
        }
    }
}

function MyScorllIntoView(divobj)
{
    divobj.scrollIntoView();
    //dojo.byId('index-header').scrollIntoView();
}
function getElementsByClassNameIE(obj,eleClassName)
{
	if(obj==null)
	{
		return null;
	}
	var getEleClass = [];
	var myclass = new RegExp("\\b"+eleClassName+"\\b");
	var tabs=obj.getElementsByTagName("*");
	for( var i = 0 ; i < tabs.length; i++)
	{
		var classes = tabs[i].className;
		if (myclass.test(classes))
		{
			getEleClass.push(tabs[i]);
		}
	}
	return getEleClass;
}
function changeIdentifyCodePic(obj,size){
    if(obj!=null)
    {
        obj.src = "";
        obj.src = 'invokebinary.do?sf=IdentifyCodeGet&isize='+size+'&random=' + Math.random();    
    }
}
function onQueryTableMouseOver(obj, type, pn, did)
{
    if (type != 'p')
        obj.style.textDecoration = 'underline';
}
function prepareUpdateUserInfoCall()
{
    if(SignupForm_Load==false) {
        SignupForm_Load = true;
        return AsyncLoad('signup-form-div', 'signup.htm', prepareUpdateUserInfoCall, arguments);
        //return dload('signup-form-div','signup.htm');
    }
    prepareUpdateUserInfo();
}

function prepareSignupAccountCall()
{
    if(SignupForm_Load==false)
    {
        SignupForm_Load=true;
        AsyncLoad('signup-form-div','signup.htm',prepareSignupAccountCall,arguments);
    }
    else
    {
        prepareSignupAccount();
    }
}

function resetPasswordCall()
{
    if(ResetpwdForm_Load==false)
    {
        ResetpwdForm_Load=true;
        AsyncLoad('resetpwd-form-div','resetpwdApp.htm',resetPasswordCall,arguments);
    }
    else
        resetPassword();
}
function ReSendActiveMailCall()
{
    if(ResendemailForm_Load==false)
    {
        ResendemailForm_Load=true;
        AsyncLoad('resendemail-form-div','resendemail.htm',ReSendActiveMailCall,arguments);
    }
    else
        ReSendActiveMail();
}
function setPopupDivPositionCall()
{
    if(Query_JS== false)
        return;
    setPopupDivPosition('search-popupdiv');
}


ApplicationState = function(form, datafulltext_old,datarelated_old){
    this.dataform = new Object();
	this.dataform['ipi'] = form.ipi.value;
	this.dataform['sq'] = form.sq.value;
	this.dataform['sd'] = form.sd.value;
	this.dataform['idi'] = form.idi.value;
	this.dataform['iopt'] = form.iopt.value;
	this.dataform['sc'] = form.sc.value;
	this.dataform['sds'] = form.sds.value;
	this.dataform['sde'] = form.sde.value;
	this.dataform['ip'] = form.ip.value;
	this.dataform['sdf'] = form.sdf.value;
	this.dataform['sqf'] = form.sqf.value;
    this.datafulltext=datafulltext_old;
    this.datarelated=datarelated_old;
}

function onQueryTableMouseOut(obj, type, pn, did)
{
    if (type != 'p')
        obj.style.textDecoration = 'none';
}

function escaping(obj)
{
    if(navigator.appName == 'Netscape')
    {
    	if(obj == null)
    	{
	        var ptables = document.getElementsByTagName('div');
	    	for(var i=0;i<ptables.length;i++)
	    	{
	    		if(ptables[i].className=='ptable')
	    	    {
	    			ptables[i].innerHTML = ptables[i].textContent;
	    		}
	    	}
	    }else
	    {
	    	var ptables = obj.getElementsByTagName('div');
	    	for(var i=0;i<ptables.length;i++)
	    	{
	    		if(ptables[i].className=='ptable')
	    	    {
	    			ptables[i].innerHTML = ptables[i].textContent;
	    		}
	    	}
	    	var ptables = obj.getElementsByTagName('ptable');
	    	for(var i=0;i<ptables.length;i++)
	    	{
	    		
	    	  
	    			ptables[i].innerHTML = ptables[i].textContent;
	    		
	    	}
	    }
	    		
   }
}

function getIframeObj(aID)
{
    if(dojo.isIE)
    {
        return document.frames[aID];
    }
    else
    {
        return document.getElementById(aID);
    }
}
function getIFrame(aID)
{
    if(dojo.isIE)
    {
        return document.frames[aID].document;
    }
    else
    {
        return document.getElementById(aID).contentDocument;
    }
}
function getIFrameDocument(aID) {
	
		if(dojo.isIE)
		{
			var iframename = '';
			if(document.frames[aID]!=null)
			{
				return document.frames[aID].document;
			}
			if(document.frames['iframe'+aID]!=null)
			{
				iframename = 'iframe'+aID;
			}else if(document.frames['iframehead'+aID]!=null)
			{
				iframename='iframehead'+aID;
			}
			//alert(iframename);
			if(iframename == '')
				return null;
		
	    return document.frames[iframename].document;
	    
	    
	    
	    
	    
		}else
		{
	  var frame = null;
	  var vid;
		if(aID.indexOf('iframehead')==-1)
		{
			frame = document.getElementById('iframe'+aID);
			vid = 'iframe'+aID;
			if(frame == null)
				frame = document.getElementById('iframehead'+aID);
		}else
		{
			frame = document.getElementById(aID);
			vid = aID;
			if(frame == null)
			{
				frame = document.getElementById('iframe'+aID.replace('iframehead',''));
			}
			
		}
		var rv = null;
			
		if(frame!=null)
		{
			if(frame.contentDocument)
			{
		
				rv = frame.contentDocument;
			}else
			{
					rv = frame.document;
			}
				
			
		}
	}
		return rv;
		
		
    
    // if contentDocument exists, W3C compliant (Mozilla)
    
//    if (document.getElementById(aID).contentDocument){
  //      rv = document.getElementById(aID).contentDocument;
    //} else {
    // IE
      //  rv= document.getElementById(aID).document;
    //}
   // return rv;
}


function setMxConcetpRadio(id)
{
    var concept_radio = dojo.byId('search-master-sd-CONCEPT');
    var bool_radio = dojo.byId('search-master-sd-BOOL');
    if(getDatabaseGroup(id)==3)
    {
        if(concept_radio!=null && concept_radio.checked)
            Mx_Radio = 0;
        else
            Mx_Radio = 1;
        concept_radio.disabled=true;
        bool_radio.checked=true;
        Last_Mx=true;
    }
    else if(Last_Mx)
    {
        Last_Mx=false;
        concept_radio.disabled=false;
        if(Mx_Radio==0 && concept_radio!=null)
        {
            concept_radio.checked=true;
        }
        else
        {
            bool_radio.checked=true;
        }
    } else
    {
        if(concept_radio!=null)
        {
            concept_radio.disabled=false;
        }
    }
}


function showHideParentSibling(obj, tag)
{
	if(obj == null)
	{
		return;
	}
	var sib = obj;
	if(!isNullorEmpty(tag))
	{	
		while(sib != null && sib.tagName != tag)
		{
			sib = sib.parentNode;
		}
	}
	
	if(sib == null)
	{
		return;
	}
	do
	{
	    sib = sib.nextSibling;
  }while(sib!=null && sib.tagName != tag);
  
  
  
	
	if(sib && sib.style)
	{
		if(sib.style.display == '')
		{
			sib.style.display = 'none';
		}else
		{
			sib.style.display = '';
	  }
	}
}


function showHideParentSiblings(obj, tag, inc)
{
	if(obj == null)
	{
		return;
	}
	var sib = obj;
	if(!isNullorEmpty(tag))
	{	
		while(sib != null && sib.tagName != tag)
		{
			sib = sib.parentNode;
		}
	}
	
	if(sib == null)
	{
		return;
	}
	var first=false;
	var plus = false;
	var firstDisplay;
	do
	{
	    sib = sib.nextSibling;
	    first = !first;
	    if(sib && first && !isNullorEmpty(inc))
	    {
			var img = sib.getElementsByTagName('img');
			if(img!=null && img.length>0)
			{
				plus = (img[0].src.indexOf('plus.gif')!=-1);
			}
			if(sib.style)
				firstDisplay = sib.style.display;
		}
	    if(sib!=null && sib.tagName == tag)
	    {
				if(sib && sib.style)
				{
					if(!first && !isNullorEmpty(inc))
					{
						if(firstDisplay == 'none' && !plus)
						{
							sib.style.display='';
						}else
						{
							sib.style.display = 'none';
						}
					}
					else if(sib.style.display == '')
					{
						sib.style.display = 'none';
					}else
					{
						sib.style.display = '';
					}
				}    	
	    }
  }while(sib!=null);
  
}

function CheckClientShowPatent(pn)
{
    if(!isNullorEmpty(isShowPatent) && isShowPatent && isClient)
    {
        if(isNullorEmpty(pn) || isNullorEmpty(g_innerpn))
            return true;
        if(pn==g_innerpn)
            return true;
    }
    return false;
}

function onmouseoverGif(obj,src)
{
    obj.src = 'img/'+src+'-active.gif';
}

function onmouseoutGif(obj,src)
{
    obj.src = 'img/'+src+'.gif';
}

function ifExist(elementId)
{
	if(dojo.byId(elementId)!=null)
	{
		return true;
	}
	return false;
	
}
function hidevisibleIfExist(elementId)
{
		if(ifExist(elementId))
		{
			dojo.byId(elementId).style.visibility='hidden';
		}
}
function hideIfExist(elementId)
{
		if(ifExist(elementId))
		{
			dojo.byId(elementId).style.display='none';
		}
}
function showIfExist(elementId)
{
		if(ifExist(elementId))
		{
			dojo.byId(elementId).style.display='';
		}
}

function loadSharedCombobox(selectid, startDeleteIndex)
{	
    var select = dojo.byId(selectid);
    var request = {
        url:c_sSharedGroupGetJson+'&random=' + Math.random(), 
        handleAs:"json",
	    load: function(ret, ioArgs){
	        if(ret.GroupRelationList != null)
	        { 
	            var length =select.options.length;
	            if(select==null)
	                return;
	            while(length != startDeleteIndex)
	            {  
                    for(var i = startDeleteIndex; i < length; i++)
                        select.remove(i);
                    length = select.options.length;
                }
                for(var i = 0; i < ret.GroupRelationList.length; i++)
                {
					var option = document.createElement('OPTION');
                    option.text = ret.GroupRelationList[i].Name;
                    option.value = ret.GroupRelationList[i].ID;
                    select.options.add(option);
                }
	        };
	    },
        error: function(error,ioArgs) {}
    };
    dojo.xhrGet(request);
}

function HashMap()
{
    /** Map 大小 **/
    this.count = 0;
    /** 对象 **/
    this.entry = new Object(); 
    /** 是否包含 Key **/
    this.containsKey = function ( key )
    {
        return (key in this.entry);
    }
    
    /** 存 **/
    this.put = function (key , value)
    {
        if(!this.containsKey(key))
        {
            this.count++;
        }
        this.entry[key] = value;
    }
    
    this.clear = function()
    {
		delete this.entry;
		this.entry = new Object;
		this.count = 0;
    }
    /** 取 **/
    this.get = function (key)
    {
        if( this.containsKey(key) )
        {
            return this.entry[key];
        }
        else
        {
            return null;
        }
    }
    
    /** 删除 **/
    this.remove = function ( key )
    {
        if( delete this.entry[key] )
        {
            this.count--;
        }
    }
    
    
    /** 是否包含 Value **/
    this.containsValue = function ( value )
    {
        for(var prop in this.entry)
        {
            if(this.entry[prop] == value)
            {
                return true;
            }
        }
        return false;
    }
    
    /** 所有 Value **/
    this.values = function ()
    {
        var values = new Array(this.count);
        for(var prop in this.entry)
        {
            values.push(this.entry[prop]);
        }
        return values;
    }
    
    /** 所有 Key **/
    this.keys = function ()
    {
        var key = new Array(this.count);
        for(var prop in this.entry)
        {
            key.push(prop);
        }
        return key;
    }
    
    /** Map Size **/
    this.size = function ()
    {
        return this.count;
    }
}

var DB_US_PAT=1;
var DB_US_APP=2;
var DB_CN=4;
var DB_C1=8;
var DB_EP=16;
var DB_WO=32;
var DB_MX=64;
var DB_USER=128;
function getDBByPatentPN(pn)
{
    if (pn < 10000000)
        return 0;
	else if (pn < 10060000)
	    return DB_US_APP;
	else if (pn < 15000000)
		return DB_EP;
	else if (pn < 20000000)
		return DB_WO;
    else if (pn < 200000000)
           return DB_US_APP;
    else if (pn < 210000000)
           return DB_CN;
    else if (pn < 220000000)
       	return DB_C1;
    else if (pn < 300000000)
      	return DB_MX;
    return DB_USER;
}
function onCheckShowPatent()
{
    var url = 'invokejson.do?sf=CheckShowPatent';
    var request = {
        url:url,
        form:dojo.byId('check-form'),
        handleAs:"json",
        load:function(response,ioArgs){                   
            if(response.Error!=null)
			{
				alert(response.Error);
			}
			else
			{
			    window.location.reload(); 
			}
        }
    };
    dojo.xhrPost(request);
    
}
