var current_subtab = "";
var search_last_tab = "";
var account_last_tab = "";
var analyzeTabs = new Array;
var analyzeArray = new Array;
var detailArray  = new Array;
var current_analyzed_item = "";
var __currentPMT_menu_obj = null;
var clusterTree = null;
var activate = "";
var treeObj = Array();
var select_all_form = "";
var sel_check = false;
var save_all  = 0;
var options_changed = 0 ;

var  detail_message ='<div>';
detail_message = detail_message+'<div id="PageCorners_message"><img src="images/corner_lt.png" alt="." width="10" height="10" class="fltrt" /><img src="images/corner_rt.png" width="10" height="10" alt="." /></div>';
detail_message = detail_message+'<div id="message_body">';
detail_message = detail_message+'<div style="text-align:center;padding-right:20px"><img src="images/ajax-loader.gif"/><br>Searching, Please wait</div>';
detail_message = detail_message+'<div style="float:left;padding-top:550px"><img src="images/pageBtm.png" width="721" height="10" alt="." /></div>';
detail_message = detail_message+'</div>';
detail_message = detail_message+'</div>';

var  detail_message1 ='<div>';
detail_message1 = detail_message1+'<div id="PageCorners_message"></div>';
detail_message1 = detail_message1+'<div id="message_body">';
detail_message1 = detail_message1+'<div style="text-align:center;padding-right:20px"><img src="images/ajax-loader.gif"/><br>Searching, Please wait</div>';
detail_message1 = detail_message1+'<div style="float:left;padding-top:550px"></div>';
detail_message1 = detail_message1+'</div>';
detail_message1 = detail_message1+'</div>';


function IsVisibleDiv(id) {
    var ctd = getelementbyid(id);
    if(ctd) {
        if(ctd.style.display == "none") return false;
        else return true;
    } else return false;
}


function HideDiv(id) {
    var ctd = getelementbyid(id);
    if(ctd) ctd.style.display = "none";
}

function ShowDiv(id) {
    var ctd = getelementbyid(id);
    if(ctd) ctd.style.display = "";
}


function getNumByTabname(tab){
    num = tab.charAt(8);
    return ""+num+"";
}



function SubClick_pmt(num_tab) {
    if(num_tab==""){
        tab = "pmt_tab_1"
    }
    else{
        tab = "pmt_tab_"+num_tab;
    }
    current_subtab = tab;
    
    ShowDiv("pmt_tab_"+num_tab);
    for(var i=1;i<treeObj.length;i++){
        if(i!=num_tab)  HideDiv("pmt_tab_"+i);  
    }
    
    return false;
}




function SubClick_account(tab) {
    if(tab=="") tab = account_last_tab;
    if(tab=="") tab = "account_pers_info";
    account_last_tab = tab;
    current_subtab = tab;
    if(tab=="account_pers_info") ShowDiv("account_pers_info"); else HideDiv("account_pers_info");
    if(tab=="account_subscription") ShowDiv("account_subscription"); else HideDiv("account_subscription");
    if(tab=="account_billing") ShowDiv("account_billing"); else HideDiv("account_billing");
    return false;
}


function ProcessLastTabClick() {
   
	
    if(current_subtab=="pmt_tab_1" || current_subtab=="pmt_tab_2"){
        Process_pmt_tab(getNumByTabname(current_subtab));
    }
    if(current_subtab=="account_pers_info") Process_account_pers_info("");
    if(current_subtab=="account_subscription") Process_account_subscription("");
    if(current_subtab=="user_search_options") Process_user_search_options("");
	 
}


