// ***************************************************************************************************************************************
// Default declaration and initialization
var strSelWeekendSubType = "";
// ***************************************************************************************************************************************
// Function - Used to hide or display menu
function DispLocations(strWeekendSubType)
{
	if (strSelWeekendSubType == strWeekendSubType)
	{
		strSelWeekendSubType = "";
		document.getElementById('UKWeekends').style.display = "none";
		document.getElementById('AbroadWeekends').style.display = "none";
	}
	else if (strWeekendSubType == "UKWeekends")
	{
		strSelWeekendSubType = strWeekendSubType;
		document.getElementById('UKWeekends').style.display = "block";
		document.getElementById('AbroadWeekends').style.display = "none";
	}
	else if (strWeekendSubType == "AbroadWeekends")
	{
		strSelWeekendSubType = strWeekendSubType;
		document.getElementById('UKWeekends').style.display = "none";
		document.getElementById('AbroadWeekends').style.display = "block";
	}
}
// ***************************************************************************************************************************************
// Function - Used to validate user input
function LMValidateInput()
{
	if (LMTrim(document.frmLMMyInfo.txtLMName.value) == "")
    {
        alert("Please enter your name.");
        document.frmLMMyInfo.txtLMName.focus();
        return false;
    }
    else if (LMTrim(document.frmLMMyInfo.txtLMEmail.value) == "")
    {
        alert("Please enter your email address.");
        document.frmLMMyInfo.txtLMEmail.focus();
        return false;
    }
    else if (LMVlidateEmail(LMTrim(document.frmLMMyInfo.txtLMEmail.value)) == false)
    {
        alert("Please enter valid email address.");
        document.frmLMMyInfo.txtLMEmail.focus();
        return false;
    }
    else if (LMTrim(document.frmLMMyInfo.txtLMContactNo.value) == "")
    {
        alert("Please enter your Contact Number.");
        document.frmLMMyInfo.txtLMContactNo.focus();
        return false;
    }
	else if (document.frmLMMyInfo.cmbLMPreferredMethod.value == "")
    {
        alert("Please select the preferred contact method.");
        document.frmLMMyInfo.cmbLMPreferredMethod.focus();
        return false;
    }
    else if (LMTrim(document.frmLMMyInfo.txtLMRequirements.value) == "")
    {
        alert("Please enter your requirements.");
        document.frmLMMyInfo.txtLMRequirements.focus();
        return false;
    }
    else if (LMTrim(document.frmLMMyInfo.cmbLMDestination.value) == "")
    {
        alert("Please select destination.");
        document.frmLMMyInfo.cmbLMDestination.focus();
        return false;
    }
    else if (LMTrim(document.frmLMMyInfo.cmbLMDates.value) == "")
    {
        alert("Please select dates.");
        document.frmLMMyInfo.cmbLMDates.focus();
        return false;
    }
    else if (LMTrim(document.frmLMMyInfo.txtLMNumbers.value) == "")
    {
        alert("Please enter the group count.");
        document.frmLMMyInfo.txtLMNumbers.focus();
        return false;
    }
	else if (IsNumeric(LMTrim(document.frmLMMyInfo.txtLMNumbers.value)) == false)
	{
		alert("Please enter the valid group count.");
        document.frmLMMyInfo.txtLMNumbers.focus();
        return false;
	}
	
	// Fetch the name of the selected Destination
	document.frmLMMyInfo.hdnDestination.value = document.frmLMMyInfo.cmbLMDestination.options[document.frmLMMyInfo.cmbLMDestination.selectedIndex].text;
	
	// Submit the form
    return true;
}
// ***************************************************************************************************************************************
// Function - Used to remove trailing and leading spaces
function LMTrim(strString)
{
   return strString.replace(/^\s*|\s*$/g,"");
}
// ***************************************************************************************************************************************
// Function - Used to make a check whether supplied input is a number or not
function IsNumeric(strValue)
{
	var strChar;
	var IsNumber = true;
	var strValidChars = "0123456789";
	
	for (i = 0; i < strValue.length && IsNumber == true; i++) 
	{
		strChar = strValue.charAt(i); 
		if (strValidChars.indexOf(strChar) == -1) 
		{
			IsNumber = false;
		}
	}
	
	return IsNumber;
}
// ***************************************************************************************************************************************
// Function - Used to validate email address
function LMVlidateEmail(str)
{
    var at="@"
    var dot="."
    var lat=str.indexOf(at)
    var lstr=str.length
    var ldot=str.indexOf(dot)
    
    if (str.indexOf(at)==-1)
    {
       return false;
    }
    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
    {
       return false;
    }
    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
    {
        return false;
    }
    if (str.indexOf(at,(lat+1))!=-1)
    {
        return false;
    }
    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
    {
        return false;
    }
    if (str.indexOf(dot,(lat+2))==-1)
    {
        return false;
    }
    if (str.indexOf(" ")!=-1)
    {
        return false;
    }
}
// ***************************************************************************************************************************************