var notification, Notification = Class.create();
Notification.prototype = {
	initialize: function(){
		this.row = false;
	},
	
	alert: function(message, object){
		alert(message);
		
		if(object){
			tickcheckbox(object, '');
		}
	},
	
	check_day_value: function(object){
		value = parseInt(object.value);
		if(value < 90000 || value > 450000){
			alert('It is not possible to make an online premium calculation for this current value.\n\nThe current value must range from EUR 90,000 to EUR 450,000.\n\nPlease send us an email (to yachtinsurance@commandeur.nu) or fax (to +31(0)228 566 676) for a tailor-made quote.');
			object.focus();
		}
	},
	
	impossible_agreement: function(object){
		alert("Since you do not agree with the final statement, it is not possible to obtain the Commandeur Comprehensive Insurance online. We kindly ask you to contact us by email, at yachtinsurance@commandeur.nu or by fax, at +31 (0)228 566 676.")
	
		tickcheckbox(object, '');
	},
	
	inform_change_day_value: function(){
		alert("Note: Any changes made will alter the premium indication you received earlier.")
	},
	
	impossible_boat_type: function(object){
		alert("It is not possible to prepare an online premium calculation for your type of vessel.\n\nPlease send us an email (to yachtinsurance@commandeur.nu) or fax (to +31(0)228 566 676) for a tailor-made quote.")
	
		tickcheckbox(object, '');
	},
	
	impossible_area_type: function(object){
		alert("It is not possible to prepare an online premium calculation for your sailing area.\n\nPlease send us an email (to yachtinsurance@commandeur.nu) or fax (to +31(0)228 566 676) for a tailor-made quote.")
	
		tickcheckbox(object, '');
	},
	
	impossible_taxation: function(object){
		alert("If you like our offer - which you will receive shortly - please make sure to have an appraisal report prepared before the effective date of the policy and send us a copy thereof.")
	},
	
	polis_address: function(object){
		this.toggle(object, 'postadres', true);
	},
	
	polis_extra_boat: function(object){
		if(!this.row) this.row = $('extra_boats_content').innerHTML;
		
		status = this.toggle(object, 'extra_boat', true);

		$('misc_extra_boats').selectedIndex = 0;

		if(status == 'true'){		
			$('extra_boats_content').innerHTML = this.row;
			$('extra_boats').style.display = '';
		} else {
			$('extra_boats').style.display = 'none';
		}
	},
	
	check_sail_area: function(object){
		if(object.id.indexOf('_4') > 0){
			$('sail_area_degrees').style.display = '';
		} else {
			fields = document.getElementsByClassName('degree');
			for(i=0; i<fields.length; i++){
				fields[i].value = '';
			}
		
			$('sail_area_degrees').style.display = 'none';
		}
	},
	
	toggle: function(object, element, status){
		if(this.is_checked(object)){
			if(object.id.indexOf('_0') > 0) set_open = false;
			else set_open = true;
		} else {
			if(object.id.indexOf('_0') > 0) set_open = true;
			else set_open = false;
		}
		
		if(set_open == status){
			new Effect.Appear(element, {duration: 0.5});
			
			new Effect.ScrollTo(element);
			
			return true;
		} else {
			$(element).style.display = 'none';
			
			return false;
		}
	},
	
	polis_refresh_extra_boats: function(object){
		value = object.selectedIndex;
		value++;
		$('extra_boats_content').innerHTML = '';

		for(i=0; i<value; i++){
			row = this.row;
			
			if(i > 0){
				while(row.indexOf('_0') > 0){
					row = row.replace('_0', '_' + i);
				}
			}
		
			new Insertion.Bottom('extra_boats_content', row);
		}
	},
	
	polis_validate_extra_boat: function(values){
		for(i=0; i<values.length; i++){
			for(x=0; x<values[i].length; x++){
				field = $('extra_boat_' + i + '_' + values[i][x][0]);
				
				if(field){
					field.value = values[i][x][1];
			
					if(field.value == ''){
						$('extra_boat_' + i + field.id.replace('extra_boat_' + i, '') + '_error').className = 'fieldWithErrors';
					}
				}
			}
		}
	},
	
	is_checked: function(object){
		if(object.src.indexOf('_checked') > 0){
			return true;
		} else {
			return false;
		}
	}
}

function format_currency(amount){
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s.replace('.', ',');
}