Magic damage is almost always associated with an element. Non-elemental damage is equivalent to force/sonic damage and nothing can be weak or resist it nor can you swap to it if an ability or class feature would allow you to swap elements. Non-elemental does not ignore hardness and is treated as an energy source. Physical damage is done by weapons unless otherwise noted. General rule of the elements is this: wind is strong against earth, which is strong against lightning, which is strong against water, which is strong against fire, which is strong against ice, which is strong against wind. Wind is weak to ice, which is weak to fire, which is weak to water, which is weak to lightning, which is weak to earth, which is weak to wind. Shadow and holy are both strong against each other and weak to each other. See image above for a better understanding.
If a creature is struck by elemental damage of an element it is weak to, it takes 1.5x the normal damage. When a spell of the appropriate element is cast upon the creature and forces a saving throw, the creature suffers a -2 penalty on the saving throw. A spellcaster casting a spell of an element that a creature with elemental resistance is weak to, he gets a +2 bonus on his caster level check.
If a creature is struck by elemental damage it is resistant to, it instead takes half that much damage (rounded down, minimum 1). Creatures get a +2 bonus to saving throws against spells of an element they are resistant to.
Some creatures are immune to specific elements. All spells of the chosen element have no effect whatsoever on a creature immune to that element.
Some creatures are healed by damage of a particular element. For example, the undead are healed by shadow damage. In this case, they are immune to non-damaging effects of spells of the appropriate element, and are instead healed when a spell of the element would normally deal damage (for an equal amount). If a creature has absorption to an element disregard any resistance to the same element.
Different from spell resistance, elemental resistance reduces damage by the number and element the creature has. For example, if a creature with 5 Elemental (Fire) resistance was struck by a Fire II spell for 8 points of fire damage, the creature would only take 3 points of fire damage.