var travellerMaximum=12
var defaultMaxAge = 75
var minAge=18

/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["declaration"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="no"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
	var dyniframe=new Array()
	for (i=0; i<iframeids.length; i++){
		if (document.getElementById)
			resizeIframe(iframeids[i])
		//reveal iframe for lower end browsers? (see var above):
		if ((document.all || document.getElementById) && iframehide=="no"){
			var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
			if(tempobj){
				tempobj.style.display="block"
				tempobj.style.height="250"
			}
		}
	}
}

function resizeIframe(frameid){
	var currentfr=document.getElementById(frameid)
	if (currentfr && !window.opera){
		currentfr.style.display="block"
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
			currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
		else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
			currentfr.height = currentfr.Document.body.scrollHeight;
		if (currentfr.addEventListener)
			currentfr.addEventListener("load", readjustIframe, false)
		else if (currentfr.attachEvent){
			currentfr.detachEvent("onload", readjustIframe) // Bug fix line
			currentfr.attachEvent("onload", readjustIframe)
		}
	}
}

function readjustIframe(loadevt) {
	var crossevt=(window.event)? event : loadevt
	var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
	if (iframeroot)
		resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
	if (document.getElementById)
		document.getElementById(iframeid).src=url
}

if (window.addEventListener)
	window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
	window.attachEvent("onload", resizeCaller)
else
	window.onload=resizeCaller

// ************************ date routine *************************************************************
// *
var weekday_showing = false;				// make this false to prevent the weekday element from being displayed
var dayofweek_returned_as_number = true;	// make this true to make dayofweek return a number (0-6)
var month_returned_as_number = true;		// make this true to make month return a number (0-11)
var cur = new Date();
var min_year = getFullYear(cur) 			// defines lowest year in year menu
var max_year = getFullYear(cur) + 3			// defines highest year in the year menu

// Define weekdays and months in the format you want
weekdays = new arr("Sun","Mon","Tues","Wed","Thurs","Fri","Sat");
//weekdays = new arr("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
months = new arr("Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec");
//months = new arr("January","February","March","April","May","June","July","August","September","October","November","December");

if (min_year <= 400) alert("Minimum year must be higher than 400 for this algorithm to work.");

function changeDays(numb,form,field) {
var day;
var month;
var year;
var dayofWeek;
var myData = new String();

		myData.value = field.name;

		// Select the date cbo we are working with
		switch(myData.value.substring(0,8)) {
			case 'txtRetur':
//							day = form.txtReturnDateday;
							day = document.getElementById('txtReturnDateday')
//							 month = form.txtReturnDatemonth;
							month = document.getElementById('txtReturnDatemonth')
//							year = form.txtReturnDateyear;
							year = document.getElementById('txtReturnDateyear')

							 if (weekday_showing) dayofWeek = document.getElementById('txtReturnDatedayofweek');
							 break;
			case 'txtDepar':
//			 				day = form.txtDepartureDateday;
							day = document.getElementById('txtDepartureDateday')
//							 month = form.txtDepartureDatemonth;
							month = document.getElementById('txtDepartureDatemonth')
//							 year = form.txtDepartureDateyear;
							year = document.getElementById('txtDepartureDateyear')
							 if (weekday_showing) dayofWeek = document.getElementById('txtDepartureDatedayofweek');
							 break;
		}

		mth = month.selectedIndex;
		sel = year.selectedIndex;
		yr = year.options[sel].text;

		if (numb != 1) {
			numDays = numDaysIn(mth,yr);
			day.options.length = numDays;
			for (i=27;i<numDays;i++) {
				day.options[i].text = i+1;
				day.options[i].value = i+1;
			}
			day = day.selectedIndex+1;

			if (weekday_showing) dayofWeek.selectedIndex = getWeekDay(mth,day,yr);
		}
}

function numDaysIn(mth,yr) {
	if (mth==3 || mth==5 || mth==8 || mth==10) return 30;
	else if ((mth==1) && leapYear(yr)) return 29;
	else if (mth==1) return 28;
	else return 31;
}

function leapYear(yr) {
	if (((yr % 4 == 0) && yr % 100 != 0) || yr % 400 == 0)
		return true;
	else
		return false;
}

function arr() {
	this.length=arr.arguments.length;
	for (n=0;n<arr.arguments.length;n++) {
		this[n] = arr.arguments[n];
	}
}

function getWeekDay(mth,day,yr) {
	first_day = firstDayOfYear(yr);
	for (num=0;num<mth;num++) {
		first_day += numDaysIn(num,yr);
	}
	first_day += day-1;
	return first_day%7;
}

function firstDayOfYear(yr) {
	diff = yr - 401;
	return parseInt((1 + diff + (diff / 4) - (diff / 100) + (diff / 400)) % 7);
}

// fixes a Netscape 2 and 3 bug
function getFullYear(d) { // d is a date object
	yr = d.getYear();
	if (yr < 1000)
	yr+=1900;
	return yr;
}

