/*	name			: ClassBehaviours, the javascript framework based on class-name parsing	update			: 9.3.17	author			: Maurice van Creij	dependencies	: jquery.classbehaviours.js	info			: http://www.classbehaviours.com/    This file is part of jQuery.classBehaviours.    ClassBehaviours is a javascript framework based on class-name parsing.    Copyright (C) 2008  Maurice van Creij    ClassBehaviours is free software: you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation, either version 3 of the License, or    (at your option) any later version.    ClassBehaviours is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with ClassBehaviours. If not, see http://www.gnu.org/licenses/gpl.html.*/	// create the jQuery object if it doesn't already exist	if(typeof(jQuery)=='undefined') jQuery = function(){};	// create the root classbehaviours object if it doesn't already exist	if(typeof(jQuery.classBehaviours)=='undefined') jQuery.classBehaviours = function(){};	// create the handlers child object if it doesn't already exist	if(typeof(jQuery.classBehaviours.handlers)=='undefined') jQuery.classBehaviours.handlers = function(){}	// Update a slide based on clicks on thumbnails	jQuery.classBehaviours.handlers.imageViewer = {		// properties		name: 'imageViewer',		index: 0,		stack: 1,		// methods		start: function(node){			// name the element			node.id = (node.id) ? node.id : this.name + this.index++ ;			// set the timeout events			node.onmouseover = this.stop;			node.onmouseout = this.auto;			this.auto(node);			// give all the links from the first list event handlers			allLinks = node.getElementsByTagName('UL')[0].getElementsByTagName('A');			for(var a=0; a<allLinks.length; a++){				allLinks[a].onclick = this.showImage;			}		},		auto: function(that){			var objNode = (typeof(this.nodeName)=='undefined') ? that : this ;			var imv = jQuery.classBehaviours.handlers.imageViewer;			// get the delayed time			delayTime = jQuery.classBehaviours.utilities.getClassParameter(objNode, 'auto', 4000);			// set the timer			timer = objNode.getElementsByTagName('INPUT')[0];			timer.value = (timer.value=='') ? setInterval('jQuery.classBehaviours.handlers.imageViewer.next(document.getElementById("' + objNode.id + '"));', delayTime) : '' ;		},		stop: function(that){			var objNode = (typeof(this.nodeName)=='undefined') ? that : this ;			var imv = jQuery.classBehaviours.handlers.imageViewer;			// clear the timer			timer = objNode.getElementsByTagName('INPUT')[0];			clearInterval(parseInt(timer.value));			timer.value = '';		},		next: function(that){			var objNode = (typeof(this.nodeName)=='undefined') ? that : this ;			var imv = jQuery.classBehaviours.handlers.imageViewer;			// get all the links			var allLinks = objNode.getElementsByTagName('UL')[0].getElementsByTagName('A');			var count = 0;			var found = false;			while(!found && count<allLinks.length){				// find the active one				if(allLinks[count].className == 'active'){					// stop the loop					found = true;					// activate the first one					if(count==allLinks.length-1) this.showImage(allLinks[0])					// or activate the next					else  this.showImage(allLinks[count+1]);				}				// count up				count += 1;			}		},		// events		showImage: function(that){			var objNode = (typeof(this.nodeName)=='undefined') ? that : this ;			var imv = jQuery.classBehaviours.handlers.imageViewer;			// if the slide is not active yet			if(objNode.className != 'active'){				// find the correct slide				slideObj = document.getElementById(objNode.href.split('#')[1]);				// make the slide invisible				jQuery.classBehaviours.fader.setFade(slideObj, 0);				// put it at the top of the stack				imv.stack++				slideObj.style.position = 'absolute';				slideObj.style.zIndex = imv.stack;				// fade it in				jQuery.classBehaviours.fader.fade(slideObj.id, 0, 100, 10, 100, 10, null);				// activate the clicked link				allLinks = objNode.parentNode.parentNode.getElementsByTagName('A');				for(var a=0; a<allLinks.length; a++){					allLinks[a].className = (allLinks[a]==objNode) ? 'active' : '' ;				}			}			// cancel the click			objNode.blur();			return false;		}	}	// add this addon to the jQuery object	if(typeof(jQuery.fn)!='undefined'){		// extend jQuery with this method		jQuery.fn.imageViewer = function(){			return this.each(				function(){					jQuery.classBehaviours.handlers.imageViewer.start(this);				}			);		};		// set the event handler for this jQuery method		$(document).ready(			function(){				$(".imageViewer").imageViewer();			}		);	}
