it may cost you to get it repaired depending on the fault. Cracked glass and water damage are not covered under the warranty and will cost to fix but if the phone developed a fault from the manufacturing process then it will be replaced free of charge.
To answer your question yes................If you jailbreak your phone it *technically* voids your warranty, but so long as you rstore to stock settings, and do not tell Apple that you jailbroke then yes.............Your warranty is untouched.
I have been jailbreaking for years, and have got my iPhone replaced a few times along with my iPod Touch 4G. All you have to do to maintain your warranty beofe taking in for service is to unjailbreak(restore) and update to the latest iOS.
As longs you you restore your phone, then Apple will never now that you jailbroke it. But if you send in/take in a jailbroken iPhone they will know it was jialbroken and deny you service (unless you happen to get a Geneus that doesnt care....which is slim).