/*

Begin: Page specific code for self-service 

*/

if(location.href.indexOf("/loanStatus.htm") > 0 || location.href.indexOf("FPO_Templates") > 0) {
	Channel_Om = "SalesFulfillment";
}
// set vars different for e-disclosure in enrollment, versus in self-service
if(location.href.indexOf("#tab=myProfile") < 1 && Title_Om=='PrivacyEDReview') {
	Channel_Om = "Enroll";
	SubSection_Om = "RegisterCustomer";
	Title_Om = "eSign";
}

if (jQuery('.phone-leads').length > 0) {
	SubSection_Om = "RegisterCustomer";
	if (Customer_Type.indexOf(":") > 0) {
		Customer_Type = Customer_Type.substring(0,Customer_Type.indexOf(":"));
	}
	else {
		Customer_Type = Customer_Type;
	}
}

// set var for Consumer MFA page.
if (jQuery("#question-one").length > 0 && Customer_Type=="Prospect") {
	Title_Om = "SetupProfileSQSA";
}
	
var smartwatchCount;
var ProcessFlow_Om;
var UpdatedInfo_Om;
var updatedSubSection_Om;
var LockType_Om;
//initssOmniturePageLoad(): called on load by omniture_setup.js
function initssOmniturePageLoad() { 
	events = [];
	smartwatchCount = jQuery(".smartwatch").length;
	pageName_Om = "GMACM:" + varNamed('Channel_Om') + ":" + varNamed('SubSection_Om') + ":" + varNamed('Title_Om');
	ProcessFlow_Om = "GMACM:" + varNamed('Channel_Om') + ":" + varNamed('SubSection_Om') + ":" + varNamed('Title_Om') + ":" + varNamed('Customer_Type');
	
	// enrollment: confirmation page
	if (jQuery('.phone-leads.enroll-confirm').length > 0) {
		s.linkTrackEvents='event40';
		s.linkTrackVars = 'eVar1';
		s.eVar1=varNamed('Web_User_Id');
		events.push('event40');
	}
	
	if (jQuery('.payoff-estimate').length > 0) {
		s.linkTrackEvents='event36';
		events.push('event36');	
	}
	
	if (jQuery('h3:contains("Smartwatch")').length > 0) {
		s.linkTrackEvents='event39';
		events.push('event39');	
	}
	
	// sales fulfillment link(s) present.
	if (jQuery(".dash-buy").length > 0) {
		jQuery(".overview form").each(function(){
			if (jQuery(this).attr("action") == "/loanStatus.htm") {
				s.linkTrackEvents='event52'+Web_User_Id;
				events.push('event52:'+Web_User_Id);
			}
		})
	}
	
	if (Title_Om == 'Splash') {
		var loanNumbers;
		jQuery("input").each(function(){
			if (jQuery(this).attr("name")=="loanNumber" && jQuery(this).attr("value")!="") {
					if (jQuery(this).val() != "") {
						if (typeof(loanNumbers)=="undefined") {
							loanNumbers = jQuery(this).val();
						}
						else {
							loanNumbers = loanNumbers + "," + jQuery(this).val();
						}
					}
			}
		})
		s.linkTrackEvents='event44';
		events.push('event44:' + loanNumbers);	
		s.linkTrackVars = 'eVar53';
		s.eVar53=pageName_Om;
	}
	
	// set var and event for any fulfillment page, except Splash page (where there are multiple loans
	if (jQuery(".fulfillment").length > 0 && typeof(loanNumber)!="undefined" && Title_Om != 'Splash') {
		s.linkTrackEvents='event44:'+ loanNumber;
		s.linkTrackVars = 'eVar53';
		s.eVar53=pageName_Om;
		events.push('event44:'+ loanNumber);
	}
	
	// fulfillment - final approval
	if (Title_Om == 'FinalApproval') {
		s.events='event44:' + loanNumber + ', event47:' + loanNumber;
		s.eVar53=pageName_Om;
		events.push('event47:'+ loanNumber);
	}
	
	//fulfillment - denied
	if (Title_Om == 'Declined') {
		s.events='event44:' + loanNumber + ', event48:' + loanNumber;
		s.eVar53=pageName_Om;
		events.push('event48:'+ loanNumber);
	}
	
	//fulfillment - closing
	if (Title_Om == 'Closing') {
		s.events='event44:' + loanNumber;
		s.eVar53=pageName_Om;
		//events.push('event44:'+ loanNumber);
	}

	if (jQuery("#showPwdLock").length > 0  && jQuery("#unlockBlock").length < 1) {
		LockType_Om = "Account Locked | Password Lock";
		s.linkTrackEvents='event50';
		events.push('event50');	
	}
	
	if (jQuery("#mfaUnlockDivId").length > 0) {
		LockType_Om = "Account Locked | Challenge Questions Lock";
		s.linkTrackEvents='event50';
		events.push('event50');	
	}
	
	if (jQuery("h2:contains('You don\'t currently have any GMAC Mortgage loans.')").length > 0) {
		s.linkTrackVars = 'eVar1';
		s.eVar1=Web_User_Id;
	}
	
	// If the user hasn't viewed the dashboard yet this browser session, record their log in, in a cookie.
	if (jQuery.cookie('viewedDash')=='' || jQuery.cookie('viewedDash')=='undefined' || jQuery.cookie('viewedDash')==null) {
		// to do: verify this works
		if (location.href.indexOf("accounts/index.htm") > -1) {
			s.linkTrackEvents='event1';
			events.push('event1');	
			jQuery.cookie('viewedDash', 'true');
		}
	}
	
	if (jQuery(".swtabactive").length > 0) {
		// only set event41 if it hasn't been set before
		if (jQuery.cookie('smartWatchLoanEvent')=='' || jQuery.cookie('smartWatchLoanEvent')=='undefined' || jQuery.cookie('smartWatchLoanEvent')==null) {
			
			s.linkTrackEvents="event41";
			events.push("event41:"+jQuery("input[name=loanNumber]").val());
			jQuery.cookie('smartWatchLoanEvent', jQuery("input[name=loanNumber]").val());
		}
	}
	
	// special case for in-process loan page (to handle multi-part document upload):
	if (jQuery(".details h3:contains('currently in process')").length > 0) {
		Channel_Om = 'MyAccounts';
		SubSection_Om = 'LoanStatus';
		Title_Om = 'UploadDocuments';
		s.pageName = "GMACM:MyAccounts:LoanStatus:UploadDocuments";
		ProcessFlow_Om = "GMACM:MyAccounts:LoanStatus:UploadDocuments:Customer:logged in";
	}
	
	Events_Om = events.join(',');
}

