if(typeof __ === 'undefined') var __ = new tmlib;

//-----config
__.cfg.bottomNavigationbarHome = "30%";
__.cfg.bottomNavigationBarNormal = "93px";
__.cfg.selectorImageNavigationWrapper = "#imagenavigationcontainer";
__.cfg.selectorPagewrap = "#pagewrap";
__.cfg.selectorScrollerContainer = ".imagenavigationlist";
__.cfg.widthWindowForRuleMax = 1140;


//-----instantiation
if(typeof $ !== 'undefined'){
	$(document).ready(function(){
		$("html").addClass("hasjavascript");
		
		__.router = new __.classes.router({boot: {
			elmNavigationBar: $("#navigationbar")
			,ajaxURLLoader: new __.classes.pagerAjax({
					data: {ajaxtype: "backgroundimage"}
					,onpreajaxcall: function(arguments){
						var fncThis = this;
						var fncAjaxParameters = arguments;
						if(this.elmWrapForAnimation && this.elmWrapForAnimation.length > 0){
							this.elmWrapForAnimation.fadeOut(fncThis.duration, function(){
								fncThis.loadAjaxData(fncAjaxParameters);
							});
						}else
							fncThis.loadAjaxData(fncAjaxParameters);
					}
					,onsuccess: function(argData){
						__.imageSwitcher.switche(argData);
					}
			})
			,ajaxImageNavigationLoader: new __.classes.pagerAjax({
					data: {ajaxtype: "backgroundimagenavigation"}
					,elmContainer: $("#navigationbar")
					,elmWrap: $("#imagenavigationcontainer")
					,htmlWrap: '<div id="imagenavigationcontainer"><div id="imagenavigationwrapouter"><div id="imagenavigationwrapinner"></div></div></div>'
					,selectorWrapForAnimation: "#imagenavigationcontainer"
					,selectorWrapForContent: "#imagenavigationwrapinner"
					,oninit: function(){
						//--help out scrollerCategoryImages, seems unecessary now though
						if(typeof __.scrollerImages != "undefined"){
							__.scrollerImages.setWrapper($(__.cfg.selectorImageNavigationWrapper));
							if(__.scrollerImages.boot.elmWrapOuter.length < 1)
								__.scrollerImages.boot.elmWrapOuter = $("#imagenavigationwrapouter");
							if(__.scrollerImages.boot.elmWrapInner.length < 1)
								__.scrollerImages.boot.elmWrapInner = $("#imagenavigationwrapinner");
						}
						var elmsImageItems = this.elmWrapForContent.find(this.boot.selectorNavigationItems);
						if(elmsImageItems.length > 0)
							__.lib.preloadImagesForElements({elmsItems: elmsImageItems, attrURLImage: this.boot.attrURLImage, intervalInitial: this.boot.intervalPreloadInitial});
					}
					,onpreajaxcall: function(arguments){
						var fncThis = this;
						var fncAjaxParameters = arguments;
						if(this.elmWrapForAnimation && this.elmWrapForAnimation.length > 0){
							this.elmWrapForAnimation.slideUp(fncThis.duration, function(){
								fncThis.loadAjaxData(fncAjaxParameters);
							});
						}else
							fncThis.loadAjaxData(fncAjaxParameters);
						__.imageSwitcher.boot.urlToLoad = fncAjaxParameters.url;
					}
					,onsuccess: function(argData){
						var fncThis = this;
						if($.trim(argData) != ""){
							fncThis.elmWrapForContent.html(argData);
//							__.scrollerImages.setContainer(fncThis.elmWrapForContent.find(__.cfg.selectorScrollerContainer));
							__.imageSwitcher.setListItems($(__.imageSwitcher.boot.selectorImageNavigationItems));
							__.hashHandler.hashifyURLs(__.imageSwitcher.elmsListItems);
							fncThis.elmWrapForAnimation.slideDown(fncThis.duration, function(){
//								setTimeout(function(){__.scrollerImages.resize();}, 1500);
							});
							var elmsImageItems = this.elmWrapForContent.find(this.boot.selectorNavigationItems);
							if(elmsImageItems.length > 0){
								__.lib.preloadImagesForElements({elmsItems: elmsImageItems, attrURLImage: this.boot.attrURLImage, intervalInitial: this.boot.intervalPreloadInitial});
							}
							__.imageSwitcher.boot.handlerScrollCenter.setContainer(this.elmWrapForContent.find(__.cfg.selectorScrollerContainer));

						}
						return true;
					}
					,boot: {selectorNavigationItems: ".imagenavigationlist li", attrURLImage: "data-url-image", intervalPreloadInitial: 5000}
			})
			,stringReplacerEmailFriend: new __.classes.stringReplacer({
				strIng: "/display/content/referral/index.php?reftype={{reftype}}&refunid={{refunid}}&refname={{refname}}&mainreftype={{mainreftype}}&mainrefunid={{mainrefunid}}&refurl="+encodeURIComponent(location.protocol+"//"+location.hostname)+"{{refurl}}"
				,arrMatchPieces: {reftype: "P", refunid: "required", refname: "required", mainreftype: "P", mainrefunid: "required", refurl: "required"}
			})
			,stringReplacerFacebook: new __.classes.stringReplacer({
				strIng: "http://www.facebook.com/plugins/like.php?href="+encodeURIComponent(location.protocol+"//"+location.hostname)+"{{urlpiece}}"+"&layout=button_count&show_faces=false&width=200&action=like&colorscheme=light&height=21"
				,arrMatchPieces: {urlpiece: "required"}
			})
			,elmSharingButtons: $("#navigationbar .sharingbuttons")
			,elmButtonEmailFriend: $("#navigationbar .sharingbuttons .email.button a")
			,elmButtonFacebook: $("#navigationbar .sharingbuttons .facebook.button iframe")
			,fncSetEmailFriendURL: function(arguments){
				arguments.refurl = encodeURIComponent(arguments.refurl);
				this.boot.elmButtonEmailFriend.attr("href", this.boot.stringReplacerEmailFriend.getString(arguments));
			}
			,fncNavbarHome: function(){
				this.boot.elmSharingButtons.hide();
				this.boot.elmNavigationBar.animate({bottom: __.cfg.bottomNavigationbarHome}, this.duration);
			}
			,fncNavbarNormal: function(){
				this.boot.elmSharingButtons.show();
				if(this.boot.elmNavigationBar.attr("bottom") != __.cfg.bottomNavigationBarNormal)
					this.boot.elmNavigationBar.animate({bottom: __.cfg.bottomNavigationBarNormal}, this.duration);
			}
			,fncSetFacebookURL: function(argURL){
				this.boot.elmButtonFacebook.attr("src", this.boot.stringReplacerFacebook.getString({urlpiece: argURL}));
			}
			,fncHideImageNavigation: function(){
				this.boot.ajaxImageNavigationLoader.elmWrapForAnimation.slideUp(this.duration)
				this.boot.ajaxImageNavigationLoader.elmWrapForContent.html("");
				__.imageSwitcher.elmLICurrent = $("#thisdoesntexist");
			}
			,fncBasicLoadURL: function(argURL){
				__.imageSwitcher.boot.urlToLoad = argURL;
				this.boot.ajaxURLLoader.loadAjax({url: argURL});
			}
		}});
		
		//--routes
		__.router.addRoute({
			name: "specials"
			,path: /\/specials\/([0-9]+)\/?/
			,matches: {unid: 1}
			,action: "loadPage"
			,boot: {pagetype: "editoritem", contentfor: "maincontent", editornum: 4}
		});
		__.router.addRoute({
			name: "productsitem"
			,path: /\/(products)\/([0-9]+)\/([0-9]+)\/?/
			,matches: {section: 1, catid: 2, unid: 3}
			,action: "loadPage"
			,boot: {pagetype: "editoritem", contentfor: "description", hasImageNavigation: true, editornum: 1}
		});
		__.router.addRoute({
			name: "products"
			,path: /\/(products)\/([0-9]+)\/?/
			,matches: {section: 1, catid: 2}
			,action: "loadPage"
			,boot: {pagetype: "editorcategory", contentfor: "description", hasImageNavigation: true, editornum: 1}
		});
		__.router.addRoute({
			name: "designers"
			,path: "/designers"
			,action: "loadPage"
			,boot: {pagetype: "zonepage", contentfor: "maincontent", zoneid: 4}
		});
		__.router.addRoute({
			name: "blogitem"
			,path: /\/blog\/([0-9]+)\/?/
			,matches: {unid: 1}
			,action: "loadPage"
			,boot: {pagetype: "editoritem", contentfor: "maincontent", editornum: 3}
		});
		__.router.addRoute({
			name: "blog"
			,path: /\/blog/
			,action: "loadPage"
			,boot: {pagetype: "editorlist", contentfor: "maincontent", editornum: 3}
		});
		__.router.addRoute({
			name: "about"
			,path: "/about"
			,action: "loadPage"
			,boot: {pagetype: "zonepage", contentfor: "maincontent", zoneid: 1}
		});
		__.router.addRoute({
			name: "visit"
			,path: "/visit"
			,action: "loadPage"
			,boot: {pagetype: "zonepage", contentfor: "maincontent", zoneid: 3}
		});
		__.router.addRoute({
			name: "home"
			,path: "/"
			,action: "loadPage"
			,boot: {pagetype: "editorlist", contentfor: "description", editornum: 4}
		});
		
		//--route actions
		__.router.addAction({name: "loadPage", callback: function(arguments){
			//--move navbar
			if(arguments.route.name == "home")
				this.boot.fncNavbarHome.call(this);
			else
				this.boot.fncNavbarNormal.call(this);
			//--set sharing links
			//-email a friend
			var argumentsEmailFriend = {refname: arguments.route.name, refurl: arguments.url};
			switch(arguments.route.boot.pagetype){
				case "zonepage":
					argumentsEmailFriend.refunid = arguments.route.boot.zoneid;
					argumentsEmailFriend.mainrefunid = arguments.route.boot.zoneid;
				break;
				case "editorlist":
					argumentsEmailFriend.reftype = "S";
					argumentsEmailFriend.refunid = arguments.route.boot.editornum;
					argumentsEmailFriend.mainreftype = "S";
					argumentsEmailFriend.mainrefunid = arguments.route.boot.editornum;
				break;
				case "editorcategory":
					argumentsEmailFriend.reftype = "C";
					argumentsEmailFriend.refunid = arguments.matches.catid;
					argumentsEmailFriend.mainreftype = "S";
					argumentsEmailFriend.mainrefunid = arguments.route.boot.editornum;
				break;
				case "editoritem":
					argumentsEmailFriend.reftype = "E";
					argumentsEmailFriend.refunid = arguments.matches.unid;
					argumentsEmailFriend.mainreftype = "S";
					argumentsEmailFriend.mainrefunid = arguments.route.boot.editornum;
				break;
			}
			this.boot.fncSetEmailFriendURL.call(this, argumentsEmailFriend);
			//-facebook
			this.boot.fncSetFacebookURL.call(this, arguments.url);
			//--set pagetype for external use
			__.contentPager.boot.loadContentInto = arguments.route.boot.contentfor || "maincontent";
			//--load content and image for url
			this.boot.fncBasicLoadURL.call(this, arguments.url);
			//--handle image navigation
			if(arguments.route.boot.hasImageNavigation){
				if(!(typeof arguments.matches.section != "undefined" && typeof arguments.matches.catid != "undefined" && arguments.matches.catid == $(__.imageSwitcher.boot.selectorImageNavigationList).attr(__.imageSwitcher.boot.attrCatid))){
					this.boot.ajaxImageNavigationLoader.loadAjax({url: arguments.url});
				}
			}else{
				this.boot.fncHideImageNavigation.call(this);
			}
			recordLink(arguments.url);
		}});
		
		//--fullwindow image
		__.fullWindowImage = new __.classes.fullContainerImage({elmContainer: $("body"), elmImage: $("#bgimage img"), doCenterHorizontally: true});
		
		//--hash handler
		__.hashHandler = new __.classes.hashHandler({elmsContainer: $("#topnavigationlist, #imagenavigationwrapinner, #maindescription, #maincontent, #logo"), selectorExclude: ".highslide"
			, onhashchange: function(argHash){
				var url = argHash;
				if(url.substring(0,1) == "#")
					url = url.substring(1, url.length);
				if(!url)
					url = "/";
				__.router.callRoute({path: url, arguments: {url: url}});
			}
			,oninit: function(argHash){
				if(argHash){
					var fncThis = this;
					setTimeout(function(){fncThis.onhashchange.call(fncThis, argHash);}, 500);
				}
			}
		});
				
		var mainnavigationItems = $("#topnavigationlist .topitem, #logo");

		var elmImageNavigationWrapper = $(__.cfg.selectorImageNavigationWrapper);
		//--instantiate scroller	
/*
		__.scrollerImages = new __.classes.buttonscrollerCentererHorizontalNavigation({
			elmWrapper: elmImageNavigationWrapper,
			elmContainer: elmImageNavigationWrapper.find(__.cfg.selectorScrollerContainer),
			htmlButtonContainer: '<div class="relativenavigation"><h3 class="screenreaderonly">Image Navigation</h3></div>',
			htmlButtonPrevious: '<div class="item previous"><a href="javascript://__scroll_to_previous_images"><span class="screenreaderonly">Previous</span></a></div>',
			htmlButtonNext: '<div class="item next"><a href="javascript://__scroll_to_next_images"><span class="screenreaderonly">Next</span></a></div>'
			,onresize: function(){
				var fncThis = this;
				//--shrink navigation if list is smaller than wrap
				var widthNavigationlistCurrent = fncThis.elmContainer.outerWidth();
				var newWidth = (widthNavigationlistCurrent < fncThis.boot.maxWidth)? widthNavigationlistCurrent: fncThis.boot.maxWidth;
				fncThis.boot.elmWrapInner.add(fncThis.boot.elmWrapOuter).animate({width: newWidth}, function(){
					fncThis.widthWrapper = fncThis.elmWrapper.outerWidth();
					fncThis.widthContainer = fncThis.elmContainer.outerWidth();
					fncThis.toggleButtonEnable();
				});
			}
			,boot: {elmWrapOuter: $("#imagenavigationwrapouter"), elmWrapInner: $("#imagenavigationwrapinner"), maxWidth: 732}
		});
*/

		__.relativeNavigationImages = new __.classes.relativeNavigationHandler({
			elmWrapper: elmImageNavigationWrapper
			,htmlButtonContainer: '<div class="relativenavigation"><h3 class="screenreaderonly">Image Navigation</h3></div>'
			,htmlButtonPrevious: '<div class="item previous"><a href="javascript://__go_to_previous_image"><span class="screenreaderonly">Previous</span></a></div>'
			,htmlButtonNext: '<div class="item next"><a href="javascript://__go_to_next_image"><span class="screenreaderonly">Next</span></a></div>'
			,selectorElmForLinkManagement: "a"
		});

		//--image switcher
		var selectorImageNavigationItems = "#imagenavigationcontainer .imagenavigationlist li";
		__.imageSwitcher = new __.classes.imageSwitcher({duration: 1200, elmsListItems: $(selectorImageNavigationItems), elmImage: $("#bgimage img"), elmListImages: $("#bgimage"), typeAnimation: "dissolve", attrImageURL: "data-url-image", selectorElmImageUrl: "this", doAttachEvents: false
			,oninit: function(){
				this.onpostimageanimation.call(this);
			}
			,onpreimageanimationfadeout: function(arguments){
				__.fullWindowImage.setImage(this.elmImage);
				this.queue.dequeue("image");
			}
			,onpreimageanimation: function(arguments){
				var fncUnid = arguments.newLI.attr(this.boot.attrUnid);
/* 				var fncCatid = $(this.boot.selectorImageNavigationList).attr(this.boot.attrCatid); */
				var ajaxParameters = {data: {unid: fncUnid}};
/*
				if(fncCatid)
					ajaxParameters.data.catid = fncCatid;
*/
				if(this.boot.urlToLoad)
					ajaxParameters.url = this.boot.urlToLoad;
				
				__.contentPager.loadAjax(ajaxParameters);
				this.boot.urlToLoad = false;
			}
			,onpostimageanimation: function(arguments){
/*
				var fncThis = this;
				var fncArguments = arguments || {};
*/
				var linkPrevious = "";
				var linkNext = "";
				if(typeof arguments != "undefined" && typeof arguments.newLI != "undefined" && arguments.newLI.length > 0){
					var elmLI = arguments.newLI;
				}else{
					var elmLI = this.elmLICurrent;
				}
/*
				if(!elmLI || (elmLI && elmLI.length < 1)){
					elmLI = this.elmListImages.first();
				}
*/
				if(elmLI && elmLI.length > 0){
					var previousLI = elmLI.prev();
					var nextLI = elmLI.next();
					if(previousLI.length > 0){
						linkPrevious = previousLI.find(this.boot.selectorElmHref).attr(this.boot.attrLink);
					}
					if(nextLI.length > 0){
						linkNext = nextLI.find(this.boot.selectorElmHref).attr(this.boot.attrLink);
					}
					this.boot.handlerScrollCenter.setItem(elmLI);
					__.relativeNavigationImages.setPreviousLink(linkPrevious);
					__.relativeNavigationImages.setNextLink(linkNext);
				//->wait until navigation is set
/*
				}else{
					setTimeout(function(){
__.message("refiring onpostimageanimation");		
						fncThis.onpostimageanimation(fncArguments);
					}, 100);
*/
				}
			}
/*
			,onsetlistitems: function(){
				this.onpostimageanimation();
			}
*/
			,boot: {
				attrUnid: "data-unid"
				,attrCatid: "data-catid"
				,attrLink: "href"
				,handlerScrollCenter: new __.classes.scrollerCentererHorizontal({
					elmWrapper: elmImageNavigationWrapper,
					elmContainer: elmImageNavigationWrapper.find(__.cfg.selectorScrollerContainer)
				})
				,selectorElmHref: "a"
				,selectorImageNavigationList: "#imagenavigationcontainer .imagenavigationlist"
				,selectorImageNavigationItems: selectorImageNavigationItems
				,urlToLoad: null
			}
		});
		
		__.contentPager = new __.classes.pagerAjax({url: "/products/"
			,elmWrap: $("#maindescriptionwrap")
			,elmContainer: $(__.cfg.selectorPagewrap)
			,htmlWrap: '<div id="maindescriptionwrap"><div id="maindescription"></div></div>'
			,selectorWrapForAnimation: "#maindescription"
			,selectorWrapForContent: "#maindescription"
			,onpreajaxcall: function(arguments){
				var fncThis = this;
				var fncAjaxParameters = arguments;
				var callbackMaincontent = function(){};
				var callbackMaindescription = function(){};
				var callback = function(){
					fncThis.loadAjaxData(fncAjaxParameters);
				}
				
				if(fncThis.boot.loadContentInto == "maincontent")
					callbackMaincontent = callback;
				else
					callbackMaindescription = callback;		

				fncThis.boot.elmMaincontentWrapForAnimation.fadeOut(fncThis.duration, callbackMaincontent);
				fncThis.elmWrapForAnimation.fadeOut(fncThis.duration, callbackMaindescription);
			}
			,onsuccess: function(argData){
				var fncThis = this;
				var fncData = $.parseJSON(argData);
				var fncTitle = fncData.title;
				var fncTextContent = fncData.content;
				if($.trim(fncTitle))
					document.title = fncTitle;
				else
					document.title = fncThis.boot.titleDefault;
				if($.trim(fncTextContent)){
					if(fncThis.boot.loadContentInto == "maincontent"){
						fncThis.boot.elmMaincontentWrapForContent.html(fncTextContent);
						__.hashHandler.hashifyURLs(fncThis.boot.elmMaincontentWrapForContent);
						fncThis.boot.elmMaincontentWrapForAnimation.fadeIn(fncThis.duration);
					}else{
						fncThis.elmWrapForContent.html(fncTextContent);
						__.hashHandler.hashifyURLs(fncThis.elmWrapForContent);
						fncThis.elmWrapForAnimation.fadeIn(fncThis.duration);
					}
				}
				fncThis.boot.loadContentInto = false;
				__.imageSwitcher.queue.dequeue("image");
			}
			,oninit: function(){
				//--ensure main container  is visible, will otherwise not be if created automatically
				this.elmWrap.show();
				if(this.elmWrapForAnimation.html() == "")
					this.elmWrapForAnimation.hide();
				
				//--set or create other content holder
				this.boot.elmMaincontentWrapForAnimation = $(this.boot.selectorMaincontentWrapForAnimation);
				if(this.boot.elmMaincontentWrapForAnimation.length < 1){
					this.boot.elmMaincontentWrap = $(this.boot.htmlMaincontentWrap);
					this.boot.elmMaincontentWrap.hide();
					this.boot.elmFullheighter.after(this.boot.elmMaincontentWrap);
				}else
					this.boot.elmMaincontentWrap = this.boot.elmMaincontentWrapForAnimation;
				this.boot.elmMaincontentWrapForAnimation = $(this.boot.selectorMaincontentWrapForAnimation);
				this.boot.elmMaincontentWrapForContent = $(this.boot.selectorMaincontentWrapForContent);
			}
			,boot: {
				loadContentInto: false
				,htmlMaincontentWrap: '<div id="maincontentwrapouter"><div id="maincontentwrapinner"><div id="maincontent"></div></div></div>'
				,elmFullheighter: $("#fullheighter")
				,selectorMaincontentWrapForAnimation: "#maincontentwrapouter"
				,selectorMaincontentWrapForContent: "#maincontent"
				,titleDefault: "Block Bros"
			}
		});
	});
	
	if($.browser.msie && $.browser.version < 9 && $.browser.version > 6.99999){
		__.windowWidthForMediaQueryHandler = {
			widthMax: __.cfg.widthWindowForRuleMax
			,handleResize: function(){
				var currentWidth = $("body").outerWidth();
				if(currentWidth <= this.widthMax){
					$("#imagenavigationcontainer").css("margin-left", "201px");
					$("#maincontentwrapouter").css("margin-left", "281px");
				}else{
					$("#imagenavigationcontainer").css("margin-left", "auto");
					$("#maincontentwrapouter").css("margin-left", "auto");
				}
			}
		};
		$(window).resize(function(){
			__.windowWidthForMediaQueryHandler.handleResize.call(__.windowWidthForMediaQueryHandler);
		});
	}
}