function Tab_mgmt_click(number) {
    ShowDiv("mgmt_menu_"+number);
    
    
    //to hide all others menus
    var tot = treeObj.length;
    if(tot==0)
        tot=2;
    for(var i=1;i<tot;i++){
        if(i!=number)  HideDiv("mgmt_menu_"+i);  
    }
    
    HideDiv("search_menu");
    HideDiv("search_page_top_navi");
    HideDiv("analyze_menu");
    HideDiv("patent_detail_top_navi");
    HideDiv("tools_menu");
    HideDiv("settings_menu");

    HideDiv("account_menu");
    HideDiv("account_pers_info");
    HideDiv("account_subscription");
    HideDiv("account_billing");
	
    HideDiv("patent_detail_top_navi");// mush code
    HideDiv("searchcontrol");// mush code
	
    HideDiv("PatentLeftNavi");// mush code
    HideDiv("PatenDetailMain_FullText");// mush code
	
    HideDiv("pat_top_bar");

    SubClick_pmt(number);

    var tdid = getelementbyid("tab_mgmt_"+number);
    tdid.style.backgroundColor="#F0F0F0";
    
    for(var i=1;i<treeObj.length;i++){
        if(i!=number){
            var tdid = getelementbyid("tab_mgmt_"+i);
            tdid.style.backgroundColor="#A0A0A0";
        }
    }
    
    var tdid = getelementbyid("tab_search");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_analyze");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_analyze1");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_settings");
    tdid.style.backgroundColor="#A0A0A0";
    // var tdid = getelementbyid("tab_account");
    //tdid.style.backgroundColor="#A0A0A0";

    ProcessLastTabClick();
	
    if(number==1){
		
        //makeRequest('/organize_results.php',"",AJAXProcessLabelCreateTreeOrgTab);
        LoadTree();
    }

    return false;
}


//***************************************************
// mush levt navi scroller
//***************************************************

/*
Floating Menu script-  Roy Whittle (http://www.javascript-fx.com/)
Script featured on/available at http://www.dynamicdrive.com/
This notice must stay intact for use
*/

//Enter "frombottom" or "fromtop"
var verticalpos="frombottom"
function JSFX_FloatTopDiv(leftdiv)
{
    var startX = 20,
    startY = 430;
    var ns = (navigator.appName.indexOf("Netscape") != -1);
    var d = document;
    function ml(id)
    {
        var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
        if(d.layers)el.style=el;
        el.sP=function(x,y){
            this.style.left=x;this.style.top=y;
        };
        el.x = startX;
        if (verticalpos=="fromtop")
            el.y = startY;
        else{
            el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
            el.y -= startY;
        }
        return el;
    }
    window.stayTopLeft=function()
    {
        if (verticalpos=="fromtop"){
            var pY = ns ? pageYOffset : document.body.scrollTop;
            ftlObj.y += (pY + startY - ftlObj.y)/8;
        }
        else{
            var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
            ftlObj.y += (pY - startY - ftlObj.y)/8;
        }
        ftlObj.sP(ftlObj.x, ftlObj.y);
        setTimeout("stayTopLeft()", 10);
    }
    ftlObj = ml(leftdiv);
    stayTopLeft();
}

//************************************************************************************************

//**********************

function deletePatentDetailComment(id){
	if(local_user_type != 4){ 
		if(confirm( 'Are You Sure You Want To Delete Comment? YES/NO' )){
			makeRequest('/update_comment.php?patent='+id,"",AJAXProcessHtmlTabResponse);
			getelementbyid("notes").innerHTML="";
			getelementbyid("show_bubble_"+id).innerHTML = "";
			deleteed_comments_num = deleteed_comments.length;
			deleteed_comments[deleteed_comments_num] = id;
		}
	} else {
		adv_open("Write-private-notes-about-patent.php");
	}		
}

//**********************