function DisplayDateInputCbo(cboName,returnString) {
var str=""
// Used to display date in a valid format
	if (weekday_showing) {
		str+="<select name=" + cboName + "dayofweek size=1>"
		for (i=0;i<7;i++){
			str+="<option"+(dayofweek_returned_as_number?" value="+i:"")+(cur.getDay()==i?" selected":"")+">"+weekdays[i]+"\n"
		}
		str+="</select>"
	}

	// write month element
	str+="<select class='listBorders' name=" + cboName + "month id=" + cboName + "month onChange='changeDays(0,this.form,this)' size=1>"
	for (i=0;i<12;i++){
		str+="<option"+(month_returned_as_number?" value="+i:"")+(cur.getMonth()==i?" selected":"")+">"+months[i]+"</option>\n"
	}
	// write day element
	str+="</select><select class='listBorders' name=" + cboName +"day id=" + cboName +"day size=1 onChange='changeDays(0,this.form,this)'>\n"
	for (i=1;i<=numDaysIn(cur.getMonth(),getFullYear(cur));i++){
		str+="<option"+(cur.getDate()==i?" selected":"")+ " value="+i+">"+i+"</option>\n"
	}
	// write year element
	str+="</select><select class='listBorders' name=" + cboName + "year id=" + cboName + "year onChange='changeDays(0,this.form,this)' size=1>\n"
	for (i=min_year;i<max_year;i++){
		str+="<option"+(getFullYear(cur)==i?" selected":"")+ " value="+i+">"+i+"</option>\n"
	}
	str+="</select>"
	
	if(!returnString){document.write(str)}else{return str}
}
// **																							   **
// ****************** Date routine ******************************************************************
function showForm(SchemeID,schemeTypeName){//,reselect) {//if (confirm("Debug?")){x}
	var i;
	var j;
	if (SchemeID=='') return
	if (document.getElementById('quotedeclaration')) {document.getElementById('quotedeclaration').style.display='none'}
	if (document.getElementById('quotedetail')) {document.getElementById('quotedetail').style.display='none'}
	if (document.getElementById('quotepayment')) {document.getElementById('quotepayment').style.display='none'}

/*if(reselect){
	alert("different scheme type selected by user")
	document.getElementById("SchemeSelected").value=SchemeID
}else{
	alert("read schemeid from page and set schemeid to use")
	if(document.getElementById("SchemeSelected").value!=''){SchemeID=document.getElementById("SchemeSelected").value}
}*/
//alert("showForm: showing scheme "+SchemeID+" "+schemeTypeName)
	if (SchemeID=='ERROR'){
		document.getElementById('quoteERROR').style.display='inline'
		return 
	}
	if(SchemeID==-1 && schemeTypeName=='quotepayment'){	
	//alert("payment display")
		document.getElementById('quotepayment').style.display='inline'
	//alert(document.getElementById('quotepayment').style.display)
		return 
	}
	if (SchemeID != '-1') {
		if (document.getElementById('PolicyCertificate')) {
			document.getElementById('PolicyCertificate').style.display = 'none'
		}
		if(document.getElementById('CurrentQuoteFrame')){
			if(document.getElementById(document.getElementById('CurrentQuoteFrame').value)){
				document.getElementById(document.getElementById('CurrentQuoteFrame').value).style.display = 'none'
			}
			//this element may not exist (if no tabs)
			try{document.getElementById('lftNavOff-1').className = 'lftNavOff'}catch(e){}
		}
	}
//		if (SchemeID > 0) {
//			document.getElementById('eMailQuote'+SchemeID).value = document.getElementById('eMailQuote').value
//			}
	var quotedivs = document.getElementsByTagName('div')
	for (i = 0; i < quotedivs.length; i++) {
		if(quotedivs[i].getAttribute("name")){
			if(quotedivs[i].getAttribute("name") == 'quotediv'){
//alert("showform:"+quotedivs[i].getAttribute("id"))
				var thisScheme = quotedivs[i].getAttribute("id").substr(5) //id is "quote" + schemeID
				if(thisScheme==SchemeID){
//alert("showForm1:"+thisScheme)
					if(quotedivs[i].innerHTML.length==0){
//alert("showForm1a:populate div '"+quotedivs[i].getAttribute("id")+"' with scheme '"+SchemeID+"' "+schemeTypeName)
						populateQuoteDiv(quotedivs[i],SchemeID,schemeTypeName)
//alert("showForm1b:"+thisScheme)
					}
//alert("showForm2:"+thisScheme +" 117Class="+document.getElementById('lftNavOff117').style.zIndex)
					//this element may not exist (if no tabs)
					try{document.getElementById('lftNavOff'+thisScheme).className = 'lftNavOn'}catch(e){}
//alert("showForm2a:"+thisScheme +" 117Class="+document.getElementById('lftNavOff117').style.zIndex )
					document.getElementById('quote'+thisScheme).style.display='inline'
//alert("showForm3" )
//alert("showForm3:"+thisScheme)
					}
				else {
//alert("hiding div:"+thisScheme)
					document.getElementById('quote'+thisScheme).style.display='none'
//if(thisScheme==117){alert("hidden golf div")}
					if (thisScheme == 0 ) {
						var imgs = document.getElementsByName('quoteimage')
						for (j = 0; j < imgs.length; j++) {
							imgs[j].style.visibility='hidden'
						}
					}else {
//alert("changing tab:"+thisScheme)
						//this element may not exist (if no tabs)
						try{document.getElementById('lftNavOff'+thisScheme).className = 'lftNavOff'}catch(e){}
//if(thisScheme==117){alert("changed golf tab")}
					}
				}		
			}
		}
	}
	if (SchemeID == '-1') {
		document.getElementById(document.getElementById('CurrentQuoteFrame').value).style.display = 'inline'
		try{document.getElementById("lftNavOff-1").className='lftNavOn'}catch(e){}
	}
}

function closeForm(SchemeID) {
		document.getElementById('quote'+SchemeID).style.visibility='hidden'
		}
		
function Premium() {
	if (document.getElementById('XSWaiver').value == 'Y') {
		document.getElementById('PayPremium').value = document.getElementById('PremiumIncXS').value
		document.getElementById('PayIPT').value = document.getElementById('IPTIncXS').value
		}
	else {
		document.getElementById('PayPremium').value = document.getElementById('Premium').value
		document.getElementById('PayIPT').value = document.getElementById('IPT').value
		}
	return true;
	}	

function SetTotal(XS) {
	var premiumdivs = document.getElementsByName('divPayPremium')
	var i
	if (XS == 'Y') 
	{
		document.getElementById('XSWaiver').value = 'Y'
		document.getElementById('divIncEx').innerHTML = 'Including '
		//document.getElementById('iptQuote').innerHTML = document.getElementById('IPTIncXS').value + ' Included Above'
		document.getElementById('PayPremium').value = document.getElementById('PremiumIncXS').value
		document.getElementById('PayIPT').value = document.getElementById('IPTIncXS').value
		document.getElementById("divQuoteIPT").innerHTML = document.getElementById('IPTIncXS').value
		for (i = 0; i < premiumdivs.length; i++) 
		{
			premiumdivs[i].innerHTML = document.getElementById('PremiumIncXS').value			
		}
		if(document.getElementById('divAlternativePremium'))
		{
			document.getElementById('divAlternativePremium').innerHTML = document.getElementById('AlternativePremiumIncXS').value
		}
	}else{
		document.getElementById('XSWaiver').value = 'N'
		document.getElementById('divIncEx').innerHTML = 'Excluding '
		//document.getElementById('iptQuote').innerHTML = document.getElementById('IPT').value + ' Included Above'		
		document.getElementById('PayPremium').value = document.getElementById('Premium').value
		document.getElementById('PayIPT').value = document.getElementById('IPT').value
		document.getElementById("divQuoteIPT").innerHTML = document.getElementById('IPT').value
		for (i = 0; i < premiumdivs.length; i++) 
		{
			premiumdivs[i].innerHTML = document.getElementById('Premium').value
		}
		if(document.getElementById('divAlternativePremium'))
		{
			document.getElementById('divAlternativePremium').innerHTML = document.getElementById('AlternativePremium').value
		}
	}
}

