//***************HOTEL SPECIFIC VALIDATIONS START*********************//

function ContactpersonInfoValidation(ddl1, txtFN1, txtLN1, ddl2, txtFN2, txtLN2, chk) {
    alert('hai');
}

function ShowChildAgePanel(ddlName, pnlName) {

    var dropdownIndex = document.getElementById(ddlName).selectedIndex;

    if (dropdownIndex == 0) {
        document.getElementById(pnlName).style.visibility = 'hidden';
        for (var i = 1; i <= 8; i++) {
            document.getElementById('ccDdl' + i).style.visibility = 'hidden';
            document.getElementById('ccDdl' + i).selectedIndex = 0;
        }
    }
    else {

        document.getElementById(pnlName).style.visibility = 'visible';

        for (var i = 1; i <= 8; i++) {
            if (i > (dropdownIndex)) {
                document.getElementById('ccDdl' + i).style.visibility = 'hidden';
                document.getElementById('ccDdl' + i).selectedIndex = 0;
            }
            else {
                document.getElementById('ccDdl' + i).style.visibility = 'visible';
            }
        }
    }
}

function ShowChildAgePanelOnLoad() {
    var argv = ShowChildAgePanelOnLoad.arguments;
    var argc = argv.length;
    var argCnt = 0;

    //var dropdownIndex = document.getElementById( ddlName ).selectedIndex; 

    for (var i = 0; i < argc; i++) {
        if (argv[i] > 1) {
            document.getElementById('ccDdl' + i).style.visibility = 'visible';
            argCnt++;
        }
        else {
            document.getElementById('ccDdl' + i).style.visibility = 'hidden';
        }
    }

    if (argCnt > 0) {
        document.getElementById('ccDdlNoOfExtraBed').style.visibility = 'visible';
        document.getElementById('ccPnlFirstColapsibleTop').style.visibility = 'visible';
    }
    else {
        document.getElementById('ccDdlNoOfExtraBed').style.visibility = 'hidden';
        document.getElementById('ccPnlFirstColapsibleTop').style.visibility = 'hidden';
        document.getElementById('ccPnlFirstColapsibleTop').style.height = '0px';
    }
}

function CheckTotalRoomsRequired(ctrl1, ctrl2, ctrl3, ctrl4, ctrl5, ctrl6, CtrlChgd, CtrlPanel, ctrl7) {
    var SBGuestCnt = parseInt(document.getElementById(ctrl1).options[document.getElementById(ctrl1).selectedIndex].text);
    var DBGuestCnt = parseInt(document.getElementById(ctrl2).options[document.getElementById(ctrl2).selectedIndex].text);
    var TRGuestCnt = parseInt(document.getElementById(ctrl3).options[document.getElementById(ctrl3).selectedIndex].text);
    var QGuestCnt = parseInt(document.getElementById(ctrl4).options[document.getElementById(ctrl4).selectedIndex].text);
    var TSGuestCnt = parseInt(document.getElementById(ctrl5).options[document.getElementById(ctrl5).selectedIndex].text);
    var TBGuestCnt = parseInt(document.getElementById(ctrl6).options[document.getElementById(ctrl6).selectedIndex].text);
    var TBChildGuestCnt = 0;
    if (document.getElementById(ctrl7) != null) {
        TBChildGuestCnt = parseInt(document.getElementById(ctrl7).options[document.getElementById(ctrl7).selectedIndex].text);
    }

    //var KGSGuestCnt = parseInt(document.getElementById( ctrl7 ).options[document.getElementById( ctrl7 ).selectedIndex].text);
    //var KGDGuestCnt = parseInt(document.getElementById( ctrl8 ).options[document.getElementById( ctrl8 ).selectedIndex].text);
    // var QNSGuestCnt = parseInt(document.getElementById( ctrl9 ).options[document.getElementById( ctrl9 ).selectedIndex].text);
    // var QNDGuestCnt = parseInt(document.getElementById( ctrl10 ).options[document.getElementById( ctrl10 ).selectedIndex].text);

    var MaxNoOfGuest = TBChildGuestCnt + SBGuestCnt + DBGuestCnt * 2 + TRGuestCnt * 3 + QGuestCnt * 4 + TSGuestCnt + TBGuestCnt * 2;

    if (MaxNoOfGuest > 8) {
        document.getElementById(CtrlChgd).selectedIndex = 0;
        window.alert('Booking of more than 8 guest not allowed. Please change your option to continue.\n Suggestions:  \n (1). 2 Quad Rooms Or 4 Double Rooms \n (2). 2 Double Room and 1 Quad Room \n (3). 2 Triple Room and 1 Double Room \n (4). 2 Single Room and 1 Double Room and 1 Quad Room \n (5). 2 Double Room and 2 Twin Room \n (6). 2 Single Room and 2 Twin (for sole use) Room and 1 Quad Room');
        return false;
    }
}

