// Administrative JavaScript Functions
var scrWidth  = self.screen.availWidth;
var scrHeight = self.screen.availHeight;
var winEdit, winNudge;
var currentObj, currentTblName = "";

function if_new_lot( map_id, lot_id, lot_x, lot_y, flag ) {
	if ( lot_id == 0 && flag == 1 ) {
		var scrTop = (scrHeight / 2) - 200;
		var scrLeft = (scrWidth / 2) - 250;
		document.location.href = "details.php?mid=" + map_id + "&lid=" + lot_id + "&lx=" + lot_x + "&ly=" + lot_y;
	}
}
function index_onload() {
	for ( x = 0; x < document.forms[0].elements.length; x++ ) {
		if ( document.forms[0].elements[x].type != "hidden" ) {
			document.forms[0].elements[x].focus();
			break;
		}
	}
}
function edit_lot( map_id, lot_id, lot_x, lot_y ) {
	var scrTop  = ( scrHeight / 2 ) - 240;
	var scrLeft = ( scrWidth / 2 )  - 370;
	document.location.href = "details.php?mid=" + map_id + "&lid=" + lot_id + "&lx=" + lot_x + "&ly=" + lot_y;
}

function nudge_lot( map_id, lot_id, lot_x, lot_y ) {
	var scrTop  = ( scrHeight / 2 ) - 100;
	var scrLeft = ( scrWidth / 2 )  - 100;
	winNudge = open( "nudgelot.php?mid=" + map_id + "&lid=" + lot_id + "&lx=" + lot_x + "&ly=" + lot_y, "nudgeWindow", "status=no,width=200,height=260,top=" + scrTop + ",left=" + scrLeft);
	winNudge.focus();
}

function map_settings( map_id ) {
	var scrTop  = ( scrHeight / 2 ) - 240;
	var scrLeft = ( scrWidth / 2 )  - 370;
	document.location.href = "mapsettings.php?mid=" + map_id, "editWindow";
}

function edit_builders( org_id ) {
	var scrTop  = ( scrHeight / 2 ) - 300;
	var scrLeft = ( scrWidth  / 2 ) - 370;
	document.location.href = "builder_edit.php?org_id=" + org_id;
}
function edit_contacts( org_id, mid ) {
	document.location.href = "contact_edit.php?org_id=" + org_id + "&mid=" + mid;
}

function edit_image( lot_id, map_id ) {
	var scrTop 	= ( scrHeight / 2 ) - 240;
	var scrLeft = ( scrWidth  / 2 ) - 370;
	document.location.href = "image_edit.php?lid=" + lot_id + "&mid=" + map_id;
}

function amenity_image( lot_id ) {
	document.location.href = "amenity_image.php?lid=" + lot_id;
}


function show_map( map_id ) {
	var scrTop  = ( scrHeight / 2 ) - 200;
	var scrLeft = ( scrWidth / 2 )  - 250;
	document.location.href = "showmap.php?mid=" + map_id;
}

function edit_status( org_id ) {
	var scrTop 	= ( scrHeight / 2 ) - 240;
	var scrLeft = ( scrWidth  / 2 ) - 370;
	document.location.href = "status_edit.php?org_id=" + org_id;
}

function map_settings_submit() {
	if ( document.mapsettings.button.value == "Close" ) {
		winObj.close();
		return false;
	} else {
		return true;
	}
}
function close_me() {
	opener.location.reload(1);
	self.close();
}
function set_color( pcolor ) {
	currentObj.value = pcolor;
	if ( document.getElementById ) {
		obj = document.getElementById( currentTblName );
		if ( obj ) {
			obj.style.backgroundColor = pcolor;
		}
	}
}
function view_home_details( lot_id ) {
	var scrTop  = ( scrHeight / 2 ) - 250;
	var scrLeft = ( scrWidth  / 2 ) - 420;
	lotView = open( "lotview.php?lot_id=" + lot_id, "lotView", "width=740,height=480,scrollbars=yes,status=yes,resizable=yes,top=" + scrTop + ",left=" + scrLeft );
}
function view_lot_details( lot_id ) {
	var scrTop  = ( scrHeight / 2 ) - 250;
	var scrLeft = ( scrWidth  / 2 ) - 420;
	lotView = open( "lotviewlot.php?lot_id=" + lot_id, "lotView", "width=740,height=480,scrollbars=yes,status=yes,resizable=yes,top=" + scrTop + ",left=" + scrLeft );
}
function openCP( frmObj, tblName ) {
	currentObj = frmObj;
	currentTblName = tblName;
	pick = window.open( "cp/picker.php?clr=" + escape(frmObj.value), "Picker", "width=395,height=365,scrollbars=no,location=no,left=10,top=10,menubar=no,resizable=no,toolbar=no,status=no");
	pick.focus();
}
function ss() {
	self.status = "";
	if ( ss.arguments.length > 0 )
		self.status = ss.arguments[0];
	return true;
}

