// JavaScript Document

var screenshots = new Array();
screenshots['New Statement Available'] = '/customer-service/images/image-popup-new-statement.gif';
screenshots['Payment Posted'] = '/customer-service/images/image-popup-payment-posted.gif';
screenshots['Minimum Payment Not Received'] = '/customer-service/images/image-popup-min-not-rec.gif';
screenshots['Balance Transfer Posted'] = '/customer-service/images/image-popup-balance-transf.gif';
screenshots['Refund/Credit Posted'] = '/customer-service/images/image-popup-refund-credit.gif';
screenshots['Nearing Credit Limit'] = '/customer-service/images/image-popup-credit-limit.gif';
screenshots['Purchase Exceeds Set Amount'] = '/customer-service/images/image-popup-purchase-exceed.gif';
screenshots['Balance Exceeds Set Amount'] = '/customer-service/images/image-popup-balance-exceeds.gif';
screenshots['Discover Card E-mail Newsletters and Special Offers'] = '/customer-service/images/image-popup-special-offers.gif';

var description = new Array();
description['New Statement Available'] = 'Receive an e-mail when a new statement is available to view online in the Account Center.';
description['Payment Posted'] = 'Receive an e-mail when payments post to your Discover Card account.';
description['Minimum Payment Not Received'] = 'Receive an e-mail 6 to 7 days prior to your payment due date if your minimum payment due has not been received and you do not have any pending payments.';
description['Balance Transfer Posted'] = 'Receive an e-mail when each requested Balance Transfer posts to your Discover&reg; Card Account.';
description['Refund/Credit Posted'] = 'Receive an e-mail when a merchant credit or refund posts to your Discover&reg; Card Account.';
description['Nearing Credit Limit'] = 'Receive an e-mail when you are approaching your Discover&reg; Card account credit limit, based on a dollar amount that you select.';
description['Purchase Exceeds Set Amount'] = 'Receive an e-mail when any purchase charged to your account is equal to or larger than a dollar amount you specify.';
description['Balance Exceeds Set Amount'] = 'Receive an e-mail when your account balance reaches a specific dollar amount that you select.';
description['Discover Card E-mail Newsletters and Special Offers'] = 'Receive newsletters and special offers by e-mail.';

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

function reminderInit(){
	if(document.getElementById('reminders')){
		var reminder = document.getElementById('reminders');
		var r = reminder.getElementsByTagName('a');
		for(var i = 0; i < r.length; i++){
			r[i].onclick = displayReminder;
		}
	}
	if(document.getElementById('close-button')){
		document.getElementById('close-button').onclick = hideReminder;
	}
}

function displayReminder(){
	if(document.getElementById('reminder-popup')){
		updateReminder(this.innerHTML, this.numID);
		document.getElementById('reminder-popup').style.display = 'block';
		//document.getElementById('cover').style.display = 'block';
	}
	return false;
}
function hideReminder(){
	if(document.getElementById('reminder-popup')){
		document.getElementById('reminder-popup').style.display = 'none';
		//document.getElementById('cover').style.display = 'none';
	}
	return false;
}
function updateReminder(ttt){
	if(typeof arguments[0] == 'string'){
		var arg = arguments[0];
	}
	else{
		var arg = this.innerHTML;
	}
	if(document.getElementById('reminder-popup-title')){
		document.getElementById('reminder-popup-title').innerHTML = 'E-mail Reminder: ' + arg;
	}
	if(document.getElementById('reminder-popup-description')){
		document.getElementById('reminder-popup-description').innerHTML = description[arg];
	}
	if(document.getElementById('popup-menu')){
		var menu = document.getElementById('popup-menu');
		var m = menu.getElementsByTagName('li');
		for(var i = 0; i < m.length; i++){
			if(m[i].firstChild.nodeName == 'A'){
				temp = m[i].firstChild.innerHTML.toString().trim();
			}
			else{
				temp = m[i].innerHTML.toString().trim();
			}
			if(temp == arg){
				m[i].innerHTML = temp;
			}
			else{
				m[i].innerHTML = '<a href="#">' + temp + '</a>';
				m[i].firstChild.onclick = updateReminder;
			}
		}
	}
	if(document.getElementById('screenshot')){
		document.getElementById('screenshot').src = screenshots[arg];
	}
	return false;
}

addLoadEvent(reminderInit);