var initialPersonalInfo = new Array();
var updatedPersonalInfo = new Array();

// set value of cookies equal to customer data, prior to customer making updates
function setInitialInfoCookies() {
	// store initial personal info values in cookie
	if (jQuery('.profile.information.saved').length < 1) {
		jQuery.cookie('ss-initialPersonalInfo',"|");
	}
	if (jQuery('#updateProfileInfo').length > 0) {
		var cookieString="";
		jQuery(':input', '#updateProfileInfo').each(function() {
			if (jQuery(this).attr('type') != 'hidden') {
				if (jQuery(this).attr('type')=='radio')
				{
					if (jQuery(this).is(":checked")) {
						if(jQuery(this).val()=="Y") {
							cookieString = cookieString + "Yes";
						}
						else
						{
							cookieString = cookieString + "No";
						}
					}
				}
				else
				{
					cookieString = cookieString + jQuery(this).val();
					if (jQuery(this).attr("id")!="mailingaddress1") {
						cookieString = cookieString + "|";
					}
				}
			}
        });
		jQuery.cookie('ss-initialPersonalInfo', null);
		if ((location.protocol).indexOf("http:") > -1) {
			jQuery.cookie('ss-initialPersonalInfo', cookieString, { expires: 1, path: '/', secure: false });
		}
		else if ((location.protocol).indexOf("https:") > -1) {
			jQuery.cookie('ss-initialPersonalInfo', cookieString, { expires: 1, path: '/', secure: true });
		}
	}
	initialPersonalInfo = jQuery.cookie('ss-initialPersonalInfo').split("|");
}
//setUpdatedInfoCookies(): set value of cookies equal to customer data after customer has made updates
function setUpdatedInfoCookies() {
	if ((location.protocol).indexOf("http:") > -1) {
		jQuery.cookie('ss-updatedPersonalInfo',"|", { expires: 1, path: '/', secure: false });
	}
	else if ((location.protocol).indexOf("https:") > -1) {
		jQuery.cookie('ss-updatedPersonalInfo',"|", { expires: 1, path: '/', secure: true });
	}
	// if customer has updated their personal info:
	if (jQuery(".profile.information.saved").length > 0) {
		var cookieString="";
		jQuery(".profile.information.saved dl dd").each(function(i) {
			cookieString = cookieString + jQuery(this).html().trim();
			if (i<jQuery(".profile.information.saved dl dd").length-1) {
				cookieString = cookieString + "|";
			}
		});	
		//jQuery.cookie('ss-updatedPersonalInfo', null);
		if ((location.protocol).indexOf("http:") > -1) {
			jQuery.cookie('ss-updatedPersonalInfo', cookieString, { expires: 1, path: '/', secure: false });
		}
		else if ((location.protocol).indexOf("https:") > -1) {
			jQuery.cookie('ss-updatedPersonalInfo', cookieString, { expires: 1, path: '/', secure: true });
		}
	}
	updatedPersonalInfo = jQuery.cookie('ss-updatedPersonalInfo').split("|");
}
//setChangedInfoProp(): compare initial profile values cookie with updated form values cookie.
//determine what values changes, set change codes, and store in prop13
function setChangedInfoProp() {
	if (jQuery(".profile.information.saved").length > 0) {
		UpdatedInfo_Om="PersonalInfoUpdated:";
		mailingAddressUpdated = false;		
		if (initialPersonalInfo.length == updatedPersonalInfo.length) {
			for (a=0;a<updatedPersonalInfo.length;a++) {
				if (initialPersonalInfo[a]!=updatedPersonalInfo[a]) {
					if (a==0) {
						// email address updated
						UpdatedInfo_Om = UpdatedInfo_Om + "EA";
					}
					if (a>0 && a<5) {
						// mailing address updated
						if (!mailingAddressUpdated) {
							if (UpdatedInfo_Om.indexOf("EA") > -1) {
								UpdatedInfo_Om = UpdatedInfo_Om + "|";
							}
							UpdatedInfo_Om = UpdatedInfo_Om + "MA";
							mailingAddressUpdated = true;
						}
					}
					if (a==6) {
						// alert preference updated
							if (UpdatedInfo_Om.indexOf("MA") > -1) {
								UpdatedInfo_Om = UpdatedInfo_Om + "|";
							}
						UpdatedInfo_Om = UpdatedInfo_Om + "AP";
					}
				}
			}
		}
		else
		{
			return false;
		}
	}
	if ("undefined" != typeof(Title_Om)) {
		if (Title_Om=="UsernameUpdated") {
			UpdatedInfo_Om="Username Updated";
		}
		if (Title_Om=="PasswordUpdated") {
			UpdatedInfo_Om="Password Updated";
		}
		if (Title_Om=="ImageAndPhraseUpdated") {
			UpdatedInfo_Om="ImageAndPhrase Updated";
		}
		if (Title_Om=="UpdatedChallengeQA") {
			UpdatedInfo_Om="ChallengeQA Updated";
		}
	}
}

