// Issuer Level JavaScript Document for Microsite
function openSummaryWindow()
{
   var url = "https://www.halifaxcards.co.uk/NASApp/halifaxcards/do/SummaryBox?sc=" + document.pageForm.sourceCode.value + "&special=nobrand";
   window.open(url, 'cardSummary', 'scrollbars=yes,menubar=no,status=no,toolbar=no,resizable=no,dependent=yes,width=600,height=400')
}

function openBrWindow(theURL,winName,features) 
{		
	if (pageForm.SelectedCard != null)
	{
		// we are on the chooseCard page
		theURL = theURL + "?CardType=" + pageForm.CardType.value;
	}		
	// opens popup windows			
	window.open(theURL,winName,features);
}

function displaySection() 
{	
	if (document.pageForm.SummaryPage__ctl0_summaryDetails__ctl0_HasAdditionalCardholder)
	{
		if(document.pageForm.SummaryPage__ctl0_summaryDetails__ctl0_HasAdditionalCardholder.value == "False")
			hideObject('additionalcards');
	}
	
	if(document.pageForm.SummaryPage__ctl0_summaryDetails_HasAdditionalCardholder)
	{
		if(document.pageForm.SummaryPage__ctl0_summaryDetails_HasAdditionalCardholder.value == "False")
			hideObject('additionalcards');
	}
}
	
function showEmploymentTextBox(triggerID) 
{	
	var titleDDL = document.pageForm.FinancialPage__ctl0_currentEmployment_lbx_EmploymentDetails_OccupationStatus.value;
	if (titleDDL == 'Self-employed')
	{
		document.getElementById(triggerID).style.display = 'inline';
		if(document.pageForm.FinancialPage__ctl0_currentEmployment_tb_EmploymentDetails_OccupationStatusOther.value == '')
			document.pageForm.FinancialPage__ctl0_currentEmployment_tb_EmploymentDetails_OccupationStatusOther.value = 'Nature of self-employment';

	}	
	else if(titleDDL == 'Retired')
	{
		document.getElementById(triggerID).style.display = 'inline';
		if(document.pageForm.FinancialPage__ctl0_currentEmployment_tb_EmploymentDetails_OccupationStatusOther.value == '')
			document.pageForm.FinancialPage__ctl0_currentEmployment_tb_EmploymentDetails_OccupationStatusOther.value = 'Employment before retirement';

	}
	else {
		//Reset the Other field to be blank
		document.getElementById(triggerID).style.display = 'none';
		document.pageForm.FinancialPage__ctl0_currentEmployment_tb_EmploymentDetails_OccupationStatusOther.value = '';
	}		
}
	
function updateEmploymentTextBox(triggerID)
{
	var titleDDL = document.pageForm.FinancialPage__ctl0_currentEmployment_lbx_EmploymentDetails_OccupationStatus.value
	if (titleDDL == 'Self-employed')
	{
		document.getElementById(triggerID).style.display = 'inline';
		document.pageForm.FinancialPage__ctl0_currentEmployment_tb_EmploymentDetails_OccupationStatusOther.value = 'Nature of self-employment';
	}
	else if (titleDDL == 'Retired')
	{
		document.getElementById(triggerID).style.display = 'inline';
		document.pageForm.FinancialPage__ctl0_currentEmployment_tb_EmploymentDetails_OccupationStatusOther.value = 'Employment before retirement';
	}
	else {
		//Reset the Other field to be blank
		document.getElementById(triggerID).style.display = 'none';
		document.pageForm.FinancialPage__ctl0_currentEmployment_tb_EmploymentDetails_OccupationStatusOther.value = '';
	}
}
	