function Tab_analyze_click() {
    HideDiv("mgmt_menu_1");
    HideDiv("search_menu");
    HideDiv("search_page_top_navi");
    ShowDiv("analyze_menu");
    ShowDiv("patent_detail_top_navi");
    HideDiv("tools_menu");
    HideDiv("settings_menu");
    HideDiv("account_menu");
    HideDiv("account_pers_info");
    HideDiv("account_subscription");
    HideDiv("account_billing");
    HideDiv("searchcontrol");// mush code
    if(current_analyzed_item != "") onAnalyzeSubTabClick(current_analyzed_item);

    var tdid = getelementbyid("tab_analyze1");
    tdid.style.backgroundColor="#A0A0A0";

    var tdid = getelementbyid("tab_search");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_analyze");
    tdid.style.backgroundColor="#F0F0F0";
    var tdid = getelementbyid("tab_mgmt_1");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_settings");
    tdid.style.backgroundColor="#A0A0A0";
    //var tdid = getelementbyid("tab_account");
    //tdid.style.backgroundColor="#A0A0A0";
    return false;
}
function Tab_analyze1_click() {
		
    HideDiv("mgmt_menu_1");
    HideDiv("search_menu");
    HideDiv("search_page_top_navi");
    HideDiv("analyze_menu");
    HideDiv("patent_detail_top_navi");
    HideDiv("tools_menu");
    HideDiv("settings_menu");
    HideDiv("account_menu");
    HideDiv("account_pers_info");
    HideDiv("account_subscription");
    HideDiv("account_billing");
    HideDiv("searchcontrol");// mush code
    var tdid = getelementbyid("tab_search");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_analyze");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_analyze1");
    tdid.style.backgroundColor="#F0F0F0";
    var tdid = getelementbyid("tab_mgmt_1");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_settings");
    tdid.style.backgroundColor="#A0A0A0";

    //var tdid = getelementbyid("tab_account");
    //tdid.style.backgroundColor="#A0A0A0";
    return false;
}

function Tab_tools_click() {
    //to hide all others menus
    var tot = treeObj.length;
    if(tot==0)
        tot=2;
    for(var i=1;i<tot;i++){
        HideDiv("mgmt_menu_"+i);
        
        var tdid = getelementbyid("tab_mgmt_"+i);
    //  tdid.style.backgroundColor="#A0A0A0";
    }

    HideDiv("search_menu");
    HideDiv("search_page_top_navi");
    HideDiv("analyze_menu");
    HideDiv("patent_detail_top_navi");
    ShowDiv("tools_menu");
    HideDiv("settings_menu");

    HideDiv("account_menu");
    HideDiv("account_pers_info");
    HideDiv("account_subscription");
    HideDiv("account_billing");

    HideDiv("pat_top_bar");
    HideDiv("patent_detail_top_navi");// mush code
    HideDiv("PatentLeftNavi");// mush code
    HideDiv("PatenDetailMain_FullText");// mush code
    HideDiv("searchcontrol");// mush code
    var tdid = getelementbyid("tab_search");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_analyze");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_tools");
    tdid.style.backgroundColor="#F0F0F0";
    var tdid = getelementbyid("tab_settings");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_account");
    tdid.style.backgroundColor="#A0A0A0";


    return false;
}

function onSubClick_setting(tab) {
    
    if(tab=="") tab = "settings_menu";
    if(tab=="") tab = "settings_menu";
    search_last_tab = tab;
    current_subtab = tab;
    Process_user_search_options("");
    return false;
}

function Tab_settings_click() {
	if(local_user_type == 1){  
		HideDiv("search_ajax");
		ShowDiv("settings_menu");
		HideDiv("setting_div");
		HideDiv('google_web_ctl_container');
		HideDiv("search_view_web");
		HideDiv("search_view_perior");
		HideDiv("search_view_img");
		HideDiv("search_graph");
		document.getElementById( current_search_div ).setAttribute("class" , "");
		document.getElementById( current_search_div ).setAttribute("className" , "");
		onSubClick_setting("");
		return false;
	} else {
		adv_open("adv.php");
	}
}

