$.log = function() {
	if (window.console) window.console.log.apply(window.console, arguments);
	else alert([].slice.apply(arguments, 0));
	return arguments[0];
};
$.fn.log = function(){ return $.log(this); };

$.write = function(s) {
	return $(s).insertAfter('script:last');
};

$.timeline = function(action, duration, easing) {
	var args = [].slice.call(arguments, 3),
		t = this.timeline,
		start = new Date().getTime();

	easing = $.isFunction(easing) && easing || t.easing[easing] || t.easing.swing;

	t.timers.push(function(cur) {
		var pos = (cur - start) / duration;
		return action(pos, easing.apply(null, [pos].concat(args)));
	});

	if (t.timers.length == 1) {
		var timer = setInterval(function(){
			var cur = new Date().getTime();
			t.timers = $.grep(t.timers, function(fn){ return fn(cur); });
			if (!t.timers.length) clearInterval(timer);
		}, 13);
	}
};

$.extend($.timeline, {
	timers: [],
	easing: {
		linear: function(cur) { return cur; },
		swing: function(cur) { return 0.5 - 0.5 * Math.cos(cur * Math.PI ); }
	}
});

var baseHref = $('base').attr('href').replace(/.*\/\/[^\/]*/, '');
$.cookie.addId = function(name, id){
	$.cookie.remId(name, id);
	this(name, (this(name) || ',') + id + ',', {expires: 30, path: baseHref});
};
$.cookie.remId = function(name, id){
	this(name, (this(name) || ',').split(','+ id +',').join(','), {expires:30,path:baseHref});
};
$.fn.events = function() {
	var dispach = function(exp, fn){
		return function(e){
			var $t = jQuery(e.target);
			while ($t[0] && $t[0] != this && !$t.is(exp)) $t = $t.parent();
			if ($t[0] && $t[0] != this) return fn.apply($t[0], arguments);
		};
	};
	for (var i = 0, a = arguments, ln = a.length; i < ln; i += 3)
		this.bind(a[i], dispach(a[i+1], a[i+2]));
	return this;
};
$.formatPrice = function(s, d) {
	s = ""+ Math.round(s);
	var out = [];
	while (s) {
		out.unshift(s.substring(s.length - 3, s.length));
		s = s.substring(0, s.length - 3);
	}
	return out.join(' ') +' '+ d;
};

$.singularize = function(string) {
	var c = string.charAt(0);
	if (parseInt(string.length) == 1) {
		return c.toUpperCase();
	}
	else {
		return c.toUpperCase() + string.slice(1, string.length - 1).toLowerCase();
	}
}

$.fn.formatPrice = function(s, d) {
	return this.text($.formatPrice(s, d));
};

$.fn.swapClass = function(from, to) {
	return this.removeClass(from).addClass(to);
};

$('html').addClass('js-hide');

$(function(){
	try { document.execCommand("BackgroundImageCache", false, true); } catch(e) {};

	for (var i in App.selects) if (!App.selects[i].executed) App(i);
	$('html').removeClass('js-hide');

	$('table.alt tbody tr:odd').addClass('odd');

});

function App(sel) {
	var jq = typeof App.selects[sel] == "function" && $(sel);
	if (jq && jq.length) {
		App.selects[sel].call(jq, jq);
		App.selects[sel].executed = true;
	}
}