function CheckPageContentsBeforeSubmitHotel(city, Date1, Date2, ctrl1, ctrl2, ctrl3, ctrl4, ctrl5, ctrl6) {
    var SBGuestCnt = parseInt(document.getElementById(ctrl1).options[document.getElementById(ctrl1).selectedIndex].text);
    var DBGuestCnt = parseInt(document.getElementById(ctrl2).options[document.getElementById(ctrl2).selectedIndex].text);
    var TRGuestCnt = parseInt(document.getElementById(ctrl3).options[document.getElementById(ctrl3).selectedIndex].text);
    var QGuestCnt = parseInt(document.getElementById(ctrl4).options[document.getElementById(ctrl4).selectedIndex].text);
    var TSGuestCnt = parseInt(document.getElementById(ctrl5).options[document.getElementById(ctrl5).selectedIndex].text);
    var TBGuestCnt = parseInt(document.getElementById(ctrl6).options[document.getElementById(ctrl6).selectedIndex].text);

    //var KGSGuestCnt = parseInt(document.getElementById( ctrl7 ).options[document.getElementById( ctrl7 ).selectedIndex].text); 
    //var KGDuestCnt = parseInt(document.getElementById( ctrl8 ).options[document.getElementById( ctrl8 ).selectedIndex].text); 
    //var QNSGuestCnt = parseInt(document.getElementById( ctrl9 ).options[document.getElementById( ctrl9 ).selectedIndex].text); 
    //var QNDGuestCnt = parseInt(document.getElementById( ctrl10 ).options[document.getElementById( ctrl10 ).selectedIndex].text); 

    var totalroomsselected = SBGuestCnt + DBGuestCnt + TRGuestCnt + QGuestCnt + TSGuestCnt + TBGuestCnt;

    var IsTrue = true;

    var msgStr = "Please review following selection(s) to continue: \n";
    var Ctrl1FocusPriority = false;
    var Ctrl2FocusPriority = false;
    var Ctrl3FocusPriority = false;
    var Ctrl4FocusPriority = false;

    if (CheckCityValue(city) == false) {
        IsTrue = false;
        msgStr = msgStr + "* Please specify a valid city.\n";
        Ctrl1FocusPriority = true;
    }

    var msgRtnd = CheckDateValues(Date1, Date2);
    if (msgRtnd != '') {
        IsTrue = false;
        msgStr = msgStr + msgRtnd;
        Ctrl2FocusPriority = true;
    }
    else if (IsGreaterDate(Date1, Date2) == false) {
        msgStr = msgStr + "* Check In Date Cannot be greater than Check Out Date. \n";
        IsTrue = false;
        Ctrl3FocusPriority = true;
    }

    if (totalroomsselected < 1) {
        IsTrue = false;
        msgStr = msgStr + "* Please select atleast one room. \n";
        Ctrl4FocusPriority = true;
    }

    if (msgStr == "Please review following selection(s) to continue: \n") {
        IsTrue = true;
    }
    else {
        IsTrue = false;
        window.alert(msgStr);
        if (Ctrl1FocusPriority == true) {
            document.getElementById(city).focus();
        }
        else if (Ctrl2FocusPriority == true) {
            document.getElementById(Date1).focus();
        }
        else if (Ctrl3FocusPriority == true) {
            document.getElementById(Date1).focus();
        }
        else if (Ctrl4FocusPriority == true) {
            document.getElementById(ctrl1).focus();
        }
    }
    return IsTrue;
}