function Search_option_click(){
   
    var tot = treeObj.length;
    if(tot==0)
        tot=2;
    for(var i=1;i<tot;i++){
        HideDiv("mgmt_menu_"+i);
        
        var tdid = getelementbyid("tab_mgmt_"+i);
    // tdid.style.backgroundColor="#A0A0A0";
    }
    
    
    HideDiv("search_menu");
    HideDiv("search_page_top_navi");
    HideDiv("analyze_menu");
    HideDiv("patent_detail_top_navi");
    HideDiv("tools_menu");
    HideDiv("settings_menu");
    ShowDiv("account_menu");
    HideDiv("patent_detail_top_navi");// mush code
    HideDiv("PatentLeftNavi");// mush code
    HideDiv("PatenDetailMain_FullText");// mush code
    HideDiv("searchcontrol");// mush code
    SubClick_account("");


    HideDiv("pat_top_bar");


    var tdid = getelementbyid("tab_search");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_analyze");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_tools");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_settings");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_account");
    tdid.style.backgroundColor="#F0F0F0";


    ProcessLastTabClick();

    return false;

}
function Tab_account_click() {
    //to hide all others menus
    var tot = treeObj.length;
    if(tot==0)
        tot=2;
    for(var i=1;i<tot;i++){
        HideDiv("mgmt_menu_"+i);
        
        var tdid = getelementbyid("tab_mgmt_"+i);
    //  tdid.style.backgroundColor="#A0A0A0";
    }
    
    HideDiv("search_menu");
    HideDiv("search_page_top_navi");
    HideDiv("analyze_menu");
    HideDiv("patent_detail_top_navi");
    HideDiv("tools_menu");
    HideDiv("settings_menu");
    ShowDiv("account_menu");
    SubClick_account("");


    HideDiv("pat_top_bar");


    var tdid = getelementbyid("tab_search");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_analyze");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_tools");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_settings");
    tdid.style.backgroundColor="#A0A0A0";
    var tdid = getelementbyid("tab_account");
    tdid.style.backgroundColor="#F0F0F0";


    ProcessLastTabClick();

    return false;
}
function onSubClick_account(tab) {
    SubClick_account(tab);
    ProcessLastTabClick();
    return false;
}

//---------------------------------------------------------------------
function Process_user_search_options (action) {
  
    if(action=="") {
        var did = getelementbyid("settings_menu");
        makeRequest('/user_search_option.php',"",AJAXProcessHtmlTabResponse);
    } else
    if(action=="post_info") {
        options_changed = 1;
		var post_str = "us_class_code="+encodeURI(document.regform.us_class_code.value)+
        "&intl_class_code="+encodeURI(document.regform.intl_class_code.value)+
        "&filing_date="+encodeURI(document.regform.filing_date.value)+
        "&abstract="+encodeURI(document.regform.abstract.value)+
        "&first_claim="+encodeURI(document.regform.first_claim.value)+
        "&all_claims="+encodeURI(document.regform.all_claims.value)+
        "&filing_date="+encodeURI(document.regform.filing_date.value)+
        "&issue_date="+encodeURI(document.regform.issue_date.value)+
        "&inventor="+encodeURI(document.regform.inventor.value)+
        "&assignee="+encodeURI(document.regform.assignee.value)+
        "&first_drawing="+encodeURI(document.regform.first_drawing.value)+
        "&field_of_search="+encodeURI(document.regform.field_of_search.value)+
        "&us_application_num="+encodeURI(document.regform.us_application_num.value)+
        "&parent_case="+encodeURI(document.regform.parent_case.value)+
        "&priority_data="+encodeURI(document.regform.priority_data.value)+
        "&us_prior_art_refs="+encodeURI(document.regform.us_prior_art_refs.value)+
        "&intl_prior_art_refs="+encodeURI(document.regform.intl_prior_art_refs.value)+
        "&other_prior_art_refs="+encodeURI(document.regform.other_prior_art_refs.value)+
        "&examiner="+encodeURI(document.regform.examiner.value)+
        "&assistant_examiner="+encodeURI(document.regform.assistant_examiner.value)+
        "&attorney="+encodeURI(document.regform.attorney.value)+
					
        "&adv_us_class_code="+encodeURI(document.regform.adv_us_class_code.value)+
        "&adv_intl_class_code="+encodeURI(document.regform.adv_intl_class_code.value)+
        "&adv_filing_date="+encodeURI(document.regform.adv_filing_date.value)+
        "&adv_abstract="+encodeURI(document.regform.adv_abstract.value)+
        "&adv_first_claim="+encodeURI(document.regform.adv_first_claim.value)+
        "&adv_all_claims="+encodeURI(document.regform.adv_all_claims.value)+
        "&adv_filing_date="+encodeURI(document.regform.adv_filing_date.value)+
        "&adv_issue_date="+encodeURI(document.regform.adv_issue_date.value)+
        "&adv_inventor="+encodeURI(document.regform.adv_inventor.value)+
        "&adv_assignee="+encodeURI(document.regform.adv_assignee.value)+
        "&adv_first_drawing="+encodeURI(document.regform.adv_first_drawing.value)+
        "&adv_field_of_search="+encodeURI(document.regform.adv_field_of_search.value)+
        "&adv_us_application_num="+encodeURI(document.regform.adv_us_application_num.value)+
        "&adv_parent_case="+encodeURI(document.regform.adv_parent_case.value)+
        "&adv_priority_data="+encodeURI(document.regform.adv_priority_data.value)+
        "&adv_us_prior_art_refs="+encodeURI(document.regform.adv_us_prior_art_refs.value)+
        "&adv_intl_prior_art_refs="+encodeURI(document.regform.adv_intl_prior_art_refs.value)+
        "&adv_other_prior_art_refs="+encodeURI(document.regform.adv_other_prior_art_refs.value)+
        "&adv_examiner="+encodeURI(document.regform.adv_examiner.value)+
        "&adv_assistant_examiner="+encodeURI(document.regform.adv_assistant_examiner.value)+
        "&adv_attorney="+encodeURI(document.regform.adv_attorney.value)+
        "&action="+encodeURI(document.regform.action.value)
        makeRequest('/user_search_option.php',post_str,AJAXProcessHtmlTabResponse);

    }
    return false;
}