function hideCardholder(objVal)
{      
	hideObject(objVal);
	document.pageForm.PersonalPage__ctl0_personalDetails_additionalCardholders_cardholder1_tb_Cardholder_FirstName1.value='';
	document.pageForm.PersonalPage__ctl0_personalDetails_additionalCardholders_cardholder1_tb_Cardholder_Surname1.value ='';
	document.pageForm.PersonalPage__ctl0_personalDetails_additionalCardholders_cardholder1_lbx_Cardholder_TitlePrefix1.value = '';
	document.pageForm.PersonalPage__ctl0_personalDetails_additionalCardholders_cardholder1_tb_Cardholder_TitlePrefixOther1.value ='';
	showTextBox('PersonalPage__ctl0_personalDetails_additionalCardholders_cardholder1_tb_Cardholder_TitlePrefixOther1', 'Other', 'Unselected');
	document.pageForm.PersonalPage__ctl0_personalDetails_additionalCardholders_cardholder1_tb_Cardholder_Middleinitial1.value ='';
	document.pageForm.PersonalPage__ctl0_personalDetails_additionalCardholders_cardholder1_tb_Cardholder_BirthDay1.value ='dd';
	document.pageForm.PersonalPage__ctl0_personalDetails_additionalCardholders_cardholder1_tb_Cardholder_BirthMonth1.value ='mm';
	document.pageForm.PersonalPage__ctl0_personalDetails_additionalCardholders_cardholder1_tb_Cardholder_BirthYear1.value ='yyyy';
}

IssuerFinancialPage = function()
{
	showEmploymentTextBox('FinancialPage__ctl0_currentEmployment_tb_EmploymentDetails_OccupationStatusOther' );
	setFocus('FinancialPage__ctl0_currentEmployment_lbx_EmploymentDetails_OccupationStatus')      
}

IssuerPersonalPage = function()
{	
	showTextBox('PersonalPage__ctl0_personalDetails_nameAndContactDetails_tb_TitlePrefixOther', 'Other', document.pageForm.PersonalPage__ctl0_personalDetails_nameAndContactDetails_lbx_TitlePrefix.value);
	showTextBox('PersonalPage__ctl0_personalDetails_additionalCardholders_cardholder1_tb_Cardholder_TitlePrefixOther1', 'Other', document.pageForm.PersonalPage__ctl0_personalDetails_additionalCardholders_cardholder1_lbx_Cardholder_TitlePrefix1.value);
	if (document.pageForm.PersonalPage__ctl0_personalDetails_additionalCardholders_AdditionalCardYes.checked == true) showObject('additionalcards');
	if (document.pageForm.PersonalPage__ctl0_personalDetails_additionalCardholders_AdditionalCardNo.checked == true) hideCardholder('additionalcards');
	setFocus('PersonalPage__ctl0_personalDetails_nameAndContactDetails_lbx_TitlePrefix');
}

IssuerIntroductionPage = function()
{	
	//setFocus('ChooseCardPage__ctl0_nameAndContactDetails_tb_FirstName');	
	if (document.pageForm.IntroductionPage__ctl0_JointApplicantQuestion_rb_JointApplicantYes.checked)
		showObject('jointDetails');
	if (document.pageForm.IntroductionPage__ctl0_JointApplicantQuestion2_rb_SameAddressNo.checked)
		showObject('jointPostcode');	
	checkBrowser(5.0,0,2,5.0,0,2,2,'','oldbrowser.htm');
}

// JavaScript Document

function showTextBox(triggerID, triggerValue, currentValue) 
{
	if (currentValue == triggerValue) { 
		document.getElementById(triggerID).style.display = 'inline';
	}
	else {
		document.getElementById(triggerID).style.display = 'none';
		document.getElementById(triggerID).value = 'Enter here';
	}
}

function FinancialLoad()
{
	if (typeof BrandFinancialPage != "undefined"){BrandFinancialPage();}		
	else if (typeof IssuerFinancialPage != "undefined"){IssuerFinancialPage();}
}

function PersonalDetailsLoad()
{
	if (typeof BrandPersonalPage != "undefined"){BrandPersonalPage();}	
	else if (typeof IssuerPersonalPage != "undefined"){IssuerPersonalPage();}
}

function IntroductionLoad()
{
	if (typeof BrandIntroductionPage != "undefined"){BrandIntroductionPage();}	
	else if (typeof IssuerIntroductionPage != "undefined"){IssuerIntroductionPage();}
}

function writePrintButtonDiv()
{
	document.write("<div id='printbutton'><a href='javascript:void(0)' title='Print this page' onclick='javascript: window.print();return false'>Print</a></div>");
}

function writeCloseButtonDiv()
{
    document.write("<div id='buttons'><input type='submit' onclick='javascript: window.close();return false' value='Close window' tabindex='501' class='formbutton'></div>");
}

function displayMousePointer()
{
   if (typeof(Page_IsValid) != "undefined" && Page_IsValid == true)
   {
      MM_showHideLayers('mouseWaitDiv','','show');
   }
}