﻿// JavaScript Document
// for jquery 

// compress me as jq.tales.pack.js at http://jscompress.com/ (pref. packer)

$(document).ready(function(){
	
	
// home-icon first tab	
// don't ask: for IE7, we need to pull the textlabel up: for this, write a span across the label (only in ie7)
	   $('#topnav li:first-child a .stretcher').each(function() {

		  string = $(this).text();
		  var filename = 'ico.home';
		  if($.browser.msie && $.browser.version=="7.0"){	
		  	$(this).html('<img src="/websites/44/uploads/image/basics/' + filename + '.gif" alt="' + string + '" /> <br>' + '<span class="hometxtcontainer">' + string +'</span>');
		  }
		  else{
			$(this).html('<img src="/websites/44/uploads/image/basics/' + filename + '.gif" alt="' + string + '" /> <br>' + string );  	
			  
			  }
		  //$(this).html('<img src="/websites/44/uploads/image/basics/' + filename + '.gif" alt="' + string + '" /><br />Home');
		  
		  
    });		
	
	
	
						   
//FAQ
	//Hide (Collapse) the toggle containers on load
							$(".toggle_container").hide(); 
							
							
							//Slide up and down on click
							$("div.toggletrigger").click(function(e){
								e.preventDefault();
								
								//$(".toggle_container").slideUp("10"); 
								//$(this).next(".toggle_container").slideToggle("10");
								$(".toggle_container").hide(); 
								$(this).next(".toggle_container").show();
							});
							

	//jquery/jquery.client.js	
	(function() {
		
	//0. give id's to subnav with icons
	
	
	   
		   		 $('#navcontainer ul li:nth-child(1)').attr('id','item1');
				 $('#navcontainer ul li:nth-child(2)').attr('id','item2');
				 $('#navcontainer ul li:nth-child(3)').attr('id','item3');
				 $('#navcontainer ul li:nth-child(4)').attr('id','item4');
				 $('#navcontainer ul li:nth-child(5)').attr('id','item5');
	
	//1. replace class 'no-js' on html with 'js', so we can differentiate between javascript-enabled & disabled clients
	$('html').removeClass('no-js');
	$('html').addClass('js');
	
	
	
				var BrowserDetect = {
					init: function () {
						this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
						this.version = this.searchVersion(navigator.userAgent)
							|| this.searchVersion(navigator.appVersion)
							|| "an unknown version";
						this.OS = this.searchString(this.dataOS) || "an unknown OS";
					},
					searchString: function (data) {
						for (var i=0;i<data.length;i++)	{
							var dataString = data[i].string;
							var dataProp = data[i].prop;
							this.versionSearchString = data[i].versionSearch || data[i].identity;
							if (dataString) {
								if (dataString.indexOf(data[i].subString) != -1)
									return data[i].identity;
							}
							else if (dataProp)
								return data[i].identity;
						}
					},
					searchVersion: function (dataString) {
						var index = dataString.indexOf(this.versionSearchString);
						if (index == -1) return;
						return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
					},
					dataBrowser: [
						{
							string: navigator.userAgent,
							subString: "Chrome",
							identity: "Chrome"
						},
						{ 	string: navigator.userAgent,
							subString: "OmniWeb",
							versionSearch: "OmniWeb/",
							identity: "OmniWeb"
						},
						{
							string: navigator.vendor,
							subString: "Apple",
							identity: "Safari",
							versionSearch: "Version"
						},
						{
							prop: window.opera,
							identity: "Opera"
						},
						{
							string: navigator.vendor,
							subString: "iCab",
							identity: "iCab"
						},
						{
							string: navigator.vendor,
							subString: "KDE",
							identity: "Konqueror"
						},
						{
							string: navigator.userAgent,
							subString: "Firefox",
							identity: "Firefox"
						},
						{
							string: navigator.vendor,
							subString: "Camino",
							identity: "Camino"
						},
						{		// for newer Netscapes (6+)
							string: navigator.userAgent,
							subString: "Netscape",
							identity: "Netscape"
						},
						{
							string: navigator.userAgent,
							subString: "MSIE",
							identity: "Explorer",
							versionSearch: "MSIE"
						},
						{
							string: navigator.userAgent,
							subString: "Gecko",
							identity: "Mozilla",
							versionSearch: "rv"
						},
						{ 		// for older Netscapes (4-)
							string: navigator.userAgent,
							subString: "Mozilla",
							identity: "Netscape",
							versionSearch: "Mozilla"
						}
					],
					dataOS : [
						{
							string: navigator.platform,
							subString: "Win",
							identity: "Windows"
						},
						{
							string: navigator.platform,
							subString: "Mac",
							identity: "Mac"
						},
						{
							string: navigator.userAgent,
							subString: "iPhone",
							identity: "iPhone"
					    },
						{
							string: navigator.platform,
							subString: "Linux",
							identity: "Linux"
						}
					]
				
				};
				
				BrowserDetect.init();
				
				window.$.client = { os : BrowserDetect.OS, browser : BrowserDetect.browser };
				//alert($.client.browser)
				//alert($.client.os)
				
				$('html').addClass($.client.os);
				$('html').addClass($.client.browser);
				
			})();
			
			
	//jq-tales/jq-tales.IE678.first-last-child.js
		
		

		//not necessary when using selectivizr
		if($.browser.msie && $.browser.version=="6.0"){	$('li:last-child').addClass('last-child')};
		if($.browser.msie && $.browser.version=="7.0"){	$('li:last-child').addClass('last-child')};
		if($.browser.msie && $.browser.version=="8.0"){	$('li:last-child').addClass('last-child')};
	
		if($.browser.msie && $.browser.version=="6.0"){	$('li:first-child').addClass('first-child')};
		if($.browser.msie && $.browser.version=="7.0"){	$('li:first-child').addClass('first-child')};
		if($.browser.msie && $.browser.version=="8.0"){	$('li:first-child').addClass('first-child')};
		
		if($.browser.msie && $.browser.version=="6.0"){	$('nav:last-child').addClass('last-child')};
		if($.browser.msie && $.browser.version=="7.0"){	$('nav:last-child').addClass('last-child')};
		if($.browser.msie && $.browser.version=="8.0"){	$('nav:last-child').addClass('last-child')};
	
		
		if($.browser.msie && $.browser.version=="6.0"){	$('div.item:last-child').addClass('last-child')};
		if($.browser.msie && $.browser.version=="7.0"){	$('div.item:last-child').addClass('last-child')};
		if($.browser.msie && $.browser.version=="8.0"){	$('div.item:last-child').addClass('last-child')};
		
		
		if($.browser.msie && $.browser.version=="6.0"){	$('.overzicht #contentwrapper .item:odd').addClass('odd')};
		if($.browser.msie && $.browser.version=="7.0"){	$('.overzicht #contentwrapper .item:odd').addClass('odd')};
		if($.browser.msie && $.browser.version=="8.0"){	$('.overzicht #contentwrapper .item:odd').addClass('odd')};
		

		if($.browser.msie && $.browser.version=="6.0"){	$('.downloads #contentsection article:odd').addClass('rightarticle')};
		if($.browser.msie && $.browser.version=="7.0"){	$('.downloads #contentsection article:odd').addClass('rightarticle')};
		if($.browser.msie && $.browser.version=="8.0"){	$('.downloads #contentsection article:odd').addClass('rightarticle')};
			
			
//fotoalbum swap image
$('#thumbband a').click(function(event){
	event.preventDefault();
	var pictoshow = $(this).attr("href");
	//$("#replaceme").fadeOut();
	$("#replaceme").attr({src : pictoshow});
	//$("#replaceme").fadeIn();
	
	})





})




