// EMAIL Reminder Functions
//------------------------------------------------------------------
var hasEmailPopup = false;
// Change Email reminder
function ChangeEmailReminderClick(e)
{
var emailMeAReminderLink = document.getElementById("EmailMeAReminder")
var mouseX, mouseY;
// Try and get the event object
if (!e) e = window.event;
// Horrible code to calculate the events location within the document
if ( e.pageX )
{
//Mozilla
mouseX = e.pageX;
mouseY = e.pageY;
}
else if( e.clientX )
{
mouseX = e.clientX;
mouseY = e.clientY;
if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
//IE 4, 5 & 6 (in non-standards compliant mode)
mouseX += document.body.scrollLeft;
mouseY += document.body.scrollTop;
} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
//IE 6 (in standards compliant mode)
mouseX += document.documentElement.scrollLeft;
mouseY += document.documentElement.scrollTop;
}
}
//Make sure the popup isn't of the bottom
if( mouseY + 105 > document.documentElement.scrollTop + document.documentElement.clientHeight && document.documentElement.clientHeight > 0 )
mouseY = document.documentElement.scrollTop + document.documentElement.clientHeight - 115;
// Make sure the popup isn't of the top
if( mouseY - 105 < document.documentElement.scrollTop && document.documentElement.scrollTop > 0 )
mouseY = document.documentElement.scrollTop + 105;
// Display the Email reminder popup
emailMeAReminderLink.style.display = "block";
emailMeAReminderLink.style.left = "" + (mouseX - 100) + "px";
emailMeAReminderLink.style.top = "" + (mouseY - 100) + "px";
hasEmailPopup = true;
// Return false to prevent anchor executing
return false;
}
// Hide the Email reminder popup
function ChangeEmailReminderBlur()
{
// If the popup is being displayed, remove it
if ( hasEmailPopup )
document.getElementById("EmailMeAReminder").style.display = "none";
ResetEmailPopupForm();
hasEmailPopup = false;
// Return false to prevent anchor executing
return false;
}
// Submit button click
function EmailMeAReminderFormSubmit(e)
{
// The radios within the form
var items = document.getElementsByName('EmailTime');
// Find the currently selected one
for( var i = 0; i < items.length; i++ ) {
if(items[i].checked)
emailReminder = items[i].value;
}
// Set the text under the button
SetEmailReminderText(emailReminder);
// Check if we're saving the default
isDefaultEmailSaved = document.getElementById("SaveEmailTime").checked;
// Call the AJAX
var returnValue = SaveToWatchlist();
// Blur the popup
ChangeEmailReminderBlur();
return returnValue;
}
// Changes the text update the SaveToWatchlist link
function SetEmailReminderText ( period )
{
if(period == 0)
document.getElementById('EmailReminderTimePeriod').innerHTML = 'No email reminder';
else if(period == 1)
document.getElementById('EmailReminderTimePeriod').innerHTML = 'Email me 1 hr before closing';
else
document.getElementById('EmailReminderTimePeriod').innerHTML = 'Email me ' + period + ' hrs before closing';
}
function ResetEmailPopupForm()
{
// Uncheck the save checkbox
document.getElementById("SaveEmailTime").checked = isDefaultEmailSaved;
// The radios within the form
var items = document.getElementsByName('EmailTime');
// Select the current saved value
for( var i = 0; i < items.length; i++ ) {
if(items[i].value == emailReminder)
items[i].checked = true;
}
}