function funcTrim(paramString)
{
    var strString=new String(paramString);
    var strReturnText;
    strReturnText="";
    bNonBlankStarted=false;
    bNonBlankEnded=false;
    strIntermediateBlankChunk="";
    var iLoop;
    for(iLoop=0;iLoop<strString.length;iLoop++)
    {
        if(strString.charCodeAt(iLoop)!=32)
        {
            if(!bNonBlankStarted)
            {
                bNonBlankStarted=true;
            }
            if(bNonBlankStarted && !bNonBlankEnded)
            {
                strReturnText+=strString.charAt(iLoop);
            }
            if(bNonBlankEnded)
            {
                strReturnText+=(strIntermediateBlankChunk+strString.charAt(iLoop));
                bNonBlankEnded=false;
                strIntermediateBlankChunk="";
            }
        }
        else
        {
            if(bNonBlankStarted)
            {
                bNonBlankEnded=true;
                strIntermediateBlankChunk+=" ";
            }
        }
    }
    return strReturnText;
}
 
 
function funcIsEmail(str_param_email)
{
    var str_current_character;
    var b_valid_email,b_period_present;
    var i_last_position_of_period,b_correct_length_extension;
    var i_num_at_symbol=0;
    var i_pos_at_symbol;
    var i_length_of_server_name=1;
    var i_pos_consecutive_dots;
    var str_email=new String(funcTrim(str_param_email));
    i_length=str_email.length;
    b_period_present=1;
    b_correct_length_extension=1;
    i_last_position_of_period=0;
 
    if(i_length==0)
    {
        return true;
    }
 
    for(i_loop=0; i_loop<i_length; i_loop++)
    {
        if(!((str_email.charCodeAt(i_loop)>=65 && str_email.charCodeAt(i_loop)<=90)
            || (str_email.charCodeAt(i_loop)>=97 && str_email.charCodeAt(i_loop)<=122)
            || (str_email.charCodeAt(i_loop)>=48 && str_email.charCodeAt(i_loop)<=57)
            || (str_email.charAt(i_loop)=="@")
            || (str_email.charAt(i_loop)=="_")
            || (str_email.charAt(i_loop)=="-")
            || (str_email.charAt(i_loop)==".")))
        {
            return false;
        }
    }
 
    i_pos_consecutive_dots=str_email.indexOf('..');
    if(i_pos_consecutive_dots!=-1)
    {
        return false;
    }
 
    var i_pos_space;
    i_pos_space = str_email.indexOf(' ');
    if(i_pos_space!=-1)
    {
        return false;
    }
 
    i_last_position_of_period = str_email.lastIndexOf('.');
    if(i_last_position_of_period<=0)
    {
        b_period_present=0;
    }
 
    if(((i_length-i_last_position_of_period)>5) || ((i_length-i_last_position_of_period)<3))
    {
        b_correct_length_extension=0;
    }
 
    for(i_loop=0;i_loop<=i_length;i_loop++)
    {
        str_current_character=str_email.charAt(i_loop);
        if (str_current_character=='@')
        {
            i_num_at_symbol=i_num_at_symbol + 1;
        }
    }
 
    if(i_num_at_symbol!=1)
    {
        return false;
    }
 
    i_pos_at_symbol = str_email.indexOf('@');
    if(str_email.charAt(i_pos_at_symbol+1) == '.')
    {
        i_length_of_server_name=0;
    }
 
    if((i_num_at_symbol==1) && (b_period_present==1) && (b_correct_length_extension==1) && (i_length_of_server_name==1))
    {
        b_valid_email=1;
    }
    else
    {
        b_valid_email=0;
    }
 
    if(b_valid_email==0)
    {
        return false;
    }
    else
    {
        return true;
    }
}



function displayRow(iRow)
{
    iRow = iRow + 1;
    var strRow;
    strRow = "row" + iRow;

    if (document.getElementById(strRow).style.display == 'none')
    {
        document.getElementById(strRow).style.display = 'block';
    }
    else
    {
        document.getElementById(strRow).style.display = 'none';
    }
}
	
function displayOffer(iRow)
{
    iRow = iRow + 1;
    var strRow;
    strRow = "offerRow" + iRow;

    if (document.getElementById(strRow).style.display == 'none')
    {
        document.getElementById(strRow).style.display = 'block';
    }
    else
    {
        document.getElementById(strRow).style.display = 'none';
    }
}

function SetCheckoutDate()
{
    var objForm = document.frmHotelSearch;
    var fromDay = objForm.from_day.value;
    var fromMonth = objForm.from_month.value;
    var fromYear = objForm.from_year.value;
    var toDay = objForm.to_day.value;
    var toMonth = objForm.to_month.value;
    var toYear = objForm.to_year.value;
		
    if(validateDate(fromMonth + "/" + fromDay + "/" + fromYear))
    {
        var fromDate = new Date();
        var toDate = new Date();

        fromDate.setFullYear(Number(fromYear), Number(fromMonth)-1, Number(fromDay));
        toDate.setFullYear(Number(fromYear), Number(fromMonth)-1, Number(fromDay)+2);
        toDay = toDate.getDate();
        toMonth = toDate.getMonth();
        toYear = toDate.getYear();

        objForm.to_day.options[toDay-1].selected = true;
        objForm.to_month.options[toMonth].selected = true;

        var iFromSelected = objForm.from_year.selectedIndex;

        fromYear		= fromDate.getYear();
        if(Number(toYear) == Number(fromYear))
        {

            objForm.to_year.options[iFromSelected].selected = true;
        }
        else
        {

            objForm.to_year.options[1].selected = true;
        }
    }
}
	