//----------------------------------------------------------------------

function Process_account_pers_info (action) {
    if(action=="") {

        var did = getelementbyid("account_pers_info");
        if(did.innerHTML == "") {
            // first page load
            makeRequest('/user_profile.php',"",AJAXProcessHtmlTabResponse);
        }

    } else
    if(action=="post_info") {
        var post_str = "email="+encodeURI(document.regform.email.value)+
        "&fname="+encodeURI(document.regform.fname.value)+
        "&fname="+encodeURI(document.regform.fname.value)+
        "&lname="+encodeURI(document.regform.lname.value)+
        "&company="+encodeURI(document.regform.company.value)+
        "&passw="+encodeURI(document.regform.passw.value)+
        "&cpassw="+encodeURI(document.regform.cpassw.value)+
        "&country="+encodeURI(document.regform.country.value)+
        "&action="+encodeURI(document.regform.action.value)

        makeRequest('/user_profile.php',post_str,AJAXProcessHtmlTabResponse);

    }
    return false;
}

function Process_account_subscription (action) {
    if(action=="") {

        var did = getelementbyid("account_subscription");
        if(did.innerHTML == "") {
            // first page load
            makeRequest('/subscription.php',"",AJAXProcessHtmlTabResponse);
        }

    } else
    if(action=="post_info") {
        var post_str = "email="+encodeURI(document.regform.email.value)+
        "&fname="+encodeURI(document.regform.fname.value)+
        "&fname="+encodeURI(document.regform.fname.value)+
        "&lname="+encodeURI(document.regform.lname.value)+
        "&company="+encodeURI(document.regform.company.value)+
        "&passw="+encodeURI(document.regform.passw.value)+
        "&cpassw="+encodeURI(document.regform.cpassw.value)+
        "&country="+encodeURI(document.regform.country.value)+
        "&action="+encodeURI(document.regform.action.value)

        makeRequest('/subscription.php',post_str,AJAXProcessHtmlTabResponse);

    }
    return false;
}


