Read the shader workshops:
http://www.conitec.net/shaders/After you are done with them (!) just take the diffuse shader as a basis and transform it into a multitex terrain shader yourself. Use "lerp" to blend between different textures (multiple tex2D calls from different texture samplers) based on some kind of blendmap information but multiply the textures/ colors with detail map colors first (where you scale InTex with some variables/ vecSkills, like Mr. Lotter said).