function validateSearchForm()
{
    var objForm = document.frmHotelSearch;
    var fromDay = objForm.from_day.value;
    var fromMonth = objForm.from_month.value;
    var fromYear = objForm.from_year.value;
    var toDay = objForm.to_day.value;
    var toMonth = objForm.to_month.value;
    var toYear = objForm.to_year.value;
    var strCity = objForm.cboCity.value;
		
    if (strCity == 0)
    {
        alert("Please Select A City");
        objForm.cboCity.focus();
        return false;
    }
		
    if(validateDate(fromMonth + "/" + fromDay + "/" + fromYear))
    {
        var fromDate = new Date(fromYear, fromMonth, fromDay);
    }
    else
    {
        alert("Kindly enter a valid check in/out date");
        return false;
    }

    if(validateDate(toMonth + "/" + toDay + "/" + toYear))
    {
        var toDate = new Date(toYear, toMonth, toDay);
    }
    else
    {
        alert("Please select a valid To date");
        return false;
    }
		
    if(toDate < fromDate)
    {
        alert("Kindly enter a valid check in/out date");
        return false;
    }
    return true;
}

function validateForm()
{
    var objForm = document.frmHotelSearch;
    var fromDay = objForm.from_day.value;
    var fromMonth = objForm.from_month.value;
    var fromYear = objForm.from_year.value;
    var toDay = objForm.to_day.value;
    var toMonth = objForm.to_month.value;
    var toYear = objForm.to_year.value;

    var dtCurrentDate	= new Date();
    var strCurrentYear	= dtCurrentDate.getFullYear();
    var strCurrentMonth = dtCurrentDate.getMonth()+1;
    var strCurrentDay	= dtCurrentDate.getDate();
    var dtNewDate		= new Date(strCurrentYear, strCurrentMonth, strCurrentDay+2);

    if(validateDate(fromMonth + "/" + fromDay + "/" + fromYear))
    {
        var fromDate = new Date(fromYear, fromMonth, fromDay);
    }
    else
    {
        alert("Kindly enter a valid check in/out date");
        return false;
    }

    if(validateDate(toMonth + "/" + toDay + "/" + toYear))
    {
        var toDate = new Date(toYear, toMonth, toDay);
    }
    else
    {
        alert("Kindly enter a valid check in/out date");
        return false;
    }
		
    if(toDate < fromDate)
    {
        alert("Kindly enter a valid check in/out date");
        return false;
    }

    if(dtNewDate > fromDate)
    {
        alert("Kindly enter a valid check in/out date");
        return false;
    }

    return true;
}

function validateDate(fld) {
    var RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
    var errorMessage = 'Please enter valid date as month, day, and four digit year.\nYou may use a slash, hyphen or period to separate the values.\nThe date must be a real date. 2-30-2000 would not be accepted.\nFormay mm/dd/yyyy.';
    if ((fld.match(RegExPattern)) && (fld!='')) {
        return true;
    } else {
        return false;
    }
}
	
