function search_pop(action_page, value)
{
	var url = "/scripts/pop_search.php";
	var params = "get_search=true&action_page=" + url_encode(action_page) + "&value=" + value;
	ajax_call(params, url, 'post', 'pop_callback', '', '', 'search');
}


function close_pop_div()
{
	if (document.getElementById('pop_div'))
	{
		document.getElementById('pop_div').style.display = 'none';
	}
	if (document.getElementById('pop_iframe'))
	{
		document.getElementById('pop_iframe').style.display = 'none';
	}
}

function sort_pop(action_page, oby, sby, h_var, additional_sorts)
{
	var url = "/scripts/pop_sort.php";
	var params = "get_sort=true&action_page=" + url_encode(action_page) + "&sby=" + sby + "&oby=" + oby + "&h_var=" + h_var + "&sorts=" + additional_sorts;
	ajax_call(params, url, 'post', 'pop_callback', '', '', 'sort');
}

function sort_pop_wiki(action_page, oby, sby, h_var, additional_sorts)
{
	var url = "/scripts/pop_sort_wiki.php";
	var params = "get_sort=true&action_page=" + url_encode(action_page) + "&sby=" + sby + "&oby=" + oby + "&h_var=" + h_var + "&sorts=" + additional_sorts;
	ajax_call(params, url, 'post', 'pop_callback', '', '', 'sort');
}


function pop_callback(req, type)
{
	var response = req.responseXML.documentElement;
	var html_return = response.getElementsByTagName('html_return')[0].firstChild.data;

	var scroll_top = get_scroll_top();

	var height =0;
	var width =0;

	if (navigator.appName=="Netscape")
	{
		height = window.innerHeight;
		width = window.innerWidth;
	}
	else if( document.documentElement &&( document.documentElement.clientWidth || document.documentElement.clientHeight ))
	{
		height = document.documentElement.clientHeight;
		width = document.documentElement.clientWidth;
  	}
  	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
  	{
		height = document.body.clientHeight;
		width = document.body.clientWidth;
	}

	if (!document.getElementById('pop_div'))
	{
		var pop_div = document.createElement("div");
		document.getElementById('page_content').appendChild(pop_div);

		pop_div.id = "pop_div";
		pop_div.style.position = 'absolute';
		pop_div.style.width = '380px';
		pop_div.style.top = '215px';
		pop_div.style.left = '370px';
		pop_div.style.zIndex = '51';

		// Create the iframe that is used to cover select boxes due to bug in IE6
		var pop_iframe = document.createElement("iframe");
		pop_iframe.id = "pop_iframe";
		pop_iframe.style.position = 'absolute';
		pop_iframe.style.border = 'none';
		pop_iframe.style.zIndex = (pop_div.style.zIndex-1)+'';
		pop_iframe.style.filter = 'alpha(opacity=0)';
		// Setting a small width and height prevents an odd effect created from first showing the iframe with a default size and shrinking it
		pop_iframe.style.width = '1px';
		pop_iframe.style.height = '1px';
		pop_iframe.style.top = pop_div.style.top;
		pop_iframe.style.left = pop_div.style.left;
		// Required IE6 over https - Setting a src is required to prevent IE6 from displaying an error saying that you have insecure items on your secure page
		pop_iframe.src = 'javascript:false;';

		// We never attach the iframe to the page unless it needs it. IE6 is the only browser that has the bug. Other code will continue to modify the iframe element but it will never be attached.
		if (ie_version() === 6)
		{
			document.getElementById('page_content').appendChild(pop_iframe);
		}
	}
	else
	{
		var pop_div = document.getElementById('pop_div');
		pop_div.style.display = '';

		if (ie_version() === 6)
		{
			var pop_iframe = document.getElementById('pop_iframe');
			pop_iframe.style.display = '';
		}
	}

	pop_div.innerHTML = html_return;

	if (ie_version === 6)
	{
		// Make sure the iframe has the same deminsions as the content of the popup
		pop_iframe.style.width = pop_div.offsetWidth+'px';
		pop_iframe.style.height = pop_div.offsetHeight+'px';
	}


	if (type == 'search')
	{
		// set focus to the search box
		document.getElementById('pop_search_k').focus();
	}
}