/* tales viewer */
/* functies extenden (timer, scrollable, ... */

jQuery.fn.extend({
	everyTime: function(interval, label, fn, times) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, times);
		});
	},
	oneTime: function(interval, label, fn) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, 1);
		});
	},
	stopTime: function(label, fn) {
		return this.each(function() {
			jQuery.timer.remove(this, label, fn);
		});
	}
});

jQuery.extend({
	timer: {
		global: [],
		guid: 1,
		dataKey: "jQuery.timer",
		regex: /^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,
		powers: {
			// Yeah this is major overkill...
			'ms': 1,
			'cs': 10,
			'ds': 100,
			's': 1000,
			'das': 10000,
			'hs': 100000,
			'ks': 1000000
		},
		timeParse: function(value) {
			if (value == undefined || value == null)
				return null;
			var result = this.regex.exec(jQuery.trim(value.toString()));
			if (result[2]) {
				var num = parseFloat(result[1]);
				var mult = this.powers[result[2]] || 1;
				return num * mult;
			} else {
				return value;
			}
		},
		add: function(element, interval, label, fn, times) {
			var counter = 0;
			
			if (jQuery.isFunction(label)) {
				if (!times) 
					times = fn;
				fn = label;
				label = interval;
			}
			
			interval = jQuery.timer.timeParse(interval);

			if (typeof interval != 'number' || isNaN(interval) || interval < 0)
				return;

			if (typeof times != 'number' || isNaN(times) || times < 0) 
				times = 0;
			
			times = times || 0;
			
			var timers = jQuery.data(element, this.dataKey) || jQuery.data(element, this.dataKey, {});
			
			if (!timers[label])
				timers[label] = {};
			
			fn.timerID = fn.timerID || this.guid++;
			
			var handler = function() {
				if ((++counter > times && times !== 0) || fn.call(element, counter) === false)
					jQuery.timer.remove(element, label, fn);
			};
			
			handler.timerID = fn.timerID;
			
			if (!timers[label][fn.timerID])
				timers[label][fn.timerID] = window.setInterval(handler,interval);
			
			this.global.push( element );
			
		},
		remove: function(element, label, fn) {
			var timers = jQuery.data(element, this.dataKey), ret;
			
			if ( timers ) {
				
				if (!label) {
					for ( label in timers )
						this.remove(element, label, fn);
				} else if ( timers[label] ) {
					if ( fn ) {
						if ( fn.timerID ) {
							window.clearInterval(timers[label][fn.timerID]);
							delete timers[label][fn.timerID];
						}
					} else {
						for ( var fn in timers[label] ) {
							window.clearInterval(timers[label][fn]);
							delete timers[label][fn];
						}
					}
					
					for ( ret in timers[label] ) break;
					if ( !ret ) {
						ret = null;
						delete timers[label];
					}
				}
				
				for ( ret in timers ) break;
				if ( !ret ) 
					jQuery.removeData(element, this.dataKey);
			}
		}
	}
});