function ValidatePersonalDetails()
{
    var objForm  = document.frmPersonDetails;
    var strFirstName		= objForm.txtFirstName.value;
    var strLastName = objForm.txtLastName.value;
    var iAge  = objForm.cboAge.value;
    var strAddress  = objForm.txtAddress.value;
    var strPlace  = objForm.txtPlace.value;
    var strCountry  = objForm.cboCountry.value;
    var strPostCode 	= objForm.txtPostCode.value;
    var strMobileNo 	= objForm.txtMobile.value;
    var strResiNo  = objForm.txtResi.value;
    var strEmail  = objForm.txtEmail.value;
    var strEmailConfirm = objForm.txtEmailConfirm.value;
    var strArrivalFlightNo = objForm.txtArrivalFlightNo.value;
		
    var strFromDay  = objForm.cboArrivalFlightDay.value;
    var strFromMonth 	= objForm.cboArrivalFlightMonth.value;
    var strFromYear 	= objForm.cboArrivalFlightYear.value;
		
    var strDeptFlightNo = objForm.txtDepartureFlightNo.value;
		
    var strToDay  = objForm.cboDepartureFlightDay.value;
    var strToMonth  = objForm.cboDepartureFlightMonth.value;
    var strToYear  = objForm.cboDepartureFlightYear.value;
		
    var strGuestTitle 	= objForm.cboGuestTitle_1.value;
    var strGuestFirstName = objForm.txtGuestFirstName_1.value;
    var strGuestLastName = objForm.txtGuestLastName_1.value;
    var iGuestAge  = objForm.cboGuestAge_1.value;
    var iRoomCount  = objForm.hidRoomCount.value;
    var bReturn  = true;


    var strRoomsCart		= objForm.hidRoomsCart.value;
    var arrRoomCart = strRoomsCart.split(";");
		
    var iRoomId = 0;
    var iRoomCount = 0;
    var iFeatureCount		= 0;
    var iUnit = 0;
		
    if(arrRoomCart.length > 0)
    {
        for(var iLoop = 0; iLoop < arrRoomCart.length; iLoop++)
        {
            var arrRoomCartSub = arrRoomCart[iLoop].split(",");
		
            if(arrRoomCartSub.length > 0)
            {
                iRoomId 	= arrRoomCartSub[0];
                iRoomCount		= arrRoomCartSub[1];
                iFeatureCount = document.getElementById("hidTotalRoomFeatures_"+iRoomId).value;

                for(var iLoop1 = 1; iLoop1 <= iFeatureCount; iLoop1++)
                {
                    if(eval("objForm.chkExtraFeature_"+ iRoomId +"_"+ iLoop1 +".checked"))
                    {
                        iUnit 	= document.getElementById("txtExtraFeatureUnit_"+ iRoomId +"_"+ iLoop1).value;
                        bReturn		= true;

                        if(isNaN(iUnit) == true)
                        {
                            alert("Please Enter Valid Unit");
                            bReturn = false;
                        }
                        if(bReturn == true && iUnit == 0)
                        {
                            alert("Unit must be greater than Zero");
                            bReturn = false;
                        }

                        if(bReturn == true && iUnit > iRoomCount && document.getElementById("chkExtraFeature_"+ iRoomId +"_"+ iLoop1).value == 'EB')
                        {
                            alert("Only ONE Extra Bed is allowed per room");
                            bReturn = false;
                        }

                        if(bReturn == false)
                        {
                            //alert("ok");
                            document.getElementById("txtExtraFeatureUnit_"+ iRoomId +"_"+ iLoop1).select();
                            document.getElementById("txtExtraFeatureUnit_"+ iRoomId +"_"+ iLoop1).focus();
                            break;
                        }
                    }
                }
            }
        }
    }


		
    if (bReturn == true && funcTrim(strFirstName) == "")
    {
        alert("Please Enter Your Name");
        bReturn = false;
        objForm.txtFirstName.value = "";
        objForm.txtFirstName.focus();
    }
		
    if (bReturn == true && funcTrim(strLastName) == "")
    {
        alert("Please Enter Your Name");
        bReturn = false;
        objForm.txtLastName.value = "";
        objForm.txtLastName.focus();
    }

    if (bReturn == true && funcTrim(iAge) == "")
    {
        alert("Please Enter Age");
        bReturn = false;
        objForm.cboAge.focus();
    }
		
    if (bReturn == true && funcTrim(strAddress) == "")
    {
        alert("Please Enter Address");
        bReturn = false;
        objForm.txtAddress.value = "";
        objForm.txtAddress.focus();
    }
		
    if (bReturn == true && funcTrim(strPlace) == "")
    {
        alert("Please Enter Place");
        bReturn = false;
        objForm.txtPlace.value = "";
        objForm.txtPlace.focus();
    }
		
    if (bReturn == true && funcTrim(strCountry) == "")
    {
        alert("Please Select Country");
        bReturn = false;
        objForm.cboCountry.focus();
    }
		
    if (bReturn == true && funcTrim(strPostCode) == "")
    {
        alert("Please Enter Post Code");
        bReturn = false;
        objForm.txtPostCode.value = "";
        objForm.txtPostCode.focus();
    }
		
    if (bReturn == true && funcTrim(strMobileNo) == "")
    {
        alert("Please Enter Mobile Number");
        bReturn = false;
        objForm.txtMobile.value = "";
        objForm.txtMobile.focus();
    }
		
    if (bReturn == true && funcTrim(strResiNo) == "")
    {
        alert("Please Enter Residence Number");
        bReturn =  false;
        objForm.txtResi.value = "";
        objForm.txtResi.focus();
    }
		
    if (bReturn == true && funcTrim(strEmail) == "")
    {
        alert("Please Enter Email Address");
        bReturn = false;
        objForm.txtEmail.value = "";
        objForm.txtEmail.focus();
    }
		
    if (bReturn == true && funcIsEmail(strEmail) == false)
    {
        alert("Please Enter Valid Email");
        bReturn = false;
        objForm.txtEmail.focus();
    }
		
    if (bReturn == true && funcTrim(strEmailConfirm) == "")
    {
        alert("Please Enter Email Confirmation");
        bReturn = false;
        objForm.txtEmailConfirm.value = "";
        objForm.txtEmailConfirm.focus();
    }
		
    if (bReturn == true && funcIsEmail(strEmailConfirm) == false)
    {
        alert("Please Enter Valid Email");
        bReturn = false;
        objForm.txtEmailConfirm.focus();
    }
		
    if (bReturn == true && funcTrim(strEmail)!= funcTrim(strEmailConfirm))
    {
        alert("Email Confirmation Failed !");
        bReturn = false;
        objForm.txtEmailConfirm.focus();
    }
		
    if (bReturn == true && funcTrim(strGuestTitle) == 0)
    {
        alert("Please Enter at least one guest details completely");
        bReturn = false;
        objForm.cboGuestTitle_1.focus();

    }
		
    if (bReturn == true && funcTrim(strGuestFirstName) == "")
    {
        alert("Please Enter at least one guest details completely");
        bReturn = false;
        objForm.txtGuestFirstName_1.focus();
    }
		
    if (bReturn == true && funcTrim(strGuestLastName) == "")
    {
        alert("Please Enter at least one guest details completely");
        bReturn = false;
        objForm.txtGuestLastName_1.focus();
    }
		
    if (bReturn == true && funcTrim(iGuestAge) == "")
    {
        alert("Please Enter at least one guest details completely");
        bReturn = false;
        objForm.cboGuestAge_1.focus();
    }
		

    if (bReturn == true && funcTrim(strArrivalFlightNo) == "")
    {
        alert("Please Enter Arrival Flight Number");
        bReturn = false;
        objForm.txtArrivalFlightNo.value = "";
        objForm.txtArrivalFlightNo.focus();
    }
		
    if (bReturn == true && validateDate(strFromMonth+"/"+strFromDay+"/"+strFromYear) == false)
    {
        alert("Please Enter a Valid Arrival Date");
        bReturn = false;
        objForm.cboArrivalFlightDay.focus();
    }
    else
    {
        var FromDate = new Date(strFromYear, strFromMonth, strFromDay);
    }
		
    if (bReturn == true && funcTrim(strDeptFlightNo) == "")
    {
        alert("Please Enter Departure Flight Number");
        bReturn = false;
        objForm.txtDepartureFlightNo.value = "";
        objForm.txtDepartureFlightNo.focus();
    }
		
    if (bReturn == true && validateDate(strToMonth+"/"+strToDay+"/"+strToYear) == false)
    {
        alert("Please Enter a validate Departure Date");
        bReturn = false;
        objForm.cboDepartureFlightDay.focus();
    }
    else
    {
        var ToDate = new Date(strToYear, strToMonth, strToDay);
    }
		
    if (bReturn == true && FromDate > ToDate)
    {
        alert("Arrival Date Should Not Be Greater than Departure Date");
        bReturn = false;
        objForm.cboArrivalFlightDay.focus();
    }
		
		
		
    /*	if (bReturn == true && iRoomCount > 0)
		{
 var iLoop;
 var bSelected = true;
 for(iLoop=1; iLoop<=iRoomCount; iLoop++)
 {
 if (funcTrim(eval("objForm.txtGuestName_"+iLoop+".value")) == "")
 {
 	bSelected = false;
 	break;
 }
 }

 if (bSelected == false)
 {
 alert("Please Enter Guest(s) Name");
 bReturn = false;
 }
		}
		
		if (bReturn == true && funcTrim(strCrCardType) == 0)
		{
 alert("Please Select Credit Card Type");
 bReturn = false;
 objForm.cboCreditCardType.focus();
		}
		
		if (bReturn == true && funcTrim(strCrCardNumber) == "")
		{
 alert("Please Enter Credit Card Number");
 bReturn = false;
 objForm.txtCreditCardNumber.value = "";
 objForm.txtCreditCardNumber.focus();
		}
		
		if (bReturn ==  true && isNaN(funcTrim(strCrCardNumber)))
		{
 alert("Please Enter a Valid Credit Card Number");
 bReturn = false;
 objForm.txtCreditCardNumber.focus();
		}
		
		if (bReturn == true && funcTrim(strCrCardHolderName) == "")
		{
 alert("Please Enter Card Holder Name");
 bReturn = false;
 objForm.txtCardHolderName.value = "";
 objForm.txtCardHolderName.focus();
		}
		
		if (bReturn == true && funcTrim(strCardExpireMonth) == 0)
		{
 alert("Please Enter Expire Details of Credit Card");
 bReturn = false;
 objForm.cboMonthExpire.focus();
		}
		
		if (bReturn == true && funcTrim(strCardExpireYear) == 0)
		{
 alert("Please Enter Expire Details of Credit Card");
 bReturn = false;
 objForm.cboYearExpire.focus();
		}
		
		if (bReturn == true && funcTrim(strCVCCode) == "")
		{
 alert("Please Enter CVC Code of Credit Card");
 bReturn = false;
 objForm.txtCVCCode.value = "";
 objForm.txtCVCCode.focus();
		}*/
		
    return bReturn;
}
	
	
	