//-----classes
/*-------
©router
-------- */
__.classes.router = function(arguments){
		//--optional attributes
		this.boot = arguments.boot || null;
		this.currentRoot = arguments.currentRoot || "null";
		
		//--derived attributes
		this.routes = [];
		this.actions = [];
		
		//--do something
	}
	__.classes.router.prototype.addAction = function(arguments){
		var fncName = arguments.name;
		var fncCallback = arguments.callback;
		this.actions[fncName] = fncCallback;
	}
/*
@param action (function): action to be performed by callroute for this route
@param name: name for access by callroute
@param path (optional): path regex to check
*/
	__.classes.router.prototype.addRoute = function(arguments){
		var fncName = arguments.name;
		var fncArguments = arguments;
		this.routes[fncName] = fncArguments;
	}
	__.classes.router.prototype.callRoute = function(arguments){
		var localvars = {};
		if(typeof arguments == "string"){
			localvars.name = arguments;
		}else{
			localvars = arguments;
		}
		if(typeof localvars.scope == "undefined")
			localvars.scope = this;
		if(typeof localvars.arguments == "undefined")
			localvars.arguments = {};

		if(typeof localvars.name != "undefined"){
			localvars.arguments.route = this.routes[localvars.name];
			this.actions[this.routes[localvars.name].action].call(localvars.scope, localvars.arguments);
		}else{
			this.callRouteForPath(localvars);
		}
	}
	__.classes.router.prototype.callRouteForPath = function(arguments){
		var localvars = arguments;
		if(typeof localvars.path == "undefined")
			return false;
//->return
		if(typeof localvars.scope == "undefined")
			localvars.scope = this;
		if(typeof localvars.arguments == "undefined")
			localvars.arguments = {};

		var fncRoute = this.routeLookup(localvars.path);
		if(fncRoute){
			localvars.arguments.route = fncRoute;
			if(fncRoute.path.exec){
				localvars.arguments.matches = fncRoute.path.exec(localvars.path);
				if(typeof fncRoute.matches != "undefined"){
					for(var key in fncRoute.matches){
						if(fncRoute.matches.hasOwnProperty(key))
							localvars.arguments.matches[key] = localvars.arguments.matches[fncRoute.matches[key]];
					}
				}
			}
			this.actions[fncRoute.action].call(localvars.scope, localvars.arguments)
		}
	}
	__.classes.router.prototype.routeLookup = function(argPath){
		var fncReturn = false;
		for(var key in this.routes){
			var route = this.routes[key];
			if(this.routes.hasOwnProperty(key) && typeof route.path != "undefined"){
				if(typeof route.path == "string"){
					if(route.path == argPath || route.path+"/" == argPath || route.path == argPath+"/"){
						fncReturn = route;
						break;
					}
				}else{ //-assumed a regex
					if(argPath.match(route.path)){
						fncReturn = route;
						break;
					}
				}
			}
		}
		return fncReturn;
	}