function InitPMT(vis_list) {
    treeObj[vis_list] = new JSDragDropTree();
    treeObj[vis_list].setTreeId('proj_tree_'+vis_list);
    treeObj[vis_list].setMaximumDepth(4);
    treeObj[vis_list].setMessageMaximumDepthReached('Maximum depth reached'); // If you want to show a message when maximum depth is reached, i.e. on drop.
    treeObj[vis_list].initTree();
    treeObj[vis_list].expandAll();
}




/**
function Process_pmt_tab(action) {
  if(action=="") {

	var did = getelementbyid("pmt_tab");
    if(did.innerHTML == "") {
      // first page load
      //makeRequest('/pmt.php',"",AJAXProcessHtmlTabResponse);
    }

  } else
  if(action=="post_info") {
//    var post_str = "patnum="+encodeURI(document.search_patnum.patnum.value)+
//                   "&action="+encodeURI(document.search_patnum.action.value)

//      makeRequest('/patnumsearch.php',post_str,AJAXProcessHtmlTabResponse);

  }
  return false;
}*/

function Process_pmt_tab(num_tab) {
    var did = getelementbyid("pmt_tab_"+num_tab);
    if(did.innerHTML == "") {
        // first page load
        makeRequest("/pmt"+num_tab+".php","tab_num="+num_tab+"",AJAXProcessHtmlTabResponse);
    }

    return false;
}
function onSortByClick(sort_type, sort_type_text) {
    var dsc = getelementbyid("check_desc");
    var sort_text = getelementbyid("SortByTool");
    var sort_id = getelementbyid("SortBy");
    var sort_by_dsc = getelementbyid("SortByDsc");
    if(dsc.checked) sort_by_dsc.value = "1"; else sort_by_dsc.value = "0";
    sort_id.value = sort_type;
    sort_text.value = sort_type_text;
    return Process_search_advance("refine");
}

function SelectAllPatents(sel,frm,all_) {
   
   sel_check = sel;
   save_all  = all_;
   if(frm!=''){
     select_all_form = frm;
   } else {
 	    frm = select_all_form ;
   }
	var f = getelementbyid(frm);
    var e;
    if(f) {
        for(i=0;i<f.elements.length;i++) {
            e = f.elements[i];
            if(e.type == "checkbox" && e.name.indexOf("check_")==0 && e.name != "check_desc") {
                e.checked = sel;
            }
        }


    }
}

function SelectTen(sel,frm) {
    SelectAllPatents(false,frm,0);
	sel_check = sel;
    var f = getelementbyid(frm);
    var e;
    var check_count = 0
    if(f) {
        for(i=0;i<f.elements.length;i++) {
            e = f.elements[i];
            if(e.type == "checkbox" && e.name.indexOf("check_")==0 && e.name != "check_desc" ) {
               // if ( check_count < 10 ){
                    e.checked = sel;
                    check_count++;
                //}
            }
        }


    }
    sel_check = "";
}



function AJAXProcessHtmlTabResponseClusterSearch()
{
    var ct="";
    var id_type="";
    if (http_request.readyState == 4)
    {
        if (http_request.status == 200) {
            ct = http_request.getResponseHeader('content-type');
            id_type = http_request.getResponseHeader('id-type');
            if(id_type == null) id_type="";
            if(ct.indexOf("text/html")>=0 && id_type.length>0) {
                result = http_request.responseText;
                if (clusterTree != null) delete clusterTree;
                setContent("cluster_tree_search_results", "");
                clusterTree = null;
                if(result.indexOf("MXML_TEXT:")>=0) {
                    var apl_txt = result.substr(0,result.indexOf("MXML_TEXT:"));
                    applet_xml_doc = result.substr(result.indexOf("MXML_TEXT:")+10);
                    applet_xml_query = getelementbyid("cluster_search_str");
                    mapViewApplet = null;
                    setContent("cluster_tree_search_results", apl_txt);
                //		    mapViewApplet.doStringGrok(applet_xml_query.value,  applet_xml_doc, "Federated","OpenSearch_Yahoo", "300","", "", "", "", "", "", "");
                } else {
                    setContent("cluster_tree_search_results", result);
                    InitClusterTree("li_my_query");
                }
            }
        }
    }
}