function validateBooking()
{
    var objForm = document.frmSubmitBooking;
    var iCount = objForm.hidTotalCount.value;
		
    var iLoop;
    var bSelected = false;
    var bReturn = true;
		
    for(iLoop=1; iLoop<=iCount; iLoop++)
    {
        if (funcTrim(eval("objForm.cboNoOfRooms_"+iLoop+".value")) != 0)
        {
            bSelected = true;
            break;
        }
    }
		
    if (bSelected == false)
    {
        alert("Please select no. of Rooms you want to Book");
        bReturn = false;
    }

		
    return bReturn;
}
	
	
	
function validateSEODetails()
{
    var objForm = document.frmSeoSettings;
    var strSeoTitle = objForm.seoTitle.value;
    var strSeoDescription = objForm.seoDesc.value;
    var strSeoKeywords = objForm.seoKeyword.value;
    var bReturn = true;
		
    if (funcTrim(strSeoTitle) == "")
    {
        alert("Please Enter SEO Title");
        bReturn = false;
        objForm.seoTitle.value = "";
        objForm.seoTitle.focus();
    }
		
    if (bReturn == true && funcTrim(strSeoDescription) == "")
    {
        alert("Please Enter SEO Descriptions");
        bReturn = false;
        objForm.seoDesc.value = "";
        objForm.seoDesc.focus();
    }
		
    if (bReturn == true && funcTrim(strSeoKeywords) == "")
    {
        alert("Please Enter SEO Keywords");
        bReturn = false;
        objForm.seoKeyword.value = "";
        objForm.seoKeyword.focus();
    }
		
    return bReturn;
}
	