function redisplay(type) {
	var action=''
	var theForm = document.getElementById('quoteform')
	switch(type) {
		case 'Policy':
			action = '?ID=4';
			break
		case 'Quote':
			action = '?ID=5';
			break
	}
	var qs = new Querystring()
	var schemetype= qs.get("st","")
	if(schemetype!=''){action+="&st="+schemetype}
	qs=null
	theForm.action = action	
	theForm.submit()
	}
function populateQuoteDiv(div,schemeID,schemeTypeName){//if (confirm("Debug?")){x}
	var xmlInitial
	var xmlStyle
	var style
	var qeUrl
	var cookieage = 31
	var initialRequest = document.getElementById("InitialRequest").value
	var affiliateRef = document.getElementById("InitialAffiliate").value
	var overAgeLabel = document.getElementById("OverAgeLabel").value
	var overAgeLink = document.getElementById("OverAgeLink").value
	var subdomain = document.getElementById("ConfigSubdomain").value
	var advert = document.getElementById("QueryStringAdvert").value //query string advert
	var ageInputMethod = document.getElementById("AgeInputMethod").value
	var siteagentguid = document.getElementById("SiteAgentGUID").value
	var wideScreen = document.getElementById("WideScreen").value
/* ASP cannot create cookies with underscores in their name. Home pages of sites that do not have QE on them 
   need to drop advertid cookie otherwise it is lost
   if(advert.length==0) {
		var qs = new Querystring(document.referrer.split('?')[1])
		advert = qs.get("advertid",QEgetCookie(document.location.hostname+'_advertid'))
		if(advert==null) advert=''
	}
	QEsetCookie( document.location.hostname+'_advertid', advert, cookieage, '/', '', '' ) 		
*/
	if(advert.length==0) {
		//this is an advert id dumped onto a page by an affiliate landing page e.g. Go/180mk via go cookie
		if(document.getElementById("advertid")){advert = document.getElementById("advertid").value}
		
		if(advert.length==0) {
			var qs = new Querystring(document.referrer.split('?')[1])
			var existingCookie = QEgetCookie(document.location.hostname+'advertid')
if(existingCookie==null){existingCookie=QEgetCookie('advertid')}
			if(existingCookie==null){//backwards compatability
				existingCookie = QEgetCookie(document.location.hostname+'_advertid')
			}else{ 
				if(existingCookie.length==0){existingCookie = QEgetCookie(document.location.hostname+'_advertid')} //backwards compatability
			}
			//get advertid from querystring. if it doesnt exist use the cookie value 
			advert = qs.get("advertid",existingCookie)
			if(advert==null) advert=''
		}
	}
	QEsetCookie( document.location.hostname+'advertid', advert, cookieage, '/', '', '' ) 		
	QEsetCookie( 'advertid', advert, cookieage, '/', '', '' ) 		

	try{
		var quoteExtra = document.getElementById("QuoteExtra").value
	}catch(e){	var quoteExtra = 'N'}
	var initial
	var url_root
	var page_name
	var today=new Date()

//McM Apr2007 - always use QE defined in config file. This overcomes x-domain post errors in IE7 (and simplifies QE posting)
//	//set QE url. if this is the first time the QE has been accessed; use the InitialQEUrl (derived from config file)
//	//otherwise use @url from previous calls to QE (stored on page as QEUrl)
	qeUrl = document.getElementById("InitialQEUrl").value
//display loading div
	showLoading(true)
	//delay to allow screen to render
	setTimeout(function(){
		try{
//alert("PQD1:"+initialRequest)
			xmlInitial = createDom()
			if(xmlInitial){
				initial=jsPost(initialRequest,qeUrl)
				if(initial){
					//use serverside transform as some browsers (Safari) cannot do client side
//alert("PQD2:"+initial)
					var schemeFormURL = assembleSchemeFormURL(schemeID,affiliateRef,today.getDate(),months[today.getMonth()],today.getFullYear(),dNumDaysIn(today.getMonth(),today.getFullYear()),overAgeLabel,overAgeLink,advert,quoteExtra,subdomain,ageInputMethod,siteagentguid,wideScreen)
//alert("PQD3:"+schemeFormURL)
					showLoading(false)
					var divHtml = jsPost(initial,schemeFormURL)
//alert("PQD4:"+divHtml)
					div.innerHTML = divHtml //"<textarea>"+initial +"      "+schemeFormURL+"</textarea>" // 
					return
				}
			}
		}
		catch(err){
			alert(err.message)
		}
		//hide loading div
		showLoading(false)
	},1)
}
function showLoading(state){
	document.getElementById("loading").style.display=(state==true?"inline":"none")
	document.getElementById("loading").style.zIndex=(state==true?"99":"0")
}
function openCertWindow(source) {
new_window = open("","CertificateWindow","width=800,height=800,left=10,top=10,toolbar=yes,menubar=yes,scrollbars=yes;resizable=yes");
new_window.document.open();
new_window.document.write(HtmlDecode(document.getElementById(source).innerHTML.replace(/<Certificate>/i,"").replace(/<\/Certificate>/i,"")));
new_window.document.close(); 
}
// HtmlDecode http://lab.msdn.microsoft.com/annotations/htmldecode.js 
//   client side version of the useful Server.HtmlDecode method 
//   takes one string (encoded) and returns another (decoded) 
function HtmlDecode(s){ 
	var out = ""; 
	if (s==null) return; 
	var l = s.length; 
	for (var i=0; i<l; i++) 
	{ 
		var ch = s.charAt(i); 
		if (ch == '&'){ 
			var semicolonIndex = s.indexOf(';', i+1); 
			if (semicolonIndex > 0){ 
				var entity = s.substring(i + 1, semicolonIndex); 
				if (entity.length > 1 && entity.charAt(0) == '#'){ 
					if (entity.charAt(1) == 'x' || entity.charAt(1) == 'X') 
						ch = String.fromCharCode(eval('0'+entity.substring(1))); 
					else 
						ch = String.fromCharCode(eval(entity.substring(1))); 
				}else{ 
					switch (entity){ 
						case 'quot': ch = String.fromCharCode(0x0022); break; 
						case 'amp': ch = String.fromCharCode(0x0026); break; 
						case 'lt': ch = String.fromCharCode(0x003c); break; 
						case 'gt': ch = String.fromCharCode(0x003e); break; 
						case 'nbsp': ch = String.fromCharCode(0x00a0); break; 
						case 'iexcl': ch = String.fromCharCode(0x00a1); break; 
						case 'cent': ch = String.fromCharCode(0x00a2); break; 
						case 'pound': ch = String.fromCharCode(0x00a3); break; 
						case 'curren': ch = String.fromCharCode(0x00a4); break; 
						case 'yen': ch = String.fromCharCode(0x00a5); break; 
						case 'brvbar': ch = String.fromCharCode(0x00a6); break; 
						case 'sect': ch = String.fromCharCode(0x00a7); break; 
						case 'uml': ch = String.fromCharCode(0x00a8); break; 
						case 'copy': ch = String.fromCharCode(0x00a9); break; 
						case 'ordf': ch = String.fromCharCode(0x00aa); break; 
						case 'laquo': ch = String.fromCharCode(0x00ab); break; 
						case 'not': ch = String.fromCharCode(0x00ac); break; 
						case 'shy': ch = String.fromCharCode(0x00ad); break; 
						case 'reg': ch = String.fromCharCode(0x00ae); break; 
						case 'macr': ch = String.fromCharCode(0x00af); break; 
						case 'deg': ch = String.fromCharCode(0x00b0); break; 
						case 'plusmn': ch = String.fromCharCode(0x00b1); break; 
						case 'sup2': ch = String.fromCharCode(0x00b2); break; 
						case 'sup3': ch = String.fromCharCode(0x00b3); break; 
						case 'acute': ch = String.fromCharCode(0x00b4); break; 
						case 'micro': ch = String.fromCharCode(0x00b5); break; 
						case 'para': ch = String.fromCharCode(0x00b6); break; 
						case 'middot': ch = String.fromCharCode(0x00b7); break; 
						case 'cedil': ch = String.fromCharCode(0x00b8); break; 
						case 'sup1': ch = String.fromCharCode(0x00b9); break; 
						case 'ordm': ch = String.fromCharCode(0x00ba); break; 
						case 'raquo': ch = String.fromCharCode(0x00bb); break; 
						case 'frac14': ch = String.fromCharCode(0x00bc); break; 
						case 'frac12': ch = String.fromCharCode(0x00bd); break; 
						case 'frac34': ch = String.fromCharCode(0x00be); break; 
						case 'iquest': ch = String.fromCharCode(0x00bf); break; 
						case 'Agrave': ch = String.fromCharCode(0x00c0); break; 
						case 'Aacute': ch = String.fromCharCode(0x00c1); break; 
						case 'Acirc': ch = String.fromCharCode(0x00c2); break; 
						case 'Atilde': ch = String.fromCharCode(0x00c3); break; 
						case 'Auml': ch = String.fromCharCode(0x00c4); break; 
						case 'Aring': ch = String.fromCharCode(0x00c5); break; 
						case 'AElig': ch = String.fromCharCode(0x00c6); break; 
						case 'Ccedil': ch = String.fromCharCode(0x00c7); break; 
						case 'Egrave': ch = String.fromCharCode(0x00c8); break; 
						case 'Eacute': ch = String.fromCharCode(0x00c9); break; 
						case 'Ecirc': ch = String.fromCharCode(0x00ca); break; 
						case 'Euml': ch = String.fromCharCode(0x00cb); break; 
						case 'Igrave': ch = String.fromCharCode(0x00cc); break; 
						case 'Iacute': ch = String.fromCharCode(0x00cd); break; 
						case 'Icirc': ch = String.fromCharCode(0x00ce ); break; 
						case 'Iuml': ch = String.fromCharCode(0x00cf); break; 
						case 'ETH': ch = String.fromCharCode(0x00d0); break; 
						case 'Ntilde': ch = String.fromCharCode(0x00d1); break; 
						case 'Ograve': ch = String.fromCharCode(0x00d2); break; 
						case 'Oacute': ch = String.fromCharCode(0x00d3); break; 
						case 'Ocirc': ch = String.fromCharCode(0x00d4); break; 
						case 'Otilde': ch = String.fromCharCode(0x00d5); break; 
						case 'Ouml': ch = String.fromCharCode(0x00d6); break; 
						case 'times': ch = String.fromCharCode(0x00d7); break; 
						case 'Oslash': ch = String.fromCharCode(0x00d8); break; 
						case 'Ugrave': ch = String.fromCharCode(0x00d9); break; 
						case 'Uacute': ch = String.fromCharCode(0x00da); break; 
						case 'Ucirc': ch = String.fromCharCode(0x00db); break; 
						case 'Uuml': ch = String.fromCharCode(0x00dc); break; 
						case 'Yacute': ch = String.fromCharCode(0x00dd); break; 
						case 'THORN': ch = String.fromCharCode(0x00de); break; 
						case 'szlig': ch = String.fromCharCode(0x00df); break; 
						case 'agrave': ch = String.fromCharCode(0x00e0); break; 
						case 'aacute': ch = String.fromCharCode(0x00e1); break; 
						case 'acirc': ch = String.fromCharCode(0x00e2); break; 
						case 'atilde': ch = String.fromCharCode(0x00e3); break; 
						case 'auml': ch = String.fromCharCode(0x00e4); break; 
						case 'aring': ch = String.fromCharCode(0x00e5); break; 
						case 'aelig': ch = String.fromCharCode(0x00e6); break; 
						case 'ccedil': ch = String.fromCharCode(0x00e7); break; 
						case 'egrave': ch = String.fromCharCode(0x00e8); break; 
						case 'eacute': ch = String.fromCharCode(0x00e9); break; 
						case 'ecirc': ch = String.fromCharCode(0x00ea); break; 
						case 'euml': ch = String.fromCharCode(0x00eb); break; 
						case 'igrave': ch = String.fromCharCode(0x00ec); break; 
						case 'iacute': ch = String.fromCharCode(0x00ed); break; 
						case 'icirc': ch = String.fromCharCode(0x00ee); break; 
						case 'iuml': ch = String.fromCharCode(0x00ef); break; 
						case 'eth': ch = String.fromCharCode(0x00f0); break; 
						case 'ntilde': ch = String.fromCharCode(0x00f1); break; 
						case 'ograve': ch = String.fromCharCode(0x00f2); break; 
						case 'oacute': ch = String.fromCharCode(0x00f3); break; 
						case 'ocirc': ch = String.fromCharCode(0x00f4); break; 
						case 'otilde': ch = String.fromCharCode(0x00f5); break; 
						case 'ouml': ch = String.fromCharCode(0x00f6); break; 
						case 'divide': ch = String.fromCharCode(0x00f7); break; 
						case 'oslash': ch = String.fromCharCode(0x00f8); break; 
						case 'ugrave': ch = String.fromCharCode(0x00f9); break; 
						case 'uacute': ch = String.fromCharCode(0x00fa); break; 
						case 'ucirc': ch = String.fromCharCode(0x00fb); break; 
						case 'uuml': ch = String.fromCharCode(0x00fc); break; 
						case 'yacute': ch = String.fromCharCode(0x00fd); break; 
						case 'thorn': ch = String.fromCharCode(0x00fe); break; 
						case 'yuml': ch = String.fromCharCode(0x00ff); break; 
						case 'OElig': ch = String.fromCharCode(0x0152); break; 
						case 'oelig': ch = String.fromCharCode(0x0153); break; 
						case 'Scaron': ch = String.fromCharCode(0x0160); break; 
						case 'scaron': ch = String.fromCharCode(0x0161); break; 
						case 'Yuml': ch = String.fromCharCode(0x0178); break; 
						case 'fnof': ch = String.fromCharCode(0x0192); break; 
						case 'circ': ch = String.fromCharCode(0x02c6); break; 
						case 'tilde': ch = String.fromCharCode(0x02dc); break; 
						case 'Alpha': ch = String.fromCharCode(0x0391); break; 
						case 'Beta': ch = String.fromCharCode(0x0392); break; 
						case 'Gamma': ch = String.fromCharCode(0x0393); break; 
						case 'Delta': ch = String.fromCharCode(0x0394); break; 
						case 'Epsilon': ch = String.fromCharCode(0x0395); break; 
						case 'Zeta': ch = String.fromCharCode(0x0396); break; 
						case 'Eta': ch = String.fromCharCode(0x0397); break; 
						case 'Theta': ch = String.fromCharCode(0x0398); break; 
						case 'Iota': ch = String.fromCharCode(0x0399); break; 
						case 'Kappa': ch = String.fromCharCode(0x039a); break; 
						case 'Lambda': ch = String.fromCharCode(0x039b); break; 
						case 'Mu': ch = String.fromCharCode(0x039c); break; 
						case 'Nu': ch = String.fromCharCode(0x039d); break; 
						case 'Xi': ch = String.fromCharCode(0x039e); break; 
						case 'Omicron': ch = String.fromCharCode(0x039f); break; 
						case 'Pi': ch = String.fromCharCode(0x03a0); break; 
						case ' Rho ': ch = String.fromCharCode(0x03a1); break; 
						case 'Sigma': ch = String.fromCharCode(0x03a3); break; 
						case 'Tau': ch = String.fromCharCode(0x03a4); break; 
						case 'Upsilon': ch = String.fromCharCode(0x03a5); break; 
						case 'Phi': ch = String.fromCharCode(0x03a6); break; 
						case 'Chi': ch = String.fromCharCode(0x03a7); break; 
						case 'Psi': ch = String.fromCharCode(0x03a8); break; 
						case 'Omega': ch = String.fromCharCode(0x03a9); break; 
						case 'alpha': ch = String.fromCharCode(0x03b1); break; 
						case 'beta': ch = String.fromCharCode(0x03b2); break; 
						case 'gamma': ch = String.fromCharCode(0x03b3); break; 
						case 'delta': ch = String.fromCharCode(0x03b4); break; 
						case 'epsilon': ch = String.fromCharCode(0x03b5); break; 
						case 'zeta': ch = String.fromCharCode(0x03b6); break; 
						case 'eta': ch = String.fromCharCode(0x03b7); break; 
						case 'theta': ch = String.fromCharCode(0x03b8); break; 
						case 'iota': ch = String.fromCharCode(0x03b9); break; 
						case 'kappa': ch = String.fromCharCode(0x03ba); break; 
						case 'lambda': ch = String.fromCharCode(0x03bb); break; 
						case 'mu': ch = String.fromCharCode(0x03bc); break; 
						case 'nu': ch = String.fromCharCode(0x03bd); break; 
						case 'xi': ch = String.fromCharCode(0x03be); break; 
						case 'omicron': ch = String.fromCharCode(0x03bf); break; 
						case 'pi': ch = String.fromCharCode(0x03c0); break; 
						case 'rho': ch = String.fromCharCode(0x03c1); break; 
						case 'sigmaf': ch = String.fromCharCode(0x03c2); break; 
						case 'sigma': ch = String.fromCharCode(0x03c3); break; 
						case 'tau': ch = String.fromCharCode(0x03c4); break; 
						case 'upsilon': ch = String.fromCharCode(0x03c5); break; 
						case 'phi': ch = String.fromCharCode(0x03c6); break; 
						case 'chi': ch = String.fromCharCode(0x03c7); break; 
						case 'psi': ch = String.fromCharCode(0x03c8); break; 
						case 'omega': ch = String.fromCharCode(0x03c9); break; 
						case 'thetasym': ch = String.fromCharCode(0x03d1); break; 
						case 'upsih': ch = String.fromCharCode(0x03d2); break; 
						case 'piv': ch = String.fromCharCode(0x03d6); break; 
						case 'ensp': ch = String.fromCharCode(0x2002); break; 
						case 'emsp': ch = String.fromCharCode(0x2003); break; 
						case 'thinsp': ch = String.fromCharCode(0x2009); break; 
						case 'zwnj': ch = String.fromCharCode(0x200c); break; 
						case 'zwj': ch = String.fromCharCode(0x200d); break; 
						case 'lrm': ch = String.fromCharCode(0x200e); break; 
						case 'rlm': ch = String.fromCharCode(0x200f); break; 
						case 'ndash': ch = String.fromCharCode(0x2013); break; 
						case 'mdash': ch = String.fromCharCode(0x2014); break; 
						case 'lsquo': ch = String.fromCharCode(0x2018); break; 
						case 'rsquo': ch = String.fromCharCode(0x2019); break; 
						case 'sbquo': ch = String.fromCharCode(0x201a); break; 
						case 'ldquo': ch = String.fromCharCode(0x201c); break; 
						case 'rdquo': ch = String.fromCharCode(0x201d); break; 
						case 'bdquo': ch = String.fromCharCode(0x201e); break; 
						case 'dagger': ch = String.fromCharCode(0x2020); break; 
						case 'Dagger': ch = String.fromCharCode(0x2021); break; 
						case 'bull': ch = String.fromCharCode(0x2022); break; 
						case 'hellip': ch = String.fromCharCode(0x2026); break; 
						case 'permil': ch = String.fromCharCode(0x2030); break; 
						case 'prime': ch = String.fromCharCode(0x2032); break; 
						case 'Prime': ch = String.fromCharCode(0x2033); break; 
						case 'lsaquo': ch = String.fromCharCode(0x2039); break; 
						case 'rsaquo': ch = String.fromCharCode(0x203a); break; 
						case 'oline': ch = String.fromCharCode(0x203e); break; 
						case 'frasl': ch = String.fromCharCode(0x2044); break; 
						case 'euro': ch = String.fromCharCode(0x20ac); break; 
						case 'image': ch = String.fromCharCode(0x2111); break; 
						case 'weierp': ch = String.fromCharCode(0x2118); break; 
						case 'real': ch = String.fromCharCode(0x211c); break; 
						case 'trade': ch = String.fromCharCode(0x2122); break; 
						case 'alefsym': ch = String.fromCharCode(0x2135); break; 
						case 'larr': ch = String.fromCharCode(0x2190); break; 
						case 'uarr': ch = String.fromCharCode(0x2191); break; 
						case 'rarr': ch = String.fromCharCode(0x2192); break; 
						case 'darr': ch = String.fromCharCode(0x2193); break; 
						case 'harr': ch = String.fromCharCode(0x2194); break; 
						case 'crarr': ch = String.fromCharCode(0x21b5); break; 
						case 'lArr': ch = String.fromCharCode(0x21d0); break; 
						case 'uArr': ch = String.fromCharCode(0x21d1); break; 
						case 'rArr': ch = String.fromCharCode(0x21d2); break; 
						case 'dArr': ch = String.fromCharCode(0x21d3); break; 
						case 'hArr': ch = String.fromCharCode(0x21d4); break; 
						case 'forall': ch = String.fromCharCode(0x2200); break; 
						case 'part': ch = String.fromCharCode(0x2202); break; 
						case 'exist': ch = String.fromCharCode(0x2203); break; 
						case 'empty': ch = String.fromCharCode(0x2205); break; 
						case 'nabla': ch = String.fromCharCode(0x2207); break; 
						case 'isin': ch = String.fromCharCode(0x2208); break; 
						case 'notin': ch = String.fromCharCode(0x2209); break; 
						case 'ni': ch = String.fromCharCode(0x220b); break; 
						case 'prod': ch = String.fromCharCode(0x220f); break; 
						case 'sum': ch = String.fromCharCode(0x2211); break; 
						case 'minus': ch = String.fromCharCode(0x2212); break; 
						case 'lowast': ch = String.fromCharCode(0x2217); break; 
						case 'radic': ch = String.fromCharCode(0x221a); break; 
						case 'prop': ch = String.fromCharCode(0x221d); break; 
						case 'infin': ch = String.fromCharCode(0x221e); break; 
						case 'ang': ch = String.fromCharCode(0x2220); break; 
						case 'and': ch = String.fromCharCode(0x2227); break; 
						case 'or': ch = String.fromCharCode(0x2228); break; 
						case 'cap': ch = String.fromCharCode(0x2229); break; 
						case 'cup': ch = String.fromCharCode(0x222a); break; 
						case 'int': ch = String.fromCharCode(0x222b); break; 
						case 'there4': ch = String.fromCharCode(0x2234); break; 
						case 'sim': ch = String.fromCharCode(0x223c); break; 
						case 'cong': ch = String.fromCharCode(0x2245); break; 
						case 'asymp': ch = String.fromCharCode(0x2248); break; 
						case 'ne': ch = String.fromCharCode(0x2260); break; 
						case 'equiv': ch = String.fromCharCode(0x2261); break; 
						case 'le': ch = String.fromCharCode(0x2264); break; 
						case 'ge': ch = String.fromCharCode(0x2265); break; 
						case 'sub': ch = String.fromCharCode(0x2282); break; 
						case 'sup': ch = String.fromCharCode(0x2283); break; 
						case 'nsub': ch = String.fromCharCode(0x2284); break; 
						case 'sube': ch = String.fromCharCode(0x2286); break; 
						case 'supe': ch = String.fromCharCode(0x2287); break; 
						case 'oplus': ch = String.fromCharCode(0x2295); break; 
						case 'otimes': ch = String.fromCharCode(0x2297); break; 
						case 'perp': ch = String.fromCharCode(0x22a5); break; 
						case 'sdot': ch = String.fromCharCode(0x22c5); break; 
						case 'lceil': ch = String.fromCharCode(0x2308); break; 
						case 'rceil': ch = String.fromCharCode(0x2309); break; 
						case 'lfloor': ch = String.fromCharCode(0x230a); break; 
						case 'rfloor': ch = String.fromCharCode(0x230b); break; 
						case 'lang': ch = String.fromCharCode(0x2329); break; 
						case 'rang': ch = String.fromCharCode(0x232a); break; 
						case 'loz': ch = String.fromCharCode(0x25ca); break; 
						case 'spades': ch = String.fromCharCode(0x2660); break; 
						case 'clubs': ch = String.fromCharCode(0x2663); break; 
						case 'hearts': ch = String.fromCharCode(0x2665); break; 
						case 'diams': ch = String.fromCharCode(0x2666); break; 
						default: ch = ''; break; 
					} 
				} 
				i = semicolonIndex; 
			} 
		} 
		out += ch; 
	} 
	return out; 
} 

