// Tab function for Cards Details Page.
var alltabs = new Array();
alltabs.push('features_tab');
alltabs.push('additional_tab');
alltabs.push('rates_tab');

function switchTabExplicit(tab){
	var browserName=navigator.appName; 
	if (browserName=="Microsoft Internet Explorer") {
		document.getElementById(tab).fireEvent("onclick");
	}
	else {
		var evt = document.createEvent("MouseEvents");
		evt.initEvent("click", true, true);
		document.getElementById(tab).dispatchEvent(evt); 
	}
}

function switchCardsDetailTab(tabname) {
	for(var x=0; x < alltabs.length; x++){
		var  currenttab = document.getElementById(alltabs[x]);
		var  currentcontent = document.getElementById(alltabs[x]+"_content");
		if (alltabs[x] != tabname) {
			currenttab.className = '';
			currentcontent.style.display = 'none';
		}
		else {
			currenttab.className = 'primarytabs-currentpage';
			currentcontent.style.display = '';
		}
	}
}

// Tab function for Customer Service
var customerservicetabs = new Array();
customerservicetabs.push('faq_tab');
customerservicetabs.push('email_tab');
customerservicetabs.push('phone_tab');
customerservicetabs.push('mail_tab');

function switchCustomerServiceTab(tabname) {
	for(var x=0; x < customerservicetabs.length; x++){
		var  currenttab = document.getElementById(customerservicetabs[x]);
		var  currentcontent = document.getElementById(customerservicetabs[x]+"_content");
		var  currenttabtext = document.getElementById(customerservicetabs[x]+"_text");
		if (customerservicetabs[x] != tabname) {
			currenttab.className = '';
			currentcontent.style.display = 'none';
			currenttabtext.style.color = 'white';
		}
		else {
			currenttab.className = 'primarytabs-currentpage';
			currentcontent.style.display = '';
			currenttabtext.style.color = '#000000';
		}
	}
}


// Manage Card Tab Switch
function switchManageCardTab(tabname) {
	var alltabs = new Array();
	alltabs.push('visainquiry_tab');
	alltabs.push('additionaluser_tab');
	alltabs.push('visachipandpin_tab');
	alltabs.push('visapaywave_tab');
	alltabs.push('onlinebanking_tab');
	alltabs.push('optionalservices_tab');
	alltabs.push('agreements_tab');

	for(var x=0; x < alltabs.length; x++){
		var  currenttab = document.getElementById(alltabs[x]);
		var  currentcontent = document.getElementById(alltabs[x]+"_content");
		if (alltabs[x] != tabname) {
			if (alltabs[x] != 'default_tab') currenttab.className = 'btn-off';
			currentcontent.style.display = 'none';
		}
		else {
			if (alltabs[x] != 'default_tab') currenttab.className = 'btn-on';
			currentcontent.style.display = 'block';
		}
	}
}

// Optional Services Tab Switch
function switchOptionalServiceTab(tabname) {
	var alltabs = new Array();
	alltabs.push('creditalert_tab');
	alltabs.push('balanceprotector_tab');
	alltabs.push('travelhealthprotector_tab');
	alltabs.push('cardassistplue_tab');
	alltabs.push('talkandsave_tab');
	alltabs.push('verifiedbyvisa_tab');

	for(var x=0; x < alltabs.length; x++){
		var  currenttab = document.getElementById(alltabs[x]);
		var  currentcontent = document.getElementById(alltabs[x]+"_content");
		if (alltabs[x] != tabname) {
			if (alltabs[x] != 'default_tab') currenttab.className = 'btn-off';
			currentcontent.style.display = 'none';
		}
		else {
			if (alltabs[x] != 'default_tab') currenttab.className = 'btn-on';
			currentcontent.style.display = 'block';
		}
	}
}

// Opens a new window for Estatement index page.
function fn_tour(ln, seg, client, sessionid) 
{ 
	x = window.screen.width; 
	y = window.screen.height; 
	w = 800;
	h = 520;
	
	moveX=(x/2)-w/2; 
	moveY=(y/2)-h/2; 
	
	window.open('/oec/avatar/estatements/welcome_00.html?ln=' + ln + '&seg=' + seg + '&client=' + client + '&sessionid=' + sessionid,'RCB','width=' + w + ',height=' + h + ',status=0,left='+ moveX +',top=' + moveY + ',screenX=' + moveX + ',screenY=' + moveY + ',scrollbars=no' + ',resizable=no');
}