$.extend(App, {
	indexBanners: function(banners) {
		var div = $('<div>')[0], lis = [], con = [];
		for (var i = 0; i < banners.length; i++) {
			lis[i] = '<li><a href="javascript:changeBanner('+ i +');">'+ banners[i][0] +'</a></li>';
			con[i] = '<div class="content" style="display: none;"></div>';
		}

		div.innerHTML = '<ul>'+ lis.join('') +'</ul>'+ con.join('');

		lis = $.makeArray(div.getElementsByTagName('a'));
		con = $.makeArray(div.getElementsByTagName('div'));
		var s = document.getElementsByTagName('script');
		s = s[s.length - 1];
		while (div.firstChild)
			s.parentNode.insertBefore(div.firstChild, s);

		var last = null;
		for (var i = 0; i < lis.length; i++) {
			lis[i].onclick = function(){
				if (last) {
					last.parentNode.className = '';
					last.content.style.display = 'none';
				}
				last = this;
				last.parentNode.className = 'active';
				last.content.style.display = '';
				return false;
			};
			lis[i].content = con[i];
			con[i].innerHTML = banners[i][1];
		}
        //alert(Math.round(Math.random()));
		lis[Math.round(Math.random() * (lis.length - 1))].onclick();
		//lis[lis.length - 2].onclick();
	},

	addToCartBox: function(type, id, title, price, status) {
		status = status ? '<span class="status" style="font-weight: normal">'+ status +'</span> ' : '';
		$holder = $('#myVehicles > div.content div.' + type),
			row = App.tpl('new cart row' + (status ? ' reserved' : ''), type, id, type, id, title, price, id);

		$holder.parent().find('p.comment').remove();
		/* if ($('#myTools a.email').length != 1) {
			$('#myTools').append(App.tpl('email'));
		}*/

		var $table;
		if (!$holder.find('table').length) {
			$table = $holder
				.append(App.tpl('empty cart box'))
				.find('table').append(row);
		} else {
			var append = true;
			$table = $holder.find('table').find('strong')
				.each(function(){
					$s = $(this);
					if (parseInt(price) <= parseInt($s.text())) {
						$s.parents('tr:first')
							.before(row);
						return append = false;
					}
				})
			.end();
			if (append)
				$table.append(row);
		}

		if ($table.find('tr').length == 2) {
			var compareURL = 'cart/listCompare/' + type;
			$holder.find('p.tool').append(App.tpl('compare button1', compareURL));
		}

		var $a = $holder.find('h3 a');
		$a.html($a.html().replace(/\[(\d+)\]/, '['+ $table.find('tr').length +']'));

		$.cookie.addId('HLcookieCart' + $.singularize(type), id);
		if (($.cookie('HLcookieCompare' + $.singularize(type)) || ",").split(',').length < 6)
			$.cookie.addId('HLcookieCompare' + $.singularize(type), id);
	},

	removeFromCartBox: function() {
		var $tr = $(this).parents('tr:first');
		var tmp = $tr.attr('id').split('-'), type = tmp[0].split('_')[1], id = tmp[1];
		var $table = $(this).parents('table:first');
		$tr.remove();

		var $a = $('#myVehicles div.' + type + ' h3 a'), ln;
		$a.html($a.html().replace(/\[(\d+)\]/, '['+ (ln = $table.find('tr').length) +']'));

		if ($('#' + type + '-' + id ).size()) {
			$('#' + type + '-' + id + ' .tool').prepend(App.tpl('add to cart', type, id));
		}

		if ($('#myTools.' + type + '-' + id)) {
			$('#myTools.' + type + '-' + id).prepend(App.tpl('add to cart', type, id));
		}

		$.cookie.remId('HLcookieCart' + $.singularize(type), id);
		$.cookie.remId('HLcookieCompare' + $.singularize(type), id);

		if ($table.find('tr').length < 2) {
			$table.siblings('p.tool').find('a.button').remove();
		}

		var cartEmpty = true, cartTypes = ['Car', 'Motorcycle', 'Offroad', 'Boat'];
		for (var i = 0; (cartType = cartTypes[i]); i++) {
			if ($.cookie('HLcookieCart' + cartType) && $.cookie('HLcookieCart' + cartType) != ',') {
				cartEmpty = false;
			}
		}

		if (!ln) {
			$('#myVehicles > div.content div.' + type).find('> *:not(h3)').remove().end();
		}

		if (cartEmpty == true) {
			$('#myVehicles > div.content h2').after(App.tpl('cart comment'));
		}
		return false;
	},

	removeFromCompareBox: function(){
		var $tr = $(this).parents('tr:first');
		var tmp = $tr.attr('id').split('-'), type = tmp[0].split('_')[1], id = tmp[1];
		$tr.attr('id', '').removeClass('filled').find('td, th').html('&nbsp;');

		$('#catalogList table.catalog-list td.tool a:not([@href*=addToCompare]) + br')
			.parent().find('a:first').each(function() {
				var tmp = $(this).parents('tr:first').attr('id').split('-'), type = tmp[0], id = tmp[1];
				$(this).after(App.tpl('add to compare', type, id));
			});
		$tr.siblings('tr[@id]').each(function() {
			var tmp = this.id.split('-'), type = tmp[0].split('_')[1], id = tmp[1];
			$('#' + type + '-' + id + ' td.tool a[@href*=addToCompare]').remove();
		});

		if ($tr.parents('table:first').find('tr.filled').length < 2)
			$tr.parents('div:first').find('p.tool').remove();

		$tr.parent().append($tr);
		$.cookie.remId('HLcookieCompare' + $.singularize(type), id);
		return false;
	},
	print: function(){ $.write(App.tpl('print')); },
	selects: {
		'#myVehicles': function($cart){
			$cart.find('div.content:not(.compare)').events(
				'click', '[@href*=removeFromCart]', App.removeFromCartBox,
				'click', '[@href*=clearCart]', function(){
					var type = this.parentNode.className.split(' ')[1];
					$('#myVehicles div.' + type + ' table a[@href*=removeFromCart]').each(function(){
						App.removeFromCartBox.call(this);
					});
					return false;
				},
				'click', '[@href*=removeFromCompare]', App.removeFromCompareBox
			);

			var $o = $('#myTools, #foot, html').add($cart[0]);
			var m = $('#myTools')[0], f = $('#foot')[0], h = $('html')[0], c = $cart[0];
			var cartTop = function(){
				var tt = $o[0].offsetTop + $o[0].offsetHeight,
					tb = $o[1].offsetTop,
					wt = $o[2].scrollTop,
					wb = $o[2].clientHeight + wt,
					ct = $o[3].offsetTop,
					ch = $o[3].offsetHeight + 20,
					zt = tt > wt ? tt : wt,
					zb = tb < wb ? tb : wb,
					zh = zb - zt;

				return (ch < zh || ct > zt ? zt : (ct + ch) < zb ? (zb - ch) : ct) - tt;
			};

			var timeout;
			$(window).scroll(function(){
				clearTimeout(timeout);
				timeout = setTimeout(function(){
					var start = parseInt($cart.css('margin-top')) || 0;
					var res = cartTop();
					if (Math.abs(start - res) > 5)
						$.timeline(function(pos, ease){
							if (pos < 1)
								$cart[0].style.marginTop = ease * (res - start) + start +'px';
							else
								$cart[0].style.marginTop = res +'px';
							return pos < 1;
						}, 200);
				}, 100);
			});
		},
		'#catalog-list, table.catalog-list': function(){
			var addAll;
			this
				[window.hackAll ? 'pushStack' : 'add']([])
				.events(
				'click', '[@href*=addToCart]', addAll = function(){
					var $item = $(this).parents('.item');

					App.addToCartBox(
						$item.attr('id').split('-')[0],
						$item.attr('id').split('-')[1],
						$item.find('h3 a').html().replace(/<\/?a[^>]>|<small[\s\S]*?<\/small>/ig, ''),
						$item.find('big').text(),
						$item.find('p.pic > .status').text()
					);

					$(this).remove();
					return false;
				},
				'click', '[@href*=addToCompare]', function(){
					var $tr = $(this).parents('tr:first');
					var type = $tr.attr('id').split('-')[0];
					var id = $tr.attr('id').split('-')[1];
					var $table = $('#myVehicles table');
					var ln = $table.find('tr.filled').length;
					if (ln < 4) {
						$table.find('tr:not(.filled):first')
							.before(App.tpl('compare box row', type, id, type, id, $tr.find('h3').html().replace(/<small.*/ig, ''), type, id))
							.remove();

						if ($table.find('tr.filled').length == 2)
							$table.after(App.tpl('compare button', 'cart/listCompare/' + type));

						(ln == 3 ? $tr.parents('table') : $tr)
							.find('a[@href*=addToCompare]').remove();

						$.cookie.addId('HLcookieCompare' + $.singularize(type), id);
					}
					return false;
				},
				'click', '[@href*=removeFromCart]', function() {
					var $tr = $(this).parents('tr:first');
					var tmp = $tr.attr('id').split('-'), type = tmp[0], id = tmp[1];
					$('#compare_'+ type + '-' + id + ' a[@href*=removeFromCompare]').each(function(){
						App.removeFromCompareBox.call(this);
					});
					$tr.remove();
					$.cookie.remId('HLcookieCart' + $.singularize(type), id);
					return false;
				})
				[window.hackAll ? 'end' : 'add']([])
				.find('a[@href$=addToCart/'+ ($.cookie('HLcookieCart') || ",").split(',').join('], a[@href$=addToCart/') +']')
					.each(addAll);
			window.hackAll = true;
		},
		'#myTools.view': function(){
			this.events(
				'click', '[@href*=addToCart]', function() {
					var tmp = $(this).parents('#myTools').attr('class').split(' ')[1].split('-'), type = tmp[0], id = tmp[1];
					App.addToCartBox(
						type,
						id,
						$('#carTitle').html().replace(/<small[\s\S]*?<\/small>/ig, ''),
						$('#carLizing big').text() +' Lt',
						$('#status').text()
					);

					$(this).remove();
					return false;
				});
		},
		'#search': function(){
			if (window.searchModels) {
				$('#FilterMakeId').bind('change', function(){
					var opt = $('#FilterModelId')[0].options,
						arr = window.searchModels;

					opt.length = 0;
					opt[0] = new Option(' ', '');
					if (arr[this.value]) {
						arr = arr[this.value];
						for (var i=0,l=arr.length; i<l; i++) {
							opt[i+1] = new Option(arr[i][1], arr[i][0]);
						}
					}
				}).trigger('change');
				$('#FilterModelId').val(window.FilterModelId);
			}

			var SearchMore = $.cookie('HLcookieSearch') == "none";
			if (!SearchMore)
				$('#search div.expand').css('display', 'none');

			var timer;
			var $toggle = $(App.tpl('search more button'))
				.appendTo(this)
				.find('a')
					.bind('dblclick', function() {
						return false;
					})
					.bind('click', function(){
					window.clearTimeout(timer);
					var s = this;
					timer = window.setTimeout(function(){
						$('span', s).toggle();
						$.cookie('HLcookieSearch', $('span:first', s).css('display'), {path:baseHref});
						$('#search div.expand').slideToggle('fast');
					}, 500);
					return false;
				});

			if (SearchMore) $toggle.find('span').toggle();
		},
		'#carPhoto': function(){
			var carPhotos = window.carPhotos;
			if (carPhotos && carPhotos.length) {
				var currentPhotoIndex = 0;
				var changeCarPhoto = function(n) {
					var i = currentPhotoIndex = (carPhotos.length + currentPhotoIndex + n) % carPhotos.length;
					$('#carPhotoNavigation a.prev').css('visibility', !i ? 'hidden' : '');
					$('#carPhotoNavigation a.next').css('visibility', i == carPhotos.length - 1 ? 'hidden' : '');
					$('#carPhoto img').attr('src', carPhotos[i]);
					var $txt = $('#carPhotoNavigation span')
						txt =  $txt.text().replace(/\d+/g, '##').split('##');
					$txt.text((i + 1) + txt[1] + carPhotos.length);
				}

				$(this)
					.append(App.tpl('car photos', carPhotos.length))
					.find('a.prev').bind('click', function(){ changeCarPhoto(-1); return false }).css('visibility', 'hidden').end()
					.find('a.next').bind('click', function(){ changeCarPhoto(1); return false}).end();
			}
		},
		'#popularCars li:last, #newCars li:last': function(){ this.css('border', '0') },
		'#rightContent li': function(){
			this.hover(function(){$(this).toggleClass('hover')}, function(){$(this).toggleClass('hover')})
		},
		'#poll': function(_this){
			var $ps = $('button', this),
				check = function(){
					$ps.attr("disabled", ($(':radio[@checked]', _this).length < 2)
						? "disabled" : "");
				};
			check();
			$(':radio', this).bind('click', check);
		},
		'#catalogList li[h3.super-price], #catalogList th[h3.super-price]': function() {
			var hide = true;
			this.hover(function(){
				hide = false;
				$('div.super-price-bug', this).show('fast', function(){
					var $this = $(this);
					if (hide) setTimeout(function(){$this.hide('fast');}, 0);
					hide = true;
				});
			}, function(){
				if (hide) $('div.super-price-bug', this).hide('fast');
				hide = true;
			});
			$('div.super-price-bug').hide();
		},
		'#catalog-list.linear h3.super-price': function() {
			$(this).hover(
				function() {
					$(this).addClass('over');
				},
				function() {
					$(this).removeClass('over');
				}
			);
		},
		'#catalogList table.compare-list.cars': function(self){
			this.find('thead td')
				.append(App.tpl('compare expand'))
				.find('a').bind('click', function(){
					self.find('.hidden').removeClass('hidden');
					$.cookie('HLcookieCompareCats', '', {path:baseHref});
					return false;
				});
			this.addClass('js').find('.rowgroup').bind('click', function(){
				var $tbody = $(this).parents('tbody:first').toggleClass('hidden');
				var id = $tbody.attr('class').replace(/\D+/g, '');
				$.cookie[$tbody.is('.hidden') ? 'addId' : 'remId']('HLcookieCompareCats', id);
			});
			this.find('tbody.cat-'+ ($.cookie('HLcookieCompareCats') || ',').split(',').join(', tbody.cat-')).addClass('hidden');
		},
		'a.test-drive': function(){
			
			this.bind('click', function(){
				App.templates['popup'] = 'width=400,height=470,top=%s,left=%s,scrollbars=no';
				window.open(this.href, '', App.tpl('popup', Math.round(window.screen.height / 2 - 240), Math.round(window.screen.width / 2 - 320)));
				return false;
			});
		},
		'a.email': function(){
			
			this.bind('click', function(){
				App.templates['popup'] = 'width=400,height=250,top=%s,left=%s,scrollbars=no';
				window.open(this.href, '', App.tpl('popup', Math.round(window.screen.height / 2 - 240), Math.round(window.screen.width / 2 - 320)));
				return false;
			});
		},
		'a.switch-paging': function() {

			var type = $.cookie('HLcookieCatalogView') || 'linear';

			var $catalog  = $('#catalog-list');
			var $switcher = this.before('<a href="#" id="switch-view" class="' + type + '">' + App.tpl('catalog layout ' + type) + '</a>').prev();

			$switcher.bind('click', function() {
				if ($(this).is('.grid')) {
					$(this).swapClass('grid', 'linear').html(App.tpl('catalog layout linear'));
					$catalog.swapClass('grid', 'linear');
					$.cookie('HLcookieCatalogView', 'linear', {expires:30,path:baseHref});
				}
				else {
					$(this).swapClass('linear', 'grid').html(App.tpl('catalog layout grid'));
					$catalog.swapClass('linear', 'grid');
					$.cookie('HLcookieCatalogView', 'grid', {expires:30,path:baseHref});
				}
				return false;
			});
			if ($switcher.is('.grid')) {
				$catalog.swapClass('linear', 'grid');
			}
		},
		'td.availability div': function() {
			$(this).hover(
				function() {
					$(this).addClass('over');
				},
				function() {
					$(this).removeClass('over');
				}
			);
		},
		'form#bug-report': function() {
			$(this).hide();
			$(this).before(App.tpl('bug report'));
			$('#bugReportLink').click(function() {
				var $form = $(this).parent().next();
				if ($form.is(':hidden')) {
					$form.show();
					$(this).parent().remove();
				}
			});
		}
	},
	tpl: function(name){
		var out = "", tpl = this.templates && this.templates[name] || null;
		if (tpl) {
			tpl = tpl.split('%s');
			var out = tpl[0];
			for (var i = 1, ln = tpl.length; i < ln; i++) out += (arguments[i] || "") + tpl[i];
		}
		return out;
	}
});