function validateTabSearch(){
	 
    var objForm = document.frm_search_hotel;
    var strCity = objForm.cboCity.value;

    var strFromDate = objForm.txtcheckin.value;
    var strToDate = objForm.txtcheckout.value;
    var dtCurrentDate = new Date();
    var strCurrentYear = dtCurrentDate.getFullYear();
    var strCurrentMonth = dtCurrentDate.getMonth();
    var strCurrentDay = dtCurrentDate.getDate();
    if(strCurrentDay.length == 1)
        strCurrentDay = "0"+ strCurrentDay;
    var dtNewDate		= new Date(strCurrentYear, strCurrentMonth, strCurrentDay+2);
    // ********
    dtNew=new Date();
    day=""+dtNewDate.getDate();
    if(day.length==1)
        day = "0"+day;
    dtNew=dtNewDate.getFullYear()+"/"+ (dtNewDate.getMonth()+1) +"/"+day;
    //*********
    if (funcTrim(strCity) == "0")
    {
        alert("Please select a city to search hotels");
        objForm.cboCity.focus();
        return false;
    }

    if (funcTrim(strFromDate) == "")
    {
        alert("Please select check in date");
        objForm.txtcheckin.focus();
        return false;
    }
		
    var arrFromDate = strFromDate.split("/");
    var iFromDay = arrFromDate[0];
    if(iFromDay.length == 1)
        iFromDay = "0"+ iFromDay;
    var iFromMonth = arrFromDate[1];
    var iFromYear = arrFromDate[2];
		
    if(!validateDate(funcTrim(iFromMonth + "/" + iFromDay + "/" + iFromYear)))
    {
        alert("Please select a valid check in date");
        objForm.txtcheckin.focus();
        return false;
    }

    if (funcTrim(strToDate) == "")
    {
        alert("Please select check out date");
        objForm.txtcheckout.focus();
        return false;
    }
    else
        var dtFromDate = new Date(iFromYear, iFromMonth, iFromDay);

    var arrToDate = strToDate.split("/");
    var iToDay 	= arrToDate[0];
    var iToMonth = arrToDate[1];
    var iToYear = arrToDate[2];
    if(iToDay.length == 1)
        iToDay = "0"+ iToDay;

    if(!validateDate(funcTrim(iToMonth + "/" + iToDay + "/" + iToYear)))
    {
        alert("Please select a valid check out date");
        objForm.txtcheckout.focus();
        return false;
    }
    else
        var dtToDate = new Date(iToYear, iToMonth, iToDay);
		
		
		
		
    //**********
    var dtto =new Date();
    var dtfrom=new Date();
		  
    dtto=iToYear+"/"+iToMonth+"/"+iToDay
    dtfrom=iFromYear+"/"+iFromMonth+"/"+iFromDay
		
	   
    if(dtto < dtfrom)
    {
        alert("Kindly enter a valid check in/out date");
        objForm.txtcheckin.focus();
        return false;
    }
		 
		 
		 
    //if(dtNew > dtfrom)
    //{
    //    alert("Your check in date should be 48 hours ahead");
    //    objForm.txtcheckin.focus();
    //    return false;
    //}
		
    //***********
    //if(dtToDate < dtFromDate)
    //{
    //	alert("Kindly enter a valid check in date");
    //	objForm.txtcheckin.focus();
    //return false;
    //}
		
    //if(dtNewDate > dtFromDate)
    //{
    //alert("Your check in date should be 48 hours ahead of the current date");
    //objForm.txtcheckin.focus();
    //return false;
    //}
    return true;
}
	 