/*---------
©stringReplacer
----------*/
__.classes.stringReplacer = function(arguments){
		//--optional attributes
		this.boot = arguments.boot || null;
		this.arrMatchPieces = arguments.arrMatchPieces || [];
		this.strKey = arguments.strKey || "key";
		this.strMatchKey = arguments.strMatchKey || "{{key}}";
		this.strRequired = arguments.strRequired || "required";
		this.strIng = arguments.strIng || "";
	}
	__.classes.stringReplacer.prototype.getString = function(argMatchPieces){
		var fncReturn = this.strIng;
		//--set matches to defaults, override with arguments
		var fncMatchPieces = this.arrMatchPieces;
		for(var key in argMatchPieces){
			if(argMatchPieces.hasOwnProperty(key)){
				fncMatchPieces[key] = argMatchPieces[key];
			}
		}
		//--match each key with string
		for(var key in fncMatchPieces){
			//-ensure required keys passes
			if(fncMatchPieces.hasOwnProperty(key) && fncMatchPieces[key] == this.strRequired){
__.message("-exeption[regexHandler]: required key "+key+" not supplied.");
//->return on unpassed required key
				return false;
			}
			var currentMatch = this.strMatchKey.replace(this.strKey, key);
			fncReturn = fncReturn.replace(currentMatch, fncMatchPieces[key]);
		}
		return fncReturn;
	}