function InitClusterTree(vis_list) {
    if(clusterTree==null) {
        clusterTree = new JSDragDropTree();
        clusterTree.setTreeId('cluster_tree');
        clusterTree.setMaximumDepth(10);
        clusterTree.setMessageMaximumDepthReached('Maximum depth reached'); // If you want to show a message when maximum depth is reached, i.e. on drop.
        clusterTree.initTree();
        if(!vis_list) {
            clusterTree.expandAll();
        } else clusterTree.expandList(vis_list);
    }
}
function AJAXProcessHtmlTabResponse() {
    var ct="";
    var id_type="";
    if (http_request.readyState == 4)  {
        if (http_request.status == 200) {
            ct = http_request.getResponseHeader('content-type');
            id_type = http_request.getResponseHeader('id-type');
			
            if(id_type == null) id_type="";
            if(ct.indexOf("text/html")>=0 && id_type.length>0) {
                result = http_request.responseText;
                if(id_type == "settings_menu" && options_changed ==1){
					searchTools = [];
					saveSearches = [];
					searchTabs   = [];
					numSearches  = 0;
					options_changed = 0;
				}
				setContent(id_type, result);
                if(id_type=="search_patnum"){
                    num = detailArray.length;
                    detailArray[num] = result;
                }
                if (id_type == "pmt_tab_1") {
                    InitPMT(1);
                }
                if(id_type == "pmt_tab_2")  {
                    InitPMT(2);
                }
            } else if (ct.indexOf("javascript")>=0) {
                result = http_request.responseText;
                eval(result);
            } else {
                result = http_request.responseText;
                setContent(current_subtab, result);
            }
        }// end of 200 if
    } // end of 4 if
} // end of function 


function addItemsAnalyze(items) {
    num = analyzeArray.length;
    analyzeArray[num] = items;
	 
    var pats = items.split(";");
    for(i=0;i<pats.length;i++) {
        pnum = pats[i];
        if(!analyzeTabs[pnum]) {
            analyzeTabs[pnum] = pnum;
        }
        if(i==0) activate = pnum;
    }
    render_analyze_tab(pnum);
    onAnalyzeSubTabClick(activate);
    return false;
}


function render_analyze_tab(pnum) {
    var Left_navi_div="";
    var pn="";
    var div_content = "<table border=\"1\" width=\"100%\"><tr>";
    var div_content_detail="";
    var colspan = 0;
    var pn_div_text = new Array();
    for (key in analyzeTabs)  {
        pn = analyzeTabs[key];
        pn_div_id = getelementbyid("pat_div_"+pn);
        if(pn_div_id) {
            pn_div_text[pn] = pn_div_id.innerHTML;
        }
        div_content = div_content +
        "<td nowrap><a id=\"anal_pt_td_"+pn+"\" href=\"#\" onClick=\"onAnalyzeSubTabClick('"+pn+"');\">" + pn + "</a> <a href=\"#\" onClick=\"onAnalyzeSubTabCloseClick('"+pn+"');\">[x]</a></td><td><img src=\"/images/spacer.gif\" width=\"20\" height=\"30\" border=\"0\"></td>";
        //           "<td nowrap><a href=\"#\" onClick=\"onAnalyzeSubTabClick('"+pn+"');\">" + pn + "[x]</a></td><td><img src=\"/images/spacer.gif\" width=\"20\" height=\"30\" border=\"0\"></td>";
        colspan += 2;

    }
    colspan++;

    div_content=div_content + "<td width=\"100%\"></td></tr>";
    div_content=div_content + "<tr><td colspan=\""+colspan+"\">";
    for (key in analyzeTabs)  {
        pn = analyzeTabs[key];
		
        if(pn_div_text[pn]){
            div_content_detail=div_content_detail + "<div id=\"pat_div_"+pn+"\" >"+pn_div_text[pn]+"</div>";
			
			
        }else{
            div_content_detail=div_content_detail + "<div id=\"pat_div_"+pn+"\" ></div>";
		
        }

    }
    div_content=div_content + "</td></tr></table>";
    //ShowDiv("PatenDetailMain_FullText");//mush code
    //ShowDiv("patent_detail_top_navi");//mush code
    setContent("search_patnum",div_content_detail);
	
//setContent("patent_detail_top_navi",div_content);
}


