function addToMyLocations(id) {
    $.get(absolute_path + 'ajax.php?cmd=addToMyLocations',
        { 
            id: id
        },
        function(data)
        {
        	updateMyLocationLeftCol();
        }
     );
}

function removeFromMyLocations(id) {
    $.get(absolute_path + 'ajax.php?cmd=removeFromMyLocations',
        { 
            id: id
        },
        function(data)
        {
            updateMyLocationLeftCol();
        }
     );
}


function updateMyLocationLeftCol() {
	$("#mylocation_list").load(absolute_path+'ajax.php?cmd=displayMyWatchlistLeftCol');
}

function addJqueryMyLocationFunctionality() {
    // binds myLocations Icon to removing/adding ajax
    
    $("img.myLocationIcon").unbind("click"); /* entferne alte listener, falls nach einem ajax-aufruf neu initialisiert wird */
    
    $("img.myLocationIcon").click(function () {
    	var class_split = $(this).attr('class').split(' ');
        var classname_2 = class_split[1]; 
        var classname_2_split = String(classname_2).split('_'); 
        var id = classname_2_split[1];
        var text = '';
        // unchecked
        if (this.src.indexOf("inaktiv") >= 0) {
            
            $('img.'+classname_2).each(function(idx, img) {
            	var size = $(this).attr('width');
                this.src = '/img/icons/mylocations_icon_'+size+'x'+size+'_akti.png';
            });

            if(class_split[2] !== undefined) {
            	text = $('.txtEntfernenMylocations').val();
            }
                        
            addToMyLocations(id);
            


        } else {
        	// checked
            $('img.'+classname_2).each(function(idx, img) {
            	var size = $(this).attr('width');
				this.src = '/img/icons/mylocations_icon_'+size+'x'+size+'_inaktiv.png';   
            });
            
            if(class_split[2] !== undefined) {
				text = $('.txtHinzuMylocations').val();
            }
                     
            removeFromMyLocations(id); 

        }
        
        if(class_split[2] !== undefined) {
       		$('#'+class_split[2]).html(text);
		}
        return false;
        
    });
}
