/* IE6 Hover fix module */
var ieHover={lazyMode:true,init:function(){this.setDefaults();return this},setDefaults:function(){this.fixActive=/MSIE 6/.test(navigator.userAgent);if(this.fixActive){this.hoverEvents=[];this.hoverQueue=[];this.activators={onhover:{on:"onmouseenter",off:"onmouseleave"},onactive:{on:"onmousedown",off:"onmouseup"}};window.attachEvent("onload",this.bind(this.domReady,this));window.attachEvent("onunload",this.bind(this.unhookHoverEvents,this))}},domReady:function(){this.pageReady=true;if(this.lazyMode){this.processStylesheets()}if(this.hoverQueue.length){for(var a=0;a<this.hoverQueue.length;a++){this.doFix(this.hoverQueue[a].s,this.hoverQueue[a].c)}}},processStylesheets:function(){var c=document.styleSheets,a=c.length;for(var b=0;b<a;b++){this.parseStylesheet(c[b])}},parseStylesheet:function(f){if(f.imports){try{var b=f.imports,a=b.length;for(var d=0;d<a;d++){this.parseStylesheet(f.imports[d])}}catch(g){}}try{var h=(this.currentSheet=f).rules,a=h.length;for(var c=0;c<a;c++){this.parseCSSRule(h[c])}}catch(g){}},parseCSSRule:function(f){var g=f.selectorText,b=f.style.cssText;if(!/(^|\s)(([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):(hover|active)/i.test(g)||!b){return}var h=g.replace(/[^:]+:([a-z-]+).*/i,"on$1");var j=g.replace(/(\.([a-z0-9_-]+):[a-z]+)|(:[a-z]+)/gi,".$2"+h);var e=(/\.([a-z0-9_-]*on(hover|active))/i).exec(j)[1];var c=g.replace(/:(hover|active).*$/,"");var a=this.parseSelector(c);if(!a.length){return}this.currentSheet.addRule(j,b);for(var d=0;d<a.length;d++){this.addHoverElement(a[d],e,this.activators[h])}},fix:function(a,b){if(this.fixActive){if(this.pageReady){this.doFix(a,b)}else{this.hoverQueue.push({s:a,c:b})}}},doFix:function(a,c){if(this.fixActive&&typeof a==="string"){var d=this.parseSelector(a);for(var b=0;b<d.length;b++){this.addHoverElement(d[b],c||"hover",this.activators.onhover)}}},addHoverElement:function(c,b,a){if(!c.hovers){c.hovers={}}if(c.hovers[b]){return}c.hovers[b]=true;this.hookHoverEvent(c,a.on,function(){c.className+=" "+b});this.hookHoverEvent(c,a.off,function(){c.className=c.className.replace(new RegExp("\\s+"+b,"g"),"")})},hookHoverEvent:function(c,b,a){c.attachEvent(b,a);this.hoverEvents[this.hoverEvents.length]={node:c,type:b,handler:a}},unhookHoverEvents:function(){for(var b,a=0;a<this.hoverEvents.length;a++){b=this.hoverEvents[a];b.node.detachEvent(b.type,b.handler)}},parseSelector:(function(){var d=/^([^#.>`]*)(#|\.|\>|\`)(.+)$/;function e(g,f){var k=g.split(/\s*\,\s*/);var j=[];for(var h=0;h<k.length;h++){j=j.concat(b(k[h],f))}return j}function b(r,p,n){r=r.replace(" ","`");var m=r.match(d);var l,o,g,q,j,h;var k=[];if(m==null){m=[r,r]}if(m[1]==""){m[1]="*"}if(n==null){n="`"}if(p==null){p=document}switch(m[2]){case"#":q=m[3].match(d);if(q==null){q=[null,m[3]]}l=document.getElementById(q[1]);if(l==null||(m[1]!="*"&&!a(l,m[1]))){return k}if(q.length==2){k.push(l);return k}return b(q[3],l,q[2]);case".":if(n!=">"){o=c(p,m[1])}else{o=p.childNodes}for(j=0,h=o.length;j<h;j++){l=o[j];if(l.nodeType!=1){continue}q=m[3].match(d);if(q!=null){if(l.className==null||l.className.match("(\\s|^)"+q[1]+"(\\s|$)")==null){continue}g=b(q[3],l,q[2]);k=k.concat(g)}else{if(l.className!=null&&l.className.match("(\\s|^)"+m[3]+"(\\s|$)")!=null){k.push(l)}}}return k;case">":if(n!=">"){o=c(p,m[1])}else{o=p.childNodes}for(j=0,h=o.length;j<h;j++){l=o[j];if(l.nodeType!=1){continue}if(!a(l,m[1])){continue}g=b(m[3],l,">");k=k.concat(g)}return k;case"`":o=c(p,m[1]);for(j=0,h=o.length;j<h;j++){l=o[j];g=b(m[3],l,"`");k=k.concat(g)}return k;default:if(n!=">"){o=c(p,m[1])}else{o=p.childNodes}for(j=0,h=o.length;j<h;j++){l=o[j];if(l.nodeType!=1){continue}if(!a(l,m[1])){continue}k.push(l)}return k}}function c(g,f){if(f=="*"&&g.all!=null){return g.all}return g.getElementsByTagName(f)}function a(g,f){if(f=="*"){return true}return g.nodeName.toLowerCase().replace("html:","")==f.toLowerCase()}return e}()),bind:function(c,b,a){return function(){return c.apply(b,a||arguments)}}}.init();
/* Text changer - light version.
Let your text's font size customizable.
by Marco Rosella - http://www.centralscrutinizer.it/en/design/js-php/text-changer
                v0.2 - May 18, 2006
*/
window.onload = function(){
	textChanger.init(); 	
}

var textChanger = {
	cpanel : 'textchanger',  //set here the id of the element (div, p) within you want to insert the control panel
	element : 'pagewidth',   	 //set here the id of the element (div, p) within you want to change the text
	defaultFS : 1.2,         //set here the default font size in 'em'
	init: function() {
		var cpel = document.getElementById(textChanger.cpanel);
		var el = document.getElementById(textChanger.element);
		if (cpel == null || el == null) {alert('The elements with the \"'+textChanger.cpanel+'\" and/or \"'+textChanger.element+'\" ID do not exist in HTML source.');} else {
		var u = document.createElement('ul');
		cpel.appendChild(u);
		u.innerHTML = 
		'<li style="font-size:11px;" id="decrease"><a href="#" title="Decrease font size">A</a></li>'+
		'<li style="font-size:15px;" id="reset"><a href="#" title="Default font size">A</a></li>'+
		'<li style="font-size:17px;" id="increase"><a href="#" title="Increase font size">A</a></li>'
		var sz = textChanger.getCookie();
		el.style.fontSize = sz ? sz + 'em' : textChanger.defaultFS + 'em';
		var incr = document.getElementById('increase');
		incr.onclick = function(){textChanger.changeSize(1); return false;};
		var decr = document.getElementById('decrease');
		decr.onclick = function(){textChanger.changeSize(-1); return false;};
		var reset= document.getElementById('reset');
		reset.onclick = function(){textChanger.changeSize(0); return false;};
		}
	} ,

	changeSize: function(val) {
		var el = document.getElementById(textChanger.element);
		var size = el.style.fontSize.substring(0,3);
		var fSize = parseFloat(size,10);
		if (val == 1) {
			fSize += 0.1;
			if (fSize > 2.0) fSize = 2.0;
		} 
		if (val == -1) {
			fSize -= 0.1;
			if (fSize < 0.5) fSize = 0.5;
		}		
		if (val == 0) {
			fSize = textChanger.defaultFS;
		}
		el.style.fontSize = fSize + 'em';
		textChanger.updateCookie(fSize);
		} ,
		
	updateCookie: function(vl) {
		var today = new Date();
		var exp = new Date(today.getTime() + (365*24*60*60*1000)); //the cookie will expire in one year  
		document.cookie = 'textChangerL=size=' + vl + ';' +'expires=' + exp.toGMTString() + ';' +'path=/';
	} ,

	getCookie: function() { 
		var cname = 'textChangerL=size=';	
		var start = document.cookie.indexOf(cname);
		var len = start + cname.length;
		if ((!start) && (cname != document.cookie.substring(0,cname.length))) {return null;}
		if (start == -1) return null;
		var end = document.cookie.indexOf(";",len);
		if (end == -1) end = document.cookie.length;
		return unescape(document.cookie.substring(len, end));
	}
}
/* IE6 Hover fix module */
var ieHover = {
	lazyMode: true,
	init: function(){
		this.setDefaults();
		return this;
	},
	setDefaults: function() {
		this.fixActive = /MSIE 6/.test(navigator.userAgent);
		if(this.fixActive) {
			this.hoverEvents = []; this.hoverQueue = [];
			this.activators = {
				onhover:{on:'onmouseenter', off:'onmouseleave'},
				onactive:{on:'onmousedown', off:'onmouseup'}
			}
			window.attachEvent('onload', this.bind(this.domReady,this));
			window.attachEvent('onunload', this.bind(this.unhookHoverEvents,this));
		}
	},
	domReady: function() {
		this.pageReady = true;
		if(this.lazyMode) {
			this.processStylesheets();
		}
		if(this.hoverQueue.length) {
			for(var i = 0; i < this.hoverQueue.length; i++) {
				this.doFix(this.hoverQueue[i].s,this.hoverQueue[i].c);
			}
		}
	},
	processStylesheets: function() {
		var sheets = document.styleSheets, len = sheets.length;
		for(var i = 0; i < len; i++) { this.parseStylesheet(sheets[i]); }
	},
	parseStylesheet: function(sheet) {
		if(sheet.imports) {
			try {
				var imports = sheet.imports, l = imports.length;
				for(var i=0; i<l; i++) this.parseStylesheet(sheet.imports[i]);
			} catch(e){}
		}
		try {
			var rules = (this.currentSheet = sheet).rules, l = rules.length;
			for(var j=0; j<l; j++) this.parseCSSRule(rules[j]);
		} catch(e){}
	},
	parseCSSRule: function(rule) {
		var select = rule.selectorText, style = rule.style.cssText;
		if(!/(^|\s)(([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):(hover|active)/i.test(select) || !style) return;
		var pseudo = select.replace(/[^:]+:([a-z-]+).*/i, 'on$1');
		var newSelect = select.replace(/(\.([a-z0-9_-]+):[a-z]+)|(:[a-z]+)/gi, '.$2' + pseudo);
		var className = (/\.([a-z0-9_-]*on(hover|active))/i).exec(newSelect)[1];
		var affected = select.replace(/:(hover|active).*$/, '');
		var elements = this.parseSelector(affected);
		if(!elements.length) return;
		this.currentSheet.addRule(newSelect, style);
		for(var i=0; i < elements.length; i++) {
			this.addHoverElement(elements[i], className, this.activators[pseudo]);
		}
	},
	fix: function(selector, className) {
		if(this.fixActive) {
			if(this.pageReady) {
				this.doFix(selector,className)
			} else {
				this.hoverQueue.push({s:selector,c:className});
			}
		}
	},
	doFix: function(selector, className) {
		if(this.fixActive && typeof selector === 'string') {
			var elements = this.parseSelector(selector);
			for(var i=0; i < elements.length; i++) {
				this.addHoverElement(elements[i], className || 'hover', this.activators['onhover']);
			}
		}
	},
	addHoverElement: function(node, className, events) {
		if(!node.hovers) node.hovers = {};
		if(node.hovers[className]) return;
		node.hovers[className] = true;
		this.hookHoverEvent(node, events.on, function() { node.className += ' ' + className; });
		this.hookHoverEvent(node, events.off, function() { node.className = node.className.replace(new RegExp('\\s+'+className, 'g'),''); });
	},
	hookHoverEvent: function(node, type, handler) {
		node.attachEvent(type, handler);
		this.hoverEvents[this.hoverEvents.length] = {
			node:node, type:type, handler:handler
		};
	},
	unhookHoverEvents: function() {
		for(var e,i=0; i < this.hoverEvents.length; i++) {
			e = this.hoverEvents[i];
			e.node.detachEvent(e.type, e.handler);
		}
	},
	parseSelector: (function () {
		var g = /^([^#.>`]*)(#|\.|\>|\`)(.+)$/;
		function parseSelector(a, b) {
			var c = a.split(/\s*\,\s*/);
			var d = [];
			for (var i = 0; i < c.length; i++) {
				d = d.concat(doParse(c[i], b))
			};
			return d
		};
		function doParse(a, b, c) {
			a = a.replace(" ", "`");
			var d = a.match(g);
			var e, listNodes, listSubNodes, subselector, i, limit;
			var f = [];
			if (d == null) {
				d = [a, a]
			};
			if (d[1] == "") {
				d[1] = "*"
			};
			if (c == null) {
				c = "`"
			};
			if (b == null) {
				b = document
			};
			switch (d[2]) {
			case "#":
				subselector = d[3].match(g);
				if (subselector == null) {
					subselector = [null, d[3]]
				};
				e = document.getElementById(subselector[1]);
				if (e == null || (d[1] != "*" && !matchNodeNames(e, d[1]))) {
					return f
				};
				if (subselector.length == 2) {
					f.push(e);
					return f
				};
				return doParse(subselector[3], e, subselector[2]);
			case ".":
				if (c != ">") {
					listNodes = getElementsByTagName(b, d[1])
				} else {
					listNodes = b.childNodes
				};
				for (i = 0, limit = listNodes.length; i < limit; i++) {
					e = listNodes[i];
					if (e.nodeType != 1) {
						continue
					};
					subselector = d[3].match(g);
					if (subselector != null) {
						if (e.className == null || e.className.match("(\\s|^)" + subselector[1] + "(\\s|$)") == null) {
							continue
						};
						listSubNodes = doParse(subselector[3], e, subselector[2]);
						f = f.concat(listSubNodes)
					} else if (e.className != null && e.className.match("(\\s|^)" + d[3] + "(\\s|$)") != null) {
						f.push(e)
					}
				};
				return f;
			case ">":
				if (c != ">") {
					listNodes = getElementsByTagName(b, d[1])
				} else {
					listNodes = b.childNodes
				};
				for (i = 0, limit = listNodes.length; i < limit; i++) {
					e = listNodes[i];
					if (e.nodeType != 1) {
						continue
					};
					if (!matchNodeNames(e, d[1])) {
						continue
					};
					listSubNodes = doParse(d[3], e, ">");
					f = f.concat(listSubNodes)
				};
				return f;
			case "`":
				listNodes = getElementsByTagName(b, d[1]);
				for (i = 0, limit = listNodes.length; i < limit; i++) {
					e = listNodes[i];
					listSubNodes = doParse(d[3], e, "`");
					f = f.concat(listSubNodes)
				};
				return f;
			default:
				if (c != ">") {
					listNodes = getElementsByTagName(b, d[1])
				} else {
					listNodes = b.childNodes
				};
				for (i = 0, limit = listNodes.length; i < limit; i++) {
					e = listNodes[i];
					if (e.nodeType != 1) {
						continue
					};
					if (!matchNodeNames(e, d[1])) {
						continue
					};
					f.push(e)
				};
				return f
			}
		};
		function getElementsByTagName(a, b) {
			if (b == "*" && a.all != null) {
				return a.all
			};
			return a.getElementsByTagName(b)
		};
		function matchNodeNames(a, b) {
			if (b == "*") {
				return true
			};
			return a.nodeName.toLowerCase().replace("html:", "") == b.toLowerCase()
		};
		return parseSelector
	}()),
	bind: function(fn, scope, args) {
		return function() {
			return fn.apply(scope, args || arguments);
		}
	}
}.init();
// fix for dreamweaver //
function initClass() {document.getElementsByTagName('body')[0].className = "alternate";}
if(window.addEventListener) window.addEventListener('load', initClass, false);
else if(window.attachEvent) window.attachEvent('onload', initClass);
// mobile browsers detect
browserPlatform = {
	platforms: [
		{
			// Blackberry <5
			uaString:['BlackBerry','midp'],
			cssFile:'blackberry.css'
		},
		{
			// Symbian phones
			uaString:['symbian','midp'],
			cssFile:'symbian.css'
		},
		{
			// Opera Mobile
			uaString:['opera','mobi'],
			cssFile:'opera.css'
		},
		{
			// IE Mobile <6
			uaString:['msie','ppc'],
			cssFile:'ieppc.css'
		},
		{
			// IE Mobile 6+
			uaString:'iemobile',
			cssFile:'iemobile.css'
		},
		{
			// Palm WebOS
			uaString:'webos',
			cssFile:'webos.css'
		},
		{
			// Android
			uaString:'Android',
			cssFile:'android.css'
		},
		{
			// Blackberry 6+
			uaString:['BlackBerry','6.0','mobi'],
			cssFile:'blackberry6.0.css'
		},
		{
			// iPad
			uaString:'ipad',
			cssFile:'ipad.css',
			miscHead:''
		},
		{
			// iPhone and other webkit browsers
			uaString:['safari','mobi'],
			cssFile:'safari.css',
			miscHead:''
		}
	],
	options: {
		cssPath:'css/',
		mobileCSS:'allmobile.css'
	},
	init:function(){
		this.checkMobile();
		this.parsePlatforms();
		return this;
	},
	checkMobile: function() {
		if(this.uaMatch('mobi') || this.uaMatch('midp') || this.uaMatch('ppc') || this.uaMatch('webos')) {
			this.attachStyles({cssFile:this.options.mobileCSS});
		}
	},
	parsePlatforms: function() {
		for(var i = 0; i < this.platforms.length; i++) {
			if(typeof this.platforms[i].uaString === 'string') {
				if(this.uaMatch(this.platforms[i].uaString)) {
					this.attachStyles(this.platforms[i]);
					break;
				}
			} else {
				for(var j = 0, allMatch = true; j < this.platforms[i].uaString.length; j++) {
					if(!this.uaMatch(this.platforms[i].uaString[j])) {
						allMatch = false;
					}
				}
				if(allMatch) {
					this.attachStyles(this.platforms[i]);
					break;
				}
			}
		}
	},
	attachStyles: function(platform) {
		if(platform.cssFile) {
			document.write('<link rel="stylesheet" href="' + this.options.cssPath + platform.cssFile + '" type="text/css"/>');
		}
		if(platform.miscHead) {
			document.write(platform.miscHead);
		}
	},
	uaMatch:function(str) {
		if(!this.ua) {
			this.ua = navigator.userAgent.toLowerCase();
		}
		return this.ua.indexOf(str.toLowerCase()) != -1;
	}
}.init();