function CheckCityValue(city) {
    var IsTrue = true;
    if (document.getElementById(city).value == '') {
        //window.alert('City cannot be blank.');
        IsTrue = false;
    }

    return IsTrue;
}

function CheckDateValues(Date1, Date2) {
    //var IsTrue = '';
    var hasMsg = '';
    if (document.getElementById(Date1).value == '') {
        //window.alert('Please enter a check in date');
        hasMsg = hasMsg + '* Please enter a check in date. \n';
    }
    if (document.getElementById(Date2).value == '') {
        //window.alert('Please enter a check out date.');
        hasMsg = hasMsg + '* Please enter a check out date. \n';
    }

    if (hasMsg == '') {
        var isDate1Msg = isDateHotel(document.getElementById(Date1).value);
        var isDate2Msg = isDateHotel(document.getElementById(Date2).value);

        if (isDate1Msg != '') {
            hasMsg = hasMsg + '* ' + isDate1Msg + ' of check in date\n';
        }
        else if (isDate2Msg != '') {
            hasMsg = hasMsg + '* ' + isDate2Msg + ' of check out date\n';
        }
        else if (document.getElementById(Date1).value == document.getElementById(Date2).value) {
            //window.alert('Check In and Check Out Date cannot be same.');
            hasMsg = hasMsg + '* Check In and Check Out Date cannot be same. \n';
        }
    }
    return hasMsg;
}

function ShowSoleUsagePanel(Combo, Panel) {
    var index = document.getElementById(Combo).selectedIndex;

    if (index > 0) {
        document.getElementById(Panel).style.visibility = 'visible';
    }
    else {
        document.getElementById(Panel).style.visibility = 'hidden';
    }
}

function ValidateSoleUsageTextBox(Combo, TextBox) {
    var combovalue = document.getElementById(Combo).options[document.getElementById(Combo).selectedIndex].text;

    var textvalue = document.getElementById(TextBox).value;

    if (isInteger(textvalue) == false) {
        document.getElementById(TextBox).value = "";
        alert("Please specify valid numeric value.");

        return false;
    }

    if (textvalue > combovalue) {
        document.getElementById(TextBox).value = combovalue;
        alert("No of rooms for sole use cannot be greater than - " + combovalue);

        return false;
    }

    return true;
}

//***************HOTEL SPECIFIC VALIDATIONS END*********************//