/*-------
©hashHandler
-------- */
__.classes.hashHandler = function(arguments){
		//--optional attributes
		this.elmsContainer = arguments.elmsContainer || null;
		this.onhashchange = arguments.onhashchange || null;
		this.oninit = arguments.oninit || null;
		this.selectorAnchors = arguments.selectorAnchors || "a";
		this.selectorExclude = arguments.selectorExclude || null;
		this.selectorInclude = arguments.selectorInclude || null;

		//--derived attributes
		var fncThis = this;
		//--hashify urls
		if(this.elmsContainer)
			this.hashifyURLs(this.elmsContainer);
		
		//--attach listener for hash change
		if(this.onhashchange)
			$(window).bind("hashchange", function(){
				var url = location.hash || "/";
				fncThis.onhashchange.call(fncThis, url);
			});
		
		if(this.oninit)
			this.oninit.call(fncThis, location.hash);
	}
	__.classes.hashHandler.prototype.hashifyURLs = function(argContainers){
		if(argContainers && argContainers.length > 0){
			var elmsAnchors = argContainers.find(this.selectorAnchors).add(argContainers.filter(this.selectorAnchors));
			if(this.selectorExclude)
				elmsAnchors = elmsAnchors.not(this.selectorExclude);
			else if(this.selectorInclude)
				elmsAnchors = elmsAnchors.filter(this.selectorInclude);
			elmsAnchors.each(function(){
				var elmThis = $(this);
				var currentHref = elmThis.attr("href");
				if(currentHref && currentHref.substring(0,1) == "/")
					elmThis.attr("href", "#"+currentHref);
			});
		}
	}


