/*
 * Superfish v1.4.8 - jQuery menu widget
 * Copyright (c) 2008 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
 */

;(function(aa){
	aa.fn.superfish = function(op){

		var sf = aa.fn.superfish,
			c = sf.c,
			aaarrow = aa([''].join('')),
			over = function(){
				var aaaa = aa(this), menu = getMenu(aaaa);
				clearTimeout(menu.sfTimer);
				aaaa.showSuperfishUl().siblings().hideSuperfishUl();
			},
			out = function(){
				var aaaa = aa(this), menu = getMenu(aaaa), o = sf.op;
				clearTimeout(menu.sfTimer);
				menu.sfTimer=setTimeout(function(){
					o.retainPath=(aa.inArray(aaaa[0],o.aapath)>-1);
					aaaa.hideSuperfishUl();
					if (o.aapath.length && aaaa.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.aapath);}
				},o.delay);	
			},
			getMenu = function(aamenu){
				var menu = aamenu.parents(['ul.',c.menuClass,':first'].join(''))[0];
				sf.op = sf.o[menu.serial];
				return menu;
			},
			addArrow = function(aaa){ aaa.addClass(c.anchorClass).append(aaarrow.clone()); };
			
		return this.each(function() {
			var s = this.serial = sf.o.length;
			var o = aa.extend({},sf.defaults,op);
			o.aapath = aa('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
				aa(this).addClass([o.hoverClass,c.bcClass].join(' '))
					.filter('li:has(ul)').removeClass(o.pathClass);
			});
			sf.o[s] = sf.op = o;
			
			aa('li:has(ul)',this)[(aa.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
				if (o.autoArrows) addArrow( aa('>a:first-child',this) );
			})
			.not('.'+c.bcClass)
				.hideSuperfishUl();
			
			var aaa = aa('a',this);
			aaa.each(function(i){
				var aali = aaa.eq(i).parents('li');
				aaa.eq(i).focus(function(){over.call(aali);}).blur(function(){out.call(aali);});
			});
			o.onInit.call(this);
			
		}).each(function() {
			var menuClasses = [c.menuClass];
			if (sf.op.dropShadows  && !(aa.browser.msie && aa.browser.version < 7)) menuClasses.push(c.shadowClass);
			aa(this).addClass(menuClasses.join(' '));
		});
	};

	var sf = aa.fn.superfish;
	sf.o = [];
	sf.op = {};
	sf.IE7fix = function(){
		var o = sf.op;
		if (aa.browser.msie && aa.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
			this.toggleClass(sf.c.shadowClass+'-off');
		};
	sf.c = {
		bcClass     : 'sf-breadcrumb',
		menuClass   : 'sf-js-enabled',
		anchorClass : 'sf-with-ul',
		arrowClass  : 'sf-sub-indicator',
		shadowClass : 'sf-shadow'
	};
	sf.defaults = {
		hoverClass	: 'sfHover',
		pathClass	: 'overideThisToUse',
		pathLevels	: 1,
		delay		: 800,
		animation	: {opacity:'show'},
		speed		: 'normal',
		autoArrows	: true,
		dropShadows : true,
		disableHI	: false,		// true disables hoverIntent detection
		onInit		: function(){}, // callback functions
		onBeforeShow: function(){},
		onShow		: function(){},
		onHide		: function(){}
	};
	aa.fn.extend({
		hideSuperfishUl : function(){
			var o = sf.op,
				not = (o.retainPath===true) ? o.aapath : '';
			o.retainPath = false;
			var aaul = aa(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
					.find('>ul').hide().css('visibility','hidden');
			o.onHide.call(aaul);
			return this;
		},
		showSuperfishUl : function(){
			var o = sf.op,
				sh = sf.c.shadowClass+'-off',
				aaul = this.addClass(o.hoverClass)
					.find('>ul:hidden').css('visibility','visible');
			sf.IE7fix.call(aaul);
			o.onBeforeShow.call(aaul);
			aaul.animate(o.animation,o.speed,function(){ sf.IE7fix.call(aaul); o.onShow.call(aaul); });
			return this;
		}
	});

})(jQuery);














/*
 *	faded 0.3.2 - jQuery plugin
 *	written by Nathan Searles	
 *	http://nathansearles.com/faded/
 *
 *	Copyright (c) 2010 Nathan Searles (http://nathansearles.com/)
 *	Dual licensed under the MIT (MIT-LICENSE.txt)
 *	and GPL (GPL-LICENSE.txt) licenses.
 *
 *	Built for jQuery library
 *	http://jquery.com
 *	Compatible with jQuery 1.3.2+
 *
 */
