function show_sub_tree(id,count){
	if($(id).style.display=='none'){
		//new Effect.Appear(id,{ duration: 0.5 });
		$(id).show();
	} else { 
		//new Effect.Fade(id,{ duration: 0.5 });
		$(id).hide();
	}
}

function show_sub_tree2(id,indicator,item_id,dest,product_id,table_name){
	if($(id).style.display=='none'){
		
//'id'=>$id,'dest'=>'standards', 'where' => 'section_level > 0'

	new Ajax.Updater(id,'/standards/list_to_add_with_parent', 
	     {asynchronous:true, evalScripts:true, 
	     onComplete:function(request, json){
	      $(indicator).hide();
	    	$(id).show();
	     },
	     onLoading:function(request, json){
	      $(indicator).show();
	     }, parameters:'id='+product_id+'&level=1&dest='+dest+'&item_id='+item_id+'&table_name='+table_name
	     });
    
		
		//new Effect.Appear(id,{ duration: 0.5 });
		
	} else { 
		//new Effect.Fade(id,{ duration: 0.5 });
		$(id).hide();
	}
}


function show_assessment_sub_tree(id,indicator,item_id,dest,product_id,table_name){
	if($(id).style.display=='none'){
		
//'id'=>$id,'dest'=>'standards', 'where' => 'section_level > 0'

	new Ajax.Updater(id,'/assessments/list_to_add_with_parent', 
	     {asynchronous:true, evalScripts:true, 
	     onComplete:function(request, json){
	      $(indicator).hide();
	    	$(id).show();
	     },
	     onLoading:function(request, json){
	      $(indicator).show();
	     }, parameters:'id='+product_id+'&level=1&dest='+dest+'&item_id='+item_id+'&table_name='+table_name
	     });
    
		
		//new Effect.Appear(id,{ duration: 0.5 });
		
	} else { 
		//new Effect.Fade(id,{ duration: 0.5 });
		$(id).hide();
	}
}

function show_sub_tree_search(id,indicator,item_id,dest,product_id,table_name){
	if($(id).style.display=='none'){
		
//'id'=>$id,'dest'=>'standards', 'where' => 'section_level > 0'

	new Ajax.Updater(id,'/'+dest+'/list_to_search_with_parent', 
	     {asynchronous:true, evalScripts:true, 
	     onComplete:function(request, json){
	      $(indicator).hide();
	    	$(id).show();
	     },
	     onLoading:function(request, json){
	      $(indicator).show();
	     }, parameters:'id='+product_id+'&level=1&dest='+dest+'&item_id='+item_id+'&table_name='+table_name
	     });
    
		
		//new Effect.Appear(id,{ duration: 0.5 });
		
	} else { 
		//new Effect.Fade(id,{ duration: 0.5 });
		$(id).hide();
	}
}