/*-------
©pagerAjax
-------- */
__.classes.pagerAjax = function(arguments){
		//--optional arguments
		this.boot = arguments.boot || null;
		this.data = arguments.data || {};
		this.duration = arguments.duration || 500;
		this.elmContainer = arguments.elmContainer || $("body");
		this.elmWrap = arguments.elmWrap || null;
		this.selectorWrapForAnimation = arguments.selectorWrapForAnimation || null;
		this.selectorWrapForContent = arguments.selectorWrapForContent || null;
		this.htmlWrap = arguments.htmlWrap || null;
		this.oninit = arguments.oninit || null;
		this.onpreajaxcall = (typeof arguments.onpreajaxcall != "undefined")? arguments.onpreajaxcall: this.animationBasicPreCall;
		this.onsuccess = (arguments.onsuccess)? arguments.onsuccess: this.animationBasicOnSuccess;
		this.paramAjax = arguments.paramAjax || "ajaxcall";
		this.url = arguments.url || null;

		//--derived members
		if((!this.elmWrap || this.elmWrap.length < 1) && this.htmlWrap){
			this.elmWrap = $(this.htmlWrap);
			this.elmWrap.hide();
			this.elmContainer.append(this.elmWrap);
		}
		this.elmWrapForAnimation = $(this.selectorWrapForAnimation);
		this.elmWrapForContent = $(this.selectorWrapForContent);
		
		if(this.oninit)
			this.oninit.call(this);
	}
	__.classes.pagerAjax.prototype.loadAjax = function(arguments){
		var fncThis = this;
		var fncAjaxParameters = arguments;
		
		if(this.onpreajaxcall)
			this.onpreajaxcall.call(fncThis, fncAjaxParameters);
		else
			this.loadAjaxData(fncAjaxParameters);
	}
	__.classes.pagerAjax.prototype.loadAjaxData = function(arguments){
		var fncAjaxParameters = arguments;
		
		//--set default parameters
		if(!fncAjaxParameters.success)
			fncAjaxParameters.success = function(data){
				this.onsuccess.call(this, data);
			}
		if(!fncAjaxParameters.context)
			fncAjaxParameters.context = this;
		var oldData = arguments.data;
		fncAjaxParameters.data = this.data;
		if(typeof arguments.data != "undefined"){
			for(var key in oldData){
				if(oldData.hasOwnProperty(key)){
					fncAjaxParameters.data[key] = oldData[key];
				}
			}
		}
			
		fncAjaxParameters.data[this.paramAjax] = 1;
		if(!fncAjaxParameters.url)
			fncAjaxParameters.url = this.url;
		
		$.ajax(fncAjaxParameters);
	}
	__.classes.pagerAjax.prototype.animationBasicPreCall = function(arguments){
		var fncThis = this;
		var fncAjaxParameters = arguments;
		if(this.elmWrapForAnimation && this.elmWrapForAnimation.length > 0){
			this.elmWrapForAnimation.fadeOut(fncThis.duration, function(){
				fncThis.loadAjaxData(fncAjaxParameters);
			});
		}else
			fncThis.loadAjaxData(fncAjaxParameters);
	}
	__.classes.pagerAjax.prototype.animationBasicOnSuccess = function(argData){
		var fncThis = this;
		var fncTextContent = argData;

		if($.trim(fncTextContent)){
			fncThis.elmWrapForContent.html(fncTextContent);
			fncThis.elmWrapForAnimation.fadeIn(fncThis.duration);
		}
	}

/*----------
©fullContainerImage
----------*/
//-@http://css-tricks.com/perfect-full-page-background-image/
//-@http://plugins.jquery.com/project/fullscreenr
__.classes.fullContainerImage = function(arguments){
		//--optional attributes
		this.boot = arguments.boot || null;
		this.elmContainer = arguments.elmContainer || $(window);
		this.classFitWidth = arguments.classFitWidth || "fitwidth";
		this.classFitHeight = arguments.classFitHeight || "fitheight";
		this.doCenterHorizontally = arguments.doCenterHorizontally || false;
		this.doCenterVertically = arguments.doCenterVertically || false;
		this.oninit = arguments.oninit || null;
		
		//--derived attributes
		var fncThis = this;
		var fncElmImage = arguments.elmImage || null;
		this.setImage(fncElmImage);
		
		//--bind events
		this.elmContainer.bind("resize", function(){
			fncThis.setClass();
		});
		
		if(this.oninit)
			this.oninit.call(this);
	}
	__.classes.fullContainerImage.prototype.setClass = function(){
		if(this.elmImage.length > 0){
			if((this.elmContainer.width() / this.elmContainer.height()) < this.aspectRatioImage ){
				if(!this.elmImage.hasClass(this.classFitHeight)){
					this.elmImage.removeClass(this.classFitWidth).addClass(this.classFitHeight);
					if(this.doCenterVertically)
						this.elmImage.css("top", 0);
				}
				if(this.doCenterHorizontally)
					this.elmImage.css("left", -((this.elmImage.width() - this.elmContainer.width()) / 2));
			}else{
				if(!this.elmImage.hasClass(this.classFitWidth)){
					this.elmImage.removeClass(this.classFitHeight).addClass(this.classFitWidth);
					if(this.doCenterHorizontally)
						this.elmImage.css("left", 0);
				}
				if(this.doCenterVertically)
					this.elmImage.css("top", -((this.elmImage.height() - this.elmContainer.height()) / 2));
			}
		}
	}
	__.classes.fullContainerImage.prototype.setImage = function(argElmImage){
		var fncThis = this;
		this.elmImage = argElmImage;
		if(this.elmImage.length > 0){
			var fncCallback = function(){
				var fncWidthHeight = __.getHiddenElementWidthHeight(this.elmImage);
				this.aspectRatioImage = fncWidthHeight.width / fncWidthHeight.height;
				this.setClass();
			}
			if(this.elmImage.width() > 0){
				fncCallback.call(this);;
			}else{
				this.elmImage.bind("load", function(){
					fncCallback.call(fncThis);
				});
			}
		}else
			this.aspectRatio = false;

	}

/*----------
©relativeNavigationHandler
---------*/
__.classes.relativeNavigationHandler = function(arguments){
		//--optional arguments
		this.attrForLinkManagement = arguments.attrForLinkManagement || "href";
		this.boot = arguments.boot || null;
		this.elmWrapper = arguments.elmWrapper || null;
		this.eventsBindTo = (arguments.eventsBindTo)? arguments.eventsBindTo: "click touch";
		this.elmButtonPrevious = arguments.elmButtonPrevious || null;
		this.elmButtonNext = arguments.elmButtonNext || null;
		this.htmlButtonContainer = arguments.htmlButtonContainer || null;
		this.htmlButtonPrevious = arguments.htmlButtonPrevious || null;
		this.htmlButtonNext = arguments.htmlButtonNext || null;
		this.onactivateprevious = arguments.onactivateprevious || null;
		this.onactivatenext = arguments.onactivatenext || null;
		this.oninit = arguments.oninit || null;
		this.selectorElmForLinkManagement = arguments.selectorElmForLinkManagement || null;
		this.testShowNext = arguments.testShowNext || function(){return true;};
		this.testShowPrevious = arguments.testShowPrevious || function(){return true;};
		
		
		//--derived members
		var fncThis = this;
		//-create button navigation
		if(this.htmlButtonContainer){
			this.elmButtonContainer = $(this.htmlButtonContainer)
			this.elmWrapper.append(this.elmButtonContainer);
		}else{
			this.elmButtonContainer = this.elmWrapper;
		}
		if(arguments.elmButtonPrevious){
			this.elmButtonPrevious = arguments.elmButtonPrevious;
		}else if(this.htmlButtonPrevious){
			this.elmButtonPrevious = $(this.htmlButtonPrevious);
			this.elmButtonContainer.append(this.elmButtonPrevious);
		}
		if(arguments.elmButtonNext){
			this.elmButtonNext = arguments.elmButtonNext;
		}else if(this.htmlButtonNext){
			this.elmButtonNext = $(this.htmlButtonNext);
			this.elmButtonContainer.append(this.elmButtonNext);
		}
		
		//--bind actions
		if(this.elmButtonPrevious && this.elmButtonPrevious.length > 0)
			this.bindActionPrevious(this.elmButtonPrevious);
		if(this.elmButtonNext && this.elmButtonNext.length > 0)
			this.bindActionNext(this.elmButtonNext)
		
		this.handleButtonShowHide();	
	}
	__.classes.relativeNavigationHandler.prototype.bindActionPrevious = function(argElement){
		var fncThis = this;
		if(fncThis.onactivateprevious)
			argElement.bind(this.eventsBindTo, function(){fncThis.onactivateprevious.call(fncThis)});
	}
	__.classes.relativeNavigationHandler.prototype.bindActionNext = function(argElement){
		var fncThis = this;
		if(fncThis.onactivatenext)
			argElement.bind(this.eventsBindTo, function(){fncThis.onactivatenext.call(fncThis)});
	}
	__.classes.relativeNavigationHandler.prototype.handleButtonShowHide = function(){
		if(this.testShowPrevious()){
			this.elmButtonPrevious.show();
		}else{
			this.elmButtonPrevious.hide();
		}
		if(this.testShowNext()){
			this.elmButtonNext.show();
		}else{
			this.elmButtonNext.hide();
		}
	}
	__.classes.relativeNavigationHandler.prototype.setPreviousLink = function(argLink){
		if(this.selectorElmForLinkManagement){
			if(this.selectorElmForLinkManagement == "this")
				var elmForLinkManagement = this.elmButtonPrevious;
			else
				var elmForLinkManagement = this.elmButtonPrevious.find(this.selectorElmForLinkManagement);
			if(argLink)
				elmForLinkManagement.attr(this.attrForLinkManagement, argLink);
			else
				elmForLinkManagement.removeAttr(this.attrForLinkManagement);
			if(argLink){
				this.elmButtonPrevious.show();
			}else{
				this.elmButtonPrevious.hide();
			}
		}else
			return false;
	}
	__.classes.relativeNavigationHandler.prototype.setNextLink = function(argLink){
		if(this.selectorElmForLinkManagement){
			if(this.selectorElmForLinkManagement == "this")
				var elmForLinkManagement = this.elmButtonNext;
			else
				var elmForLinkManagement = this.elmButtonNext.find(this.selectorElmForLinkManagement);
			if(argLink)
				elmForLinkManagement.attr(this.attrForLinkManagement, argLink);
			else
				elmForLinkManagement.removeAttr(this.attrForLinkManagement);
			if(argLink){
				this.elmButtonNext.show();
			}else{
				this.elmButtonNext.hide();
			}
		}else
			return false;
	}

