$(document).ready(function() {
	/* Slideshow */
	time = 6000;
	slide = 800;
	i=0;
	go = false;
	if($('#slideshow')) { setup(); }
});

/* ----- SLIDESHOW FUNCTIONS ----- */
function setup() {
	cur = 0;
	imgs = $('#slides li');
	// IE8 fixes
	if($('.lt-ie9').length) {
		p = $('#slides li p');
		$(p).hide();
		$(p[cur]).show();
	}
	dots = $('#circle-nav li');
	$(dots).click(pick);
	total = imgs.length;
	$(imgs[cur]).show();
	$(dots[cur]).addClass('live');

	setTimeout('slideshow()', time);
}
function slideshow() {
	move();
	
	t = setTimeout('slideshow()', time);
}
function move() {
	if(go !== false) {
		next = go;
		go = false;
	} else {
		if(cur == total - 1) {
			next = 0;
		} else {
			next = cur + 1;
		}
	}
	
	// IE8 fixes
	if($('.lt-ie9').length) {
		$(imgs[cur]).find('p').fadeOut(slide);
	}
	$(imgs[cur]).fadeOut(slide);
	$(imgs[next]).fadeIn(slide);
	// IE8 fixes
	if($('.lt-ie9').length) {
		$(imgs[next]).find('p').fadeIn(slide);
	}
	$(dots[cur]).removeClass('live');
	$(dots[next]).addClass('live');
	
	cur = next;
	if(cur == total) {
		cur = 0;
	}
}
function pick() {
	clearTimeout(t);

	i = $(this).index();
	go = i;

	slideshow();
}

// minified - placeholder / autofocus polyfill
(function(f,g){function i(a,d){for(var c=a.length,b=0;b<c;b++)if(d.call(a[b],a[b],b,a)===false)break}var e=function(){return g.addEventListener?function(a,d,c){if(a&&a.nodeName||a===f)a.addEventListener(d,c,false);else if(a&&a.length)for(var b=0;b<a.length;b++)e(a[b],d,c)}:function(a,d,c){if(a&&a.nodeName||a===f)a.attachEvent("on"+d,function(){return c.call(a,f.event)});else if(a&&a.length)for(var b=0;b<a.length;b++)e(a[b],d,c)}}(),j=g.createElement("input"),h=[].slice.call(g.getElementsByTagName("input"),
0);h=h.concat([].slice.call(g.getElementsByTagName("textarea"),0));"placeholder"in j||i(h,function(a){var d=a.getAttribute("placeholder");function c(){if(a.value==d){a.value="";a.style.color=""}}function b(){if(a.value==""){a.value=d;a.style.color="#A29797"}}e(a,"focus",c);e(a,"blur",b);e(a.form,"submit",function(){c.call(a)});e(f,"unload",function(){c.call(a)});a.value==""&&b.call(a)});"autofocus"in j||i(h,function(a){if(a.getAttribute("autofocus")!=null){a.focus();return false}})})(this,document);