jQuery(window).bind("unload", function() {
	jQuery.each(jQuery.timer.global, function(index, item) {
		jQuery.timer.remove(item);
	});
});

/**
 * jquery.scrollable 1.0.2. Put your HTML scroll.
 * 
 * Copyright (c) 2009 Tero Piirainen
 * http://flowplayer.org/tools/scrollable.html
 *
 * Dual licensed under MIT and GPL 2+ licenses
 * http://www.opensource.org/licenses
 *
 * Launch  : March 2008
 * Version : 1.0.2 - Tue Feb 24 2009 10:52:04 GMT-0000 (GMT+00:00)
 */
(function($){function fireEvent(opts,name,self,arg){var fn=opts[name];if($.isFunction(fn)){try{return fn.call(self,arg);}catch(error){if(opts.alert){alert("Error calling scrollable."+name+": "+error);}else{throw error;}return false;}}return true;}var current=null;function Scrollable(root,conf){var self=this;if(!current){current=self;}var horizontal=!conf.vertical;var wrap=$(conf.items,root);var index=0;var navi=root.siblings(conf.navi).eq(0);var prev=root.siblings(conf.prev).eq(0);var next=root.siblings(conf.next).eq(0);var prevPage=root.siblings(conf.prevPage).eq(0);var nextPage=root.siblings(conf.nextPage).eq(0);$.extend(self,{getVersion:function(){return[1,0,1];},getIndex:function(){return index;},getConf:function(){return conf;},getSize:function(){return self.getItems().size();},getPageAmount:function(){return Math.ceil(this.getSize()/conf.size);},getPageIndex:function(){return Math.ceil(index/conf.size);},getRoot:function(){return root;},getItemWrap:function(){return wrap;},getItems:function(){return wrap.children();},seekTo:function(i,time,fn){time=time||conf.speed;if($.isFunction(time)){fn=time;time=conf.speed;}if(i<0){i=0;}if(i>self.getSize()-conf.size){return self;}var item=self.getItems().eq(i);if(!item.length){return self;}if(fireEvent(conf,"onBeforeSeek",self,i)===false){return self;}if(horizontal){var left=-(item.outerWidth(true)*i);wrap.animate({left:left},time,conf.easing,fn?function(){fn.call(self);}:null);}else{var top=-(item.outerHeight(true)*i);wrap.animate({top:top},time,conf.easing,fn?function(){fn.call(self);}:null);}if(navi.length){var klass=conf.activeClass;var page=Math.ceil(i/conf.size);page=Math.min(page,navi.children().length-1);navi.children().removeClass(klass).eq(page).addClass(klass);}if(i===0){prev.add(prevPage).addClass(conf.disabledClass);}else{prev.add(prevPage).removeClass(conf.disabledClass);}if(i>=self.getSize()-conf.size){next.add(nextPage).addClass(conf.disabledClass);}else{next.add(nextPage).removeClass(conf.disabledClass);}current=self;index=i;fireEvent(conf,"onSeek",self,i);return self;},move:function(offset,time,fn){var to=index+offset;if(conf.loop&&to>(self.getSize()-conf.size)){to=0;}return this.seekTo(to,time,fn);},next:function(time,fn){return this.move(1,time,fn);},prev:function(time,fn){return this.move(-1,time,fn);},movePage:function(offset,time,fn){return this.move(conf.size*offset,time,fn);},setPage:function(page,time,fn){var size=conf.size;var index=size*page;var lastPage=index+size>=this.getSize();if(lastPage){index=this.getSize()-conf.size;}return this.seekTo(index,time,fn);},prevPage:function(time,fn){return this.setPage(this.getPageIndex()-1,time,fn);},nextPage:function(time,fn){return this.setPage(this.getPageIndex()+1,time,fn);},begin:function(time,fn){return this.seekTo(0,time,fn);},end:function(time,fn){return this.seekTo(this.getSize()-conf.size,time,fn);},reload:function(){return load();},click:function(index,time,fn){var item=self.getItems().eq(index);var klass=conf.activeClass;if(!item.hasClass(klass)&&(index>=0||index<this.getSize())){self.getItems().removeClass(klass);item.addClass(klass);var delta=Math.floor(conf.size/2);var to=index-delta;if(to>self.getSize()-conf.size){to--;}if(to!==index){return this.seekTo(to,time,fn);}}return self;}});if($.isFunction($.fn.mousewheel)){root.bind("mousewheel.scrollable",function(e,delta){var step=$.browser.opera?1:-1;self.move(delta>0?step:-step,50);return false;});}prev.addClass(conf.disabledClass).click(function(){self.prev();});next.click(function(){self.next();});nextPage.click(function(){self.nextPage();});prevPage.addClass(conf.disabledClass).click(function(){self.prevPage();});if(conf.keyboard){$(window).unbind("keypress.scrollable").bind("keypress.scrollable",function(evt){var el=current;if(!el){return;}if(horizontal&&(evt.keyCode==37||evt.keyCode==39)){el.move(evt.keyCode==37?-1:1);return evt.preventDefault();}if(!horizontal&&(evt.keyCode==38||evt.keyCode==40)){el.move(evt.keyCode==38?-1:1);return evt.preventDefault();}return true;});}function load(){navi.each(function(){var nav=$(this);if(nav.is(":empty")||nav.data("me")==self){nav.empty();nav.data("me",self);for(var i=0;i<self.getPageAmount();i++){var item=$("<"+conf.naviItem+"/>").attr("href",i).click(function(e){var el=$(this);el.parent().children().removeClass(conf.activeClass);el.addClass(conf.activeClass);self.setPage(el.attr("href"));return e.preventDefault();});if(i===0){item.addClass(conf.activeClass);}nav.append(item);}}else{var els=nav.children();els.each(function(i){var item=$(this);item.attr("href",i);if(i===0){item.addClass(conf.activeClass);}item.click(function(){nav.find("."+conf.activeClass).removeClass(conf.activeClass);item.addClass(conf.activeClass);self.setPage(item.attr("href"));});});}});if(conf.clickable){self.getItems().each(function(index,arg){var el=$(this);if(!el.data("set")){el.bind("click.scrollable",function(){self.click(index);});el.data("set",true);}});}if(conf.hoverClass){self.getItems().hover(function(){$(this).addClass(conf.hoverClass);},function(){$(this).removeClass(conf.hoverClass);});}return self;}load();var timer=null;function setTimer(){timer=setInterval(function(){self.next();},conf.interval);}if(conf.interval>0){root.hover(function(){clearInterval(timer);},function(){setTimer();});setTimer();}}jQuery.prototype.scrollable=function(conf){var api=this.eq(typeof conf=='number'?conf:0).data("scrollable");if(api){return api;}var opts={size:5,vertical:false,clickable:true,loop:false,interval:0,speed:400,keyboard:true,activeClass:'active',disabledClass:'disabled',hoverClass:null,easing:'swing',items:'.items',prev:'.prev',next:'.next',prevPage:'.prevPage',nextPage:'.nextPage',navi:'.navi',naviItem:'a',onBeforeSeek:null,onSeek:null,alert:true};$.extend(opts,conf);this.each(function(){var el=new Scrollable($(this),opts);$(this).data("scrollable",el);});return this;};})(jQuery);

/* Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 *
 * Version: 3.0.2
 * 
 * Requires: 1.2.2+
 */
(function(c){var a=["DOMMouseScroll","mousewheel"];c.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var d=a.length;d;){this.addEventListener(a[--d],b,false)}}else{this.onmousewheel=b}},teardown:function(){if(this.removeEventListener){for(var d=a.length;d;){this.removeEventListener(a[--d],b,false)}}else{this.onmousewheel=null}}};c.fn.extend({mousewheel:function(d){return d?this.bind("mousewheel",d):this.trigger("mousewheel")},unmousewheel:function(d){return this.unbind("mousewheel",d)}});function b(f){var d=[].slice.call(arguments,1),g=0,e=true;f=c.event.fix(f||window.event);f.type="mousewheel";if(f.wheelDelta){g=f.wheelDelta/120}if(f.detail){g=-f.detail/3}d.unshift(f,g);return c.event.handle.apply(this,d)}})(jQuery);


// JavaScript Document

// jquery-viewer
// requires jquery.1.3.2
// requires jquery.timers-1.2

// author: kristof vandommele
// www.tales.be

$(document).ready(function(){
						   
	//first things first:						   
	//		positioning the textoverlays
	//		 activate the first item

	// 0. , set href on items in controller and in scroller
	$('#jqtalesviewer #controller .item ').each(
		function(){
			
			//var myitem = $(this).html();
			//alert(myitem);
			//get the itemindex
				var whichControllerItem = $(this).parent().index();
				//alert(whichControllerItem);
				$(this).attr('href', '#scrolleritem'+whichControllerItem);
				//alert('whichControllerItem = '+whichControllerItem)
				//$(this).addClass("outlineborder");
							}
		)
	
	$('#scrollcontainer #scrollme .item').each(
		function(){
			
			var myitem = $(this).html();
			//alert(myitem);
			//get the itemindex
				var whichControllerItem = $(this).index();
				//alert(whichControllerItem);
				$(this).attr('id', 'scrolleritem'+whichControllerItem);
			}
		)
	
	
	//focus van a-element overdragen op parent li
	$('#jqtalesviewer #controller .item ').focus(
		function(){
			
			//var myitem = $(this).html();
			//alert(myitem);
			//get the itemindex
				$(this).parent().addClass('focus');
				//alert('whichControllerItem = '+whichControllerItem)
				//$(this).addClass("outlineborder");
							}
		)
	$('#jqtalesviewer #controller .item ').focusout(
		function(){
			
			//var myitem = $(this).html();
			//alert(myitem);
			//get the itemindex
				var whichControllerItem = $(this).index();
				$(this).parent().removeClass('focus');
				//alert('whichControllerItem = '+whichControllerItem)
				//$(this).addClass("outlineborder");
							}
		)
	// 1. loop over each .item .description, calculate height, set top-position
	
	$('#scrollcontainer #scrollme .item .description').each(
		function(){
			var myHeight = $(this).height();		
			//alert('myHeight = '+myHeight);
			var myNewTop = -myHeight -30;
			//$(this).css('top', myNewTop);
			
			}
		)
	// 2. show selected state on first item
	$('#jqtalesviewer #controller li:nth-child(1)').addClass('selected');
	
	
	//vars
	var offsetH = 641;
	var transitionTime = 750;
	var autoTimer = 4500;
	var nrofItems = $('#jqtalesviewer #controller li').children().size();
	//alert ('nr of items = '+nrofItems)
	

	// clicking on an item in the controller...
	$('#jqtalesviewer #controller .item').click(function(e){
			e.preventDefault();
			//remove selected state
			$('#jqtalesviewer #controller li').removeClass('selected');
			//set clicked item to 'selected'
			$(this).parent().addClass('selected');
			//get the clicked index (numbering starts at 0 !)
			var index = $('#jqtalesviewer #controller .item').index(this);
			//var myhref= $(this).attr(href);
			//alert(myhref);
			var offset = -(index*offsetH);
			//alert(offset);
			
			$('#scrollcontainer #scrollme').animate({
				 marginLeft: offset
			  }, transitionTime, function() {
				// Animation complete.
			  });
		})
						   
						   
						   
	$.fn.nextItem = function(){
			 return this.each(function()
				{
				//which item is active?
				var whichSelected = $('#jqtalesviewer #controller li.selected').index();
				
				//alert(whichSelected);
				var whichSelected = whichSelected+1; //adding 1 for nth-child counting
				if (whichSelected == nrofItems){
					var nextSelected = 1;
					}
				else{
					var nextSelected = whichSelected+1;
				}
				
				$('#jqtalesviewer #controller li.selected').removeClass('selected');	
				$('#jqtalesviewer #controller li:nth-child(' + nextSelected + ')').addClass('selected');
				var offset = -((nextSelected-1)*offsetH);
				$('#scrollcontainer #scrollme').animate({
					 marginLeft: offset
				  }, transitionTime, function() {
					// Animation complete.
				  });
				});
			
	}
	

	$.fn.prevItem = function(){
			 return this.each(function()
				{
				//which item is active?
				var whichSelected = $('#jqtalesviewer #controller li.selected').index();
				var whichSelected = whichSelected+1; //adding 1 for nth-child counting
				if (whichSelected == 1){
					var nextSelected = nrofItems;
					}
				else{
					var nextSelected = whichSelected-1;
				}
				
				$('#jqtalesviewer #controller li.selected').removeClass('selected');	
				$('#jqtalesviewer #controller li:nth-child(' + nextSelected + ')').addClass('selected');
				var offset = -((nextSelected-1)*offsetH);
				$('#scrollcontainer #scrollme').animate({
					 marginLeft: offset
				  }, transitionTime, function() {
					// Animation complete.
				  });
				});
			
	}
	
	$.fn.autoPlay = function(){		
		$('#jqtalesviewer #anysurfcontroller #stop').show();
		$('#jqtalesviewer #anysurfcontroller #play').hide();
		var active = false;
						if (!active) {
							//alert(autoTimer);
							active = !active;
							$('#jqtalesviewer #anysurfcontroller #next').everyTime(autoTimer, 'controlled', function() {
								var whichSelected = $('#jqtalesviewer #controller li.selected').index();
								var whichSelected = whichSelected+1; //adding 1 for nth-child counting
								if (whichSelected == nrofItems){
									var nextSelected = 1;
									}
								else{
									var nextSelected = whichSelected+1;
								}
								
								$('#jqtalesviewer #controller li.selected').removeClass('selected');	
								$('#jqtalesviewer #controller li:nth-child(' + nextSelected + ')').addClass('selected');
								var offset = -((nextSelected-1)*offsetH);
								$('#scrollcontainer #scrollme').animate({
									 marginLeft: offset
								  }, transitionTime, function() {
									// Animation complete.
								  });
							});
						}
		
		
	}		
	//var active = false;
	$.fn.autoStop = function(){
		//alert('active = ');
		
						//if (active) {
						//	active = !active;
							$('#jqtalesviewer #anysurfcontroller #next').stopTime('controlled');
							$('#jqtalesviewer #anysurfcontroller #stop').hide();
							$('#jqtalesviewer #anysurfcontroller #play').show();
						//}
		
	}

	// autostart on pageload
	$(this).autoPlay();
	
	$('#jqtalesviewer #anysurfcontroller #next').click(function(){
		$(this).nextItem();
		})
	$('#jqtalesviewer #anysurfcontroller #prev').click(function(){
		$(this).prevItem();											
		})
	$('#jqtalesviewer #anysurfcontroller #stop').click(function(){
		$(this).autoStop();											
		})
	$('#jqtalesviewer #anysurfcontroller #play').click(function(){
		$(this).autoPlay();											
		})
	
		
					   
	}	)