//DHTML Window script- Copyright Dynamic Drive (http://www.dynamicdrive.com)
//For full source code, documentation, and terms of usage,
//Visit http://www.dynamicdrive.com/dynamicindex9/dhtmlwindow.htm

var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function drag_drop(e){
if (ie5&&dragapproved&&event.button==1){
document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
}
}

function initializedrag(e){
offsetx=ie5? event.clientX : e.clientX
offsety=ie5? event.clientY : e.clientY
document.getElementById("dwindowcontent").style.display="none" //extra
tempx=parseInt(document.getElementById("dwindow").style.left)
tempy=parseInt(document.getElementById("dwindow").style.top)

dragapproved=true
document.getElementById("dwindow").onmousemove=drag_drop
document.getElementById("dwindow").onmouseout=stopdrag
}

function dynamicwindow(url,width,height){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
document.getElementById("dwindow").style.display=''
document.getElementById("dwindow").style.width=initialwidth=width+"px"
document.getElementById("dwindow").style.height=initialheight=height+"px"
document.getElementById("dwindow").style.left="30px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
document.getElementById("cframe").src=url
}
}
function maximize(){
if (minrestore==0){
minrestore=1 //maximize window
document.getElementById("maxname").setAttribute("src","/assets/restore.gif")
document.getElementById("dwindow").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
document.getElementById("dwindow").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
}
else{
minrestore=0 //restore window
document.getElementById("maxname").setAttribute("src","/assets/max.gif")
document.getElementById("dwindow").style.width=initialwidth
document.getElementById("dwindow").style.height=initialheight
}
document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}