function oSWF(obj, outputOnly) {
	if (!document.getElementById) return;
	var v = oSWF.getVersion(obj.version);
	var vars = obj.flashvars || {};
	if (oSWF.expressInstall
		&& v && v >= oSWF.installed
		&& oSWF.installed >= 6000065
	) {
		obj.src = oSWF.expressInstall +".swf";
		document.title = document.title.slice(0, 47) + " - Flash Player Installation";
		vars.MMdoctitle = document.title;
		vars.MMredirectURL = escape(window.location.href);
		vars.MMplayerType = oSWF.agent == "ns" ? "PlugIn" : "ActiveX";
	} else if (!oSWF.installed || v > oSWF.installed) {
		return oSWF.write(obj.alternative || '<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW" style="display: block; background: #284d74 url('+ oSWF.expressInstall +'.gif) no-repeat 50% 50%; width: '+ obj.width +'px; height: '+ obj.height +'px;><img src="'+ oSWF.expressInstall +'.gif" style="display: none;" alt="Adobe Flash Player Update: This content requires Adobe Flash Player. Would you like to insrall it now?" /></a>');
	}

	var a = [];
	for (var i in vars) a[a.length] = i +'='+ encodeURIComponent(vars[i]);
	obj.flashvars = a.join('&');

	if (outputOnly) return oSWF.getHTML(obj);
	else oSWF.write(obj);
}
oSWF.expressInstall = "expressinstall";
(function(obj) { for (var i in obj) oSWF[i] = obj[i] })({
	getVersion: function(str) {
		var a = str && (str + "").replace(/^\D+/, '').split(/\D+/g) || [];
		for (var i = 2, v = 0; i >= 0; i--) v += (parseInt(a[i]) || 0) * Math.pow(1000, 2 - i);
		return v;
	},
	tryActiveX: function(ver) {
		try { return new ActiveXObject("ShockwaveFlash.ShockwaveFlash"+ (ver ? '.'+ ver : "")); }
		catch (e) { return null }
	},
	agent: function() {
		var n = navigator, np = n.plugins, nm = n.mimeTypes, na = n.userAgent;
		return np && nm && nm.length && "ns"
				|| na && na.indexOf("Windows CE") >= 0 && "ce"
				|| "ie";
	}(),
	getHTML: function(obj) {
		if (oSWF.agent == "ns") {
			obj.name = obj.id;
			var html = '<embed type="application/x-shockwave-flash" src="'+ obj.src +'"';
			for (var i = 0, a = 'id,name,width,height,style,class,flashvars,bgcolor,quality,play'.split(','); i < a.length; i++)
				if (obj[a[i]]) html += ' '+ a[i] +'="'+ obj[a[i]] +'"';
			html += '/>';
		} else {
			var html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
			for (var i = 0, a = 'id,width,height,style,class'.split(','); i < a.length; i++)
				if (obj[a[i]]) html += ' '+ a[i] +'="'+ obj[a[i]] +'"';
			html += '>';
			obj.movie = obj.src;
			for (var i = 0, a = 'movie,flashvars,bgcolor,quality,play'.split(','); i < a.length; i++)
				if (obj[a[i]]) html += '<param name="'+ a[i] +'" value="'+ obj[a[i]] +'" />';
			html += "</object>";
		}
		return html;
	},
	write: function(obj) {
		var div = document.createElement('div'), b, c, html = oSWF.getHTML(obj);
		if (obj.before) b = document.getElementById(obj.before);
		else if (obj.append) c = document.getElementById(obj.append);
		else if (obj.replace) return document.getElementById(obj.replace).innerHTML = html;
		else {
			b = document.getElementsByTagName('script');
			b = b[b.length - 1];
		}
		c = c || b.parentNode;
		div.innerHTML = html;
		c.insertBefore(div.firstChild, b);
		if (oSWF.agent == 'ie')
			c.innerHTML = c.innerHTML;
	}
});

