function flipper(obj, who) {
	if (document.getElementById(""+who+"").style.display == "none" ) { 
		document.getElementById(""+who+"").style.display = "block"; 
		obj.text = "close...";
	} else { 
		document.getElementById(""+who+"").style.display = "none";
		obj.text = "expand...";
		}
	}

function flipperEx( who) {
	if (document.getElementById(who).style.display == "none" ) { 
		document.getElementById(who).style.display = "block"; 
	} else { 
		document.getElementById(who).style.display = "none";
		}
	}

function expand_list(who) {
	if (document.getElementById(who).rows(52).style.display == "none") {
		for (var ii=51; ii<document.getElementById(who).rows.length; ii++) {
			document.getElementById(who).rows(ii).style.display = "block";
		}
		document.getElementById(who).rows(50).cells(0).innerHTML = "<B><font color=red>...less</font></B>";
	} else {
		for (var ii=51; ii<document.getElementById(who).rows.length; ii++) {
		document.getElementById(who).rows(ii).style.display = "none";
		}
		document.getElementById(who).rows(50).cells(0).innerHTML = "<B>more...</B>";
		}
	}

function ro(who) {
	if (who.style.backgroundColor == "#003399") who.style.backgroundColor = "#3366CC"; else who.style.backgroundColor = "#003399";
}

function ro2(who) {
	if (who.style.backgroundColor == "#f4f4f4") who.style.backgroundColor = "#ffffff"; else who.style.backgroundColor = "#f4f4f4";
}

function open_props() {
	var oProps = window.open("properties.php", "_prop", "height = 314, width = 300, scrollbars=0, toolbar=0");
	oProps.focus();
}

function open_location(postcode) {
	var o = window.open("location.php?pcode="+postcode, "_prop", "height = 600, width = 800, scrollbars=0, toolbar=0");
	o.focus();
}
function open_history(id) {
	var o = window.open("history.php?client_id="+id, "_prop", "height = 600, width = 800, scrollbars=1, toolbar=0");
	o.focus();
}

function open_props_suppliers() {
	var oProps = window.open("properties.php?suppliers=yes", "_prop", "height = 314, width = 300, scrollbars=0, toolbar=0");
	oProps.focus();
}

function open_clients() {
	var pid = document.getElementById("property_id").value;
	var oCli = window.open("clients.php?pid=" + pid, "_clients", "height = 314, width = 300, scrollbars=0, toolbar=0");
	oCli.focus();
}

function open_suppliers() {
	var oCli = window.open("clients.php?suppliers=yes", "_clients", "height = 314, width = 300, scrollbars=0, toolbar=0");
	oCli.focus();
}

function edit_property(who) {
	var wProps = window.open("edit_property.php?pid=" + who, "_prop_edit", "height = 380, width = 700, scrollbars=0, toolbar=0");
	wProps.focus();
}

function edit_client(who) {
	var wCli = window.open("edit_client.php?cid=" + who, "_client_edit", "height = 460, width = 700, scrollbars=0, toolbar=0");
	wCli.focus();
}

function win_open(who, height, width) {
	var win = window.open(who, "_win", "height = " + height + ", width = " + width + ", scrollbars=1, toolbar=0");
	win.focus();
}

function ff(obj, who) { if (document.getElementById(who).style.display == "" || document.getElementById(who).style.display == "block") { 	document.getElementById(who).style.display = "none"; } else { document.getElementById(who).style.display = "block"; }}

function logOff() {
	location.href="?shell=0";
	}

function undo_combos(who) {
	undo_combo_value = who.options.selectedIndex;
	}

function reconfirm(who) {
	var okay = true;
	if (!confirm("Please confirm the change of this setting?")) { okay = false; who.options[undo_combo_value].selected = true; }
	return okay;
	}

