How can I get the content type of a node given its node ID?
If the value returned from arg(2) is a node ID, you can load the node with node_load(). This will return a node object, which contains its content type.

$node = node_load(arg(2));
$content_type = $node-&gt;type;