function closeit(){
document.getElementById("dwindow").style.display="none"
}

function stopdrag(){
dragapproved=false;
document.getElementById("dwindow").onmousemove=null;
document.getElementById("dwindow").onmouseout=null;
document.getElementById("dwindowcontent").style.display="" //extra
}
function printdynamicwindow(){ 
var frame = document.getElementById("cframe")//(ie5?document.cframe:window.frames['cframe'])
frame.contentWindow.focus(); 
frame.contentWindow.document.print(); 
} 

function getFormVariables(form){
    var formvars='';
	var childElements=form.childNodes;
	for(var i=0;i<childElements.length;i++){
		try{
			var name=childElements[i].getAttribute('name')
			var value=childElements[i].getAttribute('value')
			switch(childElements[i].tagName.toLowerCase()){
				case 'input': case 'textarea': case 'select':
					formvars+=name
					formvars+='='
					formvars+=value
					formvars+='&'
					break
				default:
			}
		}catch(e){}
    }
    formvars=formvars.substring(0,formvars.length-1);
    return formvars;
}

function openSchemeInformation(url,ctl,defaultType){
	var parm = 's='
	if(document.getElementById(ctl)){
		//get scheme type from drop down control
		parm += document.getElementById(ctl).options[document.getElementById(ctl).selectedIndex].text
	}else{
		//use scheme type passed as parameter
		parm += defaultType
	}
	MM_openBrWindow(url+'?'+parm,'Information','scrollbars=yes,width=600,height=600')
}
function IncludeTracking(schemetype, action, cost, reference){
	var url='insurerinfo/tracking/'
	if(action=='home')
		url+='homepage'
	else{
		url+=schemetype
		url+='_'
		url+=action
	}
	url+='html'
	var html=getFile(url)
	html=html.replace('%%PREMIUM%%',cost)
	html=html.replace('%%REFERENCE%%',reference)
	document.write (html)
}
function getFile(url){
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (req != undefined) {
		req.open("GET", url, false);
		req.send("");
		if (req.readyState == 4 && req.status == 200) { // only if "OK"
			return req.responseText
		}else{
			return ''
		}
	}else{
		return '<!--QE Cannot create http object-->'
	}
}
function includeFile(url, target,otherwise, bAsynch) {
	var includeURL = url
	var includeTARGET = target
	var includeOTHERWISE = otherwise
	var includeASYNCH = bAsynch==null?false:bAsynch
	if(document.getElementById(includeTARGET)) document.getElementById(includeTARGET).innerHTML = ' Fetching '+ url 
	if (includeOTHERWISE==null) includeOTHERWISE=''
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (req != undefined) {
		if(includeASYNCH) req.onreadystatechange = function() {ahahDone(includeURL, includeTARGET,includeOTHERWISE);};
		req.open("GET", includeURL, includeASYNCH);
		req.send("");
		if(!includeASYNCH){
			if (req.readyState == 4 && req.status == 200) { // only if "OK"
				document.getElementById(includeTARGET).innerHTML = req.responseText
			}else{
				document.getElementById(includeTARGET).innerHTML = otherwise
			}
		}
	}else{
		if(document.getElementById(includeTARGET)) document.getElementById(includeTARGET).innerHTML = otherwise
	}
}  