/* --------
©scrollerCentererHorizontal
------- */
__.classes.scrollerCentererHorizontal = function(arguments){
		//--optional arguments
		this.boot = arguments.boot || null;
		this.doUpdateWidthOnWindowResize = arguments.doUpdateWidthOnWindowResize || false;
		this.duration = arguments.duration || 500;
		if(arguments.elmWrapper)
			this.setWrapper(arguments.elmWrapper);
		else
			this.elmWrapper = null;
		this.oninit = arguments.oninit || null;
		this.onresize = arguments.onresize || null;
		
		//--derived members
		var fncThis = this;
				
		//--adjust wrapper width on window resize
		if(fncThis.doUpdateWidthOnWindowResize){
			$(window).bind("resize", function(){
				fncThis.resize();
			});
		}
		
		//--set container
		if(arguments.elmContainer)
			this.setContainer(arguments.elmContainer);
		else
			this.elmContainer = null;
		
		//-*must be done for browsers with slow image loading
//		setTimeout(function(){fncThis.resize();}, 500);

		if(fncThis.oninit)
			fncThis.oninit.call(this);
	}
	__.classes.scrollerCentererHorizontal.prototype.setItem = function(argElmItem){
//->return
		if(!argElmItem || argElmItem.length < 1)
			return false;
		var localvars = {
			position: argElmItem.position()
		};
		//--only need to move if container wider than wrapper
		if(this.widthContainer > this.widthWrapper){
			localvars.positionCenter = localvars.position.left + (argElmItem.width() / 2);
			localvars.newContainerLeft = this.centerWrapper - localvars.positionCenter
			localvars.newContainerRight = "auto";
			if(localvars.newContainerLeft > 0){
				localvars.newContainerLeft = 0;
			}
			if(this.widthWrapper - localvars.newContainerLeft > this.widthContainer){
				localvars.newContainerLeft = "auto";
				localvars.newContainerRight = 0;
			}
			if(localvars.newContainerRight == "auto"){
				this.elmContainer.animate({left: localvars.newContainerLeft}, this.duration);
				this.elmContainer.css({right: localvars.newContainerRight});
			}else{
				this.elmContainer.animate({right: localvars.newContainerRight}, this.duration);
				this.elmContainer.css({left: localvars.newContainerLeft});
			}
				
		}
	}
	__.classes.scrollerCentererHorizontal.prototype.resize = function(){
		if(this.onresize){
			this.onresize.call(this);		
		}else{
			this.widthWrapper = this.elmWrapper.outerWidth();
			this.centerWrapper = this.widthWrapper / 2;
		}
	}
	__.classes.scrollerCentererHorizontal.prototype.setContainer = function(argElement){
		var fncThis = this;
		this.elmContainer = argElement;
		if(this.elmContainer.length > 0){
			setTimeout(function(){
				fncThis.widthContainer = fncThis.elmContainer.outerWidth();
				fncThis.resize();
			}, 1500);
		}
	}
	__.classes.scrollerCentererHorizontal.prototype.setWrapper = function(argElement){
		this.elmWrapper = argElement;
		this.widthWrapper = (argElement.length > 0)? this.elmWrapper.outerWidth(): 0;
		this.centerWrapper = (argElement.length > 0)? this.widthWrapper / 2: 0;
	}