function setPageSpecificEvars(){
	setInitialInfoCookies();
	setUpdatedInfoCookies();
	setChangedInfoProp();
}

/* attach custom onclick functions to anchor tags */
function registerCustomLinks() {
	
	jQuery('#pay-bill-1').click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:MyAccounts:PayMyBill:Modal";
		s.channel = 'MyAccounts';
		s.prop35 = 'BillPay';
		s.prop4 = varNamed('Customer_Type');
		s.prop15 = s.pageName + ":" + s.prop4;
		s.t();
	});
	
	// link to Fulfillment on dashboard page
	
	jQuery(".processing a").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:" + varNamed('Channel_Om') + ":" + varNamed('SubSection_Om') + ":" + varNamed('Title_Om');
		s.tl(this,'o',s.pageName+':StartSalesFulfillment')
	});
	
	// link for eDisclosures
	jQuery(".sign a:contains('eDisclosures as of')").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:" + varNamed('Channel_Om') + ":" + varNamed('SubSection_Om') + ":" + varNamed('Title_Om');
		s.linkTrackVars = 'eVar54,events';
		s.eVar54= s.pageName;
		s.linkTrackEvents='event46';
		s.events="event46";
		events.push('event46');
		s.tl(this,'o',s.pageName+':eSignDisclosures');
	});
	
	jQuery(".e-docs a:contains('eDisclosures as of')").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:" + varNamed('Channel_Om') + ":" + varNamed('SubSection_Om') + ":" + varNamed('Title_Om');
		s.linkTrackVars = 'eVar54,events';
		s.eVar54= s.pageName;
		s.linkTrackEvents='event46';
		s.events="event46";
		events.push('event46');
		s.tl(this,'o',s.pageName+':eSignDisclosures');
	});
	
	jQuery("a:contains('eDocuments')").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:" + varNamed('Channel_Om') + ":" + varNamed('SubSection_Om') + ":" + varNamed('Title_Om');
		s.linkTrackVars = 'eVar54,events';
		s.eVar54= s.pageName;
		s.linkTrackEvents='event46';
		s.events="event46";
		events.push('event46');
		s.tl(this,'o',s.pageName+':eSignDisclosures');
	});
	
	// print link in Fulfillment
	jQuery("a:contains('print page')").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:" + varNamed('Channel_Om') + ":" + varNamed('SubSection_Om') + ":" + varNamed('Title_Om');
		s.tl(this,'o',s.pageName+':Print')
	});
	
	// upload history link in Fulfillment
	jQuery(".fulfillment a:contains('upload history')").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:" + varNamed('Channel_Om') + ":" + varNamed('SubSection_Om') + ":" + varNamed('Title_Om');
		s.tl(this,'o',s.pageName+':UploadHistory')
	});
	
	// link for view history of cleared conditions in Fulfillment
	jQuery("a:contains('History of completed loan verification items')").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:" + varNamed('Channel_Om') + ":" + varNamed('SubSection_Om') + ":" + varNamed('Title_Om');
		s.tl(this,'o',s.pageName+':VerificationHistoryView');
	});
	
	// link for view upload history in Fulfillment
	jQuery("a:contains('See upload history')").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:SalesFulfillment:SFAllSteps:UploadHistory";
		s.channel="SalesFulfillment";
		s.prop35="SFAllSteps";
		s.t();
	});
	
	// link for eLynx in docs alert box
	jQuery(".docs-alert a#interstitial-elynx").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:" + varNamed('Channel_Om') + ":" + varNamed('SubSection_Om') + ":" + varNamed('Title_Om');
		s.linkTrackVars = 'eVar54,events';
		s.eVar54= s.pageName;
		s.linkTrackEvents='event49';
		s.events="event49";
		events.push('event49');
		s.tl(this,'o',s.pageName+':eLynxConditionalApproval');
		
	});
	
	// link for signed disclosures within previous step
	jQuery(".doneStep a:contains('eDisclosures as of')").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:" + varNamed('Channel_Om') + ":" + varNamed('SubSection_Om') + ":" + varNamed('Title_Om');
		s.tl(this,'o',s.pageName+':DisclosuresHistory');
	});
	
	// link for button to return to current step
	jQuery("a.btn:contains('Return to current step')").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:" + varNamed('Channel_Om') + ":" + varNamed('SubSection_Om') + ":" + varNamed('Title_Om');
		s.tl(this,'o',s.pageName+":ReturnCurrentStep");
	});
	
	// link for clicking 'continue' button in elynx interstitial
	jQuery("#modal-interstitial-elynx a.btn:contains('continue')").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:SalesFulfillment:SFAllSteps:LeavingGMACM";
		s.channel="SalesFulfillment";
		s.prop35="SFAllSteps";
		s.t(); 
	});
	
	// link for clicking 'continue' button on Fulfillment Splash page
	jQuery("a.btn:contains('Continue')").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:" + varNamed('Channel_Om') + ":" + varNamed('SubSection_Om') + ":" + varNamed('Title_Om');
		s.tl(this,'o',s.pageName+':Continue')
	});
	
	// link for 'add a loan' in right column
	jQuery(".right-column a.modal-rc:contains('Add a loan')").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:" + varNamed('Channel_Om') + ":" + varNamed('SubSection_Om') + ":" + varNamed('Title_Om');
		s.tl(this,'o',s.pageName+':AddLoan')
	});
	
	// only attach event handlers if in SmartWatch.  saves processing time.
	if (jQuery("swtabactive").length > 0) {
		// smart watch links
		jQuery('.cross-sell-logo.smartwatch').click(function() {
			var s = s_gi(s_account);
			s.manageVars('clearVars');
			s.pageName = "GMACM:" + varNamed('Channel_Om') + ":" + varNamed('SubSection_Om') + ":" + varNamed('Title_Om');
			s.tl(this,'o',s.pageName+':SmartWatch');
		});
		
		// when user clicks second tab in SmartWatch window
		jQuery("a.mygmac_sw_table_header_a:contains('Get Cash Now')").click(function(){
			var s = s_gi(s_account);
			s.manageVars('clearVars');
			s.pageName = "GMACM:MyAccounts:SmartWatch:GetCashNow";
			s.channel = 'MyAccounts';
			s.prop35 = 'SmartWatch';
			s.prop4 = varNamed('Customer_Type');
			s.prop15 = s.pageName + ":" + s.prop4;
			s.t();
		});
		
		// when user clicks "learn more" in SmartWatch, Get Cash Now tab
		jQuery("#cash img[alt='Learn More']").click(function(){
			var s = s_gi(s_account);
			s.manageVars('clearVars');
			s.pageName = "GMACM:MyAccounts:SmartWatch:GetCashNow";
			s.channel = 'MyAccounts';
			s.prop35 = 'SmartWatch';
			s.prop4 = varNamed('Customer_Type');
			s.prop15 = s.pageName + ":" + s.prop4;
			s.tl(this,'o',s.pageName+':LearnMore')
		})
		
		// when user clicks "get started" in SmartWatch, Get Cash Now tab
		jQuery("#cash img[alt='Get Started']").click(function(){
			var s = s_gi(s_account);
			s.manageVars('clearVars');
			s.pageName = "GMACM:MyAccounts:SmartWatch:GetCashNow";
			s.channel = 'MyAccounts';
			s.prop35 = 'SmartWatch';
			s.prop4 = varNamed('Customer_Type');
			s.prop15 = s.pageName + ":" + s.prop4;
			s.tl(this,'o',s.pageName+':GetStarted');
		})
		
		// when user clicks "learn more" in SmartWatch, Get Cash Now tab
		jQuery("#buy img[alt='Learn More']").click(function(){
			var s = s_gi(s_account);
			s.manageVars('clearVars');
			s.pageName = "GMACM:MyAccounts:SmartWatch:BuyNextHome";
			s.channel = 'MyAccounts';
			s.prop35 = 'SmartWatch';
			s.prop4 = varNamed('Customer_Type');
			s.prop15 = s.pageName + ":" + s.prop4;
			s.tl(this,'o',s.pageName+':LearnMore')
		})
		
		// when user clicks "get started" in SmartWatch, Get Cash Now tab
		jQuery("#buy img[alt='Get Started']").click(function(){
			var s = s_gi(s_account);
			s.manageVars('clearVars');
			s.pageName = "GMACM:MyAccounts:SmartWatch:BuyNextHome";
			s.channel = 'MyAccounts';
			s.prop35 = 'SmartWatch';
			s.prop4 = varNamed('Customer_Type');
			s.prop15 = s.pageName + ":" + s.prop4;
			s.tl(this,'o',s.pageName+':GetStarted');
		})
		
		// when customer clicks 'Lower Your Monthly Payment' tab in SmartWatch window
		jQuery("a.mygmac_sw_table_header_a:contains('Lower Your')").click(function(){
			var s = s_gi(s_account);
			s.manageVars('clearVars');
			s.pageName = "GMACM:MyAccounts:SmartWatch:LowerMonthlyPayment";
			s.channel = 'MyAccounts';
			s.prop35 = 'SmartWatch';
			s.prop4 = varNamed('Customer_Type');
			s.prop15 = s.pageName + ":" + s.prop4;
			s.t();
		});

		// when customer clicks 'Lower Your Monthly Payment' tab in SmartWatch window
		jQuery("a.mygmac_sw_table_header_a:contains('Long Term')").click(function(){
			var s = s_gi(s_account);
			s.manageVars('clearVars');
			s.pageName = "GMACM:MyAccounts:SmartWatch:SaveInLongTerm";
			s.channel = 'MyAccounts';
			s.prop35 = 'SmartWatch';
			s.prop4 = varNamed('Customer_Type');
			s.prop15 = s.pageName + ":" + s.prop4;
			s.t();
		});
		
		// when customer clicks 'Buy Your Next Home' tab in SmartWatch window
		jQuery("a.mygmac_sw_table_header_a:contains('Next Home')").click(function(){
			var s = s_gi(s_account);
			s.manageVars('clearVars');
			s.pageName = "GMACM:MyAccounts:SmartWatch:BuyNextHome";
			s.channel = 'MyAccounts';
			s.prop35 = 'SmartWatch';
			s.prop4 = varNamed('Customer_Type');
			s.prop15 = s.pageName + ":" + s.prop4;
			s.t();
		});
	}
	
	// 'enroll' link in 'pay my bill' modal
	jQuery('#enrollPay').mouseup(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:MyAccounts:BillPay:Enroll";
		s.linkTrackVars = 'prop13,eVar27,events';
		s.linkTrackEvents='event12';
		s.prop13='Enroll for Bill Pay';
		s.tl(this,'o',s.pageName+':EnrollBillPay');
	});
	

	// 'rush pay' link in 'pay my bill' modal
	jQuery('#rushPay').mouseup(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:MyAccounts:BillPay:Enroll";
		s.linkTrackVars = 'prop13,eVar27,events';
		s.linkTrackEvents='event12';
		s.prop13='Make OneTime Payment';
		s.tl(this,'o',s.pageName+':MakeOneTimePayment');
	});
	// download 1098 links
	jQuery('.download-1098 ul a').click(function() {	
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:MyAccounts:1098Statements:Home";
		s.linkTrackVars = 'prop13,eVar27,events';
		s.linkTrackEvents='event12';
		s.prop13='Download 1098 Statement';
		s.tl(this,'o',s.pageName+':Download1098Statement');
	});
	// download account history links
	jQuery('.history ul.menu').click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:MyAccounts:AccountHistory:Home";
		s.linkTrackVars = 'prop13,eVar27,events';
		s.linkTrackEvents='event12';
		s.prop13='Download Account History';
		s.tl(this,'o',s.pageName+':DownloadAccountHistory');
	});
	// submit payoff request button
	jQuery('#submit-payoff-request').click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:MyAccounts:RequestPayoff:Home";
		s.linkTrackVars = 'prop13,eVar27,events,eVar43';
		s.linkTrackEvents='event12,event35';
		s.prop13='RequestPayoff';
		if (jQuery('#payOffRequestType1').is(":checked")==true) {
			s.eVar43='Online';
		}
		else if (jQuery('#payOffRequestType2').is(":checked")==true) {
			s.eVar43='Mail';
		}
		else if (jQuery('#payOffRequestType3').is(":checked")==true) {
			s.eVar43='Fax';
		}
		s.events='event35';
		s.tl(this,'o',s.pageName+':PayoffRequested');
	});
	// submit payoff request button
	jQuery('#savechangesId').click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:MyAccounts:MyProfile:PersonalInfo";
		s.tl(this,'o',s.pageName+':UpdatePersonalInfo');
	});
	// 'help for homeowners' link in right column
	
	jQuery('.right-column a#loss-mitigation').click(function() {
		updatedSubSection_Om = varNamed("SubSection_Om");
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		if (jQuery(".details h3:contains('currently in process')").length > 0) {
			s.pageName = "GMACM:MyAccounts:LoanStatus:UploadDocuments";
		}
		else
		{
			s.pageName = "GMACM:" + varNamed('Channel_Om') + ":" + updatedSubSection_Om + ":" + varNamed('Title_Om');
		}
		s.tl(this,'o',s.pageName+':GetHelpNow');
	});
	// accept button for e-disclosure
	jQuery('#discl .btn').click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:MyAccounts:MyProfile:PrivacyED";
		s.linkTrackVars='prop13, eVar27, events';
		s.linkTrackEvents='event12';
		s.prop13='PrivacyED Updated';
		s.tl(this,'o',s.pageName+':UpdatePrivacyED');
	});
	// decline button for e-disclosure
	jQuery('#discl .btn2').click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:MyAccounts:MyProfile:PrivacyED";
		s.tl(this,'o',s.pageName+':PrivacyEDDeclined');
	});
	//FAQs tab clicked
	jQuery("ul.tm1 li:contains('FAQs')").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:MyAccounts:FAQs:Home";
		s.channel = "MyAccounts";
		s.prop35="FAQs";
		s.prop4 = "Customer:Logged In";
		s.prop15 = s.pageName + ":" + s.prop4;
		// set following variable for Help for HomeOwners button tracking.
		updatedSubSection_Om = "FAQs";
		s.t();
	});
	//FAQ question clicked
	jQuery(".blinds.account_faqs a.blind-link").click(function() {
		s.linkTrackVars='prop5,prop19';
		s.prop5=jQuery(this).html();
		s.prop19=s.pageName;
		s.tl(this,'o',s.pageName+':Help')
	});
	//timeout warning modal triggered
	jQuery("#timeout-0").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:MyAccounts:TimeoutWarning:Modal";
		s.channel = "MyAccounts";
		s.prop35="Timeout";
		s.prop4 = "Customer:Logged In";
		s.prop15 = s.pageName + ":" + s.prop4;
		s.t();
	});
	//'log out' link from warning modal
	jQuery("#warning-message a:contains('return to my session')").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:MyAccounts:Timeout:TimeoutWarning";
		s.tl(this,'o',s.pageName+':Logout');
	});
	// 'return to session' link from warning modal
	jQuery("#warning-message a:contains('Log Out')").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:MyAccounts:Timeout:TimeoutWarning";
		s.tl(this,'o',s.pageName+':ReturnToSession');
	});
	// 'log on' link from timeout message
	jQuery("#timeout-message a:contains('log on')").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:MyAccounts:Timeout:Timeout";
		s.tl(this,'o',s.pageName+':LoginAgain');
	});
	if (s.prop4=="Prospect:logged in") {
		s.events='event1';
		s.eVar1=Web_User_Id;
	}
		
	jQuery(".overview a:contains('View Status')").click(function() {
		var s = s_gi(s_account);
		s.manageVars('clearVars');
		s.pageName = "GMACM:MyAccounts:MyAccounts:Home";
		s.tl(this,'o',s.pageName+':ViewStatus')
	});
	
	// to track client-side toggling of My Profile landing page when user toggles between FAQs and My Profile
	if (location.href.indexOf("loadlandingpage.htm#tab=myProfile") > -1 || location.href.indexOf("o3.html#tab=myProfile") > -1) {
		jQuery("ul.tm1 li:contains('My Profile')").click(function() {
			var s = s_gi(s_account);
			s.manageVars('clearVars');
			s.pageName = "GMACM:MyAccounts:MyProfile:Home";
			s.channel = "MyAccounts";
			s.prop35="MyProfile";
			s.prop4 = "Customer:Logged In";
			s.prop15 = s.pageName + ":" + s.prop4;
			// set following variable for Help for HomeOwners button tracking.
			s.t();
		});
	}
	
}

