/*
	MoreCSS 1.0 Beta 3
	Developed by yellowgreen designbüro published under MIT License.
	
	http://morecss.yellowgreen.de/
	http://morecss.yellowgreen.de/documentation/information/legal/
*/


function MoreCSS() {
				
// REGISTER CORE PROPERTIES

			MoreCSS.properties = {
	    	    'add-class' : 'addClass',
			    'auto-select' : 'autoSelect',
	    	    'command' : 'command',
	    	    'content' : 'content',
	    	    'counter' : 'counter',
	    	    'default-value' : 'defaultValue',
	    	    'execute' : 'execute',
	    	    'include-content' : 'includeContent',
	    	    'input-type' : 'inputType',
	    	    'list-style-symbol' : 'listStyleSymbol',
	    	    'list-style-color' : 'listStyleColor',
	    	    'opacity' : 'opacity',
	    	    'preload-image' : 'preloadImage',
	    	    'remove-class' : 'removeClass',
	    	    'style' : 'style',
	    	    'target' : 'target',
	    	    'text-slice' : 'textSlice',
	    		'title' : 'title',
	    	    'toggle-class' : 'toggleClass',
	    	    'tooltip' : 'tooltip'
			};

// REGISTER CORE PROPERTIES FOR FIRING ON LOAD

			MoreCSS.applyOnLoad = {
			};

// CORE PROPERTIES

			// add-class
			MoreCSS.addClass = function(element, properties, propertyValue) {
				element.className += ' ' + propertyValue;
			};

			// auto-select
			MoreCSS.autoSelect = function(element, properties, propertyValue, pseudoClass) {
				var refer = MoreCSS.getPropertyValue(properties, 'auto-select-refer', '%value');
				var execute = MoreCSS.getPropertyValue(properties, 'auto-select-execute', 'alert(%value)');

				if(!pseudoClass && element.tagName == 'SELECT') {
					element.onchange = function() {
						if(element.options[element.selectedIndex].value != '') {
							if(propertyValue == 'refer') top.location.href = refer.replace(/(\%value)/, element.options[element.selectedIndex].value);
							if(propertyValue == 'execute') eval(execute.replace(/(\%value)/, "'" + element.options[element.selectedIndex].value + "'") + ';');
						}
					};
				}
			};

			// command
			MoreCSS.command = function(element, properties, propertyValue, pseudoClass) {
				if(pseudoClass) {
					switch(propertyValue) {
						case 'back' : history.back(); break;
						case 'forward' : history.forward(); break;
						case 'reload' : location.reload(); break;
						case 'close' : window.close(); break;
						case 'print' : window.print(); break;
						case 'select' : element.select(); break;
						case 'blur' : element.blur(); break;
					}
				}
			};

			// content
			MoreCSS.content = function(element, properties, propertyValue) {
				var before = MoreCSS.getPropertyValue(properties, 'content-before', '');
				var after = MoreCSS.getPropertyValue(properties, 'content-after', '');
				
				if(propertyValue == 'append') {
					before = before.replace(/\%counter/g, MoreCSS.getElementNumber(element));
					after = after.replace(/\%counter/g, MoreCSS.getElementNumber(element));
					element.innerHTML = before + MoreCSS.trim(element.innerHTML) + after;
				}
				
				if(propertyValue == 'delete') {
					var content = MoreCSS.trim(element.innerHTML);
					if(content.slice(0, before.length) == before) content = content.slice(before.length);
					if(content.slice(content.length - after.length) == after) content = content.slice(0, content.length - after.length);
					element.innerHTML = content;
				}
			};

			// counter
			MoreCSS.counter = function(element, properties, propertyValue) {
				switch(propertyValue) {
					case 'class' : element.className += ' n' + MoreCSS.getElementNumber(element); break;
					case 'id' : element.id = 'n' + MoreCSS.getElementNumber(element); break;
				}
			};

			// default-value
			MoreCSS.defaultValue = function(element, properties, propertyValue, pseudoClass) {
				if(!pseudoClass && element.tagName == 'INPUT') {
					if(propertyValue == 'value') propertyValue = element.value; else element.value = propertyValue;
					element.onfocus = function() { if(element.value == propertyValue) element.value = ''; };
					element.onblur = function() { if(element.value == '') element.value = propertyValue; };
				}
			};

			// execute
			MoreCSS.execute = function(element, properties, propertyValue) {
				eval(propertyValue);
			};

			// include-content
			MoreCSS.includeContent = function(element, properties, propertyValue) {
				var position = MoreCSS.getPropertyValue(properties, 'include-position', 'overwrite');
				var status = MoreCSS.getPropertyValue(properties, 'include-status', '');
				
				var after = (position == 'before') ? element.innerHTML : '';
				var before = (position == 'after') ? element.innerHTML : '';
				
				if(propertyValue != '') {
					element.innerHTML = before + status + after;
					var content = MoreCSS.createXMLHttpRequest();
					content.open('get', propertyValue);
					content.onreadystatechange = function() {
						if(content.readyState == 4 && content.status == 200)
							element.innerHTML = before + content.responseText + after;
					};
					content.send(null);
				}
			};

			// input-type
			MoreCSS.inputType = function(element, properties, propertyValue) {
				element.type = propertyValue;
				
				if(propertyValue == 'search' && MoreCSS.browser() == 'Safari') {
					var host = MoreCSS.getPropertyValue(properties, 'host', '');
					var results = MoreCSS.getPropertyValue(properties, 'results', 10);
					element.setAttribute('autosave', host.substr(host.lastIndexOf('.') + 1) + '.' + host.substring(0, host.lastIndexOf('.')) + '.search_history');
					element.setAttribute('results', results);
				}
			};

			// list-style-symbol
			MoreCSS.listStyleSymbol = function(element, properties, propertyValue) {
				var padding = MoreCSS.getPropertyValue(properties, 'list-style-padding', '1.25em');
				var color = MoreCSS.getPropertyValue(properties, 'list-style-color', '');
				if(color != '') color = '; color:' + color;
				
				if(element.tagName == ('UL' || 'OL'))
					for(var i = 0; i < element.getElementsByTagName('li').length; i++) listStyle(element.getElementsByTagName('li')[i]);
				else
					listStyle(element);
				
				function listStyle(element) {
					element.style.listStyleType = 'none';
					element.innerHTML = '<span style="position:absolute; margin-left:-' + padding + color + '">' + propertyValue + '</span> ' + element.innerHTML;
				}
			};

			// list-style-color
			MoreCSS.listStyleColor = function(element, properties, propertyValue) {
				var color = MoreCSS.getPropertyValue(properties, 'color', 'black');

				if(element.tagName == ('UL' || 'OL'))
					for(var i = 0; i < element.getElementsByTagName('li').length; i++) listStyle(element.getElementsByTagName('li')[i]);
				else
					listStyle(element);
				
				function listStyle(element) {
					element.innerHTML = '<span style="color:' + color + '">' + element.innerHTML + '</span>';
					element.style.color = propertyValue;
				}
			};

			// opacity
			MoreCSS.opacity = function(element, properties, propertyValue) {
				element.style.opacity = propertyValue;
				
				if(element.filters) {
					element.style.zoom = '100%';
					element.style.filter = 'progid:DXImageTransform.Microsoft.alpha(opacity=' + propertyValue * 100 + ');';
					if(element.filters[0] && typeof element.filters[0].opacity == 'number') element.filters[0].opacity = propertyValue * 100;
						else element.style.filter = 'alpha(opacity=' + propertyValue * 100 + ')';
				} else if(typeof element.style.MozOpacity != 'undefined') element.style.MozOpacity = propertyValue;
							else if(typeof element.style.KHTMLOpacity != 'undefined') element.style.KHTMLOpacity = propertyValue;
			};

			// preload-image
			MoreCSS.preloadImage = function(element, properties, propertyValue) {
				var image = new Image();
				image.src = propertyValue;
			};

			// remove-class
			MoreCSS.removeClass = function(element, properties, propertyValue) {
				element.className = MoreCSS.removeClassName(element.className, propertyValue);
			};

			// style
			MoreCSS.style = function(element, properties, propertyValue) {
				var styleStrings = propertyValue.split(',');
				for(var i = 0; i < styleStrings.length; i++)
					element.style[MoreCSS.trim(styleStrings[i].substr(0, styleStrings[i].indexOf(':')))] = MoreCSS.trim(styleStrings[i].substr(styleStrings[i].indexOf(':') + 1));
			};

			// target
			MoreCSS.target = function(element, properties, propertyValue, pseudoClass) {
				var position = MoreCSS.getShorthand(MoreCSS.getPropertyValue(properties, 'target-position', 'center middle'));
				var width = MoreCSS.getPropertyValue(properties, 'target-width', '640px');
				var height = MoreCSS.getPropertyValue(properties, 'target-height', '480px');
				var className = MoreCSS.getPropertyValue(properties, 'target-class', '');
				var windowProperties = MoreCSS.getPropertyValue(properties, 'target-properties', 'menubar=no, locationbar=yes, status=no, scrollbars=yes');
				var close = MoreCSS.getPropertyValue(properties, 'target-close', '');
				var template = MoreCSS.getPropertyValue(properties, 'target-template', '%close%iframe');

				if(!position[1]) position[1] = position[0];
				
				if(element.tagName == 'A') {			
					if(propertyValue == 'window') {
						window.open(element.href);
					}
					
					if(propertyValue == 'popup') {
						var name = (element.rel) ? element.rel : 'popup';
						var popup = window.open(element.href, name, 'left=' + MoreCSS.getPosition(position[0], width, 'screen') + ', top=' + MoreCSS.getPosition(position[1], height, 'screen') + ', width=' + MoreCSS.getSize('width', width, 'screen') + ', height=' + MoreCSS.getSize('height', height, 'screen') + ', ' + windowProperties);
						if(popup) popup.focus();
					}
					
					if(propertyValue == 'layer') {
						var layer = document.createElement('div');
						layer.id = className;
						layer.className = className;
						layer.style.position = 'absolute';
						layer.style.top = MoreCSS.getPosition(position[1], height, 'window') + 'px';
						layer.style.left = MoreCSS.getPosition(position[0], width, 'window') + 'px';
						if(close) close = '<a href="#" onclick="document.getElementsByTagName(\'body\')[0].removeChild(document.getElementById(\'' + className + '\')); return false;">' + close + '</a>';
						var layerIFRAME = '<iframe src="' + element.href + '" width="' + MoreCSS.getSize('width', width, 'window') + '" height="' + MoreCSS.getSize('height', height, 'window') + '" frameborder="0" marginwidth="0" marginheight="0"></iframe>';
						layer.innerHTML = template.replace(/(\%close)/, close).replace(/(\%iframe)/, layerIFRAME);
						document.getElementsByTagName('body')[0].appendChild(layer);
					}
				}
			};

			// text-slice
			MoreCSS.textSlice = function(element, properties, propertyValue) {
				propertyValue = MoreCSS.getShorthand(propertyValue);
				
				if(propertyValue.length == 1) {
					var sliced = element.innerHTML.slice(0, propertyValue);
					element.innerHTML = sliced.slice(0, sliced.slice(0, propertyValue).lastIndexOf(' '));
				} else
					element.innerHTML = element.innerHTML.slice(propertyValue[0], parseInt(propertyValue[0]) + parseInt(propertyValue[1]));
			};

			// title
			MoreCSS.title = function(element, properties, propertyValue) {
				element.title = propertyValue;
			};

			// toggle-class
			MoreCSS.toggleClass = function(element, properties, propertyValue, pseudoClass, caller) {
				var behaviour = MoreCSS.getPropertyValue(properties, 'toggle-class-behaviour', 'normal');
				var active = MoreCSS.getPropertyValue(properties, 'toggle-class-active', '');
				
    			if(caller) {
    				if(behaviour == 'switch' && element.caller) {
   						MoreCSS.removeClass(element.caller, 0, active);
   						MoreCSS.removeClass(element, 0, propertyValue);
    				}
    				
    				if(MoreCSS.getElementNumber(element) == MoreCSS.getElementNumber(caller)) {
    					if(MoreCSS.classOrIDexists(element.className, propertyValue)) {
    						element.caller = caller;
    						MoreCSS.removeClass(caller, 0, active);
    						MoreCSS.removeClass(element, 0, propertyValue);
    					} else {
    						element.caller = caller;
    						MoreCSS.addClass(caller, 0, active);
    						MoreCSS.addClass(element, 0, propertyValue);
    					}
    				}
				}
			};

			// tooltip
			MoreCSS.tooltip = function(element, properties, propertyValue, pseudoClass) {
				var value = propertyValue.replace(/(\%title)/, element.title);
				var tooltip = MoreCSS.getPropertyValue(properties, 'tooltip', '');
				var className = MoreCSS.getPropertyValue(properties, 'tooltip-class', '');
				var opacity = MoreCSS.getPropertyValue(properties, 'tooltip-opacity', 1);
				
				if(!pseudoClass && value != '') {
					var tooltip = document.createElement('div');
					tooltip.className = className;
					tooltip.style.position = 'absolute'; tooltip.style.top = '-999px';
					tooltip.style.visibility = 'hidden';
					tooltip.innerHTML = (value == 'title') ? element.title : value;
					element.title = '';
					
					document.getElementsByTagName('body')[0].appendChild(tooltip);
					if(opacity != 1) MoreCSS.opacity(tooltip, true, opacity);
					
					function executeTooltip() {
						if(tooltip.style.visibility == 'hidden') {
							document.onmousemove = showTooltip;
							tooltip.style.visibility = 'visible';
						} else {
							tooltip.style.visibility = 'hidden';
							document.onmousemove = function() { return false; };
						}
					}
					
					function showTooltip(e) {
						var pos = new Array(0, 0, 10, 20);
						if(!e) e = window.event;
						if(e.pageX || e.pageY) { pos[0] = e.pageX; pos[1] = e.pageY; }
							else if(e.clientX || e.clientY) {
								pos[0] = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
								pos[1] = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
							}
						if(MoreCSS.innerSize('width') - tooltip.offsetWidth < pos[0] + pos[2] + 25) pos[0] += -tooltip.offsetWidth - pos[2];
						if(25 + pos[1] + pos[3] + tooltip.offsetHeight > MoreCSS.innerSize('height')) pos[1] += -tooltip.offsetHeight - pos[3];
						tooltip.style.top = pos[1] + pos[3] + 'px';
						tooltip.style.left = pos[0] + pos[2] + 'px';
					}
					
					element.onmouseover = executeTooltip;
					element.onmouseout = executeTooltip;				
				}
			};

// LIBRARY FUNCTIONS

			// Get element number from string
			MoreCSS.getElementNumber = function(element) {
				return element.style.counterIncrement.slice(element.style.counterIncrement.indexOf(' ') + 1);
			};

			// Check if class or ID exists
			MoreCSS.classOrIDexists = function(classOrIDstring, classOrID) {
				var classOrIDs = classOrIDstring.split(' ');
				for(var i = 0; i < classOrIDs.length; i++) if(classOrIDs[i] == classOrID) return true;
				return false;
			};

			// Get property value
			MoreCSS.getPropertyValue = function(properties, style, defaultValue) {
				for(var i = 0; i < properties.length; i++)
					if(MoreCSS.trim(properties[i].slice(0, properties[i].indexOf(':')), 'quotes') == style) return MoreCSS.trim(properties[i].slice(properties[i].indexOf(':') + 1), 'quotes');
				return defaultValue;
			};

			// Get shorthand property value
			MoreCSS.getShorthand = function(shorthandString) {
				shorthandString = shorthandString.split(' ');
				for(var i = 0; i < shorthandString.length; i++) if(shorthandString[i] == ' ') shorthandString.splice(i, 1);
				return shorthandString;
			};

			// Get cross browser computed style
			MoreCSS.getStyle = function(element, property) {
				var value = '';
				if(document.defaultView && document.defaultView.getComputedStyle) {
					value = document.defaultView.getComputedStyle(element, '').getPropertyValue(property);
				} else if(element.currentStyle) {
					property = property.replace(/\-(\w)/g, function(strMatch, p1) { return p1.toUpperCase(); });
					value = element.currentStyle[property];
				}
				return value;
			};

			// Get browser name
			MoreCSS.browser = function() {
				var browsers = new Array('Safari', 'WebKit', 'KHTML', 'Opera', 'MSIE', 'Mozilla');
				var browser = navigator.userAgent;
				for(var i = 0; i < browsers.length; i++) if(browser.indexOf(browsers[i]) != -1) browser = browsers[i];
				return browser;
			};

			// Get cross-browser innerWidth and innerHeight
			MoreCSS.innerSize = function(mode) {
				var value;
				if(self.innerWidth) {
					value = (mode == 'width') ? self.innerWidth : self.innerHeight;
				} else if(document.documentElement && document.documentElement.clientWidth) {
					value = (mode == 'width') ? document.documentElement.clientWidth : document.documentElement.clientHeight;
				} else if(document.body) {
					value = (mode == 'width') ? document.body.clientWidth : document.body.clientHeight;
				}
				return (value < 0) ? 0 : value;
			};

			// Get position in pixel by align for window or element
			MoreCSS.getPosition = function(position, size, mode) {
				size = parseInt(size);
				var scrollPosition = (window.pageYOffset) ? window.pageYOffset : document.body.scrollTop;
				
				switch(position) {
					case 'left' : case 'top' :
						position = 0;
					break;
					case 'right' :
						position = screen.availWidth - size;
					break;
					case 'center' :
						position = (mode == 'screen') ? (screen.availWidth - size) / 2 : (MoreCSS.innerSize('width') - size) / 2;
					break;
					case 'middle' :
						position = (mode == 'screen') ? (screen.availHeight - size) / 2 : scrollPosition + (MoreCSS.innerSize('height') - size) / 2;
					break;
					case 'bottom' :
						position = (mode == 'screen') ? screen.availHeight - size : MoreCSS.innerSize('height') - size;
					break;
					default :
						position = parseInt(position);
				}
				return position;
			};

			// Get size in pixel by percent
			MoreCSS.getSize = function(type, size, mode, element) {
				if(size == "auto") size = '100%';

				if(size.indexOf('%') > -1) {
					size = parseInt(size);
							
					if(type == 'width') {
						switch(mode) {
							case 'screen' :
								size = screen.availWidth * size / 100;
							break;
							case 'window' :
								size = MoreCSS.innerSize('width') * size / 100;
							break;
							case 'element' :
								var display = '';
								if(MoreCSS.getStyle(element, 'display') == 'none') { display = 'none'; element.style.display = 'block'; }
								var originalWidth = element.offsetWidth;
								element.style.width = size + '%';
								var newWidth = element.offsetWidth;
								element.style.width = originalWidth + 'px';
								if(display != '') element.style.display = display;
								size = newWidth;
							break;
						}
					}
					
					if(type == 'height') {
						switch(mode) {
							case 'screen' :
								size = screen.availHeight * size / 100;
							break;
							case 'window' :
								size = MoreCSS.innerSize('height') * size / 100;
							break;
							case 'element' :
							var display = '';
								if(MoreCSS.getStyle(element, 'display') == 'none') { display = 'none'; element.style.display = 'block'; }
								var originalHeight = element.offsetHeight;
								element.style.height = size + '%';
								var newHeight = element.offsetHeight;
								element.style.height = originalHeight + 'px';
								if(display != '') element.style.display = display;
								size = newHeight;
							break;
						}
					}
				}
				return parseFloat(size);
			};

			// Trim string
			MoreCSS.trim = function(string, mode) {
				string = string.replace(/^\s+|\s+$/g, '');
				if(mode == 'quotes') string = string.replace(/^"|^'|"$|'$|\\/g, '');
				if(mode == 'commas') string = string.replace(/^,+|,+$/g, '');
				return string;
			};

			//' Remove class name
			MoreCSS.removeClassName = function(classString, className) {
				var splittedClassString = classString.split(' ');
				for(var i = 0; i < splittedClassString.length; i++) if(splittedClassString[i] == className) splittedClassString.splice(i, 1);
				return splittedClassString.join(' ');
			};

			// Create XML request
			MoreCSS.createXMLHttpRequest = function() {
				var ua;
				if(window.XMLHttpRequest) {
					try { ua = new XMLHttpRequest(); } catch(e) { ua = false; }
				} else if(window.ActiveXObject) {
					try { ua = new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) { ua = false; }
				}
				return ua;
			};
			
			// Fire on DOM ready
			MoreCSS.onDOMready = {
				onload : [],
				
				loaded : function() {
					if(arguments.callee.done) return;
					arguments.callee.done = true;
					for(i = 0; i < MoreCSS.onDOMready.onload.length; i++) MoreCSS.onDOMready.onload[i]();
				},
				
				load : function(fireThis) {
					this.onload.push(fireThis);
					if(document.addEventListener) document.addEventListener("DOMContentLoaded", MoreCSS.onDOMready.loaded, null);
					
					if(/KHTML|WebKit/i.test(navigator.userAgent)) {
						var _timer = setInterval(function() {
							if(/loaded|complete/.test(document.readyState)) {
								clearInterval(_timer);
								delete _timer;
								MoreCSS.onDOMready.loaded();
							}
						}, 10);
					}
					
					/*@cc_on @*/
					/*@if (@_win32)
					var proto = "src='javascript:void(0)'";
					if(location.protocol == "https:") proto = "src=//0";
					document.write("<scr" + "ipt id=__ie_onload defer " + proto + "><\/scr" + "ipt>");
					var script = document.getElementById("__ie_onload");
					script.onreadystatechange = function() {
					    if(this.readyState == "complete") MoreCSS.onDOMready.loaded();
					};
					/*@end @*/
					
					window.onload = MoreCSS.onDOMready.loaded;
				}
			};

// CORE PROCESSES
			
			// 1. Start on DOM ready
			MoreCSS.onDOMready.load(getStylesheets);			

			// 2. Get paths to stylesheets
			function getStylesheets() {
				var linkTags = document.getElementsByTagName('link');
				for(var i = 0; i < linkTags.length; i++)
					if(linkTags[i].rel.toLowerCase() == 'morecss')
						getSourceCode(linkTags[i].href);
			}
			
			// 3. Get source code from stylesheets
			function getSourceCode(path) {
				var req = MoreCSS.createXMLHttpRequest();
				req.open('get', path);
				req.onreadystatechange = function() {
					if(req.readyState == 4 && req.status == 200)
						// Go to next step
						core(req.responseText.replace(/\r|\n|\t|\f/g, " ").replace(/\/\*.*?\*\//g,"").split("}"));
				};
				req.send(null);
			}

			// 4. Parse source code and run properties
			function core(styleDefinitions) {
				for(var i = 0; i < styleDefinitions.length && MoreCSS.trim(styleDefinitions[i]) != ''; i++) {				
					// Get Selector Strings
					var selectors = MoreCSS.trim(styleDefinitions[i].slice(0, styleDefinitions[i].indexOf('{')));
					
					var targetSelectors = false;
					if(selectors.indexOf('=>') > -1) {
						var targetSelectors = MoreCSS.trim(selectors.slice(selectors.indexOf('=>') + 2));
						selectors = MoreCSS.trim(selectors.slice(0, selectors.indexOf('=>')));
					}
					
					// Selector Strings to arrays
					(selectors.indexOf(' ') > -1) ? selectors = selectors.split(' ') : selectors = [selectors];
					var tempSelectors = [];
					for(var j = 0; j < selectors.length; j++) if(selectors[j] != '') tempSelectors.push(selectors[j]);
					selectors = tempSelectors;
					
					if(targetSelectors) {
						(targetSelectors.indexOf(' ') > -1) ? targetSelectors = targetSelectors.split(' ') : targetSelectors = [targetSelectors];
						var tempTargetSelectors = [];
						for(var j = 0; j < targetSelectors.length; j++) if(targetSelectors[j] != '') tempTargetSelectors.push(targetSelectors[j]);
						targetSelectors = tempTargetSelectors;
					}

					// Get properties
					var properties = MoreCSS.trim(styleDefinitions[i].slice(styleDefinitions[i].indexOf('{') + 1)).split(';');
					for(var j = 0; j < properties.length; j++) properties[j] = MoreCSS.trim(properties[j]);

    				var propertyNames = [];
    				var propertyValues = [];
    				
    				for(var j = 0; j < properties.length; j++) if(properties[j]) {
   						propertyNames[j] = MoreCSS.properties[properties[j].slice(0, properties[j].indexOf(':'))];
   						propertyValues[j] = MoreCSS.trim(properties[j].slice(properties[j].indexOf(':') + 1), 'quotes');
    				}
					
					// Go to next step
					MoreCSS.getElements(document.getElementsByTagName('body')[0], selectors, 0, targetSelectors, properties, propertyNames, propertyValues, false);
				}
			}

			// 5. Walk through elements by selector
			MoreCSS.getElements = function(node, selectors, level, targetSelectors, properties, propertyNames, propertyValues, caller) {
				if(selectors.length > level) {
					var pseudoClass = (selectors[level].indexOf(':') > -1) ? selectors[level].slice(selectors[level].indexOf(':') + 1) : false;
					var selector =  (pseudoClass) ? selectors[level].slice(0, selectors[level].indexOf(':')) : selectors[level];

					if(selectors[level] == 'body')
						MoreCSS.getElements(node, selectors, level + 1, targetSelectors, properties, propertyNames, propertyValues, caller);
					
					switch(selector.slice(0, 1)) {
						case '#' :
							node = [document.getElementById(selector.slice(1))];
						break;
						case '.' :
							var elements = node.getElementsByTagName('*'); node = [];
							for(var i = 0; i < elements.length; i++)
								if(MoreCSS.classOrIDexists(elements[i].className, selector.slice(1))) node.push(elements[i]);
						break;					
						default :
							if(selector.indexOf('.') > -1) {
								var elements = node.getElementsByTagName(selector.slice(0, selector.indexOf('.'))); node = [];
								for(var i = 0; i < elements.length; i++)
									if(MoreCSS.classOrIDexists(elements[i].className, selector.slice(selector.indexOf('.') + 1))) node.push(elements[i]);
							} else if(selector.indexOf('#') > -1) {
								node = [document.getElementById(selector.slice(selector.indexOf('#') + 1))];
							} else
								node = node.getElementsByTagName(selector);
					}
				} else {
					var pseudoClass = (selectors[level - 1] && selectors[level - 1].indexOf(':') > -1) ? selectors[level - 1].slice(selectors[level - 1].indexOf(':') + 1) : false;
					// Go to next step
					MoreCSS.applyProperties(node, pseudoClass, targetSelectors, properties, propertyNames, propertyValues, caller);
				}
				
				for(var i = 0; node != '' && i < node.length; i++) {
					var element = node[i];
					element.style.counterIncrement = 'Number ' + (i + 1);
					
					var run = 1;
   					switch(pseudoClass) {
   						case 'first-child' : i = node.length - 1; break;
   						case 'every-second-child' : if(i%2 == 0) run = 0; break;
   						case 'last-child' : if(i < node.length - 1) run = 0; break;
   						case 'anchor' : (element.href.substr(element.href.lastIndexOf('#')) == window.location.hash) ? i = node.length - 1 : run = 0; break;
       				}
       				
					if(run == 1) MoreCSS.getElements(element, selectors, level + 1, targetSelectors, properties, propertyNames, propertyValues, caller);
				}
			};
			
			// 6. Apply properties to elements
			MoreCSS.applyProperties = function(element, pseudoClass, targetSelectors, properties, propertyNames, propertyValues, caller) {
				// Validate event pseudo-class
				switch(pseudoClass) {
   					case 'hover' : pseudoClass = 'mouseover'; break;
   					case 'leave' : pseudoClass = 'mouseout'; break;
   					case 'active' : pseudoClass = 'click'; element.onclick = function() { return false; }; break;
   					case 'first-child' : case 'every-second-child' : case 'last-child' : case 'anchor' : pseudoClass = false;
   				}

				// Get Timer pseudo-class
   				var timer = (pseudoClass && pseudoClass.indexOf('timer') > -1) ? pseudoClass.substr(pseudoClass.indexOf('=') + 1) : 0;
   				if(timer > 0) pseudoClass = false;
				
				// Apply some properties on load
	    		for(var i = 0; i < propertyNames.length && MoreCSS.applyOnLoad[propertyNames[i]]; i++) {
   					if(!caller) MoreCSS[propertyNames[i]](element, properties, propertyValues[i], pseudoClass, caller, 'prepare');
					if(targetSelectors) MoreCSS.getElements(document.getElementsByTagName('body')[0], targetSelectors, 0, false, properties, propertyNames, propertyValues, element);
				}
				
				// Apply properties in standard mode, with Timer or on event
				if(!pseudoClass) (timer == 0) ? batchApply() : window.setTimeout(batchApply, timer);
					else element.addEventListener ? element.addEventListener(pseudoClass, batchApply, false) : element.attachEvent('on' + pseudoClass, batchApply);
				
				// Batch apply
				function batchApply() {
					if(targetSelectors)
						MoreCSS.getElements(document.getElementsByTagName('body')[0], targetSelectors, 0, false, properties, propertyNames, propertyValues, element, false);
					else for(var i = 0; i < propertyNames.length && propertyNames[i]; i++)
    					MoreCSS[propertyNames[i]](element, properties, propertyValues[i], pseudoClass, caller, false);
				}
			}

} new MoreCSS();