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 startTSQuote() {
		var travelquote = window.open(str_prefix+'/travel-insurance/quote/TS/loadipl.aspx','travelpopup','width=785,height=550,status=yes,scrollbars=yes,resizable=yes,location=no');
}

function recallTSQuote() {
		var travelquote = window.open(str_prefix+'/travel-insurance/quote/TS/quoterecall.aspx','travelpopup','width=785,height=550,status=yes,scrollbars=yes,resizable=yes,location=no');
}

function leaveQuote(theURL) {
	if (confirm('Are you sure you want to abort this quote?')) {
	window.location.href = theURL;
	}
}

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 viewWordings(thePDF) {
  var pdfURL = "/shared/pages/loadwording.aspx?pdf=" + thePDF + "&q=household";
  var wordingwin = window.open(pdfURL,'wordings','status=yes,scrollbars=yes,resizable=yes,width=630,height=350');
}

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=ts','popup','scrollbars=yes,resizable=yes,location=no,width=630,height=350');
}

function showOpex(opex) {
	opexURL = '/home-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_ts.pdf','noticespopup','width=630,height=350,top=15,left=15,location=no,scrollbars=yes,resizable=yes,status=yes');
}

function InsdSex() {
	var InsdMale = false;
	var InsdFemale = false;
	var maleTitles = new Array('Mr','Sir','Lord');
	var femaleTitles = new Array('Mrs','Miss','Ms','Dame','Lady');
	var InsdTitle
	var sQuestion
	if (document.quoteform.JointTitle != null) {
		InsdTitle = document.quoteform.JointTitle.options[document.quoteform.JointTitle.selectedIndex].value;
		sQuestion = document.quoteform.JointSex;
	}
	else {
		InsdTitle = document.quoteform.ContactTitle.options[document.quoteform.ContactTitle.selectedIndex].value;
		sQuestion = document.quoteform.ProposerSex;
	}
	if (InsdTitle != "") {
		for (i=0;i<maleTitles.length;i++) {
			if (InsdTitle == maleTitles[i]) {
				InsdMale = true;
			}
		}
		for (j=0;j<femaleTitles.length;j++) {
			if (InsdTitle == femaleTitles[j]) {
				InsdFemale = true;
			}
		}
		if (InsdMale) {
			sQuestion[0].checked = true;
		}
		else if (InsdFemale) {
			sQuestion[1].checked = true;
		}
		else {
			sQuestion[0].checked = false;
			sQuestion[1].checked = false;
		}
	}
}
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;
		}
	}
}
