﻿
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$  Select Hotel from List   $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

function ShowHotelList()
{
    window.open("SelectHotel.aspx","myWindow","SCREENX=20,SCREENY=20,width=350,height=360,resizable=0,menubar=0,toolbars=No,SCROLLBARS=NO");
}



function CloseSelectList()
 {
    window.close();
 } 

function SubmitQuery_click()
{
    var txtHotelId = document.getElementById("txtHotelId");
    var txtHotelName = document.getElementById("txtHotelName")
    if(txtHotelId.value == 0 || txtHotelId.value == "" || txtHotelName.value =="")
    {
        alert("Please Select Hotel First");
        txtHotelId.value="";
        txtHotelName.value="";
        txtHotelName.focus();
        return false;
    }
    
    return true;
}



function ddlCountry_change()
{
    var CityIdCount=1;
    var IsSelectedCountry = false;
    var selectedCountryid ='';
    var ddlCountry = document.getElementById("ddlCountry");
    
    for (var j = 0; j < ddlCountry.length; j++)
    {
        if (ddlCountry.options[j].selected)
        { 
            selectedCountryid = ddlCountry.options[j].value;
            IsSelectedCountry = true;           
            break;
        }
    }
    
    if(IsSelectedCountry == false)
    {
        alert('Please select a Country');
        return false;
    }
    else if(IsSelectedCountry == true && selectedCountryid != 0)
    {
        $("#ddlCity" + "> option").remove();
        $("#lbHotel" + "> option").remove();
        
        var CountryId = selectedCountryid;
        $.ajax({
            type        : "POST",
            url         : "AutoComplete.asmx/GetCityListArrayByCountryId",
            data        : "{CountryId : '"+ selectedCountryid +"'}",
            beforeSend  : function(xhr){
                xhr.setRequestHeader("Content-type", "application/json; charset=utf-8");
            },
            contentType : "application/json; charset=utf-8",
            dataType    : "json",
            
            success     : function(msg, status){
            
                 $.each(msg.d, function(index)
                  {
                        $('#ddlCity' ).append($('<option></option>').val(this.CityId).html(this.city));
                        
                        if(CityIdCount ==1 && this.CityId >0)
                        {
                            document.getElementById("hdCityId").value=this.CityId;
                            CityIdCount++;
                        }
                        
                  });
                     
            },
            error       : function(xhr, msg){
                alert(e);
            }
        });        
    }  // end else if  
     
    return false;
}


function LoadHotels()
{    
    var selectedCityid =0;     
    selectedCityid = document.getElementById("hdCityId").value;         
        
    if(selectedCityid != 0)
    {
        $("#lbHotel" + "> option").remove();       
        
        $.ajax({
            type        : "POST",
            url         : "AutoComplete.asmx/GetHotelListByCityId",
            data        : "{CityId : '"+ selectedCityid +"'}",
            beforeSend  : function(xhr){
                xhr.setRequestHeader("Content-type", "application/json; charset=utf-8");
            },
            contentType : "application/json; charset=utf-8",
            dataType    : "json",
            
            success     : function(msg, status){
            
                 $.each(msg.d, function(index) {
                        $('#lbHotel' ).append($('<option></option>').val(this.HotelId).html(this.HotelName));
                     });
                     
            },
            error       : function(xhr, msg){
                alert(e);
            }
        });
    }// end if  
    
    return false;

}

function LoadHotelByCity()
{
    var selectedCityid =0;
    var IsSelectedCity=false;
    var ddlCity = document.getElementById("ddlCity");
     
    for (var j = 0; j < ddlCity.length; j++)
    {
        if (ddlCity.options[j].selected)
        { 
            selectedCityid = ddlCity.options[j].value;
            IsSelectedCity = true;           
            break;
        }
    }
     
           
    if(IsSelectedCity == false)
    {
        alert('Please select a City');
        return false;
    }
    else if(IsSelectedCity == true && selectedCityid != 0)
    {
        $("#lbHotel" + "> option").remove();        
        
        $.ajax({
            type        : "POST",
            url         : "AutoComplete.asmx/GetHotelListByCityId",
            data        : "{CityId : '"+ selectedCityid +"'}",
            beforeSend  : function(xhr){
                xhr.setRequestHeader("Content-type", "application/json; charset=utf-8");
            },
            contentType : "application/json; charset=utf-8",
            dataType    : "json",
            
            success     : function(msg, status){
            
                 $.each(msg.d, function(index) {
                        $('#lbHotel' ).append($('<option></option>').val(this.HotelId).html(this.HotelName));
                     });
                     
            },
            error       : function(xhr, msg){
                alert(e);
            }
        });
    }// end else if  
    
    return false;

}