function Pager(how) {
	var position = null;
	
	if (how == 'next_client') {
	var a = document.frm.pos.options.length; var curr = -1;
	for (ii=0; ii<a; ii++) if (document.frm.pos.options[ii].selected) curr = ii;	
	
	if ((a - curr) > 1) { 
		location.href = '?op=3&a=2&pos=' + document.frm.pos.options[curr+1].value;
		} else {
		 alert("No more pages!");
		}
	}

	if (how == 'next_props') {
	var a = document.frm.pos.options.length; var curr = -1;
	for (ii=0; ii<a; ii++) if (document.frm.pos.options[ii].selected) curr = ii;	
	
	if ((a - curr) > 1) { 
		location.href = '?op=2&a=2&pos=' + document.frm.pos.options[curr+1].value;
	} else {
		 alert("No more pages!");
	}}
	
	if (how == 'next_certm') {
	var a = document.frm.pos.options.length; var curr = -1;
	for (ii=0; ii<a; ii++) if (document.frm.pos.options[ii].selected) curr = ii;	
	
	if ((a - curr) > 1) { 
		location.href = '?op=4&a=1&pos=' + document.frm.pos.options[curr+1].value;
	} else {
		 alert("No more pages!");
	}}
	
	if (how == 'next_certa') {
	var a = document.frm.pos.options.length; var curr = -1;
	for (ii=0; ii<a; ii++) if (document.frm.pos.options[ii].selected) curr = ii;	
	
	if ((a - curr) > 1) { 
		location.href = '?op=4&a=2&pos=' + document.frm.pos.options[curr+1].value;
	} else {
		 alert("No more pages!");
	}}

	if (how == 'next_jobs') {
	var a = document.frm.pos.options.length; var curr = -1;
	for (ii=0; ii<a; ii++) if (document.frm.pos.options[ii].selected) curr = ii;	
	
	if ((a - curr) > 1) { 
		location.href = '?op=4&a=4&pos=' + document.frm.pos.options[curr+1].value  + '&qt_month=' + document.frm.qt_month.options[document.frm.qt_month.options.selectedIndex].value + "&qt_search=" + document.frm.qt_search.value;
	} else {
		 alert("No more pages!");
	}}
	
	if (how == 'next_orders') {
	var a = document.frm.pos.options.length; var curr = -1;
	for (ii=0; ii<a; ii++) if (document.frm.pos.options[ii].selected) curr = ii;
	
	if ((a - curr) > 1) { 
		location.href = '?op=7&a=1&pos=' + document.frm.pos.options[curr+1].value  + '&qt_month=' + document.frm.qt_month.options[document.frm.qt_month.options.selectedIndex].value + "&qt_search=" + document.frm.qt_search.value;
	} else {
		 alert("No more pages!");
	}}
	
	if (how == 'next_quote') {
	var a = document.frm.pos.options.length; var curr = -1;
	for (ii=0; ii<a; ii++) if (document.frm.pos.options[ii].selected) curr = ii;	
	
	if ((a - curr) > 1) { 
		location.href = '?op=4&a=3&pos=' + document.frm.pos.options[curr+1].value + '&qt_month=' + document.frm.qt_month.options[document.frm.qt_month.options.selectedIndex].value + "&qt_search=" + document.frm.qt_search.value;
	} else {
		 alert("No more pages!");
	}}

	if (how == 'any_client') {
		 location.href = '?op=3&a=2&pos=' + document.frm.pos.options[document.frm.pos.options.selectedIndex].value;
	}
	if (how == 'any_props') {
		location.href = '?op=2&a=2&pos=' + document.frm.pos.options[document.frm.pos.options.selectedIndex].value;
	}
	if (how == 'any_certa') {
		location.href = '?op=4&a=2&pos=' + document.frm.pos.options[document.frm.pos.options.selectedIndex].value + "&ss=" + document.frm.ss.options[document.frm.ss.options.selectedIndex].value + '&sd_dd=' + document.frm.sd_dd.options[document.frm.sd_dd.options.selectedIndex].value + '&sd_mm=' + document.frm.sd_mm.options[document.frm.sd_mm.options.selectedIndex].value + '&sd_yy=' + document.frm.sd_yy.options[document.frm.sd_yy.options.selectedIndex].value + '&ed_dd=' + document.frm.ed_dd.options[document.frm.ed_dd.options.selectedIndex].value + '&ed_mm=' + document.frm.ed_dd.options[document.frm.ed_mm.options.selectedIndex].value + '&ed_yy=' + document.frm.ed_yy.options[document.frm.ed_yy.options.selectedIndex].value;
	}	
	if (how == 'any_certm') {
		location.href = '?op=4&a=1&pos=' + document.frm.pos.options[document.frm.pos.options.selectedIndex].value;
	}
	if (how == 'any_jobs') {
		location.href = '?op=4&a=4&pos=' + document.frm.pos.options[document.frm.pos.options.selectedIndex].value + '&qt_month=' + document.frm.qt_month.options[document.frm.qt_month.options.selectedIndex].value + "&qt_search=" + document.frm.qt_search.value;
	}
	if (how == 'any_orders') {
		location.href = '?op=7&a=1&pos=' + document.frm.pos.options[document.frm.pos.options.selectedIndex].value + '&qt_month=' + document.frm.qt_month.options[document.frm.qt_month.options.selectedIndex].value + "&qt_search=" + document.frm.qt_search.value;
	}
	if (how == 'any_products') {
		location.href = '?op=7&a=2&pos=' + document.frm.pos.options[document.frm.pos.options.selectedIndex].value + '&qt_suppl1=' + document.frm.qt_suppl1.options[document.frm.qt_suppl1.options.selectedIndex].value + "&qt_suppl2=" + document.frm.qt_suppl2.value + "&qt_search=" + document.frm.qt_search.value;
	}
	if (how == 'any_quote') {
		location.href = '?op=4&a=3&pos=' + document.frm.pos.options[document.frm.pos.options.selectedIndex].value  + '&qt_month=' + document.frm.qt_month.options[document.frm.qt_month.options.selectedIndex].value + "&qt_search=" + document.frm.qt_search.value;
	}}
	