function ahahDone(url, target,otherwise){
	if (req.readyState == 4) { // only if req is "loaded"
 		if (req.status == 200) { // only if "OK"
			document.getElementById(target).innerHTML = req.responseText	
		} else {
			if(document.getElementById(target)){
				if(otherwise!=null){
					document.getElementById(target).innerHTML = req.status+' '+url + otherwise
				}else{
					document.getElementById(target).innerHTML+=req.status+' '+url
				}
			}
		}
	}
}
function goBack(){
	var referrer=document.referrer
	if(referrer.length==0){
		history.go(-1)
	}else{
		var url = referrer.split('?')
		var backUrl=url[0]+'?st='+document.getElementById("QuoteSchemeType").value
		//copy rest of qs
		try{
			var qs = url[1].split('&')
			for(var i=0;i<qs.length;i++){if(qs[i].split('=')[0]!='st')backUrl+='&'+qs[i]}
		}catch(e){}
		location.href=backUrl
	}
}
function whichForm(selectedSchemeID,schemeTypeName){
	//IE6,IE7 and FF all behave differently when going back to previous page
	//Use st value in querystring to identify scheme to be displayed and set 
	//dropdown list and form to show correctly
//alert("whichForm")
	if(document.getElementById("PolicyType")){
		var qs = new Querystring()
		var qsSchemeType= qs.get("st","")

		if(qsSchemeType.length==0){
			showForm(document.getElementById("PolicyType")[document.getElementById("PolicyType").selectedIndex].value,schemeTypeName)
		}else{
			for(var i=0;i<document.getElementById("PolicyType").length;i++){
				if(document.getElementById("PolicyType").options[i].text==qsSchemeType){
					//set dropdown value
					document.getElementById("PolicyType").selectedIndex=i
					//show correct form
					showForm(document.getElementById("PolicyType")[i].value,qsSchemeType)
					break;
				}
			}
		}
	}else{
		//scheme specific page - use scheme value that has been saved on page
		showForm(selectedSchemeID,schemeTypeName)
	}
}
function assembleSchemeFormURL(schemeID,affiliateRef,day,month,year,numDays,overAgeLabel,overAgeLink,advert,quoteExtra,subdomain,ageInputMethod,siteagentguid,wideScreen){
	var url_root=this.document.location.href
	url_root=url_root.split("//")[0]+"//"+url_root.split("//").pop().split("/")[0]
	var url = url_root+"/QE/schemeform.asp"
	url+="?"
	url+="thisScheme="+escape(schemeID)
	url+="&affiliateRef="+escape(affiliateRef)
	url+="&todayday="+escape(day)
	url+="&todaymonth="+escape(month)
	url+="&todayyear="+escape(year)
	url+="&daysinmonth="+escape(numDays)
	url+="&overAgeLabel="+escape(overAgeLabel)
	url+="&overAgeLink="+escape(overAgeLink)
	url+="&advert="+escape(advert)
	url+="&quoteExtra="+escape(quoteExtra)
	url+="&subdomain="+escape(subdomain==null?'':subdomain)
	url+="&ageinputmethod="+escape(ageInputMethod)
	url+="&siteagentguid="+escape(siteagentguid)
	url+="&widescreen="+escape(wideScreen)
	return url
}

