;(function($,undefined){
	var _timer=[],
		_fw=window._fw=function(){
			var argms=arguments
			this.each(function(){
				var th=$(this)					
				for(var i=0,opt={};i<argms.length;i++)
					if(typeof argms[i]==typeof '')
						if(_fw[argms[i]]!=undefined)
							$.extend(opt,_fw[argms[i]]),
							th.data(argms[i],opt)
						else
							void(0)//coming soon ajax script loader
					else
						if(typeof argms[i]==typeof {})
							$.extend(opt,argms[i])
				if(th.data('opt'))
					$.extend(opt,th.data('opt'))
				opt.init.call(th,opt)
			})			
			return this
		}
		
	//modules
	_fw=$.extend(_fw,{
		"_ajaxSlider":{
			spinner:false,
			navLinks:'a[rel=nav]',
			pagArea:'>a',
			pagActiveCl:'active',
			pagEv:'click',
			pagRefreshEv:'_pagRefresh',
			showEv:'_show',
			changeEv:'_change',
			pagination:false,
			prevEv:'_prev',
			nextEv:'_next',
			nextBu:false,
			prevBu:false,
			animationCallback:function(){},
			pagFu:function(){
				var opt=this,
					pags=opt.pags=$(opt.pagination)
				pags.parent()
					.delegate(opt.pagination+':not(.'+opt.pagActiveCl+')'+(opt.pagArea?' '+opt.pagArea:''),opt.pagEv,function(){
						var th=$(this)
						pags.removeClass(opt.pagActiveCl)
						th.praParent('li').addClass(opt.pagActiveCl)
						opt.changeFu(th)
						return false
					})
					.delegate(opt.pagination+'.'+opt.pagActiveCl+(opt.pagArea?' '+opt.pagArea:''),opt.pagEv,function(e){
						return false
					})
				opt.holder.trigger(opt.pagRefreshEv)
			},
			changeFu:function(data){
				var opt=this,
					url=data.attr('href')
				opt.holder.data({url:url})
				opt.showFu()
				opt.holder.trigger(opt.changeEv)
			},
			nextFu:function(){
				var opt=this,
					act=opt.act=opt.pags.parent().find('.'+opt.pagActiveCl),
					next=act.next()
				if(next.length)
					opt.pags.removeClass(opt.pagActiveCl),
					next.addClass(opt.pagActiveCl),
					opt.changeFu(opt.pagArea?next.find(opt.pagArea):next),
					opt.holder.trigger(opt.pagRefreshEv)
				else
					opt.pags.removeClass(opt.pagActiveCl),
					opt.act=opt.pags.eq(0).addClass(opt.pagActiveCl),
					opt.changeFu(opt.pagArea?opt.act.find(opt.pagArea):opt.act),
					opt.holder.trigger(opt.pagRefreshEv)
			},
			prevFu:function(){
				var opt=this,
					act=opt.act=opt.pags.parent().find('.'+opt.pagActiveCl),
					next=act.prev()
				if(next.length)
					opt.pags.removeClass(opt.pagActiveCl),
					opt.act=next.addClass(opt.pagActiveCl),
					opt.changeFu(opt.pagArea?next.find(opt.pagArea):next),
					opt.holder.trigger(opt.pagRefreshEv)
				else
					opt.pags.removeClass(opt.pagActiveCl),
					opt.act=opt.pags.eq(-1).addClass(opt.pagActiveCl),
					opt.changeFu(opt.pagArea?opt.act.find(opt.pagArea):opt.act),
					opt.holder.trigger(opt.pagRefreshEv)
			},
			showFu:function(){
				var opt=this,
					holder=opt.holder,
					spinner=opt.spinner,
					url=holder.data('url')
				holder.empty()
				holder.append(spinner)
				
				holder.load(url,{},function(){					
					spinner.detach()
					opt.animationCallback.call(holder,opt)
				})
				holder.trigger(opt.showEv,url)
			},
			init:function(opt){
				var holder=opt.holder=this,
					tmp,
					spinner=opt.spinner=$(opt.spinner,holder)

				if(opt.pagination)	
					opt.pagFu()
				
				if(opt.navLinks)
					$(opt.navLinks).live(opt.pagEv,function(){
						var th=$(this),
							tmp
						if((tmp=th.data('opt'))!=undefined&&tmp.clearPags)
							$(opt.pagination).removeClass(opt.pagActiveCl)
						opt.changeFu(th)
						return false
					})

				holder
					.bind(opt.nextEv,function(){
						opt.nextFu()
					})
					.bind(opt.prevEv,function(){
						opt.prevFu()
					})
				if(opt.nextBu)
					opt.nextBu=$(opt.nextBu),
					opt.nextBu.bind('click',function(){
						opt.nextFu()
						return false
					})
				if(opt.prevBu)
					opt.prevBu=$(opt.prevBu),
					opt.prevBu.bind('click',function(){
						opt.prevFu()
						return false
					})
				holder.data({opt:opt})
			}
		},
		"_forms":{
			target:'input[type=text],input[type=password],input[type=tel],input[type=email],textarea',
			buttons:'a[rel=reset],a[rel=submit]',
			event:'click',
			backBu:false,
			afterFu:function(){},
			submitFu:function(){
				var opt=this,
					method=opt.form.attr('method')
				method=!!method?method:'get'
				$.ajax({
					url:opt.form.attr('action'),
					method:method,
					cache:false,
					data:opt.form.serializeArray(),
					success:function(r){
						opt.response=r
						opt.showFu()
					}
				})
			},
			showFu:function(){
				var opt=this
				opt.form.parent().height(opt.form.parent().height())
				opt.form.fadeOut(function(){
					opt.response=$('<div>'+opt.response+'</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.form.before(opt.response)
					opt.form.parent().height('auto')
					opt.backBu.click(function(){
						opt.hideResFu()
						return false
					})
					opt.afterFu()
				})
			},
			hideResFu:function(){
				var opt=this
				opt.response.remove()
				opt.form.parent().height(opt.form.parent().height())
				opt.form.fadeIn(function(){
					opt.form.parent().height('auto')
				})
			},
			init:function(opt){
				var form=opt.form=this,
					inputs=opt.inputs=$(opt.target,form)
				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]()
						return false
					})
				})
				form.data({opt:opt})
			}
		}
	})
	
	//jQuery methods
	$.fn.extend({
		"_bgSlider":function(opt){
			return _fw.apply(this,['_bgSlider',opt])
		},
		"_ajaxSlider":function(opt){
			return _fw.apply(this,['_ajaxSlider',opt])
		},
		"_forms":function(opt){
			return _fw.apply(this,['_forms',opt])
		}
	})
	
	

})(jQuery)