function delete_product(who) {
	if (confirm("Are sure you want to delete this product?")) {location.href = "?op=7&a=2&pid=" + who + "&DELETE=yes"; }
	}

function delete_property(who) {
	if (confirm("Please confirm deletion of this property?")) {
		location.href="?DELETE=yes&pid=" + who;
		window.opener.location.reload(true);
		window.close();
	}
}

function delete_client(who) {
	if (confirm("Please confirm deletion of this client...")) {
		location.href="?DELETE=yes&cid=" + who;
		window.opener.location.reload(true);
		window.close();
	}
}

function print_all_certs(que) {
	var o = window.open("print_all_certs.php" + que, "_certs", "height = 600, width = 800, scrollbars=1, toolbar=0");
	o.focus();
}
function print_all_quots(que) {
	var o = window.open("print_all_quots.php" + que, "_certs", "height = 600, width = 800, scrollbars=1, toolbar=0");
	o.focus();
}
function print_all_jobs(que) {
	var o = window.open("print_all_jobs.php" + que, "_certs", "height = 600, width = 800, scrollbars=1, toolbar=0");
	o.focus();
}

function print_all_orders(que) {
	var o = window.open("print_all_orders.php" + que, "_orders", "height = 600, width = 800, scrollbars=1, toolbar=0");
	o.focus();
}

function getNPPage(combo, direction /* 1, -1*/) {
	cb = document.getElementById(combo);
	var page = cb.options[cb.selectedIndex].value;
	
	if(cb.selectedIndex == cb.options.length - 1 && direction == 1) return;
	if(cb.selectedIndex == 0 && direction == -1) return ;
	cb.selectedIndex = (page-1) + direction;
	
}

