function adjust_limit(ptr) {
	v = ptr.options[ptr.options.selectedIndex].value;
	l = location.href;
	if(l.indexOf('limit') > -1)
		l = l.replace(/limit\=[0-9]+/g,'limit=' + v);
	else
		l = l + '&limit=' + v;
	window.location = l;
}
function big_button_search() {
	document.forms[cur_search + '_search'].submit();
}

cur_search = false;
function search_swap(ptr, t) {
	// search boxes
	p = document.getElementById('s' + t);
	c = document.getElementById('s' + cur_search);

	// search buttons
	a = document.getElementById('b' + cur_search);
	b = ptr;
	
	a.className = '';
	b.className = 'highlight';

	if(cur_search)
		c.style.display = 'none';
	cur_search = t;
	p.style.display = '';
}

cur_saved = false;
function saved_swap(ptr, t) {
	// search boxes
	p = document.getElementById('g' + t);
	c = document.getElementById('g' + cur_saved);

	// search buttons
	a = document.getElementById('h' + cur_saved);
	b = ptr;
	
	a.className = '';
	b.className = 'highlight';

	if(cur_saved)
		c.style.display = 'none';
	cur_saved = t;
	p.style.display = '';
}

function toggle_display(id) {
	o = document.getElementById(id);
	if(o.style.display == '')
		o.style.display = 'none';
	else
		o.style.display = '';
}

function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

function show_home_ajax() {
	if (http.readyState == 4) {
		response = http.responseText;
		document.getElementById('home_information').innerHTML 	= response;	
		document.forms['request_information_form'].mlsn.value 	= show_home_mlsn;
	}
}

show_home_mlsn = false;
function get_home_ajax(mlsn, search_type, id, anch) {
	if(document.getElementById(id).style.display == 'none')
		show_box(id, anch); 
	
	show_home_mlsn = mlsn;
	http.open('get', 'index.php?action=list&type=' + search_type + '&ajax_information=' + mlsn + '&junk=' + (new Date()).valueOf());
	http.onreadystatechange = show_home_ajax; 		
	http.send(null);	
}

function show_box(box, anch) {
	toggle_display(box);
	a = document.getElementById(anch);
	p = find_pos(a)
	
	ADD_DHTML(box);
	dd.elements[box].setZ(999);
	
	dd.elements[box].moveTo(p[0] + 10, p[1] + 10);
}

function set_position(obj, x, y) {
	obj.style.left 	= x + 'px';
	obj.style.top 	= y + 'px';
}

function find_pos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop 	= obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop 	+= obj.offsetTop
		}
	}

	return [curleft,curtop];
}

function clear_forms(ptr) {
	forms = document.forms;
	
	for(x = 0; x < forms.length; x++) {
		els = forms[x].elements;
		for(z = 0; z < els.length; z++) {
			e = els[z].type;
			
			if(e == "text")
				els[z].value = '';
			if(e == "select-one" && ptr.name != els[z].name)
				els[z].selectedIndex = 0;
		}
	}
}

function navigateFrame(url) {
  var w = document.getElementById("header_ifr")
  w.contentWindow.location.replace(url)
}