//Helpers
;(function($){
	$.fn.extend({
		praParent:function(expr,fu){
			var th=this,
				test=function(o){
					var i,
						tf=true
					if(fu)
						fu.call(o)
					if(typeof expr===typeof '')
						return o.is(expr)
					if(typeof expr===typeof {}){
						for(i in expr)
							tf=!!any(o.css(i),expr[i].split(' '))
						return tf
					}
				}
			if(!th.length)return false
			while(th=th.parent())
				if(test(th))
					break
				else
					if(th.is('html'))
						return false
			return th
		},
		waitImgLoad:function(fn){
			var th=this,
				img=$('img',this),
				num=img.length
			img.each(function(){
				if(!this.complete)
					$(this).load(function(){
						if(!--num)
							fn.call(th)
					})					
				else
					if(!--num)
						fn.call(th)
			})
			return this
		},
		popUp:function(){
			this.each(function(){
				var th=$(this),
					pos=th.praParent({position:'relative absolute'}).getPos()
				if(!th.hasClass('_popuped'))
					th
						.data({
							  _popUpParent:th.parent(),
							  left:th.attr('offsetLeft'),
							  top:th.css('offsetLeft')
							 })
						.css({
							zIndex:9000,
							position:'absolute',
							left:pos.x+th.data('left'),
							top:pos.y+th.data('top')
							})
						.appendTo('body')
						.addClass('_popuped')
			})
			return this
		},
		pushBack:function(){
			this.each(function(){
				var th=$(this)
				th.appendTo(th.data('_popUpParent'))
				th.css({
					  left:th.data('left'),
					  top:th.data('top')
					  })
				th.removeClass('_popuped')
			})			
			return this
		},
		getPos:function(){
			var ret
			this.each(function(){
				var r={x:0,y:0},
					o=this
				while(o){
					r.x+=o.offsetLeft
					r.y+=o.offsetTop
					o=o.offsetParent
				}
				ret=r
			})
			return ret
		}

	})
})(jQuery)
//jquery.drift.js
;(function($){
	$.fn.extend({
		drift:function(opt){
			opt=$.extend({
				fullScreenClass:'_fs',
				functer:function(pc){
					var th=$(this)
					th.css({
						left:th.data('stX')+pc.x*th.data('dX')+'px',
						top:th.data('stY')+pc.y*th.data('dY')+'px'
					},'fast')
				}, 
				minWidth:0,
				minHeight:0,
				maxWidth:0,
				maxHeight:0
			},opt)
			
			var th=$(this),body=$(document.body),callee=arguments.callee
				maw=opt.maxWidth||parseInt(body.css('max-width')),
				miw=opt.minWidth||parseInt(body.css('min-width')),
				mah=opt.maxHeight||parseInt(body.css('max-height')),
				mih=opt.minHeight||parseInt(body.css('min-height')),
				dw=maw-miw,
				dh=mah-mih
				
			if(!(maw&&mah&&miw&&mih))return false
			
			th.each(function(){
				var tmp={left:this.offsetLeft,top:this.offsetTop},
					delta=function(a,b){return a<b?b-a:a-b}
				$(this)
					.data({stX:tmp.left,stY:tmp.top})
					.addClass(opt.fullScreenClass)
					.data({dX:delta(tmp.left,this.offsetLeft),dY:delta(tmp.top,this.offsetTop)})
					.removeClass(opt.fullScreenClass)
					.css({position:'absolute',left:tmp.left+'px',top:tmp.top+'px'})
			})
			
			$(window).bind('resize load',function(){
				th.each(function(){
					var x=(body.width()-miw)/dw,
						y=(body.height()-mih)/dh
					opt.functer.call(this,{
						x:x>0?x:0,
						y:y>0?y:0
					})
				})
			})
		}
	})	
})(jQuery)

function clone(obj){
	if(!obj||typeof obj!=typeof {})
		return obj
	if(obj instanceof Array)
		return [].concat(obj)
	var tmp=new obj.constructor(),
		i
	for(i in obj)
		if(obj.hasOwnProperty(i))
			tmp[i]=clone(obj[i])
	return tmp
}

function any(inp,vrs){
	var ret=false
	if(arguments.length>2)
		vrs=$.extend([],arguments),
		vrs.shift()
	for(var i=0;i<vrs.length;i++)
		if(inp==vrs[i])
			ret=vrs[i]
	return ret
}
