;(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,{
		"_slider":{
			dataName:'_slider',
			show:false,
			items:'>ul>li',
			duration:400,
			easing:'',
			slideshow:false,
			changeEv:'_change',
			showEv:'_show',
			nextEv:'_next',
			prevEv:'_prev',
			pagEv:'click',
			pagination:false,
			currCl:'current',
			navLinks:'a[rel=nav]',
			pagActiveCl:'active',
			pagArea:'a',			
			animationCallback:function(){},
			init:function(opt){
				var holder=opt.holder=this
				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
					})
				opt.holder.data(opt.dataName,opt)
			}
		},
		"_vSlider":{
			show:false,
			cloneCl:'_clone',
			clone:false,
			mousewheel:false,
			mwFu:function(){
				var opt=this
				opt.holder.bind('mousewheel',function(e,d){
					if(d<0){
						if(opt.mousewheel)
							opt.mousewheel=false,
							opt.nextFu(),
							setTimeout(function(){
								opt.mousewheel=true
							},140)
					}else{
						if(opt.mousewheel)
							opt.mousewheel=false,
							opt.prevFu(),
							setTimeout(function(){
								opt.mousewheel=true
							},140)
					}
					return false
				})
			},
			preFu:function(){
				var opt=this,
					holder=opt.holder,
					items=opt.itms,
					ul=opt.ul,
					itemH=items.outerHeight()+parseInt(items.css('marginBottom'))+parseInt(items.css('marginTop'))
				if(opt.clone)
					items.clone().addClass(opt.cloneCl).appendTo(ul),
					items=$(opt.items,opt.holder)
				holder.data({itemH:itemH})
				if(opt.show)
					holder
						.height(itemH*opt.show)
						.css({overflow:'hidden',zIndex:1})
				if(holder.css('position')!='absolute')
					holder.css({position:'relative',zIndex:1})
				ul.css({position:'relative'})
//var tmp=Math.round(items.length/2),  -- om in het midden te starten
//starten met het 3de item
				var tmp=3,
					i=tmp
				while(i--)
					items.eq(-1).prependTo(ul)
				ul.css({top:-Math.floor(tmp/2)*itemH})
					.data({sY:-Math.floor(tmp/2)*itemH})
				return opt
			},
			nextFu:function(opt){
				var opt=this
				opt.holder.trigger(opt.changeEv,'next')
			},
			prevFu:function(opt){
				var opt=this
				opt.holder.trigger(opt.changeEv,'prev')
			},
			changeFu:function(data){
				var opt=this
					holder=opt.holder,
					items=opt.itms=$(opt.items,holder),
					ul=opt.ul,
					itemH=holder.data('itemH')
				if(data=='next'||data=='prev')
					if(data=='next')
						items.eq(-1)
							.prependTo(items
									   	.parent().stop().css({
															top:parseInt(ul.css('top'))-itemH
															})
										)
					else
						items.eq(0)
							.appendTo(items
										.parent().stop().css({
															top:parseInt(ul.css('top'))+itemH
															})
										)
				opt.showFu.call(opt)
			},
			showFu:function(){				
				var opt=this,
					holder=opt.holder,
					items=opt.itms,
					ul=opt.ul,
					itemH=holder.data('itemH')
				ul.stop().animate({
					top:ul.data('sY')
					},{
					duration:opt.duration,
					easing:opt.easing,
					complete:function(){
						opt.animationCallback()
					}
				})				
				holder.trigger(opt.showEv)
			},
			init:function(opt){
				var holder=opt.holder=this,
					items=opt.itms=$(opt.items,holder),
					ul=opt.ul=items.parent()
				opt.preFu(opt)

				holder
					.bind(opt.changeEv,function(e,data){
						opt.changeFu(data)
						return false
					})
					.bind(opt.nextEv,function(){
						opt.nextFu()
						return false
					})
					.bind(opt.prevEv,function(){
						opt.prevFu()
						return false
					})
				if(opt.show!==false)
					opt.changeFu('next')
				if(opt.slideshow)
					holder.data({_timer:_timer.length})
				opt.holder.data(opt.dataName,opt)
				
				if(opt.mousewheel)
					opt.mwFu()
			}
		},
		"_gSlider":{
			preFu:function(){
				var opt=this,
					holder=opt.holder,
					items=opt.itms,
					ul=opt.ul,
					itemW=items.outerWidth()+parseInt(items.css('marginLeft'))+parseInt(items.css('marginRight'))
				if(opt.clone)
					items.clone().addClass(opt.cloneCl).appendTo(ul),
					items=$(opt.items,opt.holder)
				holder.data({itemW:itemW})
				if(opt.show)
					holder
						.width(itemW*opt.show)
						.height(items.height())
						.css({overflow:'hidden',zIndex:1})
				if(holder.css('position')!='absolute')
					holder.css({position:'relative',zIndex:1})
				ul.css({position:'relative',width:items.length*itemW})
//var tmp=Math.round(items.length/2),   -- om in het midden te starten
                    var tmp=Math.round(items.length-1),
					i=tmp
				while(i--)
					items.eq(-1).prependTo(ul)
				ul.css({left:-Math.floor(tmp/2)*itemW})
					.data({sX:-Math.floor(tmp/2)*itemW})
				return opt
			},
			changeFu:function(data){
				var opt=this
					holder=opt.holder,
					items=opt.itms=$(opt.items,holder),
					ul=opt.ul,
					itemW=holder.data('itemW')
				if(data=='next'||data=='prev')
					if(data=='next')
						items.eq(-1)
							.prependTo(items
									   	.parent().stop().css({
															left:parseInt(ul.css('left'))-itemW
															})
										)
					else
						items.eq(0)
							.appendTo(items
										.parent().stop().css({
															left:parseInt(ul.css('left'))+itemW
															})
										)
				opt.showFu()
			},
			showFu:function(){				
				var opt=this,
					holder=opt.holder,
					items=opt.itms,
					ul=opt.ul,
					itemW=holder.data('itemW')
				ul.stop().animate({
					left:ul.data('sX')
					},{
					duration:opt.duration,
					easing:opt.easing,
					complete:function(){
						opt.animationCallback.call(holder)
					}
				})				
				holder.trigger(opt.showEv)
			}
		},
		"_dropDownMenu":{
			dataName:'_dropDown',
			showEv:"mouseenter",
			hideEv:'mouseleave',
			items:'>li',
			visibleCl:'_visible',
			hiddenCl:'_hidden',
			expandCl:'_active',
			area:false,
			easing:'',
			duration:666,
			wait:1000,
			enable:true,
			enableData:'dropDownEnable',
			animationCallback:function(){},
			preFu:function(){
				var opt=this
				opt.ul
					.css({opacity:0})
					.hide()
			},
			showFu:function(){
				var opt=this					
				if($.browser.msie&&$.browser.version=='7.0')
				opt.ul.show()
				else
				opt.ul					
					.show()
					.stop()
					.animate({
						opacity:1
						},{
						duration:opt.duration,
						easing:opt.easing,
						complete:function(){
									opt.ul.removeClass(opt.hiddenCl).addClass(opt.visibleCl)
									opt.animationCallback.call(this)
								}
						})
			},
			hideFu:function(){
				var opt=this
				if($.browser.msie&&$.browser.version=='7.0')
				opt.ul.hide()
				else
				opt.ul
					.stop()
					.animate({
						opacity:0
						},{
						duration:opt.duration,
						easing:opt.easing,
						complete:function(){
									opt.ul.hide().removeClass(opt.visibleCl).addClass(opt.hiddenCl)
									opt.animationCallback.call(this)
								}
						})
			},
			init:function(opt){
				var ul=opt.ul=this,
					holder=opt.holder=this.parent(),
					items=opt.itms=$(opt.items,ul),
					area=opt.area?holder.find(opt.area):holder,
					timer=opt._timer=_timer[_timer.length]=''
				opt.preFu()
				holder.data(opt.enableData,opt.enable)
				area
					.bind(opt.showEv,function(){
						if(holder.data(opt.enableData))
							clearTimeout(opt._timer),
							holder.addClass(opt.expandCl),
							opt.showFu()
						return false
					})
				ul
					.bind(opt.showEv,function(){
						if(holder.data(opt.enableData))
							clearTimeout(opt._timer),
							holder.addClass(opt.expandCl),
							opt.showFu()
						return false
					})
				holder
					.bind(opt.hideEv,function(){
						if(holder.data(opt.enableData))
							opt._timer=setTimeout(function(){
								holder.removeClass(opt.expandCl)
								opt.hideFu()
							},opt.wait)
					})
				opt.holder.data(opt.dataName,opt)
			}
		},
		"_dropDown#1":{
			preFu:function(){
				var opt=this
				if(opt.ul.css('position')!='absolute')
					opt.ul.css({position:'relative',zIndex:-1})
				opt.itms.each(function(){
					var th=$(this)
					th.data('sPosY',th.attr('offsetTop'))
						.css({top:-th.height()})
				}).css({position:'absolute'}).hide()
				opt.ul.css({zIndex:-2})
			},
			showFu:function(){
				var opt=this
				opt.itms.each(function(){
					var th=$(this)
					th.show()
						.stop()
						.animate({
								top:th.data('sPosY')
								},{
								duration:opt.duration,
								easing:opt.easing,
								complete:function(){
									opt.ul.css({zIndex:2})
									opt.animationCallback()
								}
								})					
				})
			},
			hideFu:function(){
				var opt=this
				opt.itms.each(function(){
					var th=$(this)
					th.stop()
						.animate({
								top:-th.height()
								},{
								duration:opt.duration,
								easing:opt.easing,
								complete:function(){
									th.hide()
									opt.animationCallback()
								}
								})
					opt.ul.css({zIndex:-2})
				})
			}
		},"_ajaxSlider":{
			spinner:false,
			navLinks:'a[rel=nav]',
			pagArea:'>a',
			pagActiveCl:'active',
			pagEv:'click',
			showEv:'_show',
			changeEv:'_change',
			pagination: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
					})
			},
			changeFu:function(data){
				var opt=this,
					url=data.attr('href')
				opt.holder.data({url:url})
				opt.showFu()
				opt.holder.trigger(opt.changeEv)
			},
			showFu:function(){
				var opt=this,
					holder=opt.holder,
					spinner=$(opt.spinner),
					url=holder.data('url')
				holder.find('*').remove()
				holder.append(spinner)				
				holder.load(url,{},function(){
					spinner.remove()
					opt.animationCallback.call(holder,opt)
				})
				holder.trigger(opt.showEv,url)
			},
			init:function(opt){
				var holder=opt.holder=this,
					tmp
				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
					})
			}
		},
		"_tooltip":{
			tipCl:'tooltip',
			tipEv:'mouseenter',
			hideEv:'mouseleave',
			duration:400,
			easing:'',
			wait:400,
			padL:10,
			padT:30,
			atMouse:false,
			animationCallback:function(){},
			preFu:function(){
				var opt=this
				opt.tooltip.css({zIndex:9999,opacity:0,position:'absolute'})
				opt.tooltip.hide()
			},
			mouseFu:function(){
				var opt=this
				opt.tooltip.css({left:opt.mX+opt.padL,top:opt.mY+opt.padT})
				opt.tooltip.data('owner',opt.holder)
			},
			showFu:function(){
				var opt=this
				if(opt.atMouse)
					$('body>.'+opt.tipCl).each(function(){
						var th=$(this)
						th.appendTo(th.data('owner'))
					})
				if(opt.atMouse)
					opt.tooltip.appendTo('body')				
				opt.tooltip
					.show()
					.stop()
					.animate({
							opacity:1
							},{
							duration:opt.duration,
							easing:opt.easing,
							complete:function(){
								opt.animationCallback()
							}
							})
			},
			hideFu:function(){
				var opt=this
				opt.tooltip
					.stop()
					.animate({
							opacity:0
							},{
							duration:opt.duration,
							easing:opt.easing,
							complete:function(){
								if(opt.atMouse)
									opt.tooltip.appendTo(opt.holder)
								opt.tooltip.hide()
								opt.animationCallback()
							}
							})
			},
			init:function(opt){
				var holder=opt.holder=this,
					tooltip=opt.tooltip=$('.'+opt.tipCl,holder),
					timer=opt._timer=_timer[_timer.length]=''
				opt.preFu()
				if(tooltip.length)
					holder
						.bind(opt.tipEv,function(){
							timer=setTimeout(function(){
								if(opt.atMouse)
									opt.mouseFu()
								opt.showFu()
							},opt.wait)
							
						})
						.bind(opt.hideEv,function(){
							clearTimeout(timer)
							opt.hideFu()
						})
					tooltip
						.bind(opt.tipEv,function(){
							opt.showFu()
						})
						.bind('mouseout',function(){
							opt.hideFu()
						})
				if(opt.atMouse)
					$(document).bind('mousemove',function(e){
						opt.mX=e.pageX
						opt.mY=e.pageY
					})
			}
		},
		"_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,
			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
					})
				})
			},
			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({
		"_dropDownMenu":function(opt){
			return _fw.apply(this,['_dropDownMenu','_dropDown#1',opt])
		},
		"_ajaxSlider":function(opt){
			return _fw.apply(this,['_ajaxSlider',opt])
		},
		"_vSlider":function(opt){
			return _fw.apply(this,['_slider','_vSlider',opt])
		},
		"_gSlider":function(opt){
			return _fw.apply(this,['_slider','_vSlider','_gSlider',opt])
		},
		"_tooltip":function(opt){
			return _fw.apply(this,['_tooltip',opt])
		},
		"_forms":function(opt){
			return _fw.call(this,'_forms',opt)
		}
	})
	
	

})(jQuery)

