$.extend(_fw.meth,{	
	forms:{
		target:'input[type=text],input[type=password],input[type=tel],input[type=email],textarea',
		buttons:'a[rel=reset],a[rel=submit]',
		event:'click',
		validate:true,
		invalidCl:'invalid',
		errorCl:'error',
		errorMsg:'Please enter a valid values',
		mailHandlerURL:'bin/MailHandler.php',
		ownerEmail:'support@guardlex.com',
		stripHTML:true,
		smtpMailServer:'localhost',
		backBu:false,
		responseHTML:'<div class="contact-form-response"><p>Contact form submitted!<br>We will be in touch soon.</p><br></div>',
		afterFu:function(){},
		errorShow:function(el){
			var _=this
			el.parent().addClass(_.invalidCl)
		},
		errorHide:function(el){
			var _=this
			el.parent().removeClass(_.invalidCl)
		},
		validateFu:function(el,type){
			var _=this
			;({
				name:function(){return /^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/.test(this.val())},
				email:function(){return /^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i.test(this.val())},
				tel:function(){return /^\+?(\d[\d\-\+\(\) ]{5,}\d$)/.test(this.val())}
			})[type].call(el)
			?_.errorHide(el)
			:_.errorShow(el)
		},
		valFu:function(){
			var _=this,
				elms=_.elms=
			([$('input.name',_.form).each(function(){
				var th=$(this).bind('blur vldtn',function(){
					_.validateFu(th,'name')
				})
			}),
			$('[type=email]',_.form).each(function(){
				var th=$(this).bind('blur vldtn',function(){
					_.validateFu(th,'email')
				})
			}),
			$('[type=tel]',_.form).each(function(){
				var th=$(this).bind('blur vldtn',function(){
					_.validateFu(th,'tel')
				})
			}),
			$('textarea',_.form).each(function(){
				var th=$(this).bind('blur vldtn',function(){
					if(this.value.length<20)
						_.errorShow(th)
					else
						_.errorHide(th)
				})
			})])
		},
		submitFu:function(){
			var _=this,
				datas={}
			$(_.elms).each(function(){
				$(this).trigger('vldtn')
			})
			if(_.form.has('.'+_.invalidCl).length)
				alert(_.errorMsg)
			else
				datas={
					name:$('.name',_.form).val(),
					email:$('.email',_.form).val(),
					message:$('.message',_.form).val(),
					owner_email:_.ownerEmail,
					stripHTML:_.stripHTML
				},
				$.ajax({
					type: "POST",
					url:_.mailHandlerURL,
					data:datas,
					success: function(){
						_.showFu()
					}
				})			
		},
		showFu:function(){
			var opt=this
			opt.form.parent().height(opt.form.parent().height())
			opt.form.fadeOut(function(){
				opt.response=$('<div>'+opt.responseHTML+'</div>')
					.width(opt.form.width())
					.css({minHeight:opt.form.outerHeight(),width:opt.form.outerWidth()})
				if(opt.backBu)
					opt.backBu=$(opt.backBu),
					opt.response.append(opt.backBu),
					opt.backBu.click(function(){
						opt.hideResFu()
						opt.form[0].reset()
						return false
					})
				opt.form.before(opt.response)
				opt.form.parent().height('auto')
				
				opt.afterFu()
			})
		},
		hideResFu:function(){
			var opt=this
			opt.form.parent().height(opt.form.parent().height())
			opt.response.remove()
			opt.form.fadeIn(function(){
				opt.form.parent().height('auto')
			})
		},		
		init:function(opt){
			var form=opt.form=this,
				inputs=opt.inputs=$(opt.target,form)
			if(opt.validate)
				opt.valFu()
			inputs.each(function(){
				var th=$(this)
				th.data({defValue:th.attr('value')})
				th
					.bind('focus',function(){
						if(th.attr('value')==th.data('defValue'))
							th.attr({value:''})
					})
					.bind('blur',function(){
						if(th.attr('value')=='')
							th.attr({value:th.data('defValue')})
					})					
			})
			$(opt.buttons,form).each(function(){
				var th=$(this)
				th.bind(opt.event,function(){
					if(this.rel=='submit')
						opt.submitFu()
					else
						form[0][this.rel](),
						form.find('.'+opt.invalidCl).removeClass(opt.invalidCl)
					return false
				})
			})
		}
	},
	shadowBox:{
			target:false,
			showEv:'click',
			closeBu:'a.close',
			fader:true,
			duration:400,
			faderCSS:{
				position:'fixed',
				left:0,
				top:0,
				bottom:0,
				right:0,
				zIndex:9999,
				opacity:.7,
				background:'#000'
			},
			boxCSS:{
				position:'fixed',
				left:'50%',
				top:'50%',
				zIndex:9999
			},
			callback:function(){},
			preFu:function(){
				var _=this
				if(_.fader)
					_.fader=$('<div>')
						.css(_.faderCSS)
						.bind(_.showEv,function(){
							_.hideFu()
							return false
						})
				_.box=$('<div>')
					.css(_.boxCSS)
					.append(_.target)
			},
			showFu:function(){
				var _=this
				_.fader
					.appendTo('body')
					.css({opacity:0})
					.stop()
					.animate({
						opacity:_.faderCSS.opacity
						},{
						duration:_.duration,
						complete:function(){
							_.box
								.appendTo('body')
								.css({
									marginLeft:-_.box.width()/2,
									marginTop:-_.box.height()/2
								})
								.hide()
								.slideDown(_.duration,function(){
									_.callback()
								})
						}						
						})
			},
			hideFu:function(){
				var _=this
				_.box.slideUp(function(){$(this).detach()})
				_.fader
					.stop()
					.animate({
						opacity:0
						},{
						duration:_.duration,
						complete:function(){
							_.fader.detach()
						}
					})
			},
			init:function(_){
				var target=_.target=$(this)
				if(!target.length)
					return false
				else
					_.preFu()
				if(_.links)
					$(_.links).live(_.showEv,function(){
						_.showFu()
						return false
					})
				if(_.closeBu)
					$(_.closeBu).live(_.showEv,function(){
						_.hideFu()
						return false
					})
			}
		}
})