// Chip and PIN how it works script.
var step1_on = '/cards/_assets-custom/images/chip-pin-step1-on.jpg';
var step1_off = '/cards/_assets-custom/images/chip-pin-step1-off.jpg';
var step1_content = '<h3 class="firstline">Step 1</h3><p><strong>Insert your card into the chip-enabled terminal and leave it there.</strong></p><p>Your card should never leave your sight. This helps to further reduce the risk of fraud.</p>';
var step1_tip = 'Your RBC Visa chip card should be inserted chip with the chip facing up.';
var step1_img = '<img src="/cards/_assets-custom/images/chip-pin-step1-main.jpg" alt="Chip &amp; Pin &ndash; Step 1" width="140" height="140" />';

var step2_on = '/cards/_assets-custom/images/chip-pin-step2-on.jpg';
var step2_off = '/cards/_assets-custom/images/chip-pin-step2-off.jpg';
var step2_content = '<h3 class="firstline">Step 2</h3><p><strong>Follow the instructions as they appear on the screen and enter your PIN when prompted.</strong></p><p>You\'re the one in control of the transaction process.</p>';
var step2_tip = 'Remember to always protect your PIN and never disclose it to anyone. For more information on using a PIN with your chip card <br>and on protecting your PIN, click <a href="cards/chip/protecting.html">here</a>';
var step2_img = '<img src="/cards/_assets-custom/images/chip-pin-step2-main.jpg" alt="Chip &amp; Pin &ndash; Step 2" width="140" height="140" />';

var step3_on = '/cards/_assets-custom/images/chip-pin-step3-on.jpg';
var step3_off = '/cards/_assets-custom/images/chip-pin-step3-off.jpg';
var step3_content = '<h3 class="firstline">Step 3</h3><p><strong>Wait for the transaction to be completed.</strong></p><p>When completing a chip and PIN transaction, there\'s no need to sign the receipt because the PIN serves as the validation.</p>';
var step3_tip = 'While a signature is not required for chip and PIN transactions, during the transition some merchants may still ask for one. To avoid disruption, explain that this is not necessary but go ahead and sign the receipt. This will only be a temporary practice until merchants become familiar with the process.';
var step3_img = '<img src="/cards/_assets-custom/images/chip-pin-step3-main.jpg" alt="Chip &amp; Pin &ndash; Step 3" width="140" height="140" />';

var step4_on = '/cards/_assets-custom/images/chip-pin-step4-on.jpg';
var step4_off = '/cards/_assets-custom/images/chip-pin-step4-off.jpg';
var step4_content = '<h3 class="firstline">Step 4</h3><p><strong>Remove your card from the terminal and you\'re on your way.</strong></p><p>The overall process is quick and easy.</p>';
var step4_tip = 'Removing your card too soon could terminate the transaction before it\'s approved. Do not remove your card until prompted.';
var step4_img = '<img src="/cards/_assets-custom/images/chip-pin-step4-main.jpg" alt="Chip &amp; Pin &ndash; Step 4" width="140" height="140" />';

function rollIn(section) {
	var chip_pin_content = document.getElementById('chip_pin_content');
	var chip_pin_tip = document.getElementById('chip_pin_tip');
	var chip_pin_img = document.getElementById('chip_pin_img');
	var image_section = document.getElementById(section + '-btn');
	
	rollOut(section);
	
	if (section == 'step1') {
		chip_pin_content.innerHTML = step1_content;
		chip_pin_tip.innerHTML = step1_tip;
		chip_pin_img.innerHTML = step1_img;
		image_section.src = step1_on;
	}
	else if (section == 'step2') {
		chip_pin_content.innerHTML = step2_content;
		chip_pin_tip.innerHTML = step2_tip;
		chip_pin_img.innerHTML = step2_img;
		image_section.src = step2_on;			
	}
	else if (section == 'step3') {
		chip_pin_content.innerHTML = step3_content;
		chip_pin_tip.innerHTML = step3_tip;
		chip_pin_img.innerHTML = step3_img;
		image_section.src = step3_on;			
	}
	else if (section == 'step4') {
		chip_pin_content.innerHTML = step4_content;
		chip_pin_tip.innerHTML = step4_tip;
		chip_pin_img.innerHTML = step4_img;
		image_section.src = step4_on;			
	}
	
}

function rollOut(section) {
	var image_section = document.getElementById(section + '-btn');

	if (section != 'step1') document.getElementById('step1-btn').src = step1_off;
	if (section != 'step2') document.getElementById('step2-btn').src = step2_off;
	if (section != 'step3') document.getElementById('step3-btn').src = step3_off;
	if (section != 'step4') document.getElementById('step4-btn').src = step4_off;

}
