		var moving = false;				// er verið að færa eitthvað?
		var current_item_id = null;		// id númer á þeirri mynd sem er verið að færa
		var move_to_item_id = null;		// id númer á þeirri mynd sem á að færa til
		
		var move_temp = null;			// bráðabirgða object fyrir move image
		var cur_temp = null;			// bráðabirgða object fyrir current image
		
		var move_direction = null;		// sú átt sem myndin á að færast í : before | after

		// bý til þrjár myndir sem ég nota til að "hover-a"
		// myndin með ör til vinstri
		var hover_left = new Image();
		hover_left.src = 'bin/web/images/img_left.gif';
		
		// myndin með ör til hægri
		var hover_right = new Image();
		hover_right.src = 'bin/web/images/img_right.gif';
		
		// myndin sem skilgreinir þá mynd sem á að færa
		var replace = new Image();
		replace.src = 'bin/web/images/img_replace.gif';
		
		function moveItem(id)
		{
			if(moving)
			{
				moving = false;
				replaceCurrentImage();
			}
			
			moving = true;
			current_item_id = id;
			
			replaceCurrentImage();
		}
		
		function replaceCurrentImage()
		{
			// sækja myndina sem object
			// sæki fyrst parent div elementið sem hefur id
			parentObj = document.getElementById(current_item_id);
			
			// finn "öll" img tög undir div'inu
			imgObj = parentObj.getElementsByTagName('img');

			if(cur_temp == null)
			{
				cur_temp = new Image();
				cur_temp.src = imgObj[0].src;
			}
			
			if(moving)
			{
				imgObj[0].src = replace.src;
			}
			else
			{
				imgObj[0].src = cur_temp.src;
				cur_temp = null;
			}
		}
		
		function getItemId(obj)
		{
			parentObj = obj.parentNode;
			return parentObj.id;
		}
		
		function doAction(obj)
		{
			move_to_item_id = getItemId(obj);
			
			if(moving && move_to_item_id != current_item_id)
			{
				doMove();
			}
			else
			{
				moving = false;
				move_temp = null;
				if(current_item_id != null)
					replaceCurrentImage();
			}
		}
		
		function doImageOver(obj)
		{
			if(moving)
			{
				if(move_temp == null)
				{
					move_temp = new Image();
					move_temp.src = obj.src;
				}

				if(getItemId(obj) != current_item_id)
				{
					if(getItemId(obj) < current_item_id)
					{
						obj.src = hover_left.src;
						move_direction = 'before';
					}
					else
					{
						obj.src = hover_right.src;
						move_direction = 'after';
					}
				}
			}
		}
		
		function doImageOut(obj)
		{
			if(moving)
			{
				obj.src = move_temp.src;
				move_temp = null;
			}
		}
		
		function doMove()
		{
			moving = false;
			document.location.href = 'bin/actions/move_image.php?trip='+trip_id+'&cur_id='+ current_item_id +'&move_id='+ move_to_item_id +'&keyword='+ move_direction;
		}
		
		
		function deleteItem(id)
		{
			if(confirm("Ertu viss um að þú viljir eyða þessari mynd?"))
				document.location.href = 'bin/actions/delete_image.php?id='+ id+'&from='+ trip_id;
		}