
var page = {
	init : function() {
		this.initDateInputs();
		window.addEvent('domready', this.showNoPersons);
		window.addEvent('domready', this.hideMedical);
		window.addEvent('domready', this.hideMaterialInfo);
		window.addEvent('domready', this.hideHomeStart);
		window.addEvent('domready', this.datePop);
		window.addEvent('domready', this.disableContents);
		if ($('retrieve_quote') || $('retrieve_xml')) window.addEvent('domready', this.displayRetrieval);
		if ($('travellingParty')) $('travellingParty').getElement('input[name=children]').addEvent('click', this.showNoPersons);
		if ($('quoteOptions')) {
			if ($('quoteOptions').getElement('input[name=cruise]')) $('quoteOptions').getElement('input[name=cruise]').addEvent('click', this.showNoPersons);
			if ($('quoteOptions').getElement('input[name=golf]')) $('quoteOptions').getElement('input[name=golf]').addEvent('click', this.showNoPersons);
			if ($('quoteOptions').getElement('input[name=business]') && $('noBusiness')) $('quoteOptions').getElement('input[name=business]').addEvent('click', this.showNoPersons);
			if ($('quoteOptions').getElement('input[name=indtraveller]') && $('noInd')) $('quoteOptions').getElement('input[name=indtraveller]').addEvent('click', this.showNoPersons);
		}
		this.hideSports();
		this.hideCountries();
		this.hideRetrieval();
		$$('input.smoothbox').addEvent('click', this.displaySmoothbox);
		$$('a.countries').addEvent('click', this.displayCountries);
//		$$('input.conditionssmoothbox').addEvent('click', this.displayConditionsSmoothbox);
		this.loadBubble();
		this.showHelperTips();
		$$('.helperText').setStyle('display', 'none');

		$$('#yourDetails .input').addEvent('focus', this.clearInput);
		$$('#yourDetails .input').addEvent('blur', this.refill);
		$$('#apartner .input').addEvent('focus', this.clearInput);
		$$('#apartner .input').addEvent('blur', this.refill);
		$$('#achildren .input').addEvent('focus', this.clearInput);
		$$('#achildren .input').addEvent('blur', this.refill);
		$$('#yourDetails_h .input').addEvent('focus', this.clearInput);
		$$('#yourDetails_h .input').addEvent('blur', this.refill);
		$$('#jointPolicy_h .input').addEvent('focus', this.clearInput);
		$$('#jointPolicy_h .input').addEvent('blur', this.refill);
		
		window.addEvent('domready', function() {
			if ($('previousClaimYes')) {
				if ($('claims')) {
					if ($('previousClaimYes').checked == true) {
						var slide = new Fx.Slide('claims').show();
						$('claims').parentNode.setStyle('height', '45px');
						$$('#claims .qcol2').setStyle('display', 'block');
					} else {
						var slide = new Fx.Slide('claims').hide();
					}
					
					$('previousClaimYes').addEvent('change', function(e) {
						e = new Event(e);
						slide.slideIn();
						e.stop();
					});
					
					$('previousClaimNo').addEvent('change', function(e) {
						e = new Event(e);
						slide.slideOut();
						e.stop();
					});
					
					slide.addEvent('onComplete', function() {
						if ($('previousClaimYes').checked == true) {
							$('claims').parentNode.setStyle('height', '45px');
							$$('#claims .qcol2').setStyle('display', 'block');
						} else {
							$('claims').parentNode.setStyle('height', 'auto');
							$$('#claims .qcol2').setStyle('display', 'none');
						}
					});
				}
			}
		});
		
		window.addEvent('domready', function() {			
			if ($('jp_slide')) {
				if ($('jp_showtoggle').checked == true) {
					var slide = new Fx.Slide('jp_slide').show();
					$('jp_slide').parentNode.setStyle('height', 'auto');
				} else {
					var slide = new Fx.Slide('jp_slide').hide();
				}
				
				$('jp_showtoggle').addEvent('change', function(e) {
					e = new Event(e);
					slide.slideIn();
					e.stop();
				});
				
				$('jp_hidetoggle').addEvent('change', function(e) {
					e = new Event(e);
					slide.slideOut();
					e.stop();
				});
				
				slide.addEvent('onComplete', function() {
					$('jp_slide').parentNode.setStyle('height', 'auto');
				});
			}
		});
		
		window.addEvent('domready', function() {
			if ($('ac_slide')) {
				if ($('ac_showtoggle').checked == true) {
					var slide = new Fx.Slide('ac_slide').show();
					$('ac_slide').parentNode.setStyle('height', 'auto');
				} else {
					var slide = new Fx.Slide('ac_slide').hide();
				}
				
				$('ac_showtoggle').addEvent('change', function(e) {
					e = new Event(e);
					slide.slideIn();
					e.stop();
				});
				
				$('ac_hidetoggle').addEvent('change', function(e) {
					e = new Event(e);
					slide.slideOut();
					e.stop();
				});
				
				slide.addEvent('onComplete', function() {
					$('ac_slide').parentNode.setStyle('height', 'auto');
				});
			}
		});
		
		if ($('toggle')) {
			var slide = new Fx.Slide('slide').hide();

			$('toggle').addEvent('click', function(e) {
				e = new Event(e);
				slide.toggle();
				e.stop();
			});

			if (typeof(showSlide) != 'undefined' && showSlide === true) {
				slide.slideIn();
			}
			
			slide.addEvent('onComplete', function() {
				if (slide.open == true) {
					$('toggle').innerHTML = '- Click here if you wish to hide this section -';
					$('slide').parentNode.setStyle('height', 'auto');
				} else {
					$('toggle').innerHTML = '+ Click here if you wish to declare Specific Individual Items of value +';
				}
			});
		}
		
		if ($('coverType')) $$('#coverType .select').addEvent('change', this.disableContents);
		if ($('sc1')) $('sc1').addEvent('keyup', this.jumpSCBox);
		if ($('sc2')) $('sc2').addEvent('keyup', this.jumpSCBox);
	},
	
	initDateInputs : function()
	{
		// Add the onchange event handler to the start date input
   	if ($('sdate')) document.getElementById("sdate").onchange = this.setReservationDates;
   	if ($('sdate_h')) document.getElementById("sdate_h").onchange = this.setReservationDates;
	},
	
	setReservationDates : function()
	{
		// Check the associated datePicker object is available (be safe)
  		if(!("sdate" in datePickerController.datePickers)) {
      	return;
      }
      
      // Check the value of the input is a date of the correct format
      var dt = datePickerController.dateFormat(this.value, datePickerController.datePickers["sdate"].format.charAt(0) == "m");
      
      // If the input's value cannot be parsed as a valid date then return
      if(dt == 0) return;

      // Grab the value set within the endDate input and parse it using the dateFormat method
      // N.B: The second parameter to the dateFormat function, if TRUE, tells the function to favour the m-d-y date format
      if ($('edate')) {
      	var edv = datePickerController.dateFormat($('edate').value, datePickerController.datePickers["edate"].format.charAt(0) == "m");

	      // Grab the end date datePicker Objects
   	   var ed = datePickerController.datePickers["edate"];
			
			ed.setRangeLow( dt );
      
   	   // If theres a value already present within the end date input and it's smaller than the start date
   	   // then clear the end date value
   	   if(edv < dt) {
   	   	$('edate').value = "";
   	   }
		}
	}, 
	
	datePop : function()
	{
		var currentDate = new Date();
		
		if ($('sdate_h')) {
			$('sdate_h').addEvent('blur', function() {
				var sdate = $('sdate_h').value.split('/');
				var selectedDate = new Date(sdate[2],sdate[1]-1,sdate[0]);
				
				var currentDate_ms = currentDate.getTime();
				var selectedDate_ms = selectedDate.getTime();
				
				var ONE_DAY = 1000*60*60*24;
				
				var difference_ms = Math.abs(selectedDate_ms - currentDate_ms);
				
				var noDays = Math.round(difference_ms/ONE_DAY) + 1;
				
				if (noDays <= 10) {
					alert('Please note that cover will not be in force until Paymentshield have confirmed that your application has been accepted and the policy has been put on risk. '+
					'In some cases they may request additional information before they can make a decision. In rare cases they may decline a risk. So do not leave yourself uninsured. Wait until you have the confirmation '+
					'before you cancel your old cover. If you do not hear within a few days then please contact us.');
				}
			});
		}
		
	},
	
	showNoPersons : function()
	{
		if ($('travellingParty')) {
			if ($('travellingParty').getElement('input[name=children]').checked) {
				$('noChildren').setStyle('display', 'block');
			} else {
				$('noChildren').setStyle('display', 'none');
			}
		}
		
		if ($('quoteOptions')) {
			if ($('quoteOptions').getElement('input[name=cruise]')) {
				if ($('quoteOptions').getElement('input[name=cruise]').checked) {
					$('noCruise').setStyle('display', 'block');
				} else {
					$('noCruise').setStyle('display', 'none');
				}
			}
			
			if ($('quoteOptions').getElement('input[name=golf]')) {
				if ($('quoteOptions').getElement('input[name=golf]').checked) {
					$('noGolf').setStyle('display', 'block');
				} else {
					$('noGolf').setStyle('display', 'none');
				}
			}
			
			if ($('quoteOptions').getElement('input[name=business]') && $('noBusiness')) {
				if ($('quoteOptions').getElement('input[name=business]').checked) {
					$('noBusiness').setStyle('display', 'block');
				} else {
					$('noBusiness').setStyle('display', 'none');
				}
			}
			
			if ($('quoteOptions').getElement('input[name=indtraveller]')) {
				if ($('quoteOptions').getElement('input[name=indtraveller]').checked) {
					$('noInd').setStyle('display', 'block');
				} else {
					$('noInd').setStyle('display', 'none');
				}
			}
		}
	},
	
	hideMedical : function()
	{
		if ($('confirmMedical')) {
			var med = $('confirmMedical').getElements('input[name=medicalCondition]');
			var medCover = $('confirmMedical').getElements('input[name=medicalConditionCovered]');
			var medListed = $('confirmMedical').getElements('input[name=medicalConditionListed]');
			$('medicalConditionCovered').setStyle('display', 'none');
			$('medicalConditionCoveredAns').setStyle('display', 'none');		
			$('medicalConditionListed').setStyle('display', 'none');
			$$('.listedConditions').setStyle('display', 'none');
			$('medicalConditionListedAns').setStyle('display', 'none');			
			
			medCover.each(function(input) {
				input.disabled = true;
			});
			
			medListed.each(function(input) {
				input.disabled = true;
			});
			
			if (med[0].checked == true) {
				medCover.each(function(input) {
					input.disabled = false;
				});
			}

			if (medCover[0].checked == true) {
				medListed.each(function(input) {
					input.disabled = false;
				});
			}

			// Display medicalConditionCovered if medicalConditionYes is selected
			if (med[0].checked) {
				$('medicalConditionCovered').setStyle('display', 'block');
				$('medicalConditionCoveredAns').setStyle('display', 'block');			
			}

			// Display medicalConditionListed if medicalConditionCoveredYes is selected
			if (medCover[0].checked) {
				$('medicalConditionListed').setStyle('display', 'block');
				$$('.listedConditions').setStyle('display', 'block');
				$('medicalConditionListedAns').setStyle('display', 'block');
			}

			med.each(function(input) {
				input.addEvent('click', function() {
					if (input.value == 'yes') {
						$('medicalConditionCovered').setStyle('display', 'block');
						$('medicalConditionCoveredAns').setStyle('display', 'block');			
						medCover.each(function(input) {
							input.disabled = false;
						});
					} else {
						$('medicalConditionCovered').setStyle('display', 'none');
						$('medicalConditionCoveredAns').setStyle('display', 'none');	
						medCover.each(function(input) {
							input.disabled = true;
						});
					}
				})
			});
			
			medCover.each(function(input) {
				input.addEvent('click', function() {
					if (input.value == 'yes') {
						$('medicalConditionListed').setStyle('display', 'block');
						$$('.listedConditions').setStyle('display', 'block');
						$('medicalConditionListedAns').setStyle('display', 'block');			
						medListed.each(function(input) {
							input.disabled = false;
						});
					} else {
						$('medicalConditionListed').setStyle('display', 'none');
						$$('.listedConditions').setStyle('display', 'none');
						$('medicalConditionListedAns').setStyle('display', 'none');	
						medListed.each(function(input) {
							input.disabled = true;
						});
					}
				})
			});
		}
	},
	
	hideSports : function()
	{
		if (!$('select_activities')) return false;
		$('select_activities').setStyle('display', 'none');
	},
	
	hideCountries : function()
	{
		if (!$('select_destination')) return false;
		$('select_destination').setStyle('display', 'none');
	},
	
	hideRetrieval : function()
	{
		if ($('retrieve_quote')) $('retrieve_quote').setStyle('display', 'none');
		if ($('retrieve_xml')) $('retrieve_xml').setStyle('display', 'none');
	},
	
	hideMaterialInfo : function()
	{
		var material = $$('.assumptions_qs').getElements('input[name=material]');
		if ($('material_info')) $('material_info').setStyle('display', 'none');

		material.each(function(input) {
			input.addEvent('domready', function() {
				if (input[0].checked == true) {
					$('material_info').setStyle('display', 'block');
				}
			}),
	
			input.addEvent('click', function() {
				if (input[0].checked == true) {
					$('material_info').setStyle('display', 'block');
				} else {
					$('material_info').setStyle('display', 'none');
				}
			})
		});
	},
	
	displaySmoothbox : function()
	{
		$$('input.smoothbox').each(
			function(el) {
				if (el.checked) {
					TB_show('Please select the options you want to add to your cover and click CLOSE on the top right of this box','#TB_inline?height=375&width=570&inlineId=select_activities','');
				}
				
				if (!el.checked) {
					if (confirm("This will clear your currently selected Sports Activities for cover. Would you like to continue?")) {
						$('activities').setHTML('&nbsp;');
					} else {
						el.checked = true;
					}
				}
			});
	},
	
	displayConditionsSmoothbox : function()
	{
		$('conditionsListed').setStyle('display', 'block');
		$('medicalConditionListed').setStyle('display', 'block');
		$$('input.conditionssmoothbox').each(
			function(el) {
				if (el.checked) {
					TB_show('Please select the conditions you want to add and click CLOSE on the top right of this box','#TB_inline?height=375&width=570&inlineId=select_conditions','');
				}
			});
	},
	
	displayCountries : function()
	{
		if ($('countries').innerHTML != '&nbsp;') {
			if (confirm("Your current country selections will be cleared to allow you to make changes. Would you like to continue?")) {
				$('countries').setHTML('&nbsp;');
				$$('a.countries').each(
					function(el) {
						if (el) {
							TB_show('Please select the one or more destinations for which you will be travelling to:','#TB_inline?height=375&width=570&inlineId=select_destination','');
						}
					});
			}
		} else {
			$$('a.countries').each(
				function(el) {
					if (el) {
						TB_show('Please select the one or more destinations for which you will be travelling to:','#TB_inline?height=375&width=570&inlineId=select_destination','');
					}
				});
		}
	},
	
	displayRetrieval : function()
	{
		$$('div.retrieval').each(
			function(el) {
				if (el) {
					if ($('retrieve_quote')) {
						TB_show('', '#TB_inline?height=375&width=570&inlineId=retrieve_quote','', true); 
						$('TB_closeAjaxWindow').setStyle('display', 'none');
					}
					
					if ($('retrieve_xml')) {
						TB_show('', '#TB_inline?height=475&width=570&inlineId=retrieve_xml','', true); 
						$('TB_closeAjaxWindow').setStyle('display', 'none');
					}
				}
			});
	},
	
	loadBubble : function() {
		var id;
		var idArr = $$('.helper a').getProperty('href');
		var imgArr = $$('.question img');

		for (var i=0; i<idArr.length; i++) {
			id = idArr[i].replace(/\#/, '');
			if ($(id)) imgArr[i].setProperty('title', imgArr[i].getProperty('title') + "::" + $(id).innerHTML);
		}		
		
		$$('.helper a').removeProperty('href');
	},
	
	showHelperTips : function()
	{
		// Reset Alt tags to blank, IE Hack
		$$('.helperImg').setProperty('alt', '');
		
		var tips = new Tips($$('.helperImg'), {
								// Temporarily removed for smoother rendition of the Bubble 
/*								initialize : function() {
									this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
								},
								onShow : function(toolTip) {
									this.fx.start(1);
								},
								onHide : function(toolTip) {
									this.fx.start(0);
								},
	*/							
								showDelay: 0,
								hideDelay: 0,
								offsets: {
									x: -150,
									y: 16
								},
								fixed: false
			});
	},
	
	clearInput : function()
	{
		if (this.name == "main[firstname]" || this.name == 'partner[firstname]' || this.name == 'children[firstname][]' || this.name == 'c[0][firstname]' || this.name == 'c[1][firstname]') {
			if (this.value == 'Forename') {
				this.value = '';
			}
		}
		
		if (this.name == "main[lastname]" || this.name == 'partner[lastname]' || this.name == 'children[lastname][]' || this.name == 'c[0][lastname]' || this.name == 'c[1][lastname]') {
			if (this.value == 'Surname') {
				this.value = '';
			}
		}

		if (this.name == "main[email]" || this.name == 'c[0][email]') {
			if (this.value == 'Email') {
				this.value = '';
			}
		}

		if (this.name == "main[address1]") {
			if (this.value == 'Address Line 1') {
				this.value = '';
			}
		}

		if (this.name == "main[address2]") {
			if (this.value == 'Address Line 2') {
				this.value = '';
			}
		}

		if (this.name == "main[town]") {
			if (this.value == 'Town') {
				this.value = '';
			}
		}
		
		if (this.name == "main[county]") {
			if (this.value == 'County') {
				this.value = '';
			}
		}

		if (this.name == "main[pcode]") {
			if (this.value == 'Postcode') {
				this.value = '';
			}
		}

		if (this.name == "main[phone]" || this.name == 'c[0][phone]') {
			if (this.value == 'Telephone') {
				this.value = '';
			}
		}
		
		if (this.name == 'c[0][mobile]') {
			if (this.value == 'Mobile') {
				this.value = '';
			}
		}
	},
	
	refill : function()
	{
		if (this.name == "main[firstname]" || this.name == 'partner[firstname]' || this.name == 'children[firstname][]' || this.name == 'c[0][firstname]' || this.name == 'c[1][firstname]') {
			if (this.value == '') {
				this.value = "Forename";
			}
		}
		
		if (this.name == "main[lastname]" || this.name == 'partner[lastname]' || this.name == 'children[lastname][]' || this.name == 'c[0][lastname]' || this.name == 'c[1][lastname]') {
			if (this.value == '') {
				this.value = "Surname";
			}
		}
		
		if (this.name == "main[email]" || this.name == 'c[0][email]') {
			if (this.value == '') {
				this.value = "Email";
			}
		}
		
		if (this.name == "main[address1]") {
			if (this.value == '') {
				this.value = "Address Line 1";
			}
		}
		
		if (this.name == "main[address2]") {
			if (this.value == '') {
				this.value = 'Address Line 2';
			}
		}

		if (this.name == "main[town]") {
			if (this.value == '') {
				this.value = 'Town';
			}
		}
		
		if (this.name == "main[county]") {
			if (this.value == '') {
				this.value = 'County';
			}
		}

		if (this.name == "main[pcode]") {
			if (this.value == '') {
				this.value = 'Postcode';
			}
		}

		if (this.name == "main[phone]" || this.name == 'c[0][phone]') {
			if (this.value == '') {
				this.value = 'Telephone';
			}
		}
		
		if (this.name == 'c[0][mobile]') {
			if (this.value == '') {
				this.value = 'Mobile';
			}
		}
	},
	
	hideHomeStart : function() {
		// hide by default
		if ($('ncb_claims')) $('ncb_claims').setStyle('display', 'none');
		if ($('ncc_claims')) $('ncc_claims').setStyle('display', 'none');

		if ($('ncb')) var ncb = $('ncb').getElements('input[name=ncb]');
		if ($('ncc')) var ncc = $('ncc').getElements('input[name=ncc]');
		
		if ($('ncb')) {if (ncb[1].checked == true) $('ncb_claims').setStyle('display', 'block');}
		if ($('ncc')) {if (ncc[1].checked == true) $('ncc_claims').setStyle('display', 'block');}
		
		if ($('ncb')) {
			ncb.each(function(input) {
				input.addEvent('click', function() {
					if (input.value == 'no') {
						$('ncb_claims').setStyle('display', 'block');
					} else {
						$('ncb_claims').setStyle('display', 'none');
					}
				});
			});
		}
		
		if ($('ncc')) {
			ncc.each(function(input) {
				input.addEvent('click', function() {
					if (input.value == 'no') {
						$('ncc_claims').setStyle('display', 'block');
					} else {
						$('ncc_claims').setStyle('display', 'none');
					}
				});
			});
		}
		
		if ($('specificItems')) {
			if ($('individualItems_amount')) $('individualItems_amount').setStyle('display', 'none');
			if ($('jewellery_amount')) $('jewellery_amount').setStyle('display', 'none');
			if ($('individualItems_ppamount')) $('individualItems_ppamount').setStyle('display', 'none');
			
			var individual = $('individualItems').getElements('input[name=individualItems]');
			var jewellery = $('jewellery').getElements('input[name=jewellery]');
			var individual_pp = $('individualItems_pp').getElements('input[name=individualItems_pp]');
			
			if (individual[0].checked == true) $('individualItems_amount').setStyle('display', 'block');
			if (jewellery[0].checked == true) $('jewellery_amount').setStyle('display', 'block');
			if (individual_pp[0].checked == true) $('individualItems_ppamount').setStyle('display', 'block');	
			
/*			if ($('individualItems_amount')) {
				var individualItems_amount = new Fx.Slide('individualItems_amount').hide();
				var individual = $('individualItems').getElements('input[name=individualItems]');
				
				individual.each(function(input) {
					input.addEvent('click', function() {
						if (input.value == 'yes') {
							individualItems_amount.slideIn();
						} else {
							individualItems_amount.slideOut();
						}
					});
				});
			}	
			
			if ($('jewellery_amount')) {
				var jewellery_amount = new Fx.Slide('jewellery_amount').hide();
				var jewellery = $('jewellery').getElements('input[name=jewellery]');
				
				jewellery.each(function(input) {
					input.addEvent('click', function() {
						if (input.value == 'yes') {
							jewellery_amount.slideIn();
						} else {
							jewellery_amount.slideOut();
						}
					});
				});
			}	
			
			if ($('individualItems_ppamount')) {
				var individualItems_ppamount = new Fx.Slide('individualItems_ppamount').hide();
				var individual_pp = $('individualItems_pp').getElements('input[name=individualItems_pp]');
				
				individual_pp.each(function(input) {
					input.addEvent('click', function() {
						if (input.value == 'yes') {
							individualItems_ppamount.slideIn();
						} else {
							individualItems_ppamount.slideOut();
						}
					});
				});
			}	*/
			
			individual.each(function(input) {
				input.addEvent('click', function() {
					if (input.value == 'yes') {
						$('individualItems_amount').setStyle('display', 'block');
					} else {
						$('individualItems_amount').setStyle('display', 'none');
					}
				});
			});
			
			jewellery.each(function(input) {
				input.addEvent('click', function() {
					if (input.value == 'yes') {
						$('jewellery_amount').setStyle('display', 'block');
					} else {
						$('jewellery_amount').setStyle('display', 'none');
					}
				});
			});
			
			individual_pp.each(function(input) {
				input.addEvent('click', function() {
					if (input.value == 'yes') {
						$('individualItems_ppamount').setStyle('display', 'block');
					} else {
						$('individualItems_ppamount').setStyle('display', 'none');
					}
				});
			});	
		}
			
/*		if ($('specificItems')) {
			// hide by default
			if ($('individualItems_amount')) $('individualItems_amount').setStyle('display', 'none');
			if ($('jewellery_amount')) $('jewellery_amount').setStyle('display', 'none');
			if ($('individualItems_ppamount')) $('individualItems_ppamount').setStyle('display', 'none');
			if ($('ncb_claims')) $('ncb_claims').setStyle('display', 'none');
			if ($('ncc_claims')) $('ncc_claims').setStyle('display', 'none');
			
			var individual = $('individualItems').getElements('input[name=individualItems]');
			var jewellery = $('jewellery').getElements('input[name=jewellery]');
			var individual_pp = $('individualItems_pp').getElements('input[name=individualItems_pp]');
			if ($('ncb')) var ncb = $('ncb').getElements('input[name=ncb]');
			if ($('ncc')) var ncc = $('ncc').getElements('input[name=ncc]');
			
			if (individual[0].checked == true) $('individualItems_amount').setStyle('display', 'block');
			if (jewellery[0].checked == true) $('jewellery_amount').setStyle('display', 'block');
			if (individual_pp[0].checked == true) $('individualItems_ppamount').setStyle('display', 'block');			
			if ($('ncb')) {if (ncb[1].checked == true) $('ncb_claims').setStyle('display', 'block');}
			if ($('ncc')) {if (ncc[1].checked == true) $('ncc_claims').setStyle('display', 'block');}
			
			individual.each(function(input) {
				input.addEvent('click', function() {
					if (input.value == 'yes') {
						$('individualItems_amount').setStyle('display', 'block');
					} else {
						$('individualItems_amount').setStyle('display', 'none');
					}
				});
			});
			
			jewellery.each(function(input) {
				input.addEvent('click', function() {
					if (input.value == 'yes') {
						$('jewellery_amount').setStyle('display', 'block');
					} else {
						$('jewellery_amount').setStyle('display', 'none');
					}
				});
			});
			
			individual_pp.each(function(input) {
				input.addEvent('click', function() {
					if (input.value == 'yes') {
						$('individualItems_ppamount').setStyle('display', 'block');
					} else {
						$('individualItems_ppamount').setStyle('display', 'none');
					}
				});
			});
			
			if ($('ncb')) {
				ncb.each(function(input) {
					input.addEvent('click', function() {
						if (input.value == 'no') {
							$('ncb_claims').setStyle('display', 'block');
						} else {
							$('ncb_claims').setStyle('display', 'none');
						}
					});
				});
			}
			
			if ($('ncc')) {
				ncc.each(function(input) {
					input.addEvent('click', function() {
						if (input.value == 'no') {
							$('ncc_claims').setStyle('display', 'block');
						} else {
							$('ncc_claims').setStyle('display', 'none');
						}
					});
				});
			}
		}*/
	},

	disableContents : function() {
		if ($('coverType')) var cover = $('coverType').getElement('select[name=ctype]').value;
		if ($('ncc')) var ncc = $('ncc').getElements('input[name=ncc]');
		if ($('ncb')) var ncb = $('ncb').getElements('input[name=ncb]');
		var title = $$('.title');
		
		if (cover == 'Contents') {
			// Disable all Buildings related fields, re-set defaults and hide them
			title.each(function(title) {
				if (title.innerHTML == 'no claims buildings discount') {
					title.setStyle('display', 'none');
				}
			});
			
			if ($('bdiscountDetails')) $('bdiscountDetails').setStyle('display', 'none');
			
			if ($('ncb')) {
				$('ncb_claims').setStyle('display', 'none');
				ncb.each(function(input) {
					input.checked = false;
					input.disabled = true;
				});
			}
			
		} else {
			title.each(function(title) {
				if (title.innerHTML == 'no claims buildings discount') {
					title.setStyle('display', 'block');
				}
			});
			
			if ($('bdiscountDetails')) $('bdiscountDetails').setStyle('display', 'block');
			if ($('ncb')) {
				ncb.each(function(input) {
					input.disabled = false;
				});
			}
		}
		
		if (cover == 'Buildings') {		
			// Disable all Contents related fields, re-set defaults and hide them
			title.each(function(title) {
				if (title.innerHTML == 'no claims contents discount') {
					title.setStyle('display', 'none');
				}
			});				
			
			$('cdiscountDetails').setStyle('display', 'none');
			$('ncc_claims').setStyle('display', 'none');
			ncc.each(function(input) {
				input.checked = false;
				input.disabled = true;
			});			
			
			if ($('pp_title')) {
				$('pp_title').setStyle('display', 'none');
				$('pPosessions').setStyle('display', 'none');
				$('pPosessions').getElement('input[name=pposessions]').setStyle('background', 'none');
				$('pPosessions').getElement('input[name=pposessions]').setStyle('background-color', '#d6d4d4');
				$('pPosessions').getElement('input[name=pposessions]').disabled = true;
			}			
		} else {
			title.each(function(title) {
				if (title.innerHTML == 'no claims contents discount') {
					title.setStyle('display', 'block');
				}
			});
		
			if ($('pp_title')) {
				$('pp_title').setStyle('display', 'block');
				$('pPosessions').setStyle('display', 'block');
				$('pPosessions').getElement('input[name=pposessions]').setStyle('background-image', 'url(/images/boxbg.gif)');
				$('pPosessions').getElement('input[name=pposessions]').setStyle('background-color', 'transparent');
				$('pPosessions').getElement('input[name=pposessions]').disabled = false;
			}
		
			if ($('cdiscountDetails')) $('cdiscountDetails').setStyle('display', 'block');
			if ($('ncc')) {
				ncc.each(function(input) {
					input.disabled = false;
				});
			}
		}
	
/*		if ($('individualItems')) {
			if ($('coverType')) var cover = $('coverType').getElement('select[name=ctype]').value;
			var individualItems = $('individualItems').getElements('input[name=individualItems]');
			var jewellery = $('jewellery').getElements('input[name=jewellery]');
			var individualItems_pp = $('individualItems_pp').getElements('input[name=individualItems_pp]');
			if ($('ncc')) var ncc = $('ncc').getElements('input[name=ncc]');
			if ($('ncb')) var ncb = $('ncb').getElements('input[name=ncb]');
			var title = $$('.title');

			if (cover == 'Contents') {
				// Disable all Buildings related fields, re-set defaults and hide them
				title.each(function(title) {
					if (title.innerHTML == 'no claims buildings discount') {
						title.setStyle('display', 'none');
					}
				});
				
				if ($('bdiscountDetails')) $('bdiscountDetails').setStyle('display', 'none');
				
				if ($('ncb')) {
					$('ncb_claims').setStyle('display', 'none');
					ncb.each(function(input) {
						input.checked = false;
						input.disabled = true;
					});
				}
				
			} else {
				title.each(function(title) {
					if (title.innerHTML == 'no claims buildings discount') {
						title.setStyle('display', 'block');
					}
				});
				
				if ($('bdiscountDetails')) $('bdiscountDetails').setStyle('display', 'block');
				if ($('ncb')) {
					ncb.each(function(input) {
						input.disabled = false;
					});
				}
			}
			
			if (cover == 'Buildings') {		
				// Disable all Contents related fields, re-set defaults and hide them
				title.each(function(title) {
					if (title.innerHTML == 'specified items under contents') {
						title.setStyle('display', 'none');
					}
					
					if (title.innerHTML == 'specified items under personal possessions') {
						title.setStyle('display', 'none');
					}
					
					if (title.innerHTML == 'no claims contents discount') {
						title.setStyle('display', 'none');
					}
				});				
				
				if ($('pp_title')) {
					$('pp_title').setStyle('display', 'none');
					$('pPosessions').setStyle('display', 'none');
					$('pPosessions').getElement('input[name=pposessions]').setStyle('background', 'none');
					$('pPosessions').getElement('input[name=pposessions]').setStyle('background-color', '#d6d4d4');
					$('pPosessions').getElement('input[name=pposessions]').disabled = true;
				}
				
				if ($('specificItems')) $('specificItems').setStyle('display', 'none');
				$('individualItems_amount').getElement('input[name=individualItems_amount]').value = '';
				$('individualItems_amount').setStyle('display', 'none');
				individualItems.each(function(input) {
					input.checked = false;
					input.disabled = true;
				});
				
				if ($('specificItems_pp')) $('specificItems_pp').setStyle('display', 'none');
				$('jewellery_amount').getElement('input[name=jewellery_amount]').value = '';
				$('jewellery_amount').setStyle('display', 'none');
				jewellery.each(function(input) {
					input.checked = false;
					input.disabled = true;
				});
				
				$('individualItems_ppamount').getElement('input[name=individualItems_ppamount]').value = '';
				$('individualItems_ppamount').setStyle('display', 'none');
				individualItems_pp.each(function(input) {
					input.checked = false;
					input.disabled = true;
				});
				
				$('cdiscountDetails').setStyle('display', 'none');
				$('ncc_claims').setStyle('display', 'none');
				ncc.each(function(input) {
					input.checked = false;
					input.disabled = true;
				});			
				
			} else {
				title.each(function(title) {
					if (title.innerHTML == 'specified items under contents') {
						title.setStyle('display', 'block');
					}
					
					if (title.innerHTML == 'specified items under personal possessions') {
						title.setStyle('display', 'block');
					}
					
					if (title.innerHTML == 'no claims contents discount') {
						title.setStyle('display', 'block');
					}
				});
				
				if ($('pp_title')) {
					$('pp_title').setStyle('display', 'block');
					$('pPosessions').setStyle('display', 'block');
					$('pPosessions').getElement('input[name=pposessions]').setStyle('background-image', 'url(/images/boxbg.gif)');
					$('pPosessions').getElement('input[name=pposessions]').setStyle('background-color', 'transparent');
					$('pPosessions').getElement('input[name=pposessions]').disabled = false;
				}
				
				individualItems.each(function(input) {
					input.disabled = false;
				});
				
				jewellery.each(function(input) {
					input.disabled = false;
				});
				
				if ($('specificItems_pp')) $('specificItems_pp').setStyle('display', 'block');
				individualItems_pp.each(function(input) {
					input.disabled = false;
				});
				
				if ($('cdiscountDetails')) $('cdiscountDetails').setStyle('display', 'block');
				if ($('ncc')) {
					ncc.each(function(input) {
						input.disabled = false;
					});
				}
			}
		}*/
	},
	
	jumpSCBox : function() {
		if ($('sc1').value.length == '2') {
			$('sc2').focus();
		}
		
		if ($('sc2').value.length == '2') {
			$('sc3').focus();
		}
	}
};

function initPage() { page.init();}
var page = {
init : function() {
this.initDateInputs();
window.addEvent('domready', this.showNoPersons);
window.addEvent('domready', this.hideMedical);
window.addEvent('domready', this.hideMaterialInfo);
window.addEvent('domready', this.hideHomeStart);
window.addEvent('domready', this.datePop);
window.addEvent('domready', this.disableContents);
if ($('retrieve_quote') || $('retrieve_xml')) window.addEvent('domready', this.displayRetrieval);
if ($('travellingParty')) $('travellingParty').getElement('input[name=children]').addEvent('click', this.showNoPersons);
if ($('quoteOptions')) {
if ($('quoteOptions').getElement('input[name=cruise]')) $('quoteOptions').getElement('input[name=cruise]').addEvent('click', this.showNoPersons);
if ($('quoteOptions').getElement('input[name=golf]')) $('quoteOptions').getElement('input[name=golf]').addEvent('click', this.showNoPersons);
if ($('quoteOptions').getElement('input[name=business]') && $('noBusiness')) $('quoteOptions').getElement('input[name=business]').addEvent('click', this.showNoPersons);
if ($('quoteOptions').getElement('input[name=indtraveller]') && $('noInd')) $('quoteOptions').getElement('input[name=indtraveller]').addEvent('click', this.showNoPersons);
}
this.hideSports();
this.hideCountries();
this.hideRetrieval();
$$('input.smoothbox').addEvent('click', this.displaySmoothbox);
$$('a.countries').addEvent('click', this.displayCountries);
//		$$('input.conditionssmoothbox').addEvent('click', this.displayConditionsSmoothbox);
this.loadBubble();
this.showHelperTips();
$$('.helperText').setStyle('display', 'none');
$$('#yourDetails .input').addEvent('focus', this.clearInput);
$$('#yourDetails .input').addEvent('blur', this.refill);
$$('#apartner .input').addEvent('focus', this.clearInput);
$$('#apartner .input').addEvent('blur', this.refill);
$$('#achildren .input').addEvent('focus', this.clearInput);
$$('#achildren .input').addEvent('blur', this.refill);
$$('#yourDetails_h .input').addEvent('focus', this.clearInput);
$$('#yourDetails_h .input').addEvent('blur', this.refill);
$$('#jointPolicy_h .input').addEvent('focus', this.clearInput);
$$('#jointPolicy_h .input').addEvent('blur', this.refill);
window.addEvent('domready', function() {
if ($('previousClaimYes')) {
if ($('claims')) {
if ($('previousClaimYes').checked == true) {
var slide = new Fx.Slide('claims').show();
$('claims').parentNode.setStyle('height', '45px');
$$('#claims .qcol2').setStyle('display', 'block');
} else {
var slide = new Fx.Slide('claims').hide();
}
$('previousClaimYes').addEvent('change', function(e) {
e = new Event(e);
slide.slideIn();
e.stop();
});
$('previousClaimNo').addEvent('change', function(e) {
e = new Event(e);
slide.slideOut();
e.stop();
});
slide.addEvent('onComplete', function() {
if ($('previousClaimYes').checked == true) {
$('claims').parentNode.setStyle('height', '45px');
$$('#claims .qcol2').setStyle('display', 'block');
} else {
$('claims').parentNode.setStyle('height', 'auto');
$$('#claims .qcol2').setStyle('display', 'none');
}
});
}
}
});
window.addEvent('domready', function() {			
if ($('jp_slide')) {
if ($('jp_showtoggle').checked == true) {
var slide = new Fx.Slide('jp_slide').show();
$('jp_slide').parentNode.setStyle('height', 'auto');
} else {
var slide = new Fx.Slide('jp_slide').hide();
}
$('jp_showtoggle').addEvent('change', function(e) {
e = new Event(e);
slide.slideIn();
e.stop();
});
$('jp_hidetoggle').addEvent('change', function(e) {
e = new Event(e);
slide.slideOut();
e.stop();
});
slide.addEvent('onComplete', function() {
$('jp_slide').parentNode.setStyle('height', 'auto');
});
}
});
window.addEvent('domready', function() {
if ($('ac_slide')) {
if ($('ac_showtoggle').checked == true) {
var slide = new Fx.Slide('ac_slide').show();
$('ac_slide').parentNode.setStyle('height', 'auto');
} else {
var slide = new Fx.Slide('ac_slide').hide();
}
$('ac_showtoggle').addEvent('change', function(e) {
e = new Event(e);
slide.slideIn();
e.stop();
});
$('ac_hidetoggle').addEvent('change', function(e) {
e = new Event(e);
slide.slideOut();
e.stop();
});
slide.addEvent('onComplete', function() {
$('ac_slide').parentNode.setStyle('height', 'auto');
});
}
});
if ($('toggle')) {
var slide = new Fx.Slide('slide').hide();
$('toggle').addEvent('click', function(e) {
e = new Event(e);
slide.toggle();
e.stop();
});
if (typeof(showSlide) != 'undefined' && showSlide === true) {
slide.slideIn();
}
slide.addEvent('onComplete', function() {
if (slide.open == true) {
$('toggle').innerHTML = '- Click here if you wish to hide this section -';
$('slide').parentNode.setStyle('height', 'auto');
} else {
$('toggle').innerHTML = '+ Click here if you wish to declare Specific Individual Items of value +';
}
});
}
if ($('coverType')) $$('#coverType .select').addEvent('change', this.disableContents);
if ($('sc1')) $('sc1').addEvent('keyup', this.jumpSCBox);
if ($('sc2')) $('sc2').addEvent('keyup', this.jumpSCBox);
},
initDateInputs : function()
{
// Add the onchange event handler to the start date input
if ($('sdate')) document.getElementById("sdate").onchange = this.setReservationDates;
if ($('sdate_h')) document.getElementById("sdate_h").onchange = this.setReservationDates;
},
setReservationDates : function()
{
// Check the associated datePicker object is available (be safe)
if(!("sdate" in datePickerController.datePickers)) {
return;
}
// Check the value of the input is a date of the correct format
var dt = datePickerController.dateFormat(this.value, datePickerController.datePickers["sdate"].format.charAt(0) == "m");
// If the input's value cannot be parsed as a valid date then return
if(dt == 0) return;
// Grab the value set within the endDate input and parse it using the dateFormat method
// N.B: The second parameter to the dateFormat function, if TRUE, tells the function to favour the m-d-y date format
if ($('edate')) {
var edv = datePickerController.dateFormat($('edate').value, datePickerController.datePickers["edate"].format.charAt(0) == "m");
// Grab the end date datePicker Objects
var ed = datePickerController.datePickers["edate"];
ed.setRangeLow( dt );
// If theres a value already present within the end date input and it's smaller than the start date
// then clear the end date value
if(edv < dt) {
$('edate').value = "";
}
}
}, 
datePop : function()
{
var currentDate = new Date();
if ($('sdate_h')) {
$('sdate_h').addEvent('blur', function() {
var sdate = $('sdate_h').value.split('/');
var selectedDate = new Date(sdate[2],sdate[1]-1,sdate[0]);
var currentDate_ms = currentDate.getTime();
var selectedDate_ms = selectedDate.getTime();
var ONE_DAY = 1000*60*60*24;
var difference_ms = Math.abs(selectedDate_ms - currentDate_ms);
var noDays = Math.round(difference_ms/ONE_DAY) + 1;
if (noDays <= 10) {
alert('Please note that cover will not be in force until Paymentshield have confirmed that your application has been accepted and the policy has been put on risk. '+
'In some cases they may request additional information before they can make a decision. In rare cases they may decline a risk. So do not leave yourself uninsured. Wait until you have the confirmation '+
'before you cancel your old cover. If you do not hear within a few days then please contact us.');
}
});
}
},
showNoPersons : function()
{
if ($('travellingParty')) {
if ($('travellingParty').getElement('input[name=children]').checked) {
$('noChildren').setStyle('display', 'block');
} else {
$('noChildren').setStyle('display', 'none');
}
}
if ($('quoteOptions')) {
if ($('quoteOptions').getElement('input[name=cruise]')) {
if ($('quoteOptions').getElement('input[name=cruise]').checked) {
$('noCruise').setStyle('display', 'block');
} else {
$('noCruise').setStyle('display', 'none');
}
}
if ($('quoteOptions').getElement('input[name=golf]')) {
if ($('quoteOptions').getElement('input[name=golf]').checked) {
$('noGolf').setStyle('display', 'block');
} else {
$('noGolf').setStyle('display', 'none');
}
}
if ($('quoteOptions').getElement('input[name=business]') && $('noBusiness')) {
if ($('quoteOptions').getElement('input[name=business]').checked) {
$('noBusiness').setStyle('display', 'block');
} else {
$('noBusiness').setStyle('display', 'none');
}
}
if ($('quoteOptions').getElement('input[name=indtraveller]')) {
if ($('quoteOptions').getElement('input[name=indtraveller]').checked) {
$('noInd').setStyle('display', 'block');
} else {
$('noInd').setStyle('display', 'none');
}
}
}
},
hideMedical : function()
{
if ($('confirmMedical')) {
var med = $('confirmMedical').getElements('input[name=medicalCondition]');
var medCover = $('confirmMedical').getElements('input[name=medicalConditionCovered]');
var medListed = $('confirmMedical').getElements('input[name=medicalConditionListed]');
$('medicalConditionCovered').setStyle('display', 'none');
$('medicalConditionCoveredAns').setStyle('display', 'none');		
$('medicalConditionListed').setStyle('display', 'none');
$$('.listedConditions').setStyle('display', 'none');
$('medicalConditionListedAns').setStyle('display', 'none');			
medCover.each(function(input) {
input.disabled = true;
});
medListed.each(function(input) {
input.disabled = true;
});
if (med[0].checked == true) {
medCover.each(function(input) {
input.disabled = false;
});
}
if (medCover[0].checked == true) {
medListed.each(function(input) {
input.disabled = false;
});
}
// Display medicalConditionCovered if medicalConditionYes is selected
if (med[0].checked) {
$('medicalConditionCovered').setStyle('display', 'block');
$('medicalConditionCoveredAns').setStyle('display', 'block');			
}
// Display medicalConditionListed if medicalConditionCoveredYes is selected
if (medCover[0].checked) {
$('medicalConditionListed').setStyle('display', 'block');
$$('.listedConditions').setStyle('display', 'block');
$('medicalConditionListedAns').setStyle('display', 'block');
}
med.each(function(input) {
input.addEvent('click', function() {
if (input.value == 'yes') {
$('medicalConditionCovered').setStyle('display', 'block');
$('medicalConditionCoveredAns').setStyle('display', 'block');			
medCover.each(function(input) {
input.disabled = false;
});
} else {
$('medicalConditionCovered').setStyle('display', 'none');
$('medicalConditionCoveredAns').setStyle('display', 'none');	
medCover.each(function(input) {
input.disabled = true;
});
}
})
});
medCover.each(function(input) {
input.addEvent('click', function() {
if (input.value == 'yes') {
$('medicalConditionListed').setStyle('display', 'block');
$$('.listedConditions').setStyle('display', 'block');
$('medicalConditionListedAns').setStyle('display', 'block');			
medListed.each(function(input) {
input.disabled = false;
});
} else {
$('medicalConditionListed').setStyle('display', 'none');
$$('.listedConditions').setStyle('display', 'none');
$('medicalConditionListedAns').setStyle('display', 'none');	
medListed.each(function(input) {
input.disabled = true;
});
}
})
});
}
},
hideSports : function()
{
if (!$('select_activities')) return false;
$('select_activities').setStyle('display', 'none');
},
hideCountries : function()
{
if (!$('select_destination')) return false;
$('select_destination').setStyle('display', 'none');
},
hideRetrieval : function()
{
if ($('retrieve_quote')) $('retrieve_quote').setStyle('display', 'none');
if ($('retrieve_xml')) $('retrieve_xml').setStyle('display', 'none');
},
hideMaterialInfo : function()
{
var material = $$('.assumptions_qs').getElements('input[name=material]');
if ($('material_info')) $('material_info').setStyle('display', 'none');
material.each(function(input) {
input.addEvent('domready', function() {
if (input[0].checked == true) {
$('material_info').setStyle('display', 'block');
}
}),
input.addEvent('click', function() {
if (input[0].checked == true) {
$('material_info').setStyle('display', 'block');
} else {
$('material_info').setStyle('display', 'none');
}
})
});
},
displaySmoothbox : function()
{
$$('input.smoothbox').each(
function(el) {
if (el.checked) {
TB_show('Please select the options you want to add to your cover and click CLOSE on the top right of this box','#TB_inline?height=375&width=570&inlineId=select_activities','');
}
if (!el.checked) {
if (confirm("This will clear your currently selected Sports Activities for cover. Would you like to continue?")) {
$('activities').setHTML('&nbsp;');
} else {
el.checked = true;
}
}
});
},
displayConditionsSmoothbox : function()
{
$('conditionsListed').setStyle('display', 'block');
$('medicalConditionListed').setStyle('display', 'block');
$$('input.conditionssmoothbox').each(
function(el) {
if (el.checked) {
TB_show('Please select the conditions you want to add and click CLOSE on the top right of this box','#TB_inline?height=375&width=570&inlineId=select_conditions','');
}
});
},
displayCountries : function()
{
if ($('countries').innerHTML != '&nbsp;') {
if (confirm("Your current country selections will be cleared to allow you to make changes. Would you like to continue?")) {
$('countries').setHTML('&nbsp;');
$$('a.countries').each(
function(el) {
if (el) {
TB_show('Please select the one or more destinations for which you will be travelling to:','#TB_inline?height=375&width=570&inlineId=select_destination','');
}
});
}
} else {
$$('a.countries').each(
function(el) {
if (el) {
TB_show('Please select the one or more destinations for which you will be travelling to:','#TB_inline?height=375&width=570&inlineId=select_destination','');
}
});
}
},
displayRetrieval : function()
{
$$('div.retrieval').each(
function(el) {
if (el) {
if ($('retrieve_quote')) {
TB_show('', '#TB_inline?height=375&width=570&inlineId=retrieve_quote','', true); 
$('TB_closeAjaxWindow').setStyle('display', 'none');
}
if ($('retrieve_xml')) {
TB_show('', '#TB_inline?height=475&width=570&inlineId=retrieve_xml','', true); 
$('TB_closeAjaxWindow').setStyle('display', 'none');
}
}
});
},
loadBubble : function() {
var id;
var idArr = $$('.helper a').getProperty('href');
var imgArr = $$('.question img');
for (var i=0; i<idArr.length; i++) {
id = idArr[i].replace(/\#/, '');
if ($(id)) imgArr[i].setProperty('title', imgArr[i].getProperty('title') + "::" + $(id).innerHTML);
}		
$$('.helper a').removeProperty('href');
},
showHelperTips : function()
{
// Reset Alt tags to blank, IE Hack
$$('.helperImg').setProperty('alt', '');
var tips = new Tips($$('.helperImg'), {
// Temporarily removed for smoother rendition of the Bubble 
/*								initialize : function() {
this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
},
onShow : function(toolTip) {
this.fx.start(1);
},
onHide : function(toolTip) {
this.fx.start(0);
},
*/							
showDelay: 0,
hideDelay: 0,
offsets: {
x: -150,
y: 16
},
fixed: false
});
},
clearInput : function()
{
if (this.name == "main[firstname]" || this.name == 'partner[firstname]' || this.name == 'children[firstname][]' || this.name == 'c[0][firstname]' || this.name == 'c[1][firstname]') {
if (this.value == 'Forename') {
this.value = '';
}
}
if (this.name == "main[lastname]" || this.name == 'partner[lastname]' || this.name == 'children[lastname][]' || this.name == 'c[0][lastname]' || this.name == 'c[1][lastname]') {
if (this.value == 'Surname') {
this.value = '';
}
}
if (this.name == "main[email]" || this.name == 'c[0][email]') {
if (this.value == 'Email') {
this.value = '';
}
}
if (this.name == "main[address1]") {
if (this.value == 'Address Line 1') {
this.value = '';
}
}
if (this.name == "main[address2]") {
if (this.value == 'Address Line 2') {
this.value = '';
}
}
if (this.name == "main[town]") {
if (this.value == 'Town') {
this.value = '';
}
}
if (this.name == "main[county]") {
if (this.value == 'County') {
this.value = '';
}
}
if (this.name == "main[pcode]") {
if (this.value == 'Postcode') {
this.value = '';
}
}
if (this.name == "main[phone]" || this.name == 'c[0][phone]') {
if (this.value == 'Telephone') {
this.value = '';
}
}
if (this.name == 'c[0][mobile]') {
if (this.value == 'Mobile') {
this.value = '';
}
}
},
refill : function()
{
if (this.name == "main[firstname]" || this.name == 'partner[firstname]' || this.name == 'children[firstname][]' || this.name == 'c[0][firstname]' || this.name == 'c[1][firstname]') {
if (this.value == '') {
this.value = "Forename";
}
}
if (this.name == "main[lastname]" || this.name == 'partner[lastname]' || this.name == 'children[lastname][]' || this.name == 'c[0][lastname]' || this.name == 'c[1][lastname]') {
if (this.value == '') {
this.value = "Surname";
}
}
if (this.name == "main[email]" || this.name == 'c[0][email]') {
if (this.value == '') {
this.value = "Email";
}
}
if (this.name == "main[address1]") {
if (this.value == '') {
this.value = "Address Line 1";
}
}
if (this.name == "main[address2]") {
if (this.value == '') {
this.value = 'Address Line 2';
}
}
if (this.name == "main[town]") {
if (this.value == '') {
this.value = 'Town';
}
}
if (this.name == "main[county]") {
if (this.value == '') {
this.value = 'County';
}
}
if (this.name == "main[pcode]") {
if (this.value == '') {
this.value = 'Postcode';
}
}
if (this.name == "main[phone]" || this.name == 'c[0][phone]') {
if (this.value == '') {
this.value = 'Telephone';
}
}
if (this.name == 'c[0][mobile]') {
if (this.value == '') {
this.value = 'Mobile';
}
}
},
hideHomeStart : function() {
// hide by default
if ($('ncb_claims')) $('ncb_claims').setStyle('display', 'none');
if ($('ncc_claims')) $('ncc_claims').setStyle('display', 'none');
if ($('ncb')) var ncb = $('ncb').getElements('input[name=ncb]');
if ($('ncc')) var ncc = $('ncc').getElements('input[name=ncc]');
if ($('ncb')) {if (ncb[1].checked == true) $('ncb_claims').setStyle('display', 'block');}
if ($('ncc')) {if (ncc[1].checked == true) $('ncc_claims').setStyle('display', 'block');}
if ($('ncb')) {
ncb.each(function(input) {
input.addEvent('click', function() {
if (input.value == 'no') {
$('ncb_claims').setStyle('display', 'block');
} else {
$('ncb_claims').setStyle('display', 'none');
}
});
});
}
if ($('ncc')) {
ncc.each(function(input) {
input.addEvent('click', function() {
if (input.value == 'no') {
$('ncc_claims').setStyle('display', 'block');
} else {
$('ncc_claims').setStyle('display', 'none');
}
});
});
}
if ($('specificItems')) {
if ($('individualItems_amount')) $('individualItems_amount').setStyle('display', 'none');
if ($('jewellery_amount')) $('jewellery_amount').setStyle('display', 'none');
if ($('individualItems_ppamount')) $('individualItems_ppamount').setStyle('display', 'none');
var individual = $('individualItems').getElements('input[name=individualItems]');
var jewellery = $('jewellery').getElements('input[name=jewellery]');
var individual_pp = $('individualItems_pp').getElements('input[name=individualItems_pp]');
if (individual[0].checked == true) $('individualItems_amount').setStyle('display', 'block');
if (jewellery[0].checked == true) $('jewellery_amount').setStyle('display', 'block');
if (individual_pp[0].checked == true) $('individualItems_ppamount').setStyle('display', 'block');	
/*			if ($('individualItems_amount')) {
var individualItems_amount = new Fx.Slide('individualItems_amount').hide();
var individual = $('individualItems').getElements('input[name=individualItems]');
individual.each(function(input) {
input.addEvent('click', function() {
if (input.value == 'yes') {
individualItems_amount.slideIn();
} else {
individualItems_amount.slideOut();
}
});
});
}	
if ($('jewellery_amount')) {
var jewellery_amount = new Fx.Slide('jewellery_amount').hide();
var jewellery = $('jewellery').getElements('input[name=jewellery]');
jewellery.each(function(input) {
input.addEvent('click', function() {
if (input.value == 'yes') {
jewellery_amount.slideIn();
} else {
jewellery_amount.slideOut();
}
});
});
}	
if ($('individualItems_ppamount')) {
var individualItems_ppamount = new Fx.Slide('individualItems_ppamount').hide();
var individual_pp = $('individualItems_pp').getElements('input[name=individualItems_pp]');
individual_pp.each(function(input) {
input.addEvent('click', function() {
if (input.value == 'yes') {
individualItems_ppamount.slideIn();
} else {
individualItems_ppamount.slideOut();
}
});
});
}	*/
individual.each(function(input) {
input.addEvent('click', function() {
if (input.value == 'yes') {
$('individualItems_amount').setStyle('display', 'block');
} else {
$('individualItems_amount').setStyle('display', 'none');
}
});
});
jewellery.each(function(input) {
input.addEvent('click', function() {
if (input.value == 'yes') {
$('jewellery_amount').setStyle('display', 'block');
} else {
$('jewellery_amount').setStyle('display', 'none');
}
});
});
individual_pp.each(function(input) {
input.addEvent('click', function() {
if (input.value == 'yes') {
$('individualItems_ppamount').setStyle('display', 'block');
} else {
$('individualItems_ppamount').setStyle('display', 'none');
}
});
});	
}
/*		if ($('specificItems')) {
// hide by default
if ($('individualItems_amount')) $('individualItems_amount').setStyle('display', 'none');
if ($('jewellery_amount')) $('jewellery_amount').setStyle('display', 'none');
if ($('individualItems_ppamount')) $('individualItems_ppamount').setStyle('display', 'none');
if ($('ncb_claims')) $('ncb_claims').setStyle('display', 'none');
if ($('ncc_claims')) $('ncc_claims').setStyle('display', 'none');
var individual = $('individualItems').getElements('input[name=individualItems]');
var jewellery = $('jewellery').getElements('input[name=jewellery]');
var individual_pp = $('individualItems_pp').getElements('input[name=individualItems_pp]');
if ($('ncb')) var ncb = $('ncb').getElements('input[name=ncb]');
if ($('ncc')) var ncc = $('ncc').getElements('input[name=ncc]');
if (individual[0].checked == true) $('individualItems_amount').setStyle('display', 'block');
if (jewellery[0].checked == true) $('jewellery_amount').setStyle('display', 'block');
if (individual_pp[0].checked == true) $('individualItems_ppamount').setStyle('display', 'block');			
if ($('ncb')) {if (ncb[1].checked == true) $('ncb_claims').setStyle('display', 'block');}
if ($('ncc')) {if (ncc[1].checked == true) $('ncc_claims').setStyle('display', 'block');}
individual.each(function(input) {
input.addEvent('click', function() {
if (input.value == 'yes') {
$('individualItems_amount').setStyle('display', 'block');
} else {
$('individualItems_amount').setStyle('display', 'none');
}
});
});
jewellery.each(function(input) {
input.addEvent('click', function() {
if (input.value == 'yes') {
$('jewellery_amount').setStyle('display', 'block');
} else {
$('jewellery_amount').setStyle('display', 'none');
}
});
});
individual_pp.each(function(input) {
input.addEvent('click', function() {
if (input.value == 'yes') {
$('individualItems_ppamount').setStyle('display', 'block');
} else {
$('individualItems_ppamount').setStyle('display', 'none');
}
});
});
if ($('ncb')) {
ncb.each(function(input) {
input.addEvent('click', function() {
if (input.value == 'no') {
$('ncb_claims').setStyle('display', 'block');
} else {
$('ncb_claims').setStyle('display', 'none');
}
});
});
}
if ($('ncc')) {
ncc.each(function(input) {
input.addEvent('click', function() {
if (input.value == 'no') {
$('ncc_claims').setStyle('display', 'block');
} else {
$('ncc_claims').setStyle('display', 'none');
}
});
});
}
}*/
},
disableContents : function() {
if ($('coverType')) var cover = $('coverType').getElement('select[name=ctype]').value;
if ($('ncc')) var ncc = $('ncc').getElements('input[name=ncc]');
if ($('ncb')) var ncb = $('ncb').getElements('input[name=ncb]');
var title = $$('.title');
if (cover == 'Contents') {
// Disable all Buildings related fields, re-set defaults and hide them
title.each(function(title) {
if (title.innerHTML == 'no claims buildings discount') {
title.setStyle('display', 'none');
}
});
if ($('bdiscountDetails')) $('bdiscountDetails').setStyle('display', 'none');
if ($('ncb')) {
$('ncb_claims').setStyle('display', 'none');
ncb.each(function(input) {
input.checked = false;
input.disabled = true;
});
}
} else {
title.each(function(title) {
if (title.innerHTML == 'no claims buildings discount') {
title.setStyle('display', 'block');
}
});
if ($('bdiscountDetails')) $('bdiscountDetails').setStyle('display', 'block');
if ($('ncb')) {
ncb.each(function(input) {
input.disabled = false;
});
}
}
if (cover == 'Buildings') {		
// Disable all Contents related fields, re-set defaults and hide them
title.each(function(title) {
if (title.innerHTML == 'no claims contents discount') {
title.setStyle('display', 'none');
}
});				
$('cdiscountDetails').setStyle('display', 'none');
$('ncc_claims').setStyle('display', 'none');
ncc.each(function(input) {
input.checked = false;
input.disabled = true;
});			
if ($('pp_title')) {
$('pp_title').setStyle('display', 'none');
$('pPosessions').setStyle('display', 'none');
$('pPosessions').getElement('input[name=pposessions]').setStyle('background', 'none');
$('pPosessions').getElement('input[name=pposessions]').setStyle('background-color', '#d6d4d4');
$('pPosessions').getElement('input[name=pposessions]').disabled = true;
}			
} else {
title.each(function(title) {
if (title.innerHTML == 'no claims contents discount') {
title.setStyle('display', 'block');
}
});
if ($('pp_title')) {
$('pp_title').setStyle('display', 'block');
$('pPosessions').setStyle('display', 'block');
$('pPosessions').getElement('input[name=pposessions]').setStyle('background-image', 'url(/images/boxbg.gif)');
$('pPosessions').getElement('input[name=pposessions]').setStyle('background-color', 'transparent');
$('pPosessions').getElement('input[name=pposessions]').disabled = false;
}
if ($('cdiscountDetails')) $('cdiscountDetails').setStyle('display', 'block');
if ($('ncc')) {
ncc.each(function(input) {
input.disabled = false;
});
}
}
/*		if ($('individualItems')) {
if ($('coverType')) var cover = $('coverType').getElement('select[name=ctype]').value;
var individualItems = $('individualItems').getElements('input[name=individualItems]');
var jewellery = $('jewellery').getElements('input[name=jewellery]');
var individualItems_pp = $('individualItems_pp').getElements('input[name=individualItems_pp]');
if ($('ncc')) var ncc = $('ncc').getElements('input[name=ncc]');
if ($('ncb')) var ncb = $('ncb').getElements('input[name=ncb]');
var title = $$('.title');
if (cover == 'Contents') {
// Disable all Buildings related fields, re-set defaults and hide them
title.each(function(title) {
if (title.innerHTML == 'no claims buildings discount') {
title.setStyle('display', 'none');
}
});
if ($('bdiscountDetails')) $('bdiscountDetails').setStyle('display', 'none');
if ($('ncb')) {
$('ncb_claims').setStyle('display', 'none');
ncb.each(function(input) {
input.checked = false;
input.disabled = true;
});
}
} else {
title.each(function(title) {
if (title.innerHTML == 'no claims buildings discount') {
title.setStyle('display', 'block');
}
});
if ($('bdiscountDetails')) $('bdiscountDetails').setStyle('display', 'block');
if ($('ncb')) {
ncb.each(function(input) {
input.disabled = false;
});
}
}
if (cover == 'Buildings') {		
// Disable all Contents related fields, re-set defaults and hide them
title.each(function(title) {
if (title.innerHTML == 'specified items under contents') {
title.setStyle('display', 'none');
}
if (title.innerHTML == 'specified items under personal possessions') {
title.setStyle('display', 'none');
}
if (title.innerHTML == 'no claims contents discount') {
title.setStyle('display', 'none');
}
});				
if ($('pp_title')) {
$('pp_title').setStyle('display', 'none');
$('pPosessions').setStyle('display', 'none');
$('pPosessions').getElement('input[name=pposessions]').setStyle('background', 'none');
$('pPosessions').getElement('input[name=pposessions]').setStyle('background-color', '#d6d4d4');
$('pPosessions').getElement('input[name=pposessions]').disabled = true;
}
if ($('specificItems')) $('specificItems').setStyle('display', 'none');
$('individualItems_amount').getElement('input[name=individualItems_amount]').value = '';
$('individualItems_amount').setStyle('display', 'none');
individualItems.each(function(input) {
input.checked = false;
input.disabled = true;
});
if ($('specificItems_pp')) $('specificItems_pp').setStyle('display', 'none');
$('jewellery_amount').getElement('input[name=jewellery_amount]').value = '';
$('jewellery_amount').setStyle('display', 'none');
jewellery.each(function(input) {
input.checked = false;
input.disabled = true;
});
$('individualItems_ppamount').getElement('input[name=individualItems_ppamount]').value = '';
$('individualItems_ppamount').setStyle('display', 'none');
individualItems_pp.each(function(input) {
input.checked = false;
input.disabled = true;
});
$('cdiscountDetails').setStyle('display', 'none');
$('ncc_claims').setStyle('display', 'none');
ncc.each(function(input) {
input.checked = false;
input.disabled = true;
});			
} else {
title.each(function(title) {
if (title.innerHTML == 'specified items under contents') {
title.setStyle('display', 'block');
}
if (title.innerHTML == 'specified items under personal possessions') {
title.setStyle('display', 'block');
}
if (title.innerHTML == 'no claims contents discount') {
title.setStyle('display', 'block');
}
});
if ($('pp_title')) {
$('pp_title').setStyle('display', 'block');
$('pPosessions').setStyle('display', 'block');
$('pPosessions').getElement('input[name=pposessions]').setStyle('background-image', 'url(/images/boxbg.gif)');
$('pPosessions').getElement('input[name=pposessions]').setStyle('background-color', 'transparent');
$('pPosessions').getElement('input[name=pposessions]').disabled = false;
}
individualItems.each(function(input) {
input.disabled = false;
});
jewellery.each(function(input) {
input.disabled = false;
});
if ($('specificItems_pp')) $('specificItems_pp').setStyle('display', 'block');
individualItems_pp.each(function(input) {
input.disabled = false;
});
if ($('cdiscountDetails')) $('cdiscountDetails').setStyle('display', 'block');
if ($('ncc')) {
ncc.each(function(input) {
input.disabled = false;
});
}
}
}*/
},
jumpSCBox : function() {
if ($('sc1').value.length == '2') {
$('sc2').focus();
}
if ($('sc2').value.length == '2') {
$('sc3').focus();
}
}
};
function initPage() { page.init();}