
var rewaitTimeout = false
var segQS = 0
var waitCounter = 1

function processWaitPanel()
{

	rewaitTimeout = false
	
	$("div.wait").each(function (i) {
		var url = $(this).children('span:first').html()
		$(this).clone()
		$(this).slideUp()
		$(this).empty()
		$(this).removeClass('wait')			
		
		if (url.indexOf('?') == -1) {
			url += '?retry=' + waitCounter
		} else {
			url += '&retry=' + waitCounter
		}
		
		$(this).load(url, false, function() {
			if ($(this).html().toUpperCase().indexOf('<DIV CLASS="WAIT"') > -1) {				
				if (!rewaitTimeout) {
					rewaitTimeout = setTimeout(processWaitPanel, 5000)
				}
				
				waitCounter++
			}

			$(this).slideDown()
			
			//function in moveAds.js - only need be called if in the ads column
			if($(this).parent().attr('id') == 'content_secondary')
				updateAds()

		})
	})
}


$(document).ready(function(){
	rewaitTimeout = setTimeout(processWaitPanel, 5000)
})

/* generic function(s) and vars */

//tabbed box flags to prevent ads being moved before tabbed box height is set
var tabbedBoxPresent = false
var tabbedBoxCreated = false;

//this works like jquery offset. Returns the elements left and top values in pixels - cheers quirksmode.org
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
			} while (obj = obj.offsetParent);
		return [curleft,curtop];
	}
}