    var healProfiles = new Array();
	var currentProfile;

	formatPrice = function(node){
		
		var value =  $(node).text();
		var modifyValue = value.replace(' ','');
		
		if(!isNaN(modifyValue)){
			return modifyValue;
		}
		else return value;
	}

	function initTablesorter(healingID)
	{
		if($('#sortTable'+healingID+' tbody td').length > 0)
		{
			$('#sortTable'+healingID).tablesorter({sortList:[[1,0]],headers: {0:{sorter: false},2:{sorter: false},3:{sorter: false},4:{sorter: false},5:{sorter: "digit"} },  textExtraction: formatPrice});
		}
	}

    function showHideObjects(healingID)
    {
    	if(currentProfile == 0)
    	{
            if (healProfiles[healingID] == "show")
            {
                healProfiles[healingID] = "showing";
                jQuery('#divHealObj'+healingID).slideUp(1000, function(){ 
                    healProfiles[healingID] = "hide";
                    var nodeslist = jQuery('#divHeal'+healingID);
                    nodeslist[0].className = nodeslist[0].className.replace(" selected", "");                    
                });

            }
            else if (healProfiles[healingID] == "hide")
            {
                healProfiles[healingID] = "hiding";
                jQuery('#divHealObj'+healingID).slideDown(1000, function(){

                    healProfiles[healingID] = "show";
                    var nodeslist = jQuery('#divHeal'+healingID);
                    nodeslist[0].className += " selected";
                });

            }    
		}
    }

    function SelectHealing(healingID)
    {
        if (!healProfiles[healingID])
        {
            jQuery('#divHealObj'+healingID).load("/twforms/index.php?form=objects_by_heal&healing_id="+healingID,
            	{},
				function(){
					healProfiles[healingID] = "hide";
					initTablesorter(healingID);
					showHideObjects(healingID);
				}
            );
        }
        else
        {
	        showHideObjects(healingID);
        }
    }
    
    
    function current_healing()
	{
		var url = location.href;
		var reg = /[\?\&]healing_id=([0-9]+)/;
		var substr =reg.exec(url); 
		if(substr != null) return substr[1];
		return 0;
	} 
    
	jQuery(document).ready(function(){
	
		currentProfile = current_healing();
        var loadedKurorts = jQuery('.kurort_title,.kurort_titleinside');
        if (loadedKurorts.size() > 0)
        {
            loadedKurorts[0].onclick();
        } 
        
	});
