/**
 * Big Brother overlay menus
 *
 * Based on SimpleModal
 * Copyright (c) 2009 Eric Martin - http://ericmmartin.com
 *
 * Revision: $Id: simplemodal.js 185 2009-02-09 21:51:12Z emartin24 $
 *
 */

/* SMM CAN'T GET THIS WORKING
http://www.webmasterworld.com/javascript/3752159.htm
*/

function ShowDIV(d) { 
	/* IE6 IS UNSUPPORTED... SO NEVER SHOW THE MENU */
	isIE6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;
	if (! isIE6) {
		document.getElementById(d).style.display = "block"; 
	}
}

function HideDIV(d) { 
	var IE = document.all?true:false;
	if (!IE) {
	/*
		alert("Not IE");
	*/
		document.getElementById(d).style.display = "none";
		return false;
	}
	if (HideDIV.flag != 1 ) {
		HideDIV.flag=1;
		document.getElementById(d).style.display = "none";
	}
	var posx = 0;
	var posy = 0;

	var e = window.event;
	posx = e.clientX + document.body.scrollLeft;
	posy = e.clientY + document.body.scrollTop;

	/* alert(posx + "," + posy);  */


	if ((posx > 50) || (posy > 140)){
		/* alert("hide");  */
		document.getElementById(d).style.display = "none";
		return false;
	}
}


$(document).ready(function () {
	$('a#ack').click(function (e) {
		e.preventDefault();
		$.modal("<div class='ack'> \
<FORM ACTION='/cgi-bin/bb-ack.sh'><INPUT TYPE='HIDDEN' NAME='ACTION' VALUE='Ack'><CENTER><H2>to acknowledge getting paged</H2>Don't page me again about this problem again for <INPUT TYPE=TEXT NAME='DELAY' VALUE='60' SIZE=4 MAXLENGTH=4> minutes<BR><BR><B>Fix status: </B><INPUT TYPE=TEXT NAME='MESSAGE' SIZE=20 MAXLENGTH=80><BR><BR> <I><B>Enter Security Code from paging message:</I></B> <INPUT TYPE=TEXT NAME='NUMBER' SIZE=7 MAXLENGTH=7><BR><BR><INPUT TYPE='SUBMIT' NAME='SUB' class='btn2' VALUE='send ack' ALT='I'm working on it' BORDER=0 METHOD='GET'><INPUT NAME='DISP' TYPE='HIDDEN' VALUE=" + disp +"></CENTER></FORM></div>", {onOpen: modalOpen});
	});
	$('a#page').click(function (e) {
		e.preventDefault();
		$.modal("<div class='page'> \
<CENTER><H2>page the admin</H2><FORM ACTION='/cgi-bin/bb-ack.sh'><INPUT TYPE='HIDDEN' NAME='ACTION' VALUE='Page'>Message:<INPUT TYPE=TEXT NAME='MESSAGE' SIZE=25 MAXLENGTH=80><BR><BR><INPUT TYPE='SUBMIT' class='btn2' NAME='SUB' VALUE='send page' ALT='Page the admin' BORDER=0 METHOD='GET'><INPUT NAME='DISP' TYPE='HIDDEN' VALUE=" + disp + "></CENTER></FORM></div>", {onOpen: modalOpen});
        });
	$('a#data').click(function (e) {
		e.preventDefault();
		$.modal("<div class='data'> \
<CENTER><H2>manage data</H2><FORM ACTION='/cgi-bin/bb-show.sh' METHOD='POST'> <CENTER><input type='radio' name='TASKPAGE' value='bb-removehostdata.html' checked> Remove host data<BR><BR> <B>Data Management authorization code: </B> <INPUT TYPE=PASSWORD NAME=datamanagecode SIZE=25 MAXLENGTH=25><BR><BR><INPUT TYPE='SUBMIT' NAME='SUB' class='btn2' VALUE='Perform task' ALT='Perform task' BORDER=0> <INPUT NAME='DISP' TYPE='HIDDEN' VALUE=" + disp + "><INPUT NAME='PAGE' TYPE='HIDDEN' VALUE='managedata'> </CENTER> </FORM></CENTER></div>", {onOpen: modalOpen});
        });
});

/**
 * When the open event is called, this function will be used to 'open'
 * the overlay, container and data portions of the modal dialog.
 *
 * onOpen callbacks need to handle 'opening' the overlay, container
 * and data.
 */
function modalOpen (dialog) {
	dialog.overlay.fadeIn('slow', function () {
		dialog.container.fadeIn('slow', function () {
			dialog.data.slideDown('slow');
		});
	});
}

/**
 * When the close event is called, this function will be used to 'close'
 * the overlay, container and data portions of the modal dialog.
 *
 * The SimpleModal close function will still perform some actions that
 * don't need to be handled here.
 *
 * onClose callbacks need to handle 'closing' the overlay, container
 * data and iframe.
 */
function modalClose (dialog) {
	dialog.data.fadeOut('slow', function () {
		dialog.container.hide('slow', function () {
			dialog.overlay.slideUp('slow', function () {
				$.modal.close();
			});
		});
	});
}

/**
 * After the dialog is show, this callback will bind some effects
 * to the data when the 'button' button is clicked.
 *
 * This callback is completely user based; SimpleModal does not have
 * a matching function.
function modalShow (dialog) {
	dialog.data.find('input.animate').one('click', function () {
		dialog.data.slideUp('slow', function () {
			dialog.data.slideDown('slow');
		});
	});
}
 */