function btnSelect_ClientClick()
{

    var ddlCountry = document.getElementById("ddlCountry");
    if(ddlCountry.value == 0)
    {
        alert("Please Select Country");
        ddlCountry.focus();
        return false;
    }
    
    var ddlCity = document.getElementById("ddlCity");
    if(ddlCity.value == 0)
    {
        alert("Please Select City");
        ddlCity.focus();
        return false;
    }
    
    var lbHotel = document.getElementById("lbHotel");
    if(lbHotel.value == 0)
    {
        alert("Please Select Hotel");
        lbHotel.focus();
        return false;
    }
    
    
  /* var ddlHotelList = window.opener.document.getElementById("ddlHotelList");
    
    for (var j = 0; j < ddlHotelList.length; j++)
    {
        if (ddlHotelList.options[j].value == lbHotel.value)
        { 
            ddlHotelList.options[j].selected =true;
            ddlHotelList.options[j].value =ddlHotelList.value;                     
            window.close();
            break;
        }
    }*/
    
    for (var j = 0; j < lbHotel.length; j++)
    {
        if (lbHotel.options[j].selected)
        { 
            window.opener.document.getElementById("txtHotelId").value = lbHotel.options[j].value;
            window.opener.document.getElementById("txtHotelName").value = lbHotel.options[j].innerHTML;      
            break;
        }
    }
         
    window.close();

    return true;
}
 
    
    //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   Submit Feedback   $$$$$$$$$$$$$$$$$$$
  
function Rooms_CheckedChanged(chkid)
{
    for(var i=1;i<=10;i++)
    {
       if( document.getElementById('chkRoom'+i).checked == true)   
       {
            document.getElementById('chkRoom'+i).checked = false;
       }
    }
    
    chkid.checked = true;
}

function Quality_CheckedChanged(chkid)
{
    for(var i=1;i<=10;i++)
    {
       if( document.getElementById('chkQuality'+i).checked == true)   
       {
            document.getElementById('chkQuality'+i).checked = false;
       }
    }
    
    chkid.checked = true;
}

function Cleanliness_CheckedChanged(chkid)
{
    for(var i=1;i<=10;i++)
    {
       if( document.getElementById('chkCleanliness'+i).checked == true)   
       {
            document.getElementById('chkCleanliness'+i).checked = false;
       }
    }
    
    chkid.checked = true;
}

function Location_CheckedChanged(chkid)
{
    for(var i=1;i<=10;i++)
    {
       if( document.getElementById('chkLocation'+i).checked == true)   
       {
            document.getElementById('chkLocation'+i).checked = false;
       }
    }
    
    chkid.checked = true;
}

function Price_CheckedChanged(chkid)
{
    for(var i=1;i<=10;i++)
    {
       if( document.getElementById('chkPrice'+i).checked == true)   
       {
            document.getElementById('chkPrice'+i).checked = false;
       }
    }
    
    chkid.checked = true;
}
  
    
function lnkSubmitFeedBack_ClientClick()
{
    
    var txtDesc1 = document.getElementById("txtDesc1");
    if(txtDesc1.value == "")
    {
        alert("Please Enter Description");
        txtDesc1.focus();
        return false;
    }
       

    return true;
}     
             
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   Submit Testimonials   $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
   
    
function lnkSubmitTestimonial_ClientClick()
{    
    var txtTestimonial = document.getElementById("txtTestimonial");
    if(txtTestimonial.value == "")
    {
        alert("Please Enter Your Testimonial");
        txtTestimonial.focus();
        return false;
    }       
    return true;
}   
