// JavaScript Document

<!--
//initial checkCount of zero
var checkCount=0;

var skiing;

var total=0;

//maximum number of allowed checked boxes

function setChecks(obj){
	var no=document.getElementById("noofdays").value;
	var maxChecks=no*2;
	//increment/decrement checkCount
	if (obj.value == "2 - 4 Days Skiing") {
		checkCount=checkCount;
	} else {		
		if(obj.checked){
			checkCount=checkCount+1;
		} else{
			checkCount=checkCount-1;
		}
	} 
	
	
	if (document.getElementById("noofdays").value == "") {
		obj.checked=false;
		checkCount=checkCount-1;
		alert('Please select the no. of days of your stay');
	} else {
	
	
		if ((obj.value == "2 - 4 Days Skiing" && (document.getElementById("noofnights").value == "" || document.getElementById("noofdayslunch").value == "" || document.getElementById("noofdaysevemeal").value == "")) || (obj.value == "2 - 4 Days Skiing" && (document.getElementById("noofnights").value != 0 || document.getElementById("noofdays").value != 0 || document.getElementById("noofdayslunch").value != 0 || document.getElementById("noofdaysevemeal").value != 0))) {
			obj.checked=false;
			alert('2 - 4 Days Skiing is all inclusive and is only available as a single activity. To select this option please ensure that all the drop down menus are set to 0');
		}
	
		for (i = 0; i < document.plannerandquote.activities.length; i++) {
			if (document.plannerandquote.activities[i].checked) {
				if (document.plannerandquote.activities[i].value == "2 - 4 Days Skiing" && obj.value != "2 - 4 Days Skiing") {
					skiing = true;
					obj.checked=false;
					alert("Unfortunaly 2 - 4 Days Skiing is only avaiable as a single activity");		
				} else {
					skiing = false;
				} 
			}
		}
	
		if (no == 0 && obj.value != "2 - 4 Days Skiing" && !skiing && document.getElementById("noofdays").value != "") {		
		
			for (var i=0; i < document.plannerandquote.typeof_eventbreak.length; i++) {
  				if (document.plannerandquote.typeof_eventbreak[i].checked) {
      				rad_temp = document.plannerandquote.typeof_eventbreak[i].value;
      			}
   			}
			if (rad_temp == "Corporate Event") {
				if (maxChecks == 0) {
					obj.checked=false;
					alert("You are only able to select 2 - 4 Days Skiing. To select another activity please increase the no. of days of your stay");
				}
			} else {
				if (maxChecks == 0) {
					obj.checked=false;
					checkCount=checkCount-1;
					alert('The no. of days of your stay must be more than 1');
				}
			}
		} else if (obj.value != "2 - 4 Days Skiing" && document.getElementById("noofdays") != "" && maxChecks > 0) {
			if (obj.checked) {
				if (checkCount>maxChecks){
				obj.checked=false;
				checkCount=checkCount-1;
				alert('You may only choose up to '+maxChecks+' activities');
				}
			}
		}
		
	} // End of first check.
	
	
	//alert(checkCount);
}
//-->