/*-------------
©imageswitcher
------------*/
__.classes.imageSwitcher = function(arguments){
		//--optional arguments
		this.attrImageURL = (arguments.attrImageURL)?arguments.attrImageURL:"href";
		this.attrKeepWidth = arguments.attrKeepWidth || null;
		this.attrKeepHeight = arguments.attrKeepHeight || null;
		this.boot = arguments.boot || null;
		this.classCurrent = (typeof arguments.classCurrent != "undefined")? arguments.classCurrent: "current";
		this.doAttachEvents = (typeof arguments.doAttachEvents != "undefined")? arguments.doAttachEvents: true;
		this.duration = (arguments.duration)? arguments.duration: 500;
//		this.elmImage = (arguments.elmImage && arguments.elmImage.length > 0) ? arguments.elmImage : null;
		this.elmKeepDimensions = arguments.elmKeepDimensions || false;
		this.elmListImages = arguments.elmListImages || null;
		this.htmlNewImage = arguments.htmlNewImage || "<img alt=\"\" />";
		this.listItemSelectedState = arguments.listItemSelectedState || null;
		this.listItemUnselectedState = arguments.listItemUnselectedState || null;
		this.ondeselect = arguments.ondeselect || null;
		this.oninit = arguments.oninit || null;
		this.onpredeselect = arguments.onpredeselect || null;
		this.onpreimageanimation = arguments.onpreimageanimation || null;
		this.onpreselect = arguments.onpreselect || null;
		this.onpostimageanimation = arguments.onpostimageanimation || null;
		this.onpreimageanimationfadeout = arguments.onpreimageanimationfadeout || null;
		this.onpreimageanimationkeepheight = arguments.onpreimageanimationkeepheight || null;
		this.onpreimageanimationfadein = arguments.onpreimageanimationfadein || null;
		this.onpreimageanimationpostkeepheight = arguments.onpreimageanimationpostkeepheight || null;
		this.onselect = arguments.onselect || null;
		this.onsetimage = arguments.onsetimage || null;
		this.onsetlistitems = arguments.onsetlistitems || null;
		this.selectorListItemContainer = (typeof arguments.selectorListItemContainer != "undefined")?arguments.selectorListItemContainer:"li";
		this.selectorElmImageUrl = arguments.selectorElmImageUrl || "a";
		this.typeAnimation = arguments.typeAnimation || "fadeoutfadein";
		
		//--derived members
		this.inprogress=false;
		this.queue = new __.classes.animationQueue({name: "image", autoDequeue: false});
		if(arguments.elmImage)
			this.setImage(arguments.elmImage);
		else
			this.elmImage = null;
		if(arguments.elmsListItems)
			this.setListItems(arguments.elmsListItems);
		else
			this.elmsListItems = null;
		
		if(this.oninit)
			this.oninit.call(this);
	}
	__.classes.imageSwitcher.prototype.findElmLIForURL = function(argURL){
		var selectorAttribute = "["+this.attrImageURL+"='"+$.trim(argURL)+"']";
		if(this.selectorElmImageUrl == "this"){
			return this.elmsListItems.filter(selectorAttribute);
		}else{
			return this.elmsListItems.has(this.selectorElmImageUrl+selectorAttribute);
		}
	}
	__.classes.imageSwitcher.prototype.setImage = function(argElement){
		this.elmImage = argElement;
		this.urlCurrent = this.elmImage.attr("src");
		if(this.onsetimage)
			this.onsetimage.call(this);
	}
	__.classes.imageSwitcher.prototype.setListItems = function(argElements){
		this.elmsListItems = argElements;
		if(this.elmsListItems.length > 0){
			this.elmLICurrent = this.elmsListItems.filter(this.classCurrent);
			if(this.elmLICurrent.length < 1){
				this.elmLICurrent = this.findElmLIForURL(this.urlCurrent);
				this.elmLICurrent.addClass(this.classCurrent);
			}
			if(this.doAttachEvents)
				this.attachEvents();
			if(this.onsetlistitems)
				this.onsetlistitems.call(this);
		}
	}
	__.classes.imageSwitcher.prototype.attachEvents = function(){
		if(this.elmsListItems.length == 0) return false;
		var fncThis = this;
		fncThis.elmsListItems.children("a").bind("click", function(event){
			if(event.preventDefault) event.preventDefault();

			var thisItem = $(this).closest(fncThis.selectorListItemContainer);
			fncThis.switchToItem(thisItem);
			
			return false;
		});
	}
	__.classes.imageSwitcher.prototype.switchToNext = function(){
		var currentItem = this.elmsListItems.filter("."+this.classCurrent);
		this.switchToItem(currentItem.next());
	}
	__.classes.imageSwitcher.prototype.switchToPrevious = function(){
		var currentItem = this.elmsListItems.filter("."+this.classCurrent);
		this.switchToItem(currentItem.prev());
	}
	__.classes.imageSwitcher.prototype.switchToItem = function(elmNewItem){
		var currentItem = this.elmsListItems.filter("."+this.classCurrent);
//->return
		if(elmNewItem[0] == currentItem[0] || elmNewItem.length < 1) return false;		
		if(this.selectorElmImageUrl == "this"){
			var newImageURL = elmNewItem.attr(this.attrImageURL);
		}else{
			var elmA = elmNewItem.find(this.selectorElmImageUrl);
			var newImageURL = elmA.attr(this.attrImageURL);
		}
		if(!newImageURL) newImageURL = elmNewItem.attr(this.attrImageURL);
//->return
		if(!newImageURL) return false;
		this.switche(newImageURL);
	}
	__.classes.imageSwitcher.prototype.switche = function(newImageURL, arguments){
		var fncThis = this;

//-> return
		if(fncThis.inprogress==true) return false;		
		
		var oldLI = fncThis.elmsListItems.filter("."+fncThis.classCurrent);
		var newLI = this.findElmLIForURL($.trim(newImageURL));
		var newA = newLI.find("a");
		fncThis.inprogress = true;

		//--run pre-animate callback
		if(fncThis.onpredeselect)
			fncThis.onpredeselect.call(fncthis, oldLI);
		if(fncThis.onpreselect)
			fncThis.onpreselect.call(fncThis, newLI);
		
		var elmTempImage = $("<img class=\"tempimage\" src='"+newImageURL+"' />").css({"position":"absolute", "left":"-9000px", "top":"-9000px"}).appendTo("body");
		
		if(fncThis.elmKeepDimensions){
			fncThis.elmKeepDimensions.css({"height": fncThis.elmImage.height(), "width": fncThis.elmImage.width()});
			var widthNew = false, heightNew = false;
			if(fncThis.attrKeepWidth)
				widthNew = newLI.attr(fncThis.attrKeepWidth) || false;
			if(fncThis.attrKeepHeight)
				heightNew = newLI.attr(fncThis.attrKeepHeight) || false;
			if(!(widthNew || heightNew)){
				widthNew = widthNew || elmTempImage.width() || fncThis.elmImage.width();
				heightNew = heightNew || elmTempImage.height() || fncThis.elmImage.height();
			}
		}
		
		var fncLocalVariables = {newLI: newLI, oldLI: oldLI};

		//--animate navigation
		newLI.addClass(fncThis.classCurrent);

		fncThis.queue.queue({name: "navigation", callback: function(){
			oldLI.children("a").animate(fncThis.listItemUnselectedState, fncThis.duration, function(){fncThis.queue.dequeue("navigation")});
		}});
		fncThis.queue.queue({name: "navigation", callback: function(){
			oldLI.children("a").closest(fncThis.selectorListItemContainer).removeClass(fncThis.classCurrent);
			if(fncThis.ondeselect)
				fncThis.ondeselect.call(fncThis, oldLI);
			fncThis.queue.dequeue("navigation")
		}});

		fncThis.queue.dequeue({name: "navigation"});
		
		//--animate image
		if(fncThis.onpreimageanimation)
			fncThis.queue.queue({name: "image", callback: function(){
				fncThis.onpreimageanimation.call(fncThis, fncLocalVariables);
			}});
		fncThis.queue.queue({name: "image", callback: function(){
			if(newA.length > 0)
				newA.animate(fncThis.listItemSelectedState, fncThis.duration, function(){fncThis.queue.dequeue("image");});
			else
				fncThis.queue.dequeue("image");
		}});
		if(fncThis.typeAnimation == "dissolve"){
			fncThis.queue.queue({name: "image", callback: function(){
				fncThis.elmOldImage = fncThis.elmImage;
				fncThis.elmImage = $(fncThis.htmlNewImage);
				fncThis.elmImage.attr("src", newImageURL);
				fncThis.elmListImages.prepend(fncThis.elmImage);
				if(fncThis.elmImage.width() > 0){
					fncThis.queue.dequeue("image");
				}else{
					fncThis.elmImage.bind("load", function(){
						fncThis.queue.dequeue("image");
					});
				}
			}});
		}
		if(fncThis.onpreimageanimationfadeout)
			fncThis.queue.queue({name: "image", callback: function(){
				fncThis.onpreimageanimationfadeout.call(fncThis, fncLocalVariables);
			}});
		fncThis.queue.queue({name: "image", callback: function(){
			
			if(fncThis.typeAnimation == "dissolve"){
				fncThis.elmOldImage.fadeOut(fncThis.duration, function(){fncThis.queue.dequeue("image");});
			}else{
				fncThis.elmImage.fadeOut(fncThis.duration, function(){fncThis.queue.dequeue("image");});
			}
		}});
		if(fncThis.onpreimageanimationkeepheight)
			fncThis.queue.queue({name: "image", callback: function(){
				fncThis.onpreimageanimationkeepheight.call(fncThis, fncLocalVariables);
			}});
		fncThis.queue.queue({name: "image", callback: function(){
			if(fncThis.elmKeepDimensions){
				fncThis.elmKeepDimensions.animate({"height":heightNew, "width":widthNew}, function(){fncThis.queue.dequeue("image");});
			}else
				fncThis.queue.dequeue();
		}});
		if(fncThis.onpreimageanimationfadein)
			fncThis.queue.queue({name: "image", callback: function(){
				fncThis.onpreimageanimationfadein.call(fncThis, fncLocalVariables);
			}});
		fncThis.queue.queue({name: "image", callback: function(){
			if(fncThis.typeAnimation == "dissolve"){
				fncThis.elmOldImage.fadeOut(fncThis.duration).remove();
			}else{
				fncThis.elmImage.attr("src", newImageURL).fadeIn(fncThis.duration);
			}
			elmTempImage.remove();

			if(fncThis.onselect)
				fncThis.onselect.call(fncThis, newLI);
			if(fncThis.elmKeepDimensions){
				fncThis.elmKeepDimensions.animate({"height":heightNew, "width":widthNew}, function(){fncThis.queue.dequeue("image");});
			}else
				fncThis.queue.dequeue("image");
		}});
		if(fncThis.onpreimageanimationpostkeepheight)
			fncThis.queue.queue({name: "image", callback: function(){
				fncThis.onpreimageanimationpostkeepheight.call(fncThis, fncLocalVariables);
			}});
		fncThis.queue.queue({name: "image", callback: function(){
			if(fncThis.elmKeepDimensions){
				fncThis.elmKeepDimensions.css({"height":"auto", "width":"auto"}, function(){fncThis.queue.dequeue("image");});
			}else
				fncThis.queue.dequeue("image");
		}});
		fncThis.queue.queue({name: "image", callback: function(){
			fncThis.urlCurrent = fncThis.elmImage.attr("src");
			if(newLI && newLI.length > 0)
				fncThis.elmLICurrent = newLI;
/*
			else
				fncThis.elmLICurrent = fncThis.findElmLIForURL(fncThis.urlCurrent);
*/
			if(fncThis.onpostimageanimation)
				fncThis.onpostimageanimation.call(fncThis, fncLocalVariables);
			fncThis.inprogress = false;
		}});
		
		fncThis.queue.dequeue({name: "image"});
	}
	__.classes.imageSwitcher.prototype.updateElements = function(arguments){
		this.elmImage = (arguments.elmImage)?arguments.elmImage:this.elmImage;
		if(arguments.elmsListItems){
			this.elmsListItems = arguments.elmsListItems;
			if(this.doAttachEvents)
				this.attachEvents();
		}
	}