oSWF.installed = function() {
	var version = 0, x, axo;
	if (oSWF.agent == "ns") {
		if (x = navigator.plugins["Shockwave Flash"])
			version = oSWF.getVersion(x.description);
	} else if (oSWF.agent == "ce") {
		for (var i = 3; tryActiveX(i); i++)
			version = oSWF.getVersion(i);
	} else {
		if (!(axo = oSWF.tryActiveX(7)) && (axo = oSWF.tryActiveX(6))) {
			version = oSWF.getVersion('6,0,21');
			try { axo.AllowScriptAccess = "always"; }
			catch (e) { return version; }
		}
		if (axo = oSWF.tryActiveX())
			version = oSWF.getVersion(axo.GetVariable("$version"));
	}
	return version;
}();

if (!oSWF.unload && window.attachEvent) {
	oSWF.unload = true;
	// fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
	window.attachEvent("onbeforeunload", function(){
 		var fn = function(){};
		__flash_unloadHandler = __flash_savedUnloadHandler = fn;

		// fix for video streaming bug
		window.attachEvent("onunload", function(){
			var o = document.getElementsByTagName("object");
			for (var i = o.length - 1; i >= 0; i--) {
				o[i].style.display = 'none';
				for (var x in o[i]) if (typeof o[i][x] == 'function')
					o[i][x] = fn;
			}
		});
	});
}

/* add document.getElementById if needed (mobile IE < 5) */
if (!document.getElementById && document.all) {
	document.getElementById = function(id) {
		return document.all[id];
	}
}