function add_to_search(id,indicator,txt,contr,clicked,tree){
	var dest_id = 'search_'+contr; 
	var dest_url = '/'+contr+'/added_elements_serach';
	$(clicked).style.fontWeight = 'bold';
		
new Ajax.Request('/search/save_in_session', 
     {asynchronous:true, evalScripts:true, 
     onComplete:function(request, json){
	     //$(dest_id).hide();
	     //new Effect.BlindUp('my_'+contr,{ duration: 1.0 });
	     //new Effect.Fade('my_'+contr,{ duration: 1.0 });


		if(tree){
			var resp = request.responseText;
			var tab = resp.split("_");
			for(i=0; i<tab.length; i++){
	  			if($(contr+'_id_'+tab[i]))$(contr+'_id_'+tab[i]).style.fontWeight = 'bold';
			}
		}

	     new Ajax.Updater(dest_id,dest_url, 
     		{asynchronous:true, evalScripts:true, 
     		onComplete:function(request, json){
      		if(contr!='subjects')	$(indicator).hide();
      			//new Effect.BlindDown('my_'+contr,{ duration: 1.0 });
      			//new Effect.Appear('my_'+contr,{ duration: 1.0 });
      			//$('my_'+contr).show();
     if(contr=='subjects'){
    	new Ajax.Updater('standards_new','/standards/list_to_search', 
	     {asynchronous:true, evalScripts:true, 
	     onComplete:function(request, json){
	      $(indicator).hide();
	     $('standards_new').show();
	     
	     },
	     onLoading:function(request, json){
	    //  $(indicator).show();
	     }, parameters:'id=1&level=1&cont=standards&dest=standards'
	     });
    }
      			
  			}, parameters:'dest='+contr});
     },
     onLoading:function(request, json){
      $(indicator).show();
     },parameters:'index='+contr+'&txt='+txt+'&id='+id+'&tree='+tree
    });
    
   /*       			    if(contr=='subjects'){
    	new Ajax.Updater('standards_new','/standards/list_to_search', 
	     {asynchronous:true, evalScripts:true, 
	     onComplete:function(request, json){alert('a');
	     // $(indicator).hide();
	     $('standards_new').show();
	     },
	     onLoading:function(request, json){
	    //  $(indicator).show();
	     }, parameters:'id=1&level=1&cont=standards'
	     });
    }
*/
}


function clean_form(indicator){
	new Ajax.Updater('form_search','/search/show_clean_form', 
	     {asynchronous:true, evalScripts:true, 
	     onComplete:function(request, json){
	      $(indicator).hide();
	         	new Ajax.Updater('standards_new','/standards/list_to_search', 
	     {asynchronous:true, evalScripts:true, 
	     onComplete:function(request, json){
	      $(indicator).hide();
	     $('standards_new').show();
	     
	     },
	     onLoading:function(request, json){
	    //  $(indicator).show();
	     }, parameters:'id=1&level=1&cont=standards&dest=standards'
	     });
	     
	     },
	     onLoading:function(request, json){
	      $(indicator).show();
	     }});
}


function show_element(img,id){
	if($(id).style.display=='none'){
		img.src="/images/img/ico_05up.gif";
		new Effect.Appear(id,{ duration: 0.5 });
	} else { 
		new Effect.Fade(id,{ duration: 0.5 });
		img.src="/images/img/ico_05.gif";
	}
}


function remove_id(id,index,indicator,clicked){
	if($(clicked))$(clicked).style.fontWeight = 'normal';
	var obj =  index + "_" + id;
	new Ajax.Request('/search/remove_from_session', 
	     {asynchronous:true, evalScripts:true, 
	     onComplete:function(request, json){
	     if(index!='subjects') $(indicator).hide();
	      $(obj).remove();
	      
   if(index=='subjects'){
    	new Ajax.Updater('standards_new','/standards/list_to_search', 
	     {asynchronous:true, evalScripts:true, 
	     onComplete:function(request, json){
	      $(indicator).hide();
	     $('standards_new').show();
	     
	     },
	     onLoading:function(request, json){
	    //  $(indicator).show();
	     }, parameters:'id=1&level=1&cont=standards&dest=standards'
	     });
    }	      
	      
	      
	     },
	     onLoading:function(request, json){
	      $(indicator).show();
	     },parameters:'index='+index+'&id='+id
	    });
}


function show_my_element(IDHTML,URL){
	var LOADING_ICON = 'content_menu-top-loading-indicator';
	new Ajax.Updater({success: IDHTML},URL, 
	     {asynchronous:true, evalScripts:true, 
	     onComplete:function(request, json){
	      //new Effect.Appear(IDHTML,{ duration: 1.0 });
				$(IDHTML).show();
	      $(LOADING_ICON).hide();
	      new Effect.Appear($(IDHTML),{duration:1.0})
	     },
	     onLoading:function(request, json){
	      $(LOADING_ICON).show();
	      $(IDHTML).hide();
	     }
	    });
}