//====================================================================================================
//	Function Name	:	Form_Submit()
//	Purpose			:	This function will executed when user submits a Label form. It checks validity of 
//						every field in the form.
//	Parameters		:	frm  - form name
//	Return			:	true or false
 //----------------------------------------------------------------------------------------------------

function Form_Submit(frm)
{
	tailorAccomLevel =  document.getElementsByName('tailor_visit_dest[]');
 	with(frm)
    {	
 		var flg = false;
		 
		 
		for(i = 0; i < tailorAccomLevel.length; i++)
		{
			if(tailorAccomLevel[i].checked == true)
				flg = true;
		}
		
		$('.singleCheck').each(function(index){
			if($(this).attr('checked')== true)
			{
				flg = true;
			}			
		});
		$('.arrCheck').each(function(index){
		
		if($(this).attr('checked')== true)
		{
				flg = true;
		}
		});	
		
	
		if(!flg)
		{
			alert('Please Select any one destination.');
			return false;
		}
/*		if(!IsEmpty(tailor_person_name, 'Please enter name.'))
		{
 			return false;
		}
		if(!IsEmpty(tailor_person_email, 'Please enter e-mail address.'))
        {
 			return false;
        }
		else if(!IsEmail(tailor_person_email, 'Please, enter valid e-mail address.'))
        {
 			return false;
        }		
*/		if(!IsSelected(tailor_people_travel, 'Please enter number of people traveling.'))
		{
			return false;
		}
		else if(!IsInt(tailor_people_travel, 'Oppsss!!! Invalid input. \nPlease re-check number of people traveling.'))
		{
			return false;
		}
		
		
		if(tailor_room_single.value==0 && tailor_room_double_two_bed.value==0 && tailor_room_triple.value==0)
		{
			alert("Please enter number of rooms for any one.")
			tailor_room_single.focus();
			return false;
		}
		
		if(tailor_dep_from_date_month.value==04 || tailor_dep_from_date_month.value==06 || tailor_dep_from_date_month.value==09 || tailor_dep_from_date_month.value==11)
		{
			if(tailor_dep_from_date_day.value>30)
			{
				alert("wrong days departure from date!!");
				return false;
			}
		}
		else if(tailor_dep_from_date_month.value==02)
		{
			if((tailor_dep_from_date_year.value % 4 == 0) && ( (!(tailor_dep_from_date_year.value % 100 == 0)) || (tailor_dep_from_date_year.value % 400 == 0)))
			{
				if(tailor_dep_from_date_day.value>29)
				{
					alert("Wrong days for departure from date!!");
					return false;
				}
			}
			else if(tailor_dep_from_date_day.value>28)
			{
				alert("Wrong days for departure from date!!");
				return false;
			}
		}
   
		if(tailor_dep_from_date_day.value<10)
		{
			var tailor_dep_from_date = tailor_dep_from_date_year.value+'-'+tailor_dep_from_date_month.value+'-'+0+tailor_dep_from_date_day.value;
		}
		else
		{
			var tailor_dep_from_date = tailor_dep_from_date_year.value+'-'+tailor_dep_from_date_month.value+'-'+tailor_dep_from_date_day.value;
		}
		
			/*if(tailor_dep_to_date_day.value<10)
			{
				var tailor_dep_to_date = tailor_dep_to_date_year.value+'-'+tailor_dep_to_date_month.value+'-'+0+tailor_dep_to_date_day.value;
			}
			else
			{
				var tailor_dep_to_date = tailor_dep_to_date_year.value+'-'+tailor_dep_to_date_month.value+'-'+tailor_dep_to_date_day.value;
			}
			*/
		/*if(tailor_dep_to_date >= CurrDate.value)
		{
			if(tailor_dep_from_date > tailor_dep_to_date || tailor_dep_from_date < CurrDate.value)
			{
				alert("Please select date greater or same as current date & less than departure to date.")
				return false;
			}
		}*/
		
		/*if(tailor_dep_to_date_month.value==04 || tailor_dep_to_date_month.value==06 || tailor_dep_to_date_month.value==09 || tailor_dep_to_date_month.value==11)
		{
			if(tailor_dep_to_date_day.value>30)
			{
				alert("Wrong days for departure to date!!");
				return false;
			}
		}
		else if(tailor_dep_to_date_month.value==02)
		{
			if((tailor_dep_to_date_year.value % 4 == 0) && ( (!(tailor_dep_to_date_year.value % 100 == 0)) || (tailor_dep_to_date_year.value % 400 == 0)))
			{
				if(tailor_dep_to_date_day.value>29)
				{
					alert("Wrong days for departure to date!!");
					return false;
				}
			}
			else if(tailor_dep_to_date_day.value>28)
			{
				alert("wrong days for departure to date!!");
				return false;
			}
		}*/
		
/*		if(tailor_dep_to_date <= CurrDate.value || tailor_dep_to_date < tailor_dep_from_date)
		{
			alert("Please select date greater than current date & departure from date.")
			return false;
		}
*/		
		if(!IsEmpty(tailor_prefere_duration, 'Please enter duration you preferred for trip.'))
        {
 			return false;
        }
		
		/*for(p = 0; p < tailor_health_issue.length; p++)
		{
			if(tailor_health_issue[p].checked == true)
			{
				if(tailor_health_issue[p].value == 'Yes')
				{
					if(!IsEmpty(tailor_health_issue_specify, 'Please specify health issues or physical restrictions.'))
					{
						return false;
					}
				}
			}
		}*/
	}
 	return true;
}

	
function reloadCaptcha(Site_Root)
{
	document.getElementById("capatch_image_id").src = Site_Root+"image.php?time="+ Date();
}
 
function ContactForm_Submit(frm)
{
  	with(frm)
    {	
   		if(!IsEmpty(tailor_person_name, 'Please enter name.'))
		{
 			return false;
		}
		if(!IsEmpty(tailor_person_email, 'Please enter e-mail address.'))
        {
 			return false;
        }
		else if(!IsEmail(tailor_person_email, 'Please, enter valid e-mail address.'))
        {
 			return false;
        }		
		if(!IsEmpty(code_of_image, 'Please enter code shown in image.'))
		{
			code_of_image.focus();			
			return false;
		}				
	}
    
   	return true;
}

function CalcNoOfTraveler()
{
	total_room = Number(document.getElementById('tailor_room_single').value)+Number(document.getElementById('tailor_room_double_two_bed').value) +Number(document.getElementById('tailor_room_triple').value); 
	total_traveler = Number(document.getElementById('tailor_room_single').value * 1)+Number(document.getElementById('tailor_room_double_two_bed').value *2) + Number(document.getElementById('tailor_room_triple').value * 3); 
  if(total_room > 0 || total_traveler > 0)
  {
	  $('#nooftraveler').show();
 	   $('#Txtroom').html(total_room);
	    $('#TxtTraveler').html(total_traveler);
	  
  }
 
}

function checkbox(id)
{
		//var count = 0;
		if(id == 0)
		{
	//			alert('m here');
//				document.getElementById('tailor_visit_dest[]').value();
				$('.singleCheck').each(function(index){
					if($(this).val() == id)
					{
						if($(this).attr('checked')== false)
						{
							$(this).attr('checked','checked');
						}
						else
						{
							$(this).attr('checked','');	
						}
					}		
				});
				
		}
		else
		{
				$('.arrCheck').each(function(index){
					if($(this).val() == id)
					{
						if($(this).attr('checked')== false)
						{
							$(this).attr('checked','checked');
						}
						else
						{
							$(this).attr('checked','');	
						}
					}
					return true;
 		 		});	
		}
}

 
