str_ServerName = window.location.hostname;
var str_prefix;
if (str_ServerName == "www.aonquote.co.uk"){
	str_prefix = "https://www.aonquote.co.uk";
} else{
	str_prefix = "";
}

function startPCQuote() {
		var motorquote = window.open(str_prefix+'/car-insurance/quote/loadipl.aspx','motorpopup','width=785,height=550,status=yes,scrollbars=yes,resizable=yes,location=no');
}

function recallPCQuote() {
		var motorquote = window.open(str_prefix+'/car-insurance/quote/quoterecall.aspx','motorpopup','width=785,height=550,status=yes,scrollbars=yes,resizable=yes,location=no');
}
function showAOIS(istravel){
	if (istravel == null) {	
		istravel = '';
	}else{
		istravel = "?q=ts"
	}
	var wAOIS = window.open('/shared/help/aois.aspx'+istravel+'','popup','scrollbars=yes,resizable=yes,location=no,width=630,height=350');
}

function leaveQuote(theURL) {
	if (confirm('Are you sure you want to abort this quote?')) {
	window.location.href = theURL;
	}
}

function showPop(strpop) {
	var rshowPop = window.open(strpop,'popup','scrollbars=yes,resizable=yes,location=no,width=630,height=400');
}

function viewWordings(thePDF) {
  var pdfURL = "/shared/pages/loadwording.aspx?pdf=" + thePDF + "&q=motor";
  var wordingwin = window.open(pdfURL,'wordings','status=yes,scrollbars=yes,resizable=yes,width=630,height=350');
}

function driverSex() {
	var driverMale = false;
	var driverFemale = false;
	var maleTitles = new Array('Mr','Sir','Lord');
	var femaleTitles = new Array('Mrs','Miss','Ms','Dame','Lady');
	var driverTitle;
	var sQuestion;
	if (document.quoteform.DriverTitle != null) {
		driverTitle = document.quoteform.DriverTitle.options[document.quoteform.DriverTitle.selectedIndex].value;
		sQuestion = document.quoteform.DriverSex;
	}
	else if (document.quoteform.JointTitle != null) {
		driverTitle = document.quoteform.JointTitle.options[document.quoteform.JointTitle.selectedIndex].value;
		sQuestion = document.quoteform.JointSex;
	}
	else {
		driverTitle = document.quoteform.ContactTitle.options[document.quoteform.ContactTitle.selectedIndex].value;
		sQuestion = document.quoteform.ProposerSex;
	}
	if (driverTitle != "") {
		for (i=0;i<maleTitles.length;i++) {
			if (driverTitle == maleTitles[i]) {
				driverMale = true;
			}
		}
		for (j=0;j<femaleTitles.length;j++) {
			if (driverTitle == femaleTitles[j]) {
				driverFemale = true;
			}
		}
		if (driverMale) {
			sQuestion[0].checked = true;
		}
		else if (driverFemale) {
			sQuestion[1].checked = true;
		}
		else {
			sQuestion[0].checked = false;
			sQuestion[1].checked = false;
		}
	}
}


function showHelp(hSection) {
	var wHelp = window.open('/shared/help/help.aspx?helpid='+hSection,'popup','scrollbars=no,resizable=no,width=260,height=350');
}

function showGlossary(gSection) {
	if (gSection == null) {	
		gSection = '';
	}
	var wGlossary = window.open('/shared/help/glossary.aspx?glossid='+gSection+'&q=pc','popup','scrollbars=yes,resizable=yes,location=no,width=630,height=350');
}

function showOpex(opex) {
	opexURL = '/car-insurance/quote/opex_popup.aspx';
	if (opex != null) {
		opexURL += '#' + opex;
	}
	var wOpex = window.open(opexURL,'popup','scrollbars=yes,resizable=yes,location=no,width=630,height=350');
}

function printNotices() {
	var noticesWin = window.open('https://www.outrightplc.co.uk/PolicyDocumentsService/documents/online/none/toba/toba_pc.pdf','noticespopup','width=630,height=350,top=15,left=15,location=no,scrollbars=yes,resizable=yes,status=yes');
}

function showStepBack() {
	var stepbackWin = window.open('/car-insurance/quote/protected_ncb.aspx','stepbackpopup','width=630,height=350,top=15,left=15,location=no,scrollbars=yes,resizable=yes,status=yes');
}

function defaultOccupation(EmploymentStatus)
{
	// test to see whether called from proposer or additional driver page
	// and setup name of form fields appropriately
	var insuredSex;
	var occupationField;
	var employerField;
	var alertMsg = "Your employer's business has been automatically set to the most suitable for your employment status";
	var alertMsgBoth = "Your occupation and employer's business have been automatically set to the most suitable for your employment status";
	if (document.quoteform.ProposerSex != null) {
		if (document.quoteform.ProposerSex[1].checked) {
			insuredSex = document.quoteform.ProposerSex[1].value;
		}
		else {
			insuredSex = document.quoteform.ProposerSex[0].value;
		}
		occupationField = document.quoteform.ProposerOccDescFT;
		employerField = document.quoteform.ProposerEmpDescFT;
	}
	else {
			var alertMsgBoth = "Their occupation and employer's business have been automatically set to the most suitable for their employment status";
			var alertMsgStudent = "Please select the most appropriate choice from the occupation selection (Their employer's business has been automatically set to the most suitable for their employment status)";
		if (document.quoteform.DriverSex[1].checked) {
			insuredSex = document.quoteform.DriverSex[1].value;
		}
		else {
			insuredSex = document.quoteform.DriverSex[0].value;
		}
		occupationField = document.quoteform.DriverOccDescFT;
		employerField = document.quoteform.DriverEmpDescFT;
	}
	switch (EmploymentStatus) {
		case "R":
			occupationField.value = "Retired";
			employerField.value = "Not in employment";
			alert(alertMsgBoth);
			break;
		case "U":
			employerField.value = "Not in employment";
			alert(alertMsg);
			break;
		case "H":
			if (insuredSex == "M") {
				occupationField.value = "Househusband";
			}
			else {
				occupationField.value = "Housewife";
			}
			employerField.value = "Not in employment";
			alert(alertMsgBoth);
			break;
		default: return false;
	}
}