﻿var RE;
var re = function(id,mode)
{
	// Properties
	this.tabs={
		"tab_body":{
			"shown":false,
			"tab_type":1
			
		},
		"tab_rep_pub":{
			"shown":false,
			"tab_type":2
			
		},
		"tab_workgroup": {
			"shown":false,
			"tab_type":3
			
		},
		"tab_mess": {
			"shown":true,
			"tab_type":0
			
		}
	}
	

	
	
	this.id	= id ;
	this.mode=mode;
	RE=this;

}

re.prototype.showTab= function(tab_id){
	
	var tab_type=this.tabs[tab_id]["tab_type"];
	var shown=this.tabs[tab_id]["shown"];
	setCookie("active_tab",tab_id,1);
	for (id in this.tabs){
		var tab=this.tabs[id];
		var tab_btn=getObj("tab_btn"+tab.tab_type);
		var tmp=getObj(id);
		
		if(id!=tab_id){
			if(tmp){
				tmp.style.display='none';
				
			}
			
			if(tab_btn){
				
				tab_btn.className="tab_disabled";
				tab_btn.onmouseout=function (){
					this.className="tab_disabled";
				}
				tab_btn.onmouseover=function (){
					this.className="tab_over";
				}
				
			}
		}else{
			if(tmp){
				tmp.style.display='';
				//Effect.Appear(tmp.id)
			}
			
			if(tab_btn){
				
				tab_btn.className="tab_simple";
			
				tab_btn.onmouseout=function (){
					this.className="tab_simple";
				}
				tab_btn.onmouseover=function (){};
			}
		}
		
	}
	
	

	if(!shown){
		str="getinfo=true&tab_type="+tab_type+"&id_research="+this.id;
		if(this.mode=="editable"){
			str+="&editable=true";
		}
		//this.send(tab_id,"research_get_result.php","POST",str,this.onShowTab);
		request_to(tab_id,"research_get_result.php","POST",str);
		
	}
}

re.prototype.showTabBody= function(){
	var tab_id="tab_body";
	this.showTab(tab_id);
}

re.prototype.showTabTitle= function(){
	var tab_id="tab_rep_pub";
	this.showTab(tab_id);
}
re.prototype.onShowTab= function(element){
	this.tabs[element.id]["shown"]=true;
}



function request_to(element_id, url, method, param){ 
    var element = document.getElementById(element_id); 
    var str_method=method.toLowerCase();
    element.innerHTML = '<div align="center" style="width:250px"><img src="images/loader.gif" border="0" width="16" height="16"></div>'; 
    xmlhttp.open(method, url, true); 
    if(str_method=="get"){

    }else{
    	if(str_method=="post"){
    		   	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
    	}
    }

    xmlhttp.onreadystatechange = function() { 
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { 
            element.innerHTML = xmlhttp.responseText; 
            onRequestReady(element);
        } 
    } 
    xmlhttp.send(param); 
}
function onRequestReady(element){
	RE.onShowTab(element);	
}