function onAnalyzeSubTabClick(item) {
    getelementbyid("search_patnum").innerHTML = detail_message;
    detail_div = "";
    current_lft_nav_tab = "review";
    current_review_item = item;
    makeRequest('/patopen.php',"id="+item+"&id_type=search_patnum",AJAXAnalyzie);
}

function AJAXAnalyzie() {
    var ct="";
    var id_type="";
    if (http_request.readyState == 4)  {
        if (http_request.status == 200) {
            ct = http_request.getResponseHeader('content-type');
            id_type = http_request.getResponseHeader('id-type');
            if(id_type == null) id_type="";
            if(ct.indexOf("text/html")>=0 && id_type.length>0) {
                result = http_request.responseText;
                setContent(id_type, result);
                if(id_type=="search_patnum"){
                    num = detailArray.length;
                    detailArray[num] = result;
                    renderReviwTab();
                }
                if (id_type == "pmt_tab_1") {
                    InitPMT(1);
                }
                if(id_type == "pmt_tab_2")  {
                    InitPMT(2);
                }
            } else if (ct.indexOf("javascript")>=0) {
                result = http_request.responseText;
                eval(result);
            } else {
                result = http_request.responseText;
                setContent(current_subtab, result);
            }
        }// end of 200 if
    } // end of 4 if
} // end of function 

function onAnalyzeSubTabCloseClick(item) {
    current_analyzed_item = "";
    HideDiv("pat_top_bar");
    var prev = "";
    for (key in analyzeTabs)  {
        if(analyzeTabs[key]) {
            if(key == item) {
                delete analyzeTabs[item];
                break;
            }
            prev = key;
        }
    }
    render_analyze_tab();
    if(prev=="")  {
        for (key in analyzeTabs)  {
            if(analyzeTabs[key]) {
                prev = key;
                break;
            }
        }

    }


    if(prev!="") onAnalyzeSubTabClick(prev);

}




/***** PATENT TOOLBAR JS CODE  **********/
//  current_analyzed_item - current patent opened


function setValue(val){
    if ( document.getElementById(val).checked == true){
        document.getElementById(val).value = 1;
    } else {
        document.getElementById(val).value = 0;
    }
//alert(document.getElementById(val).value);
}

/**** END of PATENT TOLBAR JS CODE  *****/




function showAssignmentDIV(val){
    HideDiv("full_text_main_div");
    HideDiv("refrence_div_main");
    HideDiv("image_div_main");
    HideDiv("file_history_div_main");
    ShowDiv("assignments_div_main");
	getelementbyid("assignments_div_main").innerHTML = detail_message1;
    
	HideDiv("ref_options");
    makeRequest('/get_assignment.php?id_type=assignments_div_main&val='+val,"",AJAXProcessHtmlTabResponse);
}
function showFileHistryDIV(num){
    
    HideDiv("refrence_div_main");
    HideDiv("image_div_main");
    HideDiv("assignments_div_main");
    HideDiv("full_text_main_div");
    ShowDiv("file_history_div_main");
	getelementbyid("file_history_div_main").innerHTML = detail_message1;
    HideDiv("ref_options");
    makeRequest('/get_filedata.php?patent_id='+num+'&id_type=file_history_div_main',"",AJAXProcessHtmlTabResponse);
}

function show_setting_div (){
    ShowDiv("setting_div");
}
function hide_setting_div (){
    HideDiv("setting_div");
}
