// TEXT Reminder Functions
//------------------------------------------------------------------
var hasTextPopup = false;
// Change Text reminder
function ChangeTextReminderClick(e)
{
var textMeAReminderLink = document.getElementById("TextMeAReminder")
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 Text reminder popup
textMeAReminderLink.style.display = "block";
textMeAReminderLink.style.left = "" + (mouseX - 100) + "px";
textMeAReminderLink.style.top = "" + (mouseY - 100) + "px";
hasTextPopup = true;
// Return false to prevent anchor executing
return false;
}
// Hide the Text reminder popup
function ChangeTextReminderBlur()
{
// If the popup is being displayed, remove it
if ( hasTextPopup )
document.getElementById("TextMeAReminder").style.display = "none";
ResetTextPopupForm();
hasTextPopup = false;
// Return false to prevent anchor executing
return false;
}
// Submit button click
function TextMeAReminderFormSubmit(e)
{
// The radios within the form
var items = document.getElementsByName('TextTime');
// Find the currently selected one
for( var i = 0; i < items.length; i++ ) {
if(items[i].checked)
textReminder = items[i].value;
}
// Set the text under the button
SetTextReminderText(textReminder);
// Check if we're saving the default
isDefaultTextSaved = document.getElementById("SaveTextTime").checked;
// Call the AJAX
var returnValue = SaveToWatchlist();
// Blur the popup
ChangeTextReminderBlur();
return returnValue;
}
// Changes the text update the SaveToWatchlist link
function SetTextReminderText ( period )
{
if(period == 0)
document.getElementById('TextReminderTimePeriod').innerHTML = 'No text reminder';
else if(period == 30)
document.getElementById('TextReminderTimePeriod').innerHTML = 'Text me 30 mins before closing';
else if(period == 60)
document.getElementById('TextReminderTimePeriod').innerHTML = 'Text me 1 hr before closing';
}
function ResetTextPopupForm()
{
// Uncheck the save checkbox
document.getElementById("SaveTextTime").checked = isDefaultTextSaved;
// The radios within the form
var items = document.getElementsByName('TextTime');
// Select the current saved value
for( var i = 0; i < items.length; i++ ) {
if(items[i].value == textReminder)
items[i].checked = true;
}
}