//***************HOSTEL SPECIFIC VALIDATIONS START*********************//
function CheckFormsBeforeSubmitHostel(City, Date1, Date2, Country, Currency, Inventory) {
    var IsTrue = true;
    var msgStr = "Please review following selection(s) to continue: \n";
    countryFocusPriority = false;
    cityFocusPriority = false;
    date1FocusPriority = false;
    date2FocusPriority = false

    if (IsCountrySelect(Country) == false) {
        IsTrue = false;
        msgStr = msgStr + "* Please select a Country.\n";
        countryFocusPriority = true;
    }
    if (IsCitySelect(City) == false) {
        IsTrue = false;
        msgStr = msgStr + "* Please select a City.\n";
        cityFocusPriority = true;
    }
    var msgRtnd = CheckDateValuesForHostels(Date1, Date2);
    if (msgRtnd != '') {

        IsTrue = false;
        msgStr = msgStr + msgRtnd;
        date1FocusPriority = true;
    }
    else if (IsGreaterDate(Date1, Date2) == false) {
        //window.alert('Check In Date Cannot be greater than Check Out Date.');
        msgStr = msgStr + "* Check In Date Cannot be greater than Check Out Date. \n";
        IsTrue = false;
        date2FocusPriority = true;
    }
    if (msgStr == "Please review following selection(s) to continue: \n") {
        IsTrue = true;
    }
    else {
        IsTrue = false;
        window.alert(msgStr);
        if (countryFocusPriority == true) {
            document.getElementById(Country).focus();
        }
        else if (cityFocusPriority == true) {
            document.getElementById(City).focus();
        }
        else if (date1FocusPriority == true) {
            document.getElementById(Date1).focus();
        }
        else if (date2FocusPriority == true) {
            document.getElementById(Date1).focus();
        }

    }
    return IsTrue;

}
function IsCountrySelect(Country) {
    var IsTrue = true;
    if (document.getElementById(Country).value == '-1') {
        IsTrue = false;
    }
    return IsTrue;
}
function IsCitySelect(City) {
    var IsTrue = true;
    if (document.getElementById(City).value == '-1') {
        IsTrue = false;
    }
    return IsTrue;
}

function CheckDateValuesForHostels(Date1, Date2) {
    var hasMsg = '';
    if (document.getElementById(Date1).value == '') {
        hasMsg = hasMsg + '* Please enter a check in date. \n';
    }
    if (document.getElementById(Date2).value == '') {
        hasMsg = hasMsg + '* Please enter a check out date. \n';
    }

    if (hasMsg == '') {
        var isDate1Msg = isDateHostel(document.getElementById(Date1).value);
        var isDate2Msg = isDateHostel(document.getElementById(Date2).value);

        if (isDate1Msg != '') {
            hasMsg = hasMsg + '* ' + isDate1Msg + ' of check in date.The date format should be : dd/mm/yyyy\n';
        }
        if (isDate2Msg != '') {
            hasMsg = hasMsg + '* ' + isDate2Msg + ' of check out date.The date format should be : dd/mm/yyyy\n';
        }

        else if (document.getElementById(Date1).value == document.getElementById(Date2).value) {
            hasMsg = hasMsg + '* Check In and Check Out Date cannot be same. \n';
        }
        else if (isDate(document.getElementById(Date1).value) == false) {
            hasMsg = hasMsg + '* Invalid Check In Date. \n';
        }
        else if (isDate(document.getElementById(Date2).value) == false) {
            hasMsg = hasMsg + '* Invalid Check Out Date. \n';
        }
    }
    return hasMsg;
}
function isDateHostel(dtStr) {  //dtStr= dd/mm/yyyy
    var msgString = "";
    var daysInMonth = DaysArray(12)
    var pos1 = dtStr.indexOf(dtCh) //2
    var pos2 = dtStr.indexOf(dtCh, pos1 + 1)//5
    var strDay = dtStr.substring(0, pos1) //substring(0,2)==dd
    var strMonth = dtStr.substring(pos1 + 1, pos2)//substring(3,5) == mm
    var strYear = dtStr.substring(pos2 + 1)//substring(6) ==yyyy

    strYr = strYear

    if (pos1 == -1 || pos2 == -1) {
        msgString = "The date format should be : dd/mm/yyyy \n";
        return msgString;
    }
    else if (strDay.length != 2) {
        msgString = "Please enter a valid day";
        return msgString;
    }
    else if (strMonth.length != 2) {
        msgString = "Please enter a valid month";
        return msgString;
    }
    else if (strYr.length != 4) {
        msgString = "Please enter a valid year";
        return msgString;
    }

    if (strDay.charAt(0) == "0" && strDay.length > 1) strDay = strDay.substring(1)
    if (strMonth.charAt(0) == "0" && strMonth.length > 1) strMonth = strMonth.substring(1)
    for (var i = 1; i <= 3; i++) {
        if (strYr.charAt(0) == "0" && strYr.length > 1) strYr = strYr.substring(1)
    }
    month = parseInt(strMonth)
    day = parseInt(strDay)
    year = parseInt(strYr)
    if (strMonth.length < 1 || month < 1 || month > 12) {
        msgString = "Please enter a valid month";
    }
    else if (strDay.length < 1 || day < 1 || day > 31 || (month == 2 && day > daysInFebruary(year)) || day > daysInMonth[month]) {
        msgString = "Please enter a valid day.The date format should be : dd/mm/yyyy";
    }
    else if (strYear.length != 4 || year == 0 || year < minYear || year > maxYear) {
        msgString = "Please enter a valid 4 digit year between " + minYear + " and " + maxYear;
    }
    else if (dtStr.indexOf(dtCh, pos2 + 1) != -1 || isInteger(stripCharsInBag(dtStr, dtCh)) == false) {
        msgString = "Please enter a valid date.The date format should be : dd/mm/yyyy";
    }
    return msgString;
}

