(function () {
	var	s_pack = d[iD]('slideshow_pack'),
		s_notes = d[iD]('notes'),
		s_labels = d[iD]('labels'),
		a_left = d[iD]('arr_left'),
		a_right = d[iD]('arr_right'),
		a_play = d[iD]('arr_play'),
		s_click = d[iD]('screen_click'),
		s_n = 0,
		s_show,
		s_start,
		s_sls = [],
		s_nts = [],
		s_dts = [],
		s_lbs = [],
		label_txts = ['MarginAd', 'CornerAd', 'Toolbar', 'Sidebar', 'Banner', 'inImage', 'inVideo', 'Links'],
		note_txts = [
			'Monetize your website\'s unutilized page margins. This smart ad unit will only display if the margins are wide enough to fit, never obscuring content or ad inventory.',
			'A small, non-intrusive, and fully customizable text ad unit sits in a corner of the browser window, staying visible as users scrolls up or down the page.',
			'Increase engagement and encourage your audience to share content, while generating additional revenue from a small, seamlessly embedded ad unit.',
			'This social sharing widget runs on the web page’s unutilized margins. Increase engagement and page-views, while generating additional revenue from seamlessly placed ad messages.',
			'Fully customizable units that come in standard IAB and custom sizes.',
			'The smallest ad unit for photos available today. It displays a single line of text on a semi-transparent background, and auto-adapts to any image size.',
			'A non-intrusive, single-line text ad overlaid across the bottom of the video viewing area. ',
			
			'Links? TBD...'
		],
		note_hrefs = [
			'margin_ad.html',
			'corner_ad.html',
			'toolbar.html',
			'sidebar.html',
			'banners.html',
			'in_image.html',
			'in_video.html',
			'#'
		];
	
	_show_slide = function (n) {
		for (var j = 0; j < s_sls.length; j++) {
			s_sls[j][cN] = 'off';
			s_nts[j][cN] = 'note off';
			s_lbs[j][cN] = 'label';
		}
		s_sls[n][cN] = 'on';
		s_nts[n][cN] = 'note on';
		s_lbs[n][cN] = 'label on';
		s_click.href = note_hrefs[n];
	};
	
	a_left.onclick = function () {s_n = (s_n > 0 ? s_n - 1 : s_sls.length - 1); _show_slide(s_n);};
	a_right.onclick = function () {s_n = (s_n < s_sls.length - 1 ? s_n + 1 : 0); _show_slide(s_n);};
	
	a_play.onclick = function () {
		if (this[cN] == 'play') {
			_start_show(true);
		} else {
			if (s_show) clearInterval(s_show);
			this[cN] = 'play';
		}
	};
	
	_start_show = function (click) {
		a_play[cN] = 'pause';
		if (click) s_n = (s_n < s_sls.length - 1 ? s_n + 1 : 0);
		_show_slide(s_n);
		s_show = setInterval( function () {
			s_n = (s_n < s_sls.length - 1 ? s_n + 1 : 0); _show_slide(s_n);
		}, 10000);
	};
	
	(function () {
		var	s_num = 7, s_ready = 0;
		for (var i = 0; i < s_num; i++) {
			var	sld = d[cE]('img');
				sld.src = 'assets/img/slides/slide_'+ i +'.jpg';
				sld[cN] = 'off';
				s_pack[aC](sld);
				s_sls.push(sld);
				sld.onload = function () {s_ready++;}

			var	note = d[cE]('div');
				note[iH] = note_txts[i] + ' <a href="'+ note_hrefs[i] +'">learn more &raquo;</a>';
				note[cN] = 'note off';
				s_notes[aC](note);
				s_nts.push(note);

			var	sl = d[cE]('a');
				sl.href = 'javascript:void(0);'
				sl[cN] = 'label';
				sl[iH] = label_txts[i];
				sl[sA]('n', i);
				sl.onclick = function () {
					if (s_show) clearInterval(s_show);
					a_play[cN] = 'play';
					s_n = parseInt(this[gA]('n'));
					_show_slide(s_n);
				}
				s_labels[aC](sl);
				s_lbs.push(sl);
		}
		s_start = setInterval(
			function () {
				if (s_ready >= 4) {
					clearInterval(s_start);
					s_pack[cN] = 'run';
					_start_show();
				}
			},
		10);
	})();

})();