if(typeof jQuery != "undefined") {
	jQuery(function(aa) {
		aa.fn.extend({
			faded: function(options) {
				var settings = aa.extend({}, aa.fn.faded.defaults, options);
				return this.each(
					function() {
						if(aa.fn.jquery < "1.3.1") {return;}
						var aat = aa(this);
						var aac = aat.children(":nth-child(1)");
						var o = aa.metadata ? aa.extend({}, settings, aat.metadata()) : settings;
						var total = aac.children().size();
						var next = 0, prev = 0, number = 0, currentitem = 0, restart = 0, restartinterval = 0;
						var loaded,active,imgSrc,clicked,current;
						if (o.random) {
							aa.fn.reorder = function(callback) {
								function randOrd() { return(Math.round(Math.random())-0.5); }
									return(aa(this).each(function() {
									var aathis = aa(this);
									var aachildren = aathis.children();
									var childCount = aachildren.length;
									if (childCount > 1) {
										aachildren.hide();
										var indices = new Array();
										for (i=0;i<childCount;i++) { indices[indices.length] = i; }
										indices = indices.sort(randOrd);
										aa.each(indices,function(j,k) { 
											var aachild = aachildren.eq(k);
											var aaclone = aachild.clone(true);
											aaclone.show().appendTo(aathis);
											if (callback !== undefined) {
												callback(aachild, aaclone);
											}
										aachild.remove();
									});
									}
								}));
							};
							aac.reorder();
						}
						function pause() {
							clearInterval(autoplay);
							clearTimeout(restart);
							restart = setTimeout(function() {
								autoplay = setInterval(function(){
									animate("next");
								},o.autoplay);
							},o.autorestart);			
						}				
						aac.css({position:"relative"});			
						aac.children().css({
							position:"absolute",
							top: 0, 
							left: 0,
							zIndex: 0,
							display:"none"
						 });
						if (o.autoheight) {
							aac.animate({height: aac.children(":eq(0)").outerHeight()},o.autoheight);
						}
						if (o.pagination) {
							if (o.autopagination) {
								aat.append("<ul class="+o.pagination+"></ul>");
								aac.children().each(function(){
									aa("."+o.pagination+"",aat).append("<li><a rel="+number+" href=\"#\" onfocus=\"this.blur()\">"+(number+1)+"</a></li>");
									number++;
								});
							}
							aa("."+o.pagination+" li a:eq(0)",aat).parent().addClass("current");
							aa("."+o.pagination+" li a",aat).click(function(){
								current = aa("."+o.pagination+" li.current a",aat).attr("rel");									
								clicked = aa(this).attr("rel");
								if (current != clicked) {animate("pagination",clicked,current);}
								if(o.autoplay){pause();}
								return false;
							});
						}
						if (o.loading&&aac.children()[0].tagName=="IMG") {
							aac.css({background:"url("+o.loadingimg+") no-repeat 50% 50%"});
							imgSrc = aa("img:eq(0)",aac).attr("src") + "?" + (new Date()).getTime();
							aa("img:eq(0)",aac).attr("src", imgSrc).load(function() {
								aa(this).fadeIn(o.speed,function(){
									loaded = true;
								});
							});
						} else {
							aac.children(":eq(0)").fadeIn(o.speed,function(){
								loaded = true;
							});
						}
						if (o.bigtarget) {
							aac.css({"cursor":"pointer"});
							aac.click(function(){
								animate("next");
								if(o.autoplay){
									if (o.autorestart) {
										pause();
									} else {
										clearInterval(autoplay);	
									}
								}
								return false;
							});									
						}			
						if (o.autoplay) {
							autoplay = setInterval(function(){
								animate("next");
							},o.autoplay);
							pause();
						}
						aa("."+o.nextbtn,aat).click(function(){
							animate("next");
							if(o.autoplay){
								if (o.autorestart) {
									pause();
								} else {
									clearInterval(autoplay);	
								}
							}
							return false;
						});					
						aa("."+o.prevbtn,aat).click(function(){
							animate("prev");
							if(o.autoplay){
								if (o.autorestart) {
									pause();
								} else {
									clearInterval(autoplay);	
								}
							}
							return false;
						});
						function animate(dir,clicked,current){
							if (!active&&loaded) {
								active=true;
								switch(dir) {
									case "next":
										prev = next;
										next = currentitem*1+1;
										if (total === next) { next = 0; }
									break;
									case "prev":
										prev = next;
										next = currentitem*1-1;
										if (next === -1) { next = total-1; }
									break;
									case "pagination":
										next = clicked;
										prev = current;
									break;
								}
								if (o.pagination) {
									aa(".pagination li.current",aat).removeClass("current");
									aa(".pagination li a:eq("+next+")",aat).parent().addClass("current");
								}
								if (o.crossfade) {
									aac.children(":eq("+next+")").css({zIndex:10}).fadeIn(o.speed,function(){
										aac.children(":eq("+prev+")").css({display:"none",zIndex:0});
										aa(this).css({zIndex:0});
										currentitem = next;
										active = false;
									});
								} else {
									aac.children(":eq("+prev+")").fadeOut(o.speed,function(){
										if (o.autoheight) {
											aac.animate({height: aac.children(":eq("+next+")").outerHeight()},o.autoheight,function(){
												aac.children(":eq("+next+")").fadeIn(o.speed);
											});
										} else {
											aac.children(":eq("+next+")").fadeIn(o.speed);
										}
										currentitem = next;
										active = false;
									});
								}
							}
						}
					}
				);
				}
		});
		aa.fn.faded.defaults = {
			speed: 300,
			crossfade: false,
			bigtarget: false,
			loading: false,
			autoheight: false,
			pagination: "pagination",
			autopagination: true,
			nextbtn: "next",
			prevbtn: "prev",
			loadingimg: false,
			autoplay: false,
			autorestart: false,
			random: false
		};
	});
}











jQuery(function(){
			// main navigation init
			jQuery("#slider").faded({
				speed: 500,
				crossfade: false,
				bigtarget: false,
				loading: true,
				autoplay: 5200,
				autorestart: 4000,
				autopagination:true
			});
			
			jQuery("#faded2").faded({
				loading: true,
				speed: 200,
				crossfade: false,
				bigtarget: false,
				loading: true,
				autoplay: 5000,
				autorestart: 8000,
				autopagination:false
			});

			jQuery('ul.sf-menu').superfish({
				animation:   {opacity:'show', height:'show'},
				dropShadows: false
			});
			
		});
		
		
		//animate .block-shadow
		
		
		