//***************HOSTEL SPECIFIC VALIDATIONS END*********************//

//***********************************Common For All Future Projects******************************************************************

//&&&&&&&&&&&&&&&&&&&&&& VERIFY DATES IN DD/MM/YYYY FORMAT &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

// ((((((((((((((CALL FUNCTION isDate(dtStr) TO YOUR FUNCTION or to UI Control))))))))))))))))//

// Declaring valid date character, minimum year and maximum year

var dtCh = "/";
var minYear = 1900;
var maxYear = 2100;

function isInteger(s) {
    var i;
    for (i = 0; i < s.length; i++) {
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag) {
    var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary(year) {
    // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28);
}
function DaysArray(n) {
    for (var i = 1; i <= n; i++) {
        this[i] = 31
        if (i == 4 || i == 6 || i == 9 || i == 11) { this[i] = 30 }
        if (i == 2) { this[i] = 29 }
    }
    return this
}

function isDate(dtStr) {  //dtStr= dd/mm/yyyy
    var daysInMonth = DaysArray(12)
    var pos1 = dtStr.indexOf(dtCh) //2
    var pos2 = dtStr.indexOf(dtCh, pos1 + 1)//5
    var strDay = dtStr.substring(0, pos1) //substring(0,2)==dd
    var strMonth = dtStr.substring(pos1 + 1, pos2)//substring(3,5) == mm
    var strYear = dtStr.substring(pos2 + 1)//substring(6) ==yyyy
    strYr = strYear
    if (strDay.charAt(0) == "0" && strDay.length > 1) strDay = strDay.substring(1)
    if (strMonth.charAt(0) == "0" && strMonth.length > 1) strMonth = strMonth.substring(1)
    for (var i = 1; i <= 3; i++) {
        if (strYr.charAt(0) == "0" && strYr.length > 1) strYr = strYr.substring(1)
    }
    month = parseInt(strMonth)
    day = parseInt(strDay)
    year = parseInt(strYr)
    if (pos1 == -1 || pos2 == -1) {
        //window.alert("The date format should be : dd/mm/yyyy")
        return false
    }
    if (strMonth.length < 1 || month < 1 || month > 12) {
        //window.alert("Please enter a valid month")
        return false
    }
    if (strDay.length < 1 || day < 1 || day > 31 || (month == 2 && day > daysInFebruary(year)) || day > daysInMonth[month]) {
        //window.alert("Please enter a valid day")
        return false
    }
    if (strYear.length != 4 || year == 0 || year < minYear || year > maxYear) {
        //window.alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
        return false
    }
    if (dtStr.indexOf(dtCh, pos2 + 1) != -1 || isInteger(stripCharsInBag(dtStr, dtCh)) == false) {
        //window.alert("Please enter a valid date")
        return false
    }
    return true
}

function isDateHotel(dtStr) {  //dtStr= dd/mm/yyyy
    var msgString = "";
    var daysInMonth = DaysArray(12)
    var pos1 = dtStr.indexOf(dtCh) //2
    var pos2 = dtStr.indexOf(dtCh, pos1 + 1)//5
    var strDay = dtStr.substring(0, pos1) //substring(0,2)==dd
    var strMonth = dtStr.substring(pos1 + 1, pos2)//substring(3,5) == mm
    var strYear = dtStr.substring(pos2 + 1)//substring(6) ==yyyy

    strYr = strYear

    if (pos1 == -1 || pos2 == -1) {
        msgString = "The date format should be : dd/mm/yyyy";
        return msgString;
    }
    else if (strDay.length < 1 || strDay.length > 2) {
        msgString = "Please enter a valid day";
        return msgString;
    }
    else if (strMonth.length < 1 || strMonth.length > 2) {
        msgString = "Please enter a valid month";
        return msgString;
    }
    else if (strYr.length != 2 && strYr.length != 4) {
        msgString = "Please enter a valid year";
        return msgString;
    }

    if (strDay.charAt(0) == "0" && strDay.length > 1) strDay = strDay.substring(1)
    if (strMonth.charAt(0) == "0" && strMonth.length > 1) strMonth = strMonth.substring(1)
    for (var i = 1; i <= 3; i++) {
        if (strYr.charAt(0) == "0" && strYr.length > 1) strYr = strYr.substring(1)
    }
    month = parseInt(strMonth)
    day = parseInt(strDay)
    year = parseInt(strYr)
    if (strMonth.length < 1 || month < 1 || month > 12) {
        msgString = "Please enter a valid month";
    }
    else if (strDay.length < 1 || day < 1 || day > 31 || (month == 2 && day > daysInFebruary(year)) || day > daysInMonth[month]) {
        msgString = "Please enter a valid day";
    }
    else if (strYear.length != 4 || year == 0 || year < minYear || year > maxYear) {
        msgString = "Please enter a valid 4 digit year between " + minYear + " and " + maxYear;
    }
    else if (dtStr.indexOf(dtCh, pos2 + 1) != -1 || isInteger(stripCharsInBag(dtStr, dtCh)) == false) {
        msgString = "Please enter a valid date";
    }
    return msgString;
}

//function ValidateForm(){
//	var dt=document.frmSample.txtDate
//	if (isDate(dt.value)==false){
//		dt.focus()
//		return false
//	}
//    return true
// }

// ((((((((((((((CALL FUNCTION isDate(dtStr)TO YOUR FUNCTION or to UI Control ))))))))))))))))//

//&&&&&&&&&&&&&&&&&&&&&& VERIFY DATES IN DD/MM/YYYY FORMAT &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


//&&&&&&&&&&&&&&&&&&&&&& VERIFY DATES IN DD/MM/YYYY FORMAT &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

// ((((((((((((((CALL FUNCTION isDate(dtStr)TO YOUR FUNCTION or to UI Control ))))))))))))))))//

function IsGreaterDate(Date1, Date2)   //dtStr= dd/mm/yyyy
{
    var DateStart = document.getElementById(Date1).value;
    var DateEnd = document.getElementById(Date2).value;

    var pos1 = DateStart.indexOf(dtCh) //2
    var pos2 = DateStart.indexOf(dtCh, pos1 + 1) //5
    var strDay = DateStart.substring(0, pos1) //substring(0,2)==dd
    var strMonth = DateStart.substring(pos1 + 1, pos2) //substring(3,5) == mm
    var strYear = DateStart.substring(pos2 + 1) //substring(6) ==yyyy

    var pos11 = DateEnd.indexOf(dtCh) //2
    var pos21 = DateEnd.indexOf(dtCh, pos11 + 1)//5
    var strDay1 = DateEnd.substring(0, pos11)//substring(0,2)==dd
    var strMonth1 = DateEnd.substring(pos11 + 1, pos21)//substring(3,5) == mm
    var strYear1 = DateEnd.substring(pos21 + 1)//substring(6) ==yyyy

    var isTrue = false;

    if (strDay.length == 1) {
        strDay = "0" + strDay;
    }
    if (strMonth.length == 1) {
        strMonth = "0" + strMonth;
    }
    if (strYear.length == 2) {
        strYear = "20" + strYear;
    }



    if (strDay1.length == 1) {
        strDay1 = "0" + strDay1;
    }
    if (strMonth1.length == 1) {
        strMonth1 = "0" + strMonth1;
    }
    if (strYear1.length == 2) {
        strYear1 = "20" + strYear1;
    }

    if (strYear <= strYear1) {
        if (strMonth <= strMonth1) {
            if (strDay <= strDay1 || strDay > strDay1 && strMonth < strMonth1) {
                isTrue = true;

            }
            else if (strMonth == strMonth1) {
                 
                if (strDay > strDay1) {
                      isTrue = true;
                }
                else 
                {
                    isTrue = false;
                }
            }
        }
        else if (strMonth > strMonth1) {
            isTrue = true;
        }
        else {
            isTrue = false;
        }
    }
    else {

        isTrue = true;
    }
    return isTrue;

}

function ValidateDetail(Ctrl) {
    if (document.getElementById(Ctrl).value == "") {
        alert("Please specify phone number");
        document.getElementById(Ctrl).focus();
        return false;
    }

    if (!ValidateNo(document.getElementById(Ctrl).value, "1234567890+- ")) {
        alert("Please Enter Only Number");
        document.getElementById(Ctrl).focus();
        return false;
    }

    return true;
}
//***************Car Validation******************************//
function ValidateDatesMain() {
    var sep = "/";
    var dat1 = get_String_Date(document.getElementById("ccTxtPickUpdate").value, sep);
    var dat2 = get_String_Date(document.getElementById("ccTxtDropDate").value, sep);

    if (compareDates(dat1, dat2) > 0) {
        var nDat = new Date(); nDat.setFullYear(dat1.getFullYear(), dat1.getMonth(), dat1.getDate());


        nDat.setDate(nDat.getDate() + 1)



        document.getElementById("ccTxtDropDate").value = get_Date_String(nDat, sep);
    }
}

function validateSearchCar() {

    if (document.getElementById("<%=ccDdlPickCountry.ClientID%>").value == "Select") {
        alert("Select Pick Up Country");
        document.getElementById("<%=ccDdlPickCountry.ClientID%>").focus();
        return false;
    }



    return true;

}



//***********************************Common For All Future Projects******************************************************************

//checking selection of dropdown lists ,Ie, country and city seletion and date validation//


function validate(emailID) {
    if (!isValidEmail(document.getElementById(emailID).value)) {
        alert("Please enter a valid email address");
        return false;
    }
    return true;
}

function isValidEmail(email, required) {
    if (required == undefined) {   // if not specified, assume it's required
        required = true;
    }
    if (email == null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length == 0) {
        if (required) {
            return false;
        }
        return true;
    }
    if (!allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) { // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    } else if (email.indexOf("..") >= 0) { // two periods in a row is not valid
        return false;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
        return false;
    }
    return true;
}

function allValidChars(email) {
    var parsed = true;
    var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
    for (var i = 0; i < email.length; i++) {
        var letter = email.charAt(i).toLowerCase();
        if (validchars.indexOf(letter) != -1)
            continue;
        parsed = false;
        break;
    }
    return parsed;
}

// Valid Phone - Fax Number  Start

function ValidateNo(NumStr, String) {
    for (var Idx = 0; Idx < NumStr.length; Idx++) {
        var Char = NumStr.charAt(Idx);
        var Match = false;

        for (var Idx1 = 0; Idx1 < String.length; Idx1++) {
            if (Char == String.charAt(Idx1))
                Match = true;
        }

        if (!Match)
            return false;
    }
    return true;
}


// Valid Phone - Fax Number End

