(function() {
var ds_namespace = '__dsns_';
window[ds_namespace] = function() {
	var startDate = new Date();
	var debugEnabled = true;
	var timingEnabled = false;
		
	this.Load = function() {
		if(typeof jQuery == "function")
			window[ds_namespace].other = jQuery;
		if(typeof jQuery == "function" && (jQuery.fn.jquery == '1.3.1' || jQuery.fn.jquery == '1.3.2')) {
			window[ds_namespace].$ = jQuery;
			this.Init(window[ds_namespace].$);
		}
		else
		{
			var el = document.createElement('SCRIPT');
			el.setAttribute('language', 'JavaScript');
			el.setAttribute('src', 'http://content.secondspace.com/news/jQuery.js');
			document.getElementsByTagName('head')[0].appendChild(el);
			this.WaitForInit(1000);
		}
	}
		
	this.WaitForInit = function(max) {
		if(typeof window[ds_namespace].$ != "function") {
			if (max > 0)
				setTimeout(function() { window[ds_namespace].WaitForInit(max - 1); }, 10);
			return;
		}
		window[ds_namespace].Init(window[ds_namespace].$);
	}
	
	this.WaitForReady = function(max) {
		if(!max) max = 100;
		if(typeof window[ds_namespace].FullyInitialized != 'boolean') {
			if (max > 0)
				setTimeout(function() { window[ds_namespace].WaitForReady(max - 1); }, 10);
			return;
		}
		window[ds_namespace].Ready();
	}
	
	this.Init = function($) {
		if(!$) return;

		var log = window[ds_namespace].Log = function(o) {
			if(!debugEnabled) return;
			try {window.console && console.log ? console.log.apply(console, !!arguments.length ? arguments : [this]) : $.browser.opera && $.browser.opera.postError && $.browser.opera.postError(o || this);} catch(e) {}
			$.cache.log = $.cache.log || [];
			$.cache.log[$.cache.log.length] = arguments.length > 1 ? arguments : o || this;
			return $.cache.log.length-1;
		}
		var time = window[ds_namespace].Time = function(o) { if(!timingEnabled) return; try {window.console && console.time ? console.time.apply(console, !!arguments.length ? arguments : [this]) : $.browser.opera && $.browser.opera.postError && $.browser.opera.postError(o || this);} catch(e) {} }
		var timeEnd = window[ds_namespace].TimeEnd = function(o) { if(!timingEnabled) return; try {window.console && console.timeEnd ? console.timeEnd.apply(console, !!arguments.length ? arguments : [this]) : $.browser.opera && $.browser.opera.postError && $.browser.opera.postError(o || this);} catch(e) {} }
		var timeStamp = window[ds_namespace].TimeStamp = function(o) {if(!timingEnabled) return; log(o, (new Date()).getTime() - startDate.getTime() + 'ms');}
		
		time('Init');
		$.ajaxSetup({ cache: true });
		if(window[ds_namespace].Initialized) return;
			window[ds_namespace].Initialized = true;
		
		// if IE6 and bgiframe not loaded, go get our safe version
		var IE = window[ds_namespace].IE = $.browser.msie;
		var IE6 = window[ds_namespace].IE6 = IE && /MSIE 6/.test(navigator.userAgent);
		var IE8 = window[ds_namespace].IE8 = IE && /MSIE 8/.test(navigator.userAgent);
		if(typeof $.fn.bgIframe == 'undefined' && IE6)
			$.getScript('http://content.secondspace.com/news/bgIframe.js');
		
		var ProperDate = new RegExp('^(0[1-9]|1[0-2]|[1-9])/(0[1-9]|[12][0-9]|3[01]|[1-9])/(19|20)[0-9]{2}$');
		
		var Bind = window[ds_namespace].Bind = function(sel, ev, func) {$(sel).live(ev, func);}
		var FullQuery = window[ds_namespace].FullQuery = function(q) {var r = {};if(!q) q = CurrentSearch();if(!q) return new Array(); q = q.replace(/^\?/,'').replace(/\&$/,'');$.each(q.split('&'), function(){r[this.split('=')[0]] = this.split('=')[1];});return r;};
		var CurrentSearch = window[ds_namespace].CurrentSearch = function() {var s = GetMetaData($('.searchquery'), location.search);if(!s || s == undefined)return false;return s;}
		var GetMetaData = window[ds_namespace].GetMetaData = function(el, fallback) {el = $(el);if(typeof fallback == 'undefined')fallback = false;if(el.length == 0)return fallback;var h = $.trim(el.html());if(h.slice(0, 4) == '<!--')h = h.slice(4);if(h.slice(-3) == '-->')h = h.slice(0, -3);return $.trim(h);}
		var FindMetaArray = window[ds_namespace].FindMetaArray = function(el) {var tmp = el.find('.meta');if(tmp.length == 0) tmp = el; return FullQuery(GetMetaData(tmp));}

		function DoSearch(q) {
			var u = '/default.aspx?';
			if(typeof q == 'string') {
				u += 'ct=r&q='+q;
			} else if(typeof q == 'object') {
				for(x in q)
					u += x+'='+q[x]+'&';
				u = u.substring(0, u.length-1);
			}
			document.location.href = u;
		}
		function CachedQuery(q) {
			if(!q) return;
			if(q.key) {
				var tmp = $(document).data(q.key);
				if(tmp) {
					q.success(tmp.data, tmp.status);
					return;
				}
			}
			$.ajax({
				url:q.url,
				cache:true, 
				data: q.data, 
				dataType:'json', 
				error:q.error, 
				success: function(data, status) {
					if(q.key)
						$(document).data(q.key, {data:data, status:status});
					q.success(data, status);
				}
			});
		}
		var SetCookie = window[ds_namespace].SetCookie = function(name,value, expires) {
			if(!expires) expires = 'Wed, 1 Jan 2020 00:00:00 UTC';
			if(location.host.indexOf('.') == -1 || location.host.indexOf('www.') == 0)
				document.cookie = name+'='+value+'; expires='+expires+'; path=/';
			else
				document.cookie = name+'='+value+'; expires='+expires+'; domain='+location.host+'; path=/';
		}
		var GetCookie = window[ds_namespace].GetCookie = function(name) { 
			var nameEQ = name + '=';
			var ca = document.cookie.split(';');
			for(var i=0;i < ca.length;i++) {
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
			return null;
		}
		var DeleteCookie = window[ds_namespace].DeleteCookie = function(name) {
			SetCookie(name,'','Sat, 1 Jan 2000 00:00:00 UTC');
		}
		var SetSession = window[ds_namespace].SetSession = function(name, value) {
			var q = FullQuery(window.name);
			q[name] = encodeURIComponent(value);
			var tmp = new Array();
			for(var i in q)
				tmp.push(i+'='+q[i]);
			window.name = tmp.join('&');
		}
		var GetCookie = window[ds_namespace].GetSession = function(name) {
			return decodeURIComponent(FullQuery(window.name)[name]);
		}
		function trackActivity(type, data, id) {
			if(!id) id='na';
			data += '&aid='+id;
			(new Image()).src='/ws/'+type+'.aspx?'+data+"&rand="+Math.random()*5;
		}
		function trackEvent(cat, type, data) {
			if(typeof dsTracker != 'object') {
				if(!window[ds_namespace].DomReady)
					$(function(){ trackEvent(cat, type, data); });
				else
					log('trackEvent failed: no tracker', cat, type, data);
				return;
			}
			if(typeof cat != 'string') cat = false;
			if(typeof type != 'string') type = false;
			if(typeof data != 'string') data = false;
			
			if(cat && type && data) dsTracker._trackEvent(cat, type, data);
			else if(cat && type) dsTracker._trackEvent(cat, type);
			else if(cat) dsTracker._trackEvent(cat, "true");
		}
		function PopupRefinements(list, section, meta) {
			if(!list || !list.refinements || list.refinements.length < 1) {
				section.find('.seealllink').text('Sorry, an error occurred.');
				return;
			}
			var seealllink = section.find('.seealllink');
			if(seealllink.hasClass('aboveOverlay'))
				return;
				
			list = list.refinements;
			var tmpl = $('#refinements .seealltmpl');
			if(tmpl.length == 0)
			{
				seealllink.text('Sorry, an error occurred.');
				return;
			}
			
			tmpl = tmpl.html();
			var start = tmpl.indexOf('#loop#');
			var end = tmpl.indexOf('#end#', start);
			var seealllink = section.find('.seealllink');
			if(start == -1 || end == -1)
			{
				seealllink.text('Sorry, an error occurred.');
				return;
			}
			var link = seealllink.find('A');
			link.text(link.data('originalText'));
			
			var html = new Array();
			html.push(tmpl.substring(0, start).replace('#plural#', meta['plural']));
			var loop = tmpl.substring(start+6, end);
			var l = list.length;
			
			for(var i = 0;i < l;i++) {
				var a = list[i];
				html.push(loop.replace('#name#', a.d).replace('#link#', a.u).replace('#count#', a.c));
			}
			html.push(tmpl.substring(end+5));
			
			var popup = $(html.join('')).appendTo($('#nocss')).css({position:'absolute', zIndex:200, left:-500, top:0, height:'auto'});
			if(IE) popup.css({width: popup.width() + 20});
			var pos = section.position();
			var maxh = $(window).height();
			var h = popup.height();
			var s = $(window).scrollTop();
			var top = pos.top;
			var left = pos.left + section.width() - 1;
			if(h > maxh) {
				top = s + 10;
				popup.css({height:maxh - 15});
			} else if( top + h > maxh + s ) {
				top = (maxh + s - h - 5);
			}
			if( popup.height() - 20 < maxh && top < s)
				top = s + 10;
				
			popup.css({top:top, left:left});
			popup.data('cat', section.data('cat'));
			popup.data('type', section.data('type'));
			seealllink.addClass('aboveOverlay');
			AddOverlay();
			function Remove() {
				$(window).unbind('resize', Resized);
				$(document).unbind('mousedown', BodyClick);
				popup.remove();
				seealllink.removeClass('aboveOverlay');
				RemoveOverlay();
			}
			popup.find('A[href$="#close"]').click(function() {Remove();return false;});
			
			function BodyClick(event) {
				var target = $(event.target);
				if (!(target.parents().index(popup) >= 0 || target.parents().index(seealllink) >= 0 || target[0] == seealllink[0] || target[0] == popup[0] || target[0].tagName == 'HTML')) {
					Remove();
					return;
				}
			}
			function Resized(event) {
				if($(window).width() != savedWidth)
					Remove();
			}
			$(document).mousedown(BodyClick);
			var savedWidth = $(window).width();
			$(window).bind('resize', Resized);
		}
		
		// ATTACH EVENTS
		Bind('.seealllink A', 'click', function() {
			var me = $(this);
			var section = me.blur().parents('.refinementsection');
			if(section.find('.aboveOverlay').length > 0)
				return;
			var meta = FullQuery(GetMetaData(section.find('.meta')));
			if(!me.data('originalText'))
				me.data('originalText', me.text()).text('Loading '+meta['plural']+'...');
			
			if(IE6 && !window[ds_namespace].AllLoaded) {
				if(!me.hasClass('seeallloading') && $('.seeallloading').length > 0)
					return false;
				me.addClass('seeallloading');
				setTimeout(function() {
						$('.seeallloading').click();
					}, 500);
				return false;
			}
			if(me.hasClass('seeallloading'))
				me.removeClass('seeallloading');
				
			var q = CurrentSearch();
			
			var qs = { key: 'REFINEMENTS', atkey: meta['key'], p: '/default.aspx' + q};
			if(meta['group'] == 'sn')
				qs = { key: 'REFINEMENTS', sn:meta['sn'], p: '/default.aspx' + q};
			
			if (q && meta) {
				CachedQuery({
					key:'refinements:'+q+':'+meta['sn'],
					url:'/ws.aspx',
					data: qs, 
					error:function(req, status, error) {
						me.parent().text('Sorry, an error occurred.');
						log(status, error);
					}, 
					success: function(data, status) {
						PopupRefinements(data, section, meta);
					} 
				});
			}
			return false;
		});
		
		
		Bind('.opened, .closed', 'click', function(e) {
			var me = $(this);
			var t = $(e.target);
			if(!t.hasClass('branch') && !t.hasClass('icon'))
				return;
			if(me.hasClass('closed')) {
				me.removeClass('closed').addClass('opened').children('UL').slideDown(100);
			} else {
				me.addClass('closed').removeClass('opened').children('UL').slideUp(100);
			}
		});
		Bind('.summary .more', 'click', function(e) {
			var me = $(this);
			me.hide().next().show();
			return false;
		});
		Bind('.datepickerContainer', 'CalendarOpened', function(e) {
			if($('#overlaymask').is(':hidden'))
				AddOverlay();
		});
		Bind('.datepickerContainer', 'CalendarClosed', function(e) {
			if($('.datepickerContainer:visible').length == 0)
				RemoveOverlay();
		});
		Bind('.customdate .inputs button', 'click', function(e) {
			var q = FullQuery();
			var host = $(this).parent();
			var from = $.trim(host.find('.datefrom').val());
			var to = $.trim(host.find('.dateto').val());
			var fromValid = (from.length == 0 || ProperDate.test(from));
			var toValid = (to.length == 0 || ProperDate.test(to));
			if(!fromValid && !toValid) {
				alert('Both dates are invalid, please use the format: 01/01/2001.');
				return false;
			} else if (!fromValid) {
				alert('First date is invalid, please use the format: 01/01/2001.');
				return false;
			} else if (!toValid) {
				alert('Second date is invalid, please use the format: 01/01/2001.');
				return false;
			} 
			q['r.STRDAT'] = from + ',' + to;
			DoSearch(q);
			return false;
		});
		
		Bind('.result A', 'click', function(e) {
			var me = $(this);
			var p = me.parent();
			var data = 'unknown';
			if(p.hasClass('image')) data = 'image';
			if(p.hasClass('title')) data = 'title';
			if(p.hasClass('subtitle')) data = 'subtitle';
			p = p.parents('.result');
			trackEvent(p.data('cat'), p.data('type'), data);
		});
		Bind('.refinementsection A', 'click', function(e) {
			var me = $(this);
			var p = me.parents('.refinementsection');
			var data = me.text();
			if(me.parent().hasClass('seealllink'))
				data = 'see all';
			trackEvent(p.data('cat'), p.data('type'), data);
		});
		Bind('.seeallpopup A', 'click', function(e) {
			var me = $(this);
			var p = me.parents('.seeallpopup');
			trackEvent(p.data('cat'), p.data('type'), me.text());
		});
		Bind('.breadcrumbs A', 'click', function(e) {
			trackEvent('Breadcrumbs', $(this).text());
		});
		
		var DatePicker = function(input, offset, filler) {
			input = $(input);
			var v = input.val();
			if(typeof input.DatePicker == 'function')
				input.DatePicker({
					format:'m/d/Y', 
					date:v, 
					current:v,
					starts:0,
					permanent:true,
					offset:offset,
					filler:filler,
					onBeforeShow: function(){
						var d = input.val();
						if(ProperDate.test(d))
							input.DatePickerSetDate(d, true);
					},
					onChange: function(formated, dates){
						input.val(formated);
					}
				});
			input.keyup(function() {var d = input.val();if(ProperDate.test(d))input.DatePickerSetDate(input.val(), true);});
			setTimeout(function() {input.trigger('click');}, 200);
		}
		
		var BackupCSScache = new Array();
		var BackupCSS = function() {
			var l = BackupCSS.arguments.length;
			if(l < 3) return;
			var n = BackupCSS.arguments[0];
			var cache = BackupCSScache[n];
			if(!cache) cache = new Array();
			for(i=1;i<l;i+=2) {
				var s = BackupCSS.arguments[i];
				var o = $(s);
				var c = BackupCSS.arguments[i+1];
				var b = new Object();
				for(var t in c)
					b[t] = o.css(t);
				cache[s] = b;
				o.css(c);
			}
			BackupCSScache[n] = cache;
		}
		var RestoreCSS = function(name) {
			var c = BackupCSScache[name];
			for(var s in c)
				$(s).css(c[s]);
		}
		
		var AddOverlay = function() {
			var mask = $('#overlaymask');
			if(mask.is(':visible'))
				return;
			var tmp = $('#loaderhost');
			if(tmp.length == 0 && window[ds_namespace].DomReady)
				tmp = $('body');
			if(tmp.length == 0)
			return;
			if(mask.length == 0)
				mask = $('<div id="overlaymask" style="display:none"></div>').appendTo(tmp);
			var w = $(window).width();
			var h = $(window).height();
			var dw = $(document).width();
			var dh = $(document).height();
			if(dh>h)h=dh;
			if(dw>w)w=dw;
			if(IE6 || IE8) w -= 22;
			if(IE6) $('SELECT').css({visibility:'hidden'});
			$('object, embed').css({visibility:'hidden'});
			mask.css({position:'absolute', opacity:.0, backgroundColor:'#333', top:0, left:0, width:w, height:h,display:'block', zIndex:100}).animate({opacity:.3}, 500);
			return this;
		}
		var RemoveOverlay = function() {
			$('#overlaymask').animate({opacity:.0}, 300, function() {$(this).hide();$('object, embed, SELECT').css({visibility:'visible'});});
			return this;
		}
		
		
		
		for(f in window[ds_namespace].OnInit)
			window[ds_namespace].OnInit[f](window[ds_namespace]);
		
		var Ready = function() {
			timeStamp('Ready');
			time('Ready');
			if(window[ds_namespace].IsReady) return;
			window[ds_namespace].IsReady = true;
			for(f in window[ds_namespace].OnReady)
				window[ds_namespace].OnReady[f](window[ds_namespace])
		
			var q = FullQuery();
				
			$('.topsort SELECT').change(function() {
				var me = $(this);
				trackEvent('Sort', me.find(':selected').text());
				q['sort'] = me.val();
				if(me.find(':selected').hasClass('defopt'))
					q['sort'] = false;
				var u = '/default.aspx?';
				for(x in q)
					if(x && q[x])
						u += x+'='+q[x]+'&';
				u = u.substring(0, u.length-1);
				document.location.href = u;
			});
			// create cat tree, expand first level
			$(".catref LI").each(function() {
				var me = $(this);
				if(me.find('UL').length > 0)
					me.addClass('opened').parent().addClass('tree');
			});
			$(".catref .tree > LI").each(function() {
				$(this).prepend('<span class="icon">&nbsp;</span>');
			});
			
			// custom date picker
			$('.dateref A[href$="#customdate"]').click(function() {
				trackEvent('Refinement', 'Date', 'Custom Date');
				var dp = $('.datepicker');
				if(dp.length > 0) {
					$('.dateref .datefrom, .dateref .dateto').trigger('click');
					$('.datepicker').show();
					setTimeout(function() {
						AddOverlay();
					}, 200);
				}
				else {
					setTimeout(function() {
						$.getScript('http://content.secondspace.com/news/DatePicker.js', function() {
							DatePicker('.dateref .datefrom', {left:-100, top:5}, {width:-69, height:8});
							DatePicker('.dateref .dateto', {top:5}, {width:70, height:8});
							AddOverlay();
						});
					}, 200);
				}
				var host = $(this).parent();
				if(IE) BackupCSS('datepicker',
					'.customdate', {position:'relative', top:-3, height:29, marginBottom:-7},
					'.customdate .inputs', {position:'relative', top:-3, height:29},
					'.customdate .inputs button', {position:'relative', top:3, left:3, marginRight:5}
					);
				else
					BackupCSS('datepicker', '.customdate', {position:'relative'});
				
				$('.dateref .inputs').css('display', 'block');
				host.slideUp(200, function() {
					$('.dateref .datefrom, .dateref .dateto').trigger('click');
					$('.datepicker').show();
				});
				function Resized(event) {				
					if($(window).width() == savedWidth)
						return;
					$('.dateref A[href$="#cancel"]').click();
					$('.datepicker').remove();
					$(window).unbind('resize', Resized);
				}
				var savedWidth = $(window).width();
				$(window).bind('resize', Resized);
				return false;
			});
			$('.dateref A[href$="#cancel"]').click(function() {
				$('.datepicker').hide();
				RestoreCSS('datepicker');
				$('.dateref .link').slideDown(200);
				RemoveOverlay();
				return false;
			});
			
			$(window).load(function() {
				var youreg = new RegExp('youtube', 'i');
				$('.mediaresult .image IMG').each(function() {
					var me=$(this);
					if(youreg.test(me.attr('src'))) {
						me.css({height:120, width:160});
						return;
					}
					var h = me.height();
					var ph = me.parent().height();
					if(h <= ph)
						return;
					me.css({marginTop:(ph - h) / 2});
				});
			});
			
			// unlink last breadcrumbsv & selected date refinement
			var l = $('.breadcrumbs UL LI:last').children();
			if(l.is('A')) 
				l.after('<span>'+l.html()+'</span>').remove();
			
			var d = q["r.STRDAT"];
			if(d && d.length > 2) {
				l = $('#topsection .dateref A[href*='+d+']');
				if(l.length == 1)
					l.after('<span class="selected">'+l.text()+'</span>').remove();
			}
			
			$('.trackclick').each(function() {
				var me = $(this);
				var data = GetMetaData(me);
				var p = me.parent();
				p.click(function() {
					trackActivity('trackclick', data, p.attr('id'));
				});
			});
			
			// event tracking
			$('.trackevent').each(function() {
				var me = $(this);
				var data = GetMetaData(me);
				if(!data) return;
				var q = data.split(':');
				var cat = q[0];
				var type = false, more = false;
				if(q.length > 0) type = q[1];
				if(q.length > 1) more = q[2];
				trackEvent(cat, type, more);
			});
			$('.result').each(function() {
				var me = $(this);
				var cat = 'ArticleResult';
				var type = false;
				if(me.find('.audio').length > 0) type = 'audio';
				if(!type && me.find('.video').length > 0) type = 'video';
				if(!type && me.find('.hotlink').length > 0) type = 'hotlink';
				if(!type && me.find('.younewstitle').length > 0) type = 'younews';
				if(!type) type = 'normal';
				me.data('cat', cat);
				me.data('type', type);
			});
			$('.refinementsection').each(function() {
				var me = $(this);
				var cat = 'Refinement';
				var type = false;
				if(me.hasClass('dateref')) type = 'Date';
				if(!type && me.hasClass('mediaref')) type = 'Type';
				if(!type) type = me.find('H4').text();
				me.data('cat', cat);
				me.data('type', type);
			});
			
			// video popup
			var iphone = (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i));
			var newKomo = (window.location.host == 'search.komonews.com');

			$('.result').each(function() {
				var me = $(this);
				if(me.find('.video, .audio').length == 0) return;
				if(me.find('.younewstitle').length != 0) return;
				me.find('.image, .subtitle').click(function () {
					var link = $(this);
					var url = link.find('A').attr('href');
					if(iphone)	{
						var file = GetMetaData(me.find('.fileurl'));
						window.open(file.replace('.flv', '.mp4'));
					} else if(newKomo) {
						 if(me.find('.video').length > 0)
							 window.location = url +'?tab=video';
						 else
							 window.location = url;
							 return false;
					} else {
						var win = false;
						if(me.find('.audio').length > 0)
							win = window.open(url+'?video=pop&t=a', 'video', 'scrollbars=yes,width=800,height=630,screenx=15,screeny=15');
						else
							win = window.open(url+'?video=YHI&t=a', 'video', 'scrollbars=yes,width=800,height=630,screenx=15,screeny=15');
						if(win) {
							win.focus();
							return false;
						}
					}
				});
			});
			
			
			
			timeEnd('Ready');
		}
		var deferDelta = 1;
		var Deferred = function() {
			window[ds_namespace].HasDeferred = true;
			$('.deferred').each(function() {
				var me = $(this);
				if(me.data('deferredhook') == 'true') return;
				var id = (''+Math.random()).substr(2);
				if(me.attr('id') == '')
					me.attr('id', id);
				var html = GetMetaData(me, '');
				setTimeout(function() {
					if (html && html.length > 3 && html.substr(0, 3) == 'id=') {
						var source = $('#deferredload' + html.substr(3));
						if (source.length == 0) return;
						if(me.data('deferredhook') == 'true') return;
						me.data('deferredhook', 'true');
						//var h = source.height();
						//if(h > 0 && h < 300)
						//	h = 300;
						//me.height(h);
						var pos = me.position();
						source.css({position:'absolute', top:pos.top, left:pos.left}).addClass('moveOnResize').data('resizehost', me.attr('id'));
					} else {
						if(me.data('deferredhook') == 'true') return;
						me.data('deferredhook', 'true');
						me.html(html).css({ width: 'auto', height: 'auto' });
					}
					RePosition();
				}, deferDelta);
			});
			
			if(window[ds_namespace].HasDeferredResized) 
				return;
			function RePosition() {
				$('.moveOnResize').each(function() {
					var me = $(this);
					var host = $('#'+me.data('resizehost'));
					if(host.length == 0) return;
					var pos = host.position();
					me.css({top:pos.top, left:pos.left});
				});
			}
			function Resized(event) {
				setTimeout(function() {
					RePosition();
				}, 10);
			}
			window[ds_namespace].HasDeferredResized = true;
			$(window).bind('resize', Resized);
			$(window).bind('load', Resized);
		}
		window[ds_namespace].AllLoaded = false;
		window[ds_namespace].DomReady = false;
		window[ds_namespace].Ready = Ready;
		window[ds_namespace].Deferred = Deferred;
		window[ds_namespace].FullyInitialized = true;
		$(function(){
			$(window).bind('load', function() {window[ds_namespace].AllLoaded = true;});
			window[ds_namespace].DomReady = true;
			window[ds_namespace].Ready();
			window[ds_namespace].Deferred();
			if(IE6) $('.topads').css({display:'inline'});
		});
	}
	this.Ready = false;
	this.Deferred = false;
		
	return {
		Load:this.Load,
		WaitForInit:this.WaitForInit,
		Init:this.Init,
		WaitForReady:this.WaitForReady,
		Deferred:this.Deferred,
		Ready:this.Ready
	};
}();
window[ds_namespace].OnInit = new Array();
window[ds_namespace].OnReady = new Array();
window[ds_namespace].AddInit = function(f)	{if(window[ds_namespace].Initialized)	f(window[ds_namespace]); else window[ds_namespace].OnInit.push(f)	;}
window[ds_namespace].AddReady = function(f) {if(window[ds_namespace].IsReady)		f(window[ds_namespace]); else window[ds_namespace].OnReady.push(f)	;}
window[ds_namespace].Load();
})();