function checkAgeTravellers(checkMissing,theForm){
	var maxAge = theForm.MaxAge.value
	if(maxAge.length==0) maxAge=defaultMaxAge
//alert(theForm.id)
//x
	var travellers = theForm.travellerAge
//	var travellersCount = 0
	var valid = true
	var missing = false
	var tooOld = false
	if(typeof travellers.length != 'number'){travellers=[travellers]}
	for(var i=0;i<travellers.length;i++){
		if(!isNumeric(travellers[i].value)){
			valid=false
			travellers[i].setFocus
			//break
		}else{
			if(parseInt(travellers[i].value)>maxAge){
				travellers[i].setFocus
				tooOld=true
			}
		}
		if(travellers[i].value=='' && checkMissing) {
			missing=true
			travellers[i].setFocus
			//break
		}
		
		
	}
	if(travellers[0].value<minAge){// && theForm.SchemeType.value.indexOf('Annual')==0){
		var salesPhoneNumber = document.getElementById("SalesPhoneNumber").value
		alert("The minimum allowed age of the lead traveller of an " + theForm.SchemeType.value + " policy is "+ minAge+' years. \n\nPlease call us on '+salesPhoneNumber+' for other ages')
		return false
	}
	//if(travellers[0].value<minAge && theForm.SchemeType.value.indexOf('Annual')==0){
	//	alert("The minimum allowed age of the lead traveller of an " + theForm.SchemeType.value + " policy is "+ minAge)
	//	return false
	//}
	if(tooOld){
		alert("The maximum allowed age is "+ maxAge)
		//document.getElementById("divQuoteButton").style.display='none'
		return false
	}		
	if(travellers.length==0){
		alert("Enter the number of travellers")
		//document.getElementById("divQuoteButton").style.display='none'
		return false
	}		
	if(!valid||missing){
		alert("Valid ages must be entered for all travellers")
		//document.getElementById("divQuoteButton").style.display='none'
		return false
	}else{
		//document.getElementById("divQuoteButton").style.display='block'
		return true}
}