//Helpers
;(function($){
	$.fn.extend({
		praParent:function(name){
			var th=$(this)
			while(th=th.parent())
				if(th.is(name))
					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
		}
	})
})(jQuery)
//jquery.mousewheel.js
;(function($){
var types = ['DOMMouseScroll', 'mousewheel'];
$.event.special.mousewheel = {
	setup: function() {
		if ( this.addEventListener )
			for ( var i=types.length; i; )
				this.addEventListener( types[--i], handler, false );
		else
			this.onmousewheel = handler;
	},	
	teardown: function() {
		if ( this.removeEventListener )
			for ( var i=types.length; i; )
				this.removeEventListener( types[--i], handler, false );
		else
			this.onmousewheel = null;
	}
};
$.fn.extend({
	mousewheel: function(fn) {
		return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
	},	
	unmousewheel: function(fn) {
		return this.unbind("mousewheel", fn);
	}
});
function handler(event) {
	var args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true;	
	event = $.event.fix(event || window.event);
	event.type = "mousewheel";	
	if ( event.wheelDelta ) delta = event.wheelDelta/120;
	if ( event.detail     ) delta = -event.detail/3;	
	// Add events and delta to the front of the arguments
	args.unshift(event, delta);
	return $.event.handle.apply(this, args);}
})(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
}

