function popup(popURL, popW, popH) {
	window.open(popURL, 'popup', 'width=' + popW + ', height=' + popH + ', toolbar=no');
}

function colljump(sel) {
	location.href = sel.options[sel.selectedIndex].value;
}

function popset(targeturl) {
	window.open(targeturl, 'popset', 'width=640, height=350, toolbar=no');
	return false;
}

function popjudge(targeturl) {
	window.open(targeturl, 'judgeview', 'toolbar=no, resizable=yes');
}

function showhide(targetElement) {
	var layermode = document.getElementById(targetElement).style;
	layermode.display = (layermode.display == 'none') ? "block" : "none";
}

function toggletext(targetElement,newText,oldText) {
	targetElement.innerHTML = (targetElement.innerHTML == oldText) ? newText : oldText;
}

function confirmjump(targeturl) {
	if (confirm('Are you sure?')) {
		location.href = targeturl;
	}
	//follow with return false in onclick
}

// Remove all empty params from query string on submission
function simplifySubmit() {
    var qs = $(this).serialize();
    qs = qs.replace(/(^|&)[^&=]+=(?=&|$)/g, '');
    if (qs) qs = '?' + qs;
    location.href = this.action + qs;
    return false;
}

$( function () {

    $('form.listingsearch').submit(simplifySubmit);

} );
