    //This function sends an Ajax Request to the controller.
    function applyfilter(from_where)
        {
            var ex_id=new Array();
            var tg_id=new Array();
            var ip= document.getElementsByClassName('get_selected_experts');
            var ix= document.getElementsByClassName('select_experts');
            var sel_tag=document.getElementsByClassName('get_selected_tage');
            var tagcheck=document.getElementsByClassName('select_tags');
            
             for(is=0,ia=0;ia<sel_tag.length;ia++)
             {
    			if(tagcheck[ia].checked==true)
    			{
        			tg_id[is]=sel_tag[ia].id;
        			is++;
    			}
    		}
    
            for(ik=0,ij=0;ij<ip.length;ij++)
            {
    			if(ix[ij].checked==true)
    			{
        			ex_id[ik]=ip[ij].id;
        			ik++;
    			}
    		}
    		
    		var are_tags_and_experts_are_added = check_tags_and_experts_if_added(ip.length,sel_tag.length);
    		
    		if(are_tags_and_experts_are_added == "yes")
    		{
                if(from_where == "tags")
                {
                    if(tg_id.length > 0)
                    {
                        //This is to empty the div where the error message is shown and to clear the inner HTML of that div.
                 	    Effect.Fade('display_some_times',{duration:1.7});
                 	    document.getElementById('display_some_times').innerHTML = '';
                		
                		new Ajax.Updater('testdiv', '/my_portal/apply_filter?sel_exp='+ex_id+'&sel_tag='+tg_id, {asynchronous:true, evalScripts:true,onLoading:function(request){Element.show('loading_image');vipe_out();},onComplete:function(request){after_filter();show_exp();Element.hide('loading_image');close_tag_result();appear_a_bit_late();}});return false;
                    }
                    else
                    {
                        close_tag_result();
                        display_no_expert_selected_message('tags');
                    }
                }
                else
                {
                    if(ex_id.length > 0)
                    {
                        if(tg_id.length > 0)
                        {
                            //This is to empty the div where the error message is shown and to clear the inner HTML of that div.
                     	    Effect.Fade('display_some_times',{duration:1.7});
                     	    document.getElementById('display_some_times').innerHTML = '';
                    		
                    		new Ajax.Updater('testdiv', '/my_portal/apply_filter?sel_exp='+ex_id+'&sel_tag='+tg_id, {asynchronous:true, evalScripts:true,onLoading:function(request){Element.show('loading_image');vipe_out();},onComplete:function(request){after_filter();show_exp();Element.hide('loading_image');close_tag_result();appear_a_bit_late();}});return false;
                        }
                        else
                        {
                            close_tag_result();
                            close_sort_type();
                            display_no_expert_selected_message('tags');
                        }
                    }
                    else
                    {
                        close_tag_result();
                        close_sort_type();
                        display_no_expert_selected_message('experts');
                    }
                }
    		}
    		
    //    close_tag_result();
    }

    //A function to display the error message
    function check_tags_and_experts_if_added(ip,sel_tag)
    {
        if(ip == 0)
        {
           close_tag_result();
           close_sort_type();
           display_no_expert_selected_message('add_expert');
           return "no";
        }
        else
        {
            if(sel_tag == 0)
            {
               close_tag_result();
               close_sort_type();
               display_no_expert_selected_message('no_tags');
               return "no";
            }
            else
            {
               return "yes";
            }
        }
    }

    //This function is to close the tagresult div ie., the div with all the suggeton Tags 
    function close_tag_result()
    {
        if(variable_for_sliding_up == "tagresult")
        {
            appear_bit_late('tagresult');
            variable_for_sliding_up = "";
        }
        //this is to invert back the Tags Image to the default
        inactive_image(123,'arrow_down','arrow_up');
    
        //This is to revert back the Tags Image.
        document.getElementById('tags_mouse_over').className="no_pop_up";
        
        //This is to replace the mouseout and mouseover attributes of the Tags.
        if(on_mouse_out_for_tags != "")
        {
            replace_mouse_overs_for_this_element('tags_mouse_over');
        }
    
    }
    
    //This function is to close the sort_type div ie., the div with all the Sort Choices. 
    function close_sort_type()
    {
        if(variable_for_sliding_up == "sort_type")
        {
    //        setTimeout('appear_bit_late()',1200);
              appear_bit_late('sort_type');
              variable_for_sliding_up = "";
        }
        inactive_image(123,'arrow_down2','arrow_up2');
        document.getElementById('sort_mouse_over').className="no_pop_up";
        
        //This is to replace the mouseout and mouseover attributes of the Tags.
        if(on_mouse_out_for_sort != "")
        {
            replace_mouse_overs_for_this_element('sort_mouse_over');
        }
    }
    
    //This function changes the Images of the filter Buttons on checking the check boxes.
    function on_check_exp()
    {
        if(document.getElementById('filter1'))
            document.getElementById('filter1').style.display="none";
        if(document.getElementById('filter2'))
            document.getElementById('filter2').style.display="block";
        if(document.getElementById('filter3'))
            document.getElementById('filter3').style.display="none";
        if(document.getElementById('filter4'))
            document.getElementById('filter4').style.display="block";
    }
    
    //This function just alters the filter Images(near the Experts and in the Tags popup.) after completing the functionality.
    function after_filter()
    {
        if(document.getElementById('filter1'))
        document.getElementById('filter1').style.display="block";
        if(document.getElementById('filter2'))
        document.getElementById('filter2').style.display="none";
        if(document.getElementById('filter3'))
        document.getElementById('filter3').style.display="block";
        if(document.getElementById('filter4'))
        document.getElementById('filter4').style.display="none";
    }