/* function invoked from selfService.js when final timeout modal displays */
function setTimeoutVars() {
	var s = s_gi(s_account);
	s.manageVars('clearVars');
	s.pageName = "GMACM:MyAccounts:FinalTimeoutWarning:Modal";
	s.channel = "MyAccounts";
	s.prop35="Timeout";
	s.prop4 = varNamed('Customer_Type');
	s.prop15 = s.pageName + ":" + s.prop4;
	s.t();
}

/* function invoked from selfService.js for state fees link */
function setStateFeeVars(stateAbbreviation) {
var s = s_gi(s_account);
s.manageVars('clearVars');
s.pageName='GMACM:MyAccounts:AccountHistory:Home';
s.tl(this,'o',s.pageName+':'+ stateAbbreviation +' Fees');
}

/* function invoked from selfServiceUploadSubmission.js */
function setUploadConfirmationVars() {
// removed body of old document upload function.  replaced by setFulfillmentUploadedVars() below.
return true;
}


function setFulfillmentUploadedVars() {
events = [];
var s=s_gi(s_account);
s.manageVars('clearVars');
s.pageName='GMACM:SalesFulfillment:'+SubSection_Om+':'+Title_Om;
s.linkTrackVars='eVar55,events';
s.eVar55=s.pageName;
s.linkTrackEvents='event45';
s.events='event45';
events.push('event45');
s.tl(this,'o',s.pageName+':DocumentUploaded');
}

/* function invoked from selfService.js */
function setViewStatementsVars() {
var s = s_gi(s_account);
s.pageName='GMACM:MyAccounts:OnlineStatements:Home';
s.channel = 'MyAccounts';
s.prop35 = 'OnlineStatements';
s.prop4 = varNamed('Customer_Type');
s.prop15 = s.pageName + ":" + s.prop4;
s.t();
}

function setFutureModalVars() {
var s=s_gi(s_account);
s.manageVars('clearVars');
s.pageName="GMACM:SalesFulfillment:SFAllSteps:BePatient";
s.channel="SalesFulfillment";
s.prop35="SFAllSteps";
s.t();
}

function setPastStepVars(clickedStep){
var s=s_gi(s_account);
s.manageVars('clearVars');
s.pageName="GMACM:SalesFulfillment:SFStep"+clickedStep+":PreviousStepAccess";
s.channel="SalesFulfillment";
s.prop35="SFStep"+clickedStep;
s.t();
}

jQuery(document).ready(function() {
	//attach custom tracking links here
	registerCustomLinks();
	//set page specific eVars
	setPageSpecificEvars();
});

/*
 end : page specific code for self-service
*/