// search criteria validation for provider
function validateTabSearchProviders()
{
	 
    var objForm 	= document.frm_search_provider;
    var strCity 	= objForm.cboCity.value;

    var strFromDate		= objForm.txtcheckin.value;
    var strToDate		= objForm.txtcheckout.value;
		
    var dtCurrentDate	= new Date();
    var strCurrentYear	= dtCurrentDate.getFullYear();
    var strCurrentMonth = dtCurrentDate.getMonth()+1;
    var strCurrentDay	= dtCurrentDate.getDate();
    var dtNewDate		= new Date(strCurrentYear, strCurrentMonth, strCurrentDay+2);

    if (funcTrim(strCity) == "0")
    {
        alert("Please select a City to search");
        objForm.cboCity.focus();
        return false;
    }

    if (funcTrim(strFromDate) == "")
    {
        alert("Please select check in date");
        objForm.txtcheckin.focus();
        return false;
    }
		
    var arrFromDate = strFromDate.split("/");
    var iFromDay = arrFromDate[0];
    var iFromMonth = arrFromDate[1];
    var iFromYear = arrFromDate[2];
		
    if(!validateDate(funcTrim(iFromMonth + "/" + iFromDay + "/" + iFromYear)))
    {
        alert("Please select a valid check in date");
        objForm.txtcheckin.focus();
        return false;
    }

    if (funcTrim(strToDate) == "")
    {
        alert("Please select check out date");
        objForm.txtcheckout.focus();
        return false;
    }
    else
    var dtFromDate = new Date(iFromYear, iFromMonth, iFromDay);

    var arrToDate = strToDate.split("/");
    var iToDay 	= arrToDate[0];
    var iToMonth = arrToDate[1];
    var iToYear = arrToDate[2];

    if(!validateDate(funcTrim(iToMonth + "/" + iToDay + "/" + iToYear)))
    {
        alert("Please select a valid check out date");
        objForm.txtcheckout.focus();
        return false;
    }
    else
        var dtToDate = new Date(iToYear, iToMonth, iToDay);
		
    if(dtToDate < dtFromDate)
    {
        alert("Kindly enter a valid check in/out date");
        objForm.txtcheckin.focus();
        return false;
    }

    if(dtNewDate > dtFromDate)
    {
        alert("Your check in date should be 48 hours ahead of the current date");
        objForm.txtcheckin.focus();
        return false;
    }
		
    return true;
}		

	 
	  
function validateAreaSEODetails()
{
    var objForm = document.frmAreaSeoSettings;
    var strSeoTitle = objForm.seoTitle.value;
    var strSeoDescription = objForm.seoDesc.value;
    var strSeoKeyword = objForm.seoKeyword.value;
    var bReturn = true;
	
    if(funcTrim(strSeoTitle) == "")
    {
        alert("Please Enter Seo Title");
        bReturn = false;
        objForm.seoTitle.value = "";
        objForm.seoTitle.focus();
    }
	
    if(bReturn == true && funcTrim(strSeoDescription) == "")
    {
        alert("Please Enter Seo Description");
        bReturn = false;
        objForm.seoDesc.value = "";
        objForm.seoDesc.focus();
    }
	
    if(bReturn == true && funcTrim(strSeoKeyword) == "")
    {
        alert("Please Enter Seo Keyword");
        bReturn = false;
        objForm.seoKeyword.value = "";
        objForm.seoKeyword.focus();
    }
	
    return bReturn;
}
 
 
function validateRatePerDayDetails()
{
    var objForm = document.frmRatePerDaySettings;
    var iRateFrom = funcTrim(objForm.txtRateFrom.value);
    var iRateTo = funcTrim(objForm.txtRateTo.value);
    var bReturn = true;
	
    if(funcTrim(iRateFrom) == "")
    {
        alert("Please Enter From Rate");
        bReturn = false;
        objForm.txtRateFrom.value = "";
        objForm.txtRateFrom.focus();
    }
	
    if(bReturn == true && isNaN(iRateFrom) == true)
    {
        alert("Please Enter Valid From Rate");
        bReturn = false;
        objForm.txtRateFrom.select();
        objForm.txtRateFrom.focus();
    }
	
    if(bReturn == true && funcTrim(iRateTo) == "")
    {
        alert("Please Enter To Rate");
        bReturn = false;
        objForm.txtRateTo.value = "";
        objForm.txtRateTo.focus();
    }
	
    if(bReturn == true && isNaN(iRateTo) == true)
    {
        alert("Please Enter Valid To Rate");
        bReturn = false;
        objForm.txtRateTo.select();
        objForm.txtRateTo.focus();
    }

    if(bReturn == true && Number(iRateFrom) > Number(iRateTo))
    {
        alert("From Rate Should Be Less Than To Rate");
        bReturn = false;
        objForm.txtRateFrom.select();
        objForm.txtRateFrom.focus();
    }

    return bReturn;
}
 
/* Only for Left Menu in Hotel listing & Hotel detail pages	*/

function getHotelsList(strAreaName, iStar, iRateID, strFormAction)
{
    var objForm = document.frmHotels;
    objForm.hidAreaName.value = strAreaName;
    objForm.hidStarType.value = iStar;
    objForm.hidRateID.value = iRateID;
    objForm.action = strFormAction;
    objForm.submit();
}

	
function validateCitySEODetails()
{
    var objForm = document.frmCitySeoSettings;
    var strSeoTitle = funcTrim(objForm.seoTitle.value);
    var strSeoDescription	= funcTrim(objForm.seoDesc.value);
    var strSeoKeyword		= funcTrim(objForm.seoKeyword.value);
    var bReturn = true;
	
    if(strSeoTitle == "")
    {
        alert("Please Enter Seo Title");
        bReturn = false;
        objForm.seoTitle.value = "";
        objForm.seoTitle.focus();
    }
	
    if(bReturn == true && strSeoDescription == "")
    {
        alert("Please Enter Seo Description");
        bReturn = false;
        objForm.seoDesc.value = "";
        objForm.seoDesc.focus();
    }
	
    if(bReturn == true && strSeoKeyword == "")
    {
        alert("Please Enter Seo Keyword");
        bReturn = false;
        objForm.seoKeyword.value = "";
        objForm.seoKeyword.focus();
    }
	
    return bReturn;
}