/*-------------
©animationQueue
------------*/
__.classes.animationQueue = function(arguments){
		if(typeof arguments == "undefined") arguments = {};
		//--optional variables
		this.name = arguments.name || "tmlib";
		this.autoDequeue = arguments.autoDequeue || false;
		
		//--derived variables
		this.objQueue = $({});
	}
	__.classes.animationQueue.prototype.queue = function(arguments){
		var fncThis = this;
		var fncName = arguments.name || this.name;
		var fncCallback = arguments.callback || arguments; //-arguments is (assumed) the callback if not set explicitely
		var fncAutoDequeue = (typeof arguments.autoDequeue != "undefined")? arguments.autoDequeue: fncThis.autoDequeue;
		var fncQueueCallback = (fncAutoDequeue)
			?function(){
					var fncArguments = arguments;
					var internalThis = this;
					fncCallback.apply(internalThis, fncArguments);
					fncThis.dequeue();
				}
			:fncCallback
		;
		this.objQueue.queue(fncName, fncQueueCallback);
	}
	__.classes.animationQueue.prototype.dequeue = function(arguments){
		if(typeof arguments != "undefined")
			var fncName = arguments.name || arguments;
		else
			var fncName = this.name;
		this.objQueue.dequeue(fncName);
	}
	__.classes.animationQueue.prototype.unshift = function(arguments){
		if(typeof arguments != "undefined"){
			var fncCallback = arguments.callback || arguments;
			var fncName = arguments.name || this.name;
		}
		if(typeof fncCallback == "undefined" || !fncCallback) return false;
//->return
		var fncQueue = this.objQueue.queue(fncName);
		fncQueue.unshift(fncCallback);
	}
	__.classes.animationQueue.prototype.clearQueue = function(arguments){
		if(typeof arguments != "undefined")
			var fncName = arguments.name || arguments;
		else
			var fncName = this.name;
		this.objQueue.clearQueue(fncName);
	}


/* ********* 
©tmlib
********* */
function tmlib(){
		this.classes = {};
		this.lib = {};
		this.cfg = {};
	}
	tmlib.prototype.message = function(argument){
		if(window.console) 
			console.log(argument);
//		else alert(argument);
	}
	tmlib.prototype.addListeners = function(argElements, argEvent, argFunction, argBubble){
		var fncBubble = (argBubble)?argBubble : false;
		if(!__.lib.isArray(argElements))
			argElements = new Array(argElements);
		for(var i = 0; i < argElements.length; ++i){
			var forElement = argElements[i];
			if(forElement.attachEvent)
				forElement.attachEvent("on"+argEvent, argFunction);
			else
				forElement.addEventListener(argEvent, argFunction, fncBubble);
		}
	}
	__.lib.isArray = function(argObject){
		return typeof argObject == 'object' && (argObject instanceof Array);
	}
/*
@param elmsItems
@param attrURLImage
*/
	__.lib.preloadImagesForElements = function(arguments){
		var fncArguments = arguments;
		fncArguments.imagePaths = new Array();
		if(typeof fncArguments.attrURLImage == "undefined")
			fncArguments.attrURLImage = "href";
		fncArguments.elmsItems.each(function(){
			fncArguments.imagePaths.push($(this).attr(fncArguments.attrURLImage));
		});
		__.lib.preloadImages(fncArguments);
	}
	__.lib.preloadImages = function(arguments){
		var fncArguments = arguments;
		if(typeof fncArguments.interval == "undefined")
			fncArguments.interval = 500;
		var nextTimeout = fncArguments.intervalInitial || fncArguments.interval;
		$(arguments.imagePaths).each(function(){
			var fncThis = this;
			setTimeout(function(){
				$("<img/>")[0].src = fncThis;
			}, nextTimeout);
			nextTimeout += fncArguments.interval;
		});
	}
	__.lib.getInstanceName = function(argObject){
		for(var key in window){
			if(window[key] === argObject)
				return key;
		}
		for(var key in __){
			if(__[key] === argObject)
				return "__."+key;
			for(var subkey in __[key]){
				if(__[key][subkey] === argObject)
					return "__."+key+"."+subkey;
				for(var subsubkey in __[key][subkey]){
					if(__[key][subkey][subsubkey] === argObject)
						return "__."+key+"."+subkey+"."+subsubkey;
				}
			}
		}
	}
	tmlib.prototype.getHiddenElementWidthHeight = function(argElement){
		var originalSettings = {
			position: argElement.css("position"),
			left: argElement.css("left"),
			top: argElement.css("top")
		}

		argElement.css({"position":"absolute", "left":"-9000px", "top":"-1000px"})
		var width = argElement.outerWidth();
		var height = argElement.outerHeight();
		argElement.css(originalSettings);
		
		return {width: width, height: height};
	}
	tmlib.prototype.getRealWindowWidth = function(){
		this.getRealWindowWidthElement = $("body").append("<div></div>");
		this.getRealWindowWidthElement.css({position:"absolute", top:"-1px", left:"0", width:"100%", height:"1px"});
		return this.getRealWindowWidthElement.width();
	}

