function hide(obj_id) {
	var obj = document.getElementById(obj_id);
	if (obj) hide_obj(obj); 
}
function hide_obj(obj) {
	obj.style.display='none';
	obj.style.visibility='hidden';
}
function show(obj_id) {
	var obj = document.getElementById(obj_id);
	if (obj) show_obj(obj); 
}
function show_obj(obj) {
	obj.style.display='inline';
	obj.style.visibility='visible';
}
function toggle_hideshow(obj_id) {
	var obj = document.getElementById(obj_id);
	if (obj) {
		if (obj.style.display == 'none' && obj.style.visibility == 'hidden') {
			show_obj(obj);
		} else if (obj.style.display == 'inline' && obj.style.visibility == 'visible') {
			hide_obj(obj);
		}
	}	
}

function toggle_hideshow2(link_obj, obj_id) {
	toggle_text_hideshow(link_obj, '&curren;', '&ndash;', obj_id);
}
function toggle_details() {
	toggle_text_hideshow(document.getElementById('details_link'), 
						 'Hide Details &laquo;',
						 'Show Details &raquo;',
						 'details');
}
function toggle_comments() {
	comments_obj = document.getElementById('comments_link');
	if (comments_obj) {
		if (comments_obj.innerHTML.match("View") || comments_obj.innerHTML.match("Hide")) {
			if (comments_obj.innerHTML.match("View")) {
				view_txt = comments_obj.innerHTML;
				hide_txt = comments_obj.innerHTML.replace('View','Hide');
			} else {
				hide_txt = comments_obj.innerHTML;
				view_txt = comments_obj.innerHTML.replace('Hide','View');
			}
			toggle_text_hideshow(comments_obj, hide_txt, view_txt, 'comments');
		} else {
			toggle_hideshow('comments');
		}
	} else {
		toggle_hideshow('comments');
	}
}

function toggle_text_hideshow(link_obj, link_on_text, link_off_text, obj_id) {
	/* toggle_hideshow2() is only used by the collapse/expand toggle buttons */
	var obj = document.getElementById(obj_id);
	if (obj) {
		if (obj.style.display == 'none' && obj.style.visibility == 'hidden') {
			show_obj(obj);
			link_obj.innerHTML = link_on_text;
			setCookie(obj_id, '1', 365);
		} else if (obj.style.display == 'inline' && obj.style.visibility == 'visible') {
			hide_obj(obj);
			link_obj.innerHTML = link_off_text;
			setCookie(obj_id, '0', 365);
		}
	}	
}
 function checkEnter(e, frm) {
 	/* This function is useful if you are hiding/showing a form in IE, because if you 
	 * do that in IE, you can't just hit <enter> and have the form submit. So, in 
	 * those cases, if you are hiding/showing a form, you have to use this function
	 * to check to see if the user pressed <enter>.
	 */
	var characterCode;
 	if (navigator.appName != "Microsoft Internet Explorer") return true; 

	if (e && e.which) {
		e = e;
		characterCode = e.which;
	} else {
		e = event;
		characterCode = e.keyCode
	}
	if (characterCode == 13) {
		if (frm) frm.submit();	// submit the form and return false so that the key isn't included
		return false;
	} else {
		return true;
	}
	return false; // not reached..
 }

/* the following functions are for the listings pages */
function hide_tab(obj_id) {
	var obj = document.getElementById(obj_id);
	if (obj) {
		var tab_obj = document.getElementById(obj_id + '0');
		if (tab_obj) {
			tab_obj.style.backgroundColor = '#E2E2E2';
			tab_obj.style.border = '0px solid #DDD';
			tab_obj.style.borderBottom = '1px solid #777';
		}
		hide_obj(obj);
	}
}
function show_tab(obj_id) {
	var obj = document.getElementById(obj_id);
	if (obj) {
		var tab_obj = document.getElementById(obj_id + '0');
		if (tab_obj) {
			tab_obj.style.backgroundColor = '#FFF';
			tab_obj.style.border = '1px solid #000';
			tab_obj.style.borderBottom = '1px solid #FFF';
		}
		show_obj(obj);
	}
}
function details_tab_clicked() {
	show_tab('details_tab');
	hide_tab('comments_tab');
	hide_tab('contact_tab');
	hide_tab('similar_tab');
}
function comments_tab_clicked() {
	hide_tab('details_tab');
	show_tab('comments_tab');
	hide_tab('contact_tab');
	hide_tab('similar_tab');
}
function contact_tab_clicked() {
	hide_tab('details_tab');
	hide_tab('comments_tab');
	show_tab('contact_tab');
	hide_tab('similar_tab');
}

function similar_tab_clicked() {
	hide_tab('details_tab');
	hide_tab('comments_tab');
	hide_tab('contact_tab');
	show_tab('similar_tab');
}

/* these functions are used on the allforsale.html page */
function url_tab_clicked() {
	show_tab('url_tab');
	hide_tab('datafeed_tab');
}
function datafeed_tab_clicked() {
	hide_tab('url_tab');
	show_tab('datafeed_tab');
}