function ValidateMyBookingDetails()
{
    var objForm = document.frmMyBooking;
    var strPostCode = objForm.txtPostCode.value;
    var strEmailAddress	= objForm.txtEmailAddress.value;
    var strSecurityCode = objForm.txtSecurityCode.value;

    if(funcTrim(strPostCode) == "")
    {
        alert("Please enter post code");
        objForm.txtPostCode.focus();
        return false;
    }

    if(funcTrim(strEmailAddress) == "")
    {
        alert("Please enter email");
        objForm.txtEmailAddress.focus();
        return false;
    }

    if(funcTrim(strSecurityCode) == "")
    {
        alert("Please enter security code");
        objForm.txtSecurityCode.focus();
        return false;
    }
} 
 
function ValidateMyBookingStep2Details()
{

    var objForm = document.frmMyBookingStep2;
    var strVoucherNumber= objForm.txtVoucherNumber.value;
    var strSecurityCode = objForm.txtSecurityCode.value;

    if(funcTrim(strVoucherNumber) == "")
    {
        alert("Please enter voucher number");
        objForm.txtVoucherNumber.focus();
        return false;
    }

    if(funcTrim(strSecurityCode) == "")
    {
        alert("Please enter security code");
        objForm.txtSecurityCode.focus();
        return false;
    }
}

function ValidateMyBookingStep2Status()
{

    var objForm = document.frmMyBookingStep2Status;
    var strOrderNumber	= objForm.txtOrderNumber.value;
    var strSecurityCode = objForm.txtSecurityCode.value;

    if(funcTrim(strOrderNumber) == "")
    {
        alert("Please enter order number");
        objForm.txtOrderNumber.focus();
        return false;
    }

    if(funcTrim(strSecurityCode) == "")
    {
        alert("Please enter security code");
        objForm.txtSecurityCode.focus();
        return false;
    }
}
 
// Below functions are added on 02-07-2008 for the booking of Extra Features