function expandAgeTravellers(identifier){
	var travCount = document.getElementById("TravellerCount"+identifier)
	if(isNumeric(travCount.value)){
		var travellerCount = parseInt(travCount.value)
		var divAges = document.getElementById("divAgeTravellers"+identifier)
		var divHtml = '<p id="enterAge">Enter the <strong>Age</strong> of each traveller</p><table>'
		var buttonAtTop = parseInt(document.getElementById("QuoteButtonAtTop").value)
		//document.getElementById("divQuoteButton").style.display='none'
		if(travellerCount>0 && travellerCount<=travellerMaximum){
			divAges.innerHTML = ''
			for(var i=1;i<travellerCount+1;i++){
				divHtml+='<tr><td class="travellerNumber"><p id="noOfTravellers">'
				divHtml+=i==1?'Lead Traveller: ':'Traveller '+i+': '
				divHtml+='</p></td><td class="travellerAge"><p>'
				divHtml+='<input name="travellerAge" id="travellerAge'+i+'" '
				divHtml+='type="text" size="1" maxlength="2" autocomplete="off"/> years'
				//divHtml+='type="text" size="1" maxlength="2" autocomplete="off" onchange="checkAgeTravellers(false,this.form)"/> years'
				divHtml+='</p>'
				divHtml+='</td><td class="travellerButton" id="tdGetQuote" width="30%">'
				if((i==travellerCount && buttonAtTop==0)||(i==1 && buttonAtTop==1)) {
					//divHtml+='<div name="QuoteGhost" id="QuoteGhost" style="display:none">'
					//divHtml+='<img src="/images/quote/buttons/getquote_ghost.gif"/>'
					//divHtml+='</div>'
					divHtml+='<div name="divQuoteButton" id="divQuoteButton" style="align:bottom">'
					divHtml+='<input type="image" id="getQuote" src="/images/quote/buttons/getquote.gif" '
					divHtml+=" onmouseover='rollOver(this,\"getquote_over.gif\")' onmouseout='rollOver(this,\"getquote.gif\")' "
					divHtml+=' alt="Click HERE to get a travel insurance quote" class="quoteimagelayout" ' 
					//divHtml+=" onclick='javascript:this.style.display=\"none\";document.getElementById(\"QuoteGhost\").style.display=\"inline\";return true' "
					divHtml+='/>'
					divHtml+='</div>'
				}
				divHtml+='</td></tr>'
			}
			divAges.innerHTML = divHtml
		}else{
			alert("'Number of Travellers' must be between 1 and "+travellerMaximum)
			travCount.focus()
		}
	}else{
		alert("'Number of Travellers' must only contain numbers")
		travCount.focus()
	}
}