
function loadCalendar() {
	alert("loading calendar..");
	 $("#datePackage").datepicker({ dateFormat: 'dd/mm/yy', numberOfMonths: [1,2] } );	
	
	alert("loded");
			

//		$('#dialog_link, ul#icons li').hover(
//		function() { $(this).addClass('ui-state-hover'); }, 
//		function() { $(this).removeClass('ui-state-hover'); }
//	);
			
}	

function getChildrenAge(children) {
	

	var max = children.options[children.selectedIndex].value;
	var childrenAgeTable = "<table width='100%'><tr>";
	
	for(var i = 1; i <= max ; i++ ) {
		childrenAgeTable += "<td width='25%' align='center'>Child "+i+"<br>Age:</td>";
	}
	childrenAgeTable += "</tr><tr>";
	
	for(var i = 1; i <= max ; i++ ) {
		childrenAgeTable += "<td width='25%' align='center'><select id=child"+i+" name =child"+i+" ><option value='--'>--</option><option>1</option><option>2</option><option>3</option><option>4</option>" +
				"<option>5</option><option>6</option><option>7</option><option>8</option><option>9</option>" +
				"<option>10</option><option>11</option><option>12</option><option>13</option><option>14</option><option>15</option></select></td>";
	}
	
	childrenAgeTable += "</tr></table>";
	

	
	document.getElementById("childrenAge").innerHTML = childrenAgeTable;
	
	//document.getElementById("childrenAge").innerHTML = "hello....";
	
}

function validatePackageSearch(packageSearchForm) {

	with (packageSearchForm)
	  {
		  if (validate_required(numberOfAdults,"Select the number of Adults")==false)
		  	{
			  numberOfAdults.focus();
			  return false;
			}
	  }
	  
	  var adults = parseInt(document.getElementById("numberOfAdults").value);
	  var child = parseInt(document.getElementById("numberOfChildren").value);
	  var rooms = parseInt(document.getElementById("numberOfRooms").value);
	  var combined = child+adults;
	  if(document.getElementById("child1")!= null){
		   var child1 = document.getElementById("child1").value;
		   if(child1=="--"){
			alert("Please enter a valid age for Child 1");  
			return false;
		   }
	  }
	  if(document.getElementById("child2")!= null){
		   var child2 = document.getElementById("child2").value;
		   if(child2=="--"){
			alert("Please enter a valid age for Child 2");  
			return false;
		   }
	  }
	  if(document.getElementById("child3")!= null){
		   var child3 = document.getElementById("child3").value;
		   if(child3=="--"){
			alert("Please enter a valid age for Child 3");  
			return false;
		   }
	  }
	  if(document.getElementById("child4")!= null){
		   var child4 = document.getElementById("child4").value;
		   if(child4=="--"){
			alert("Please enter a valid age for Child 4");  
			return false;
		   }
	  }
	 
	  if(combined > 6){
		alert("Sorry, you can only book a maximum of 6 Passengers in an online booking\n\nPlease try your search again or Call us at 1.866.573.3824 to have one of our customer service agents help you book your vacation.");
		return false;
	  }
	  
	  if(adults < 5){
	    if(adults%rooms > 0){
			alert("Sorry, the adult occupancy must be consistant for all rooms in an online booking.\n\nYou cannot have "+adults+" adults in "+rooms+" rooms.\n\nPlease Try your search again or Call us at 1.866.573.3824 to have one of our customer service agents help you book your vacation.");		
			return false;
		}
	  }else{
		if(adults%rooms > 0){
			alert("Sorry, the adult occupancy must be consistant for all rooms in an online booking.\n\nYou cannot have "+adults+" adults in "+rooms+" rooms.\n\nPlease Try your search again or Call us at 1.866.573.3824 to have one of our customer service agents help you book your vacation.");		
			return false;
		}
		if(rooms == 1){
			alert("Sorry, you cannot book "+adults+" adults in one room.\n\nPlease Try your search again or Call us at 1.866.573.3824 to have one of our customer service agents help you book your vacation.");
			return false;
		} 
	  }
	  if(rooms == 1){
		if(child > 3){
			alert("Sorry, you cannot book "+child+" children in one room.\n\nPlease Try your search again or Call us at 1.866.573.3824 to have one of our customer service agents help you book your vacation.");
			return false;
		}
		if(combined > 5){
			alert("Sorry, you cannot book "+combined+" people in one room.\n\nPlease Try your search again or Call us at 1.866.573.3824 to have one of our customer service agents help you book your vacation.");
			return false;
		}
	  }
	  var dep_date = document.getElementById("date").value;
	  var date_array = dep_date.split("/");
	  //alert(date_array[0].length);
	  if(date_array[0].length > 2){
			alert("You've entered an invalid date format.  Please use DD/MM/YYYY, or use our calendar to pick a specific date.")
			return false;
	  }
	  return true;
}


function validate_required(field,alerttxt)
{
with (field)
  {

  if (value==null||value=="" || value == "0" )
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
}