function validateExtraFeature(iRoomID, iCount, strRoomCart, iRoomCount)
{
    var objForm 	= document.frmPersonDetails;
    var iUnit = 0;
    var iRate = 0;
    var iCost = 0;
    var iPersonCount	= 0;
    var iFeatureCount	= 0;
    var iUnitCount		= 0;
    var iTotalCount	 = 0;

    iPersonCount 	= document.getElementById("hidNoOfPerson_"+iRoomID).value;
    iFeatureCount	 = document.getElementById("hidTotalRoomFeatures_"+iRoomID).value;
    iUnitCount = document.getElementById("txtExtraFeatureUnit_"+iRoomID+"_"+iCount).value;
    //iTotalCount = parseInt(iRoomCount*iPersonCount);

    if(isNaN(iUnitCount) == true)
    {
        alert("Please Enter a Valid Unit");
        document.getElementById("txtExtraFeatureUnit_"+iRoomID+"_"+iCount).focus();
    }

    if(iUnitCount == 0)
    {
        alert("Unit must be greater than zero");
        document.getElementById("txtExtraFeatureUnit_"+iRoomID+"_"+iCount).focus();
    }
    if(iUnitCount > iRoomCount && document.getElementById("chkExtraFeature_"+iRoomID+"_"+iCount).value == "EB")
    {
        alert("Only ONE Extra Bed is allowed per room");
        document.getElementById("txtExtraFeatureUnit_"+iRoomID+"_"+iCount).value = iRoomCount;
        document.getElementById("txtExtraFeatureUnit_"+iRoomID+"_"+iCount).focus();
    }
	
	
	
    if(eval("objForm.chkExtraFeature_"+iRoomID+"_"+iCount+".checked"))
    {
        if(document.getElementById("chkExtraFeature_"+iRoomID+"_"+iCount).value == "EB")
        {
            document.getElementById("txtExtraFeatureUnit_"+iRoomID+"_"+iCount).readOnly = false;
            //document.getElementById("txtExtraFeatureUnit_"+iRoomID+"_"+iCount).select();
            //document.getElementById("txtExtraFeatureUnit_"+iRoomID+"_"+iCount).focus();
        }

        for(var iLoop = 1; iLoop <= iFeatureCount; iLoop++)
        {
            if(eval("objForm.chkExtraFeature_"+iRoomID+"_"+iLoop+".value") == 'EB' && eval("objForm.chkExtraFeature_"+iRoomID+"_"+iLoop+".checked"))
            {
                iUnit = parseInt(document.getElementById("txtExtraFeatureUnit_"+iRoomID+"_"+iLoop).value);
            }
        }


        if(document.getElementById("chkExtraFeature_"+iRoomID+"_"+iCount).value != "EB" && iPersonCount > 1)
        {
            document.getElementById("txtExtraFeatureUnit_"+iRoomID+"_"+iCount).value = iPersonCount;
        }

        for(var iLoop1 = 1; iLoop1 <= iFeatureCount; iLoop1++)
        {
            if(eval("objForm.chkExtraFeature_"+iRoomID+"_"+iLoop1+".value") != 'EB' && eval("objForm.chkExtraFeature_"+iRoomID+"_"+iLoop1+".checked"))
            {
                document.getElementById("txtExtraFeatureUnit_"+iRoomID+"_"+iLoop1).value = (parseInt(iPersonCount) * parseInt(iRoomCount)) + parseInt(iUnit);
            }
        }

        reCalculateTotal(strRoomCart);
		
    }
    else
    {
        if(document.getElementById("chkExtraFeature_"+iRoomID+"_"+iCount).value == "EB")
        {
            document.getElementById("txtExtraFeatureUnit_"+iRoomID+"_"+iCount).value	= 1;
            document.getElementById("txtExtraFeatureUnit_"+iRoomID+"_"+iCount).readOnly = true;
        }

        document.getElementById("txtExtraFeatureUnit_"+iRoomID+"_"+iCount).value = 1;
        document.getElementById("txtExtraFeatureTotal_"+iRoomID+"_"+iCount).value = '0.00';

        for(var iLoop = 1; iLoop <= iFeatureCount; iLoop++)
        {
            if(eval("objForm.chkExtraFeature_"+iRoomID+"_"+iLoop+".value") == 'EB' && eval("objForm.chkExtraFeature_"+iRoomID+"_"+iLoop+".checked"))
            {
                iUnit = parseInt(document.getElementById("txtExtraFeatureUnit_"+iRoomID+"_"+iLoop).value);
            }
        }


        for(var iLoop1 = 1; iLoop1 <= iFeatureCount; iLoop1++)
        {
            if(eval("objForm.chkExtraFeature_"+iRoomID+"_"+iLoop1+".value") != 'EB' && eval("objForm.chkExtraFeature_"+iRoomID+"_"+iLoop1+".checked"))
            {
                document.getElementById("txtExtraFeatureUnit_"+iRoomID+"_"+iLoop1).value = (parseInt(iPersonCount) * parseInt(iRoomCount)) + parseInt(iUnit);
            }
        }

        reCalculateTotal(strRoomCart);
    }
}
 
 
function reCalculateTotal(strRoomCart)
{
    var objForm = document.frmPersonDetails;
    var arrRoomCart = strRoomCart.split(";");
    var iTotalFeatureCost	= 0;
    var iTotalCost = 0;
    var iRoomId = 0;
    var iFeatureCount		= 0;
    var iUnit = 0;
    var iRate = 0;
    var iCost = 0;
    var iDayCount = 0;
    var iTotalPersonCount	= 0;
	
	
    iDayCount  = parseInt(document.getElementById("hidDayCount").value);
    iTotalPersonCount	= parseInt(document.getElementById("hidTotalPersonCount").value);
	
    for(var iLoop = 0; iLoop < arrRoomCart.length; iLoop++)
    {
        var arrRoomCartSub = arrRoomCart[iLoop].split(",");

        if(arrRoomCartSub.length > 0)
        {
            iRoomId 	= arrRoomCartSub[0];
            iFeatureCount = document.getElementById("hidTotalRoomFeatures_"+iRoomId).value;

            for(var iLoop1 = 1; iLoop1 <= iFeatureCount; iLoop1++)
            {
                if(eval("objForm.chkExtraFeature_"+iRoomId+"_"+iLoop1+".checked"))
                {
                    if(document.getElementById("chkExtraFeature_"+iRoomId+"_"+iLoop1).value == 'EB')
                    {
                        iTotalPersonCount = iTotalPersonCount + parseInt(document.getElementById("txtExtraFeatureUnit_"+iRoomId+"_"+iLoop1).value);
                    }

                    iUnit = document.getElementById("txtExtraFeatureUnit_"+iRoomId+"_"+iLoop1).value;
                    iRate = document.getElementById("txtExtraFeatureRate_"+iRoomId+"_"+iLoop1).value;
                    iCost = parseFloat((iUnit*iRate*iDayCount)).toFixed(2);
                    document.getElementById("txtExtraFeatureTotal_"+iRoomId+"_"+iLoop1).value = iCost;
                    iTotalFeatureCost = iTotalFeatureCost + parseFloat(document.getElementById("txtExtraFeatureTotal_"+iRoomId+"_"+iLoop1).value);
                }
            }
        }
    }

    iTotalCost = (parseFloat(document.getElementById("hidTotalCost").value) + iTotalFeatureCost).toFixed(2);

    document.getElementById("txtExtraFeatureTotal").value	= iTotalFeatureCost.toFixed(2);
    document.getElementById("txtTotalPersonCount").value	= iTotalPersonCount;
    document.getElementById("txtTotalCost").value = addCommas(iTotalCost);
}

 
function addCommas(nStr)
{
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    return x1 + x2;
}

