$('.tabs').tabslet({
  mouseevent: 'click',
  attribute: 'href',
  prev: '.prev',
  animation: true
});

$("selector").fancybox({
    arrows : false
});

 $(document).ready(function(){

 // $('#numberOfRooms option[value=1]').attr('selected', 'selected'); //number of rooms select

var Sadult    = $('.adult');
var Schild    = $('.child');
var Sinfant   = $('.infant');

$('body').delegate('.adult','change',function(){

    var $this = $(this);
    var parentDiv = $this.parents('.clonewrapper').data('id');
    $this = $this.parents('#clonewrapper'+parentDiv);



    var AdultVal = $this.find('#adult'+parentDiv);
    var thisinfant = $this.find('#infant'+parentDiv);
    var thischild = $this.find('#child'+parentDiv);

    if(AdultVal.val() > 0){

      $('#infant'+parentDiv).removeAttr('disabled');
      $('#child'+parentDiv).removeAttr('disabled');

      var total = parseInt(thisinfant.val())+parseInt(thischild.val())+parseInt(AdultVal.val());

      if(total > 5){

          AdultVal.find('option:selected').prop('selected',false);

          alert('You can choose up to 5 people.');


          return false

      }else{

          $this.find('select').css({'background-color':'none','border':'none'});

          return false;

      }


    }else{

      $('#infant'+parentDiv).attr('disabled','disabled');
      $('#child'+parentDiv).attr('disabled','disabled');

    }

});

$('body').delegate('.child','change',function(){

    var $this = $(this);
    var parentDiv = $this.parents('.clonewrapper').data('id');
    $this = $this.parents('#clonewrapper'+parentDiv);

    var AdultVal = $this.find('#adult'+parentDiv);
    var thisinfant = $this.find('#infant'+parentDiv);
    var thischild = $this.find('#child'+parentDiv);

    if(AdultVal.val() > 0){

      $('#infant'+parentDiv).removeAttr('disabled');
      $('#child'+parentDiv).removeAttr('disabled');

      var total = parseInt(thisinfant.val())+parseInt(thischild.val())+parseInt(AdultVal.val());

      if(total > 5){

          thischild.find('option:selected').prop('selected',false);

          alert('You can choose up to 5 people.');


          return false

      }else{

          $this.find('select').css({'background-color':'none','border':'none'});

          return false;

      }


    }else{

      $('#infant'+parentDiv).attr('disabled','disabled');
      $('#child'+parentDiv).attr('disabled','disabled');

    }

});

$('body').delegate('.infant','change',function(){

    var $this = $(this);
    var parentDiv = $this.parents('.clonewrapper').data('id');
    $this = $this.parents('#clonewrapper'+parentDiv);

    var AdultVal = $this.find('#adult'+parentDiv);
    var thisinfant = $this.find('#infant'+parentDiv);
    var thischild = $this.find('#child'+parentDiv);

    if(AdultVal.val() > 0){

      $('#infant'+parentDiv).removeAttr('disabled');
      $('#child'+parentDiv).removeAttr('disabled');

      var total = parseInt(thisinfant.val())+parseInt(thischild.val())+parseInt(AdultVal.val());



      if(total > 5){

          thisinfant.find('option:selected').prop('selected',false);

          alert('You can choose up to 5 people.');


          return false

      }else{

          $this.find('select').css({'background-color':'none','border':'none'});

          return false

      }


    }else{

      $('#infant'+parentDiv).attr('disabled','disabled');
      $('#child'+parentDiv).attr('disabled','disabled');

    }

});

 $('#numberOfRooms').on("change",function() {

      var $this   =   $(this);
      $( "#roomsWrapper .col-lg-12" ).html('');

      if($this.val() > 0){

       var str = $(this).val();

        var length = $('.clonewrapper').length;

         for(var a=0; a<str; a++){

           var aNew = a+1;

            var html = '<div class="clonewrapper row" id="clonewrapper'+length+'" data-id="'+length+'">'+

              '<div class="form-group col-lg-2">'+
                '<div class="form-group">'+
                  '<label for=""><?=$text["room"];?></label>'+
                '</div>'+
              '</div>'+
              '<div class="form-group col-lg-2">'+
                '<select id="adult'+length+'" class="form-control adult" name="adult[]" required>'+
                  '<option value="0">0</option>'+
                  '<option value="1">1</option>'+
                  '<option value="2">2</option>'+
                  '<option value="3">3</option>'+
                  '<option value="4">4</option>'+
                '</select>'+
              '</div>'+
              '<div class="form-group col-lg-2">'+
                '<select id="child'+length+'" class="form-control child" name="child[]" required disabled>'+
                  '<option value="0">0</option>'+
                  '<option value="1">1</option>'+
                  '<option value="2">2</option>'+
                  '<option value="3">3</option>'+
                '</select>'+
              '</div>'+
              '<div class="form-group col-lg-2">'+
                '<select id="infant'+length+'" class="form-control infant" name="infant[]" required disabled>'+
                  '<option value="0">0</option>'+
                  '<option value="1">1</option>'+
                  '<option value="2">2</option>'+
                '</select>'+
              '</div>'+

            '</div>';

            $( "#roomsWrapper .col-lg-12").append(html);

             length++;

          }//for

        }//if val

    });


    // $('body').delegate('#child1','change', function (e) {
    //     var optionSelected = $("option:selected", this);
    //     var valueSelected = this.value;
    //     $( ".childAgeWrapper").html('');
    //     if(valueSelected > 0){
    //       for (var i = 0; i <valueSelected; i++) {
    //           var aNewChildAge = i+1;
    //           $( ".childAgeWrapper"+aNewChildAge ).html('');
    //           $('.childAgeWrapper'+aNewChildAge).append('<select class="form-control" name="childAge'+aNewChildAge+'" id="childAge'+aNewChildAge+'"><option value="0">Age</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option></select>');
    //           //alert("adult["+i+"].value="+adult.value);
    //       }
    //     }//if val*/
    // });

    function get_hotel(hotel_ID){

      var site_url='https://clubexelsior.com/res/';

      var api_url='https://www.clubexelsior.com/reservation/api';

      var api_key='8E19B3FE0C8603C3F8A6453F3EDBFB12';



    }//get_hotel


 $('#btnStep1').click(function(e){

	var error = [];

   $('.adult').each(function(){

	    if($(this).val() == 0){
			error.push(1);
	    }

   });

   if(error.length > 0){

		alert('At least 1 adult is required.');

			return false;

			e.preventDefault();

   }


   var form = $("#reservationFrom");
   form.validate({
     errorPlacement: function errorPlacement(error, element) { element.before(error); },
     rules: {
         confirm: {
             equalTo: "#resortId",
             equalTo: "#checkInDate",
             equalTo: "#checkOutDate",
             equalTo: "#numberOfRooms",
         }
     }
   });

   form.validate().settings.ignore = ":disabled,:hidden";

   if(form.valid()){
      $( ".next" ).trigger( "click" );//to next tab
   }

   //console.log(get_hotel(7));

   // var resortId = $('select[name="resortId"]').val();

    var site_url='https://clubexelsior.com/res/';

    var api_url='https://www.clubexelsior.com/reservation/api';

    var api_key='8E19B3FE0C8603C3F8A6453F3EDBFB12';

   var url = api_url+'?apikey='+api_key;

   var roomCount = {};

   // $.getJSON(url,function (data){
   //
   //     //console.log(data);
   //     $('#reservationFrom').append('<input type="hidden" name="_token" value="'+data['token']+'"/>');
   //
   //     $.each(data['rooms'],function(key,value){
   //       $.each(value,function(i,item){
   //         $('.selectRoom').append('<option value="'+value[i].id+'">'+value[i].room_title+'</option>');
   //       })
   //     });
   //
   // });


   $('.priceTable tbody').empty();

   var total = 0;

   var curreny = 1;

   $.ajax({

       type: "POST",
       url: url,
       data: $('#reservationFrom').serialize(),
       error : function(error){ console.log(error); },
       success: function(requestData) {

         //  console.log("Requested data:",requestData);

           var checkInDate = $('input[name="checkInDate"]').val();
           var checkOutDate = $('input[name="checkOutDate"]').val();
           var roomAmount = $("#numberOfRooms option:selected").val();
           var currencyCode = 'GBP';

            var adultValues = document.getElementsByName('adult[]');
            var totalAdult = 0;
            for (var i = 0; i <adultValues.length; i++) {
                var adult=adultValues[i];
                totalAdult += adult.value << 0;
                //alert("adult["+i+"].value="+adult.value);
            }
            var childValues = document.getElementsByName('child[]');
            var totalChild = 0;
            for (var i = 0; i <childValues.length; i++) {
                var child=childValues[i];
                totalChild += child.value << 0;
                //alert("adult["+i+"].value="+adult.value);
            }

			var infantValues = document.getElementsByName('infant[]');
            var totalInfant = 0;
            for (var i = 0; i <infantValues.length; i++) {
                var infant=infantValues[i];
                totalInfant += infant.value << 0;
                //alert("adult["+i+"].value="+adult.value);
            }



            /*Step 2*/
            $('#resortNameWrapper').html($("#resortId option:selected").text());
            $('#totalRoomWrapperLabel').html($("#numberOfRooms option:selected").text());
            $('#totalAdultWrapperLabel').html(totalAdult);
            $('#totalChildWrapperLabel').html(totalChild);
            $('#totalInfantWrapperLabel').html(totalInfant);
            $('#totalRoomWrapperLabelStep3').html($("#numberOfRooms option:selected").text());
            $('#totalAdultWrapperLabelStep3').html(totalAdult);
            $('#totalChildWrapperLabelStep3').html(totalChild);
            $('#totalInfantWrapperLabelStep3').html(totalInfant);

      $('#totalRoomWrapper').val($("#numberOfRooms option:selected").text());
            $('#totalAdultWrapper').val(totalAdult);
            $('#totalChildWrapper').val(totalChild);
            $('#totalInfantWrapper').val(totalInfant);


           $('.priceTable tbody td').remove();
           $('.priceTable tfoot td').eq(2).html('');

           $('#checkInDateWrapper').html(checkInDate);
           $('#checkOutDateWrapper').html(checkOutDate);


           var btnText='Select Room';
           var dataReq = jQuery.parseJSON(requestData);
           if(dataReq['error']){
               $('.priceTable tbody').append('<tr><td colspan="3">'+dataReq['error']+'</td></tr>');
           }else{

             var numberOfe = $('#numberOfRooms option:selected').val();

             $(dataReq['prices']).each(function(i){

               var selectRoom ='';
               var roomPrice =  dataReq['prices'][i]['room']['total'];
               var roomID =  dataReq['prices'][i]['room'].id;

               // var hotel_url = api_url+'/hotel?resortId='+dataReq['prices'][i]['room'].hotel_ID+'&apikey='+api_key;

              // $.getJSON(hotel_url).done(function(data) {
              //       console.log("Done");
              //       // ...
              //   });
              //
              //   $.getJSON(hotel_url, function(data) {
              //         //console.log( data['hotel_name']);
              //         //$('.priceTable tbody .hotel_name').append(data['hotel_name']);
              //       });
              //
              //  var hotel_name = $.getJSON(hotel_url,function (data){return data['hotel_name'];  });

              console.log(dataReq);

         // $.getJSON(hotel_url,function (data2){
              if(roomPrice == 0){
                var resBtnClass = 'hidden';
              }else{
                var resBtnClass = '';
              }
              // console.log("Selected room:",selectRoom)


                console.log(dataReq['prices'][i]);

                if(dataReq['prices'][i]["room"]["status"] == 'no'){
                  $('.priceTable tbody').append('<div class="row roomWrapper"><div class="col-md-3 hidden-sm hidden-xs"><img src="https://clubexelsior.com/reservation/'+dataReq['prices'][i]['roomImage'].galery_path+'/'+dataReq['prices'][i]['roomImage'].galery_image+'" class="img-responsive room-list-image"  alt="" /></div><div class="col-md-3 room-detail"><span class="hotel_name">'+dataReq['prices'][i]['room'].room_content+'<strong>'+dataReq['prices'][i]['room'].hotel_name+'</strong></span><br><p><strong class="room_title_on_list">'+dataReq['prices'][i]['room'].room_title+' <br></strong></p></div><div class="col-md-3 room_content_search_list"><p><i>Please Change Your Selected Dates If You Wish To Stay In This Hotel.</i></p></div><div class="col-md-3 room_content_search_list">' +
                    '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][roomID]" value="'+dataReq['prices'][i]['room'].id+'"/>'+
                    '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][adult]" value="'+adult+'" />'+
                    '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][checkInDate]" value="'+checkInDate+'" />'+
                    '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][checkOutDate]" value="'+checkOutDate+'" />'+
                    '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][child]" value="'+child+'" />'+
                    '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][roomAmount]" value="'+roomAmount+'" />'+
                    '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][roomPriceT]" value="'+roomPrice+'" />'+
                    '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][hotel_name]" value="'+dataReq['prices'][i]['room'].hotel_name+'" />'+
                    '<p><strong>Unavailable Day(s) :</strong> </p>'+
                    '<span style="font-size:14px">'+dataReq['prices'][i]["room"]["noRoom"]+'</span>'+
                    '');

                }
              else if(dataReq['prices'][i]["room"]["total"] != 0 || dataReq['prices'][i]["room"]["total"] !=  "0"){
                // if((new Date(checkOutDate).getTime() >= new Date('01.01.2019').getTime()))  {
              $('.priceTable tbody').append('<div class="row roomWrapper"><div class="col-md-3 hidden-sm hidden-xs"><img src="https://clubexelsior.com/reservation/'+dataReq['prices'][i]['roomImage'].galery_path+'/'+dataReq['prices'][i]['roomImage'].galery_image+'" class="img-responsive room-list-image"  alt="" /></div><div class="col-md-3 room-detail"><span class="hotel_name">'+dataReq['prices'][i]['room'].room_content+'<strong>'+dataReq['prices'][i]['room'].hotel_name+'</strong></span><br><p><strong class="room_title_on_list">'+dataReq['prices'][i]['room'].room_title+' <br></strong></p></div><div class="col-md-3 room_content_search_list"><p></i><p><strong>Total Room(s) Price : </strong> '+ roomPrice*parseInt($('#totalRoomWrapperLabel').html()) +' GBP </p></div><div class="col-md-3 search_btn_wrapper">' +
              '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][roomID]" value="'+dataReq['prices'][i]['room'].id+'"/>'+
              '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][adult]" value="'+adult+'" />'+
              '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][checkInDate]" value="'+checkInDate+'" />'+
              '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][checkOutDate]" value="'+checkOutDate+'" />'+
              '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][child]" value="'+child+'" />'+
              '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][roomAmount]" value="'+roomAmount+'" />'+
              '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][roomPriceT]" value="'+roomPrice+'" />'+
              '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][hotel_name]" value="'+dataReq['prices'][i]['room'].hotel_name+'" />'+
              '<p><a href="javascript:;" class="selectRoomBtnDesign '+resBtnClass+' btn btn-primary btn-sm btn-orange">'+
              // '<select name="reservation['+dataReq['prices'][i]['room'].id+'][count]" class="room_counts roomCounte">'+
              // '</select>'+
              '<input type="hidden" class="roomTitle" name="reservation['+dataReq['prices'][i]['room'].id+'][roomTitle]" value="'+dataReq['prices'][i]['room'].room_title+'"/>'+
              '<input type="hidden" class="hotelTitle" name="reservation['+dataReq['prices'][i]['room'].id+'][hotel_name]"  value="'+dataReq['prices'][i]['room'].hotel_name+'"/>'+
              '<span class="checkedRoom">'+btnText+'<input type="radio" data-price="'+roomPrice*parseInt($('#totalRoomWrapperLabel').html())+'"  disabled="disabled" name="reservation['+dataReq['prices'][i]['room'].id+'][roomID]" value="'+dataReq['prices'][i]['room'].id+'"/>'+
              '</span></a></p><br></br><p>Please click the next button below after selecting your room type   </p>');

              }else{

				$('.priceTable tbody').append('<div class="row roomWrapper"><div class="col-md-3 hidden-sm hidden-xs"><img src="https://clubexelsior.com/reservation/'+dataReq['prices'][i]['roomImage'].galery_path+'/'+dataReq['prices'][i]['roomImage'].galery_image+'" class="img-responsive room-list-image"  alt="" /></div><div class="col-md-3 room-detail"><span class="hotel_name">'+dataReq['prices'][i]['room'].room_content+'<strong>'+dataReq['prices'][i]['room'].hotel_name+'</strong></span><br><p><strong class="room_title_on_list">'+dataReq['prices'][i]['room'].room_title+' <br></strong></p></div><div class="col-md-3 room_content_search_list"><p></i><p><strong>Total Room(s) Price : </strong> '+ roomPrice*parseInt($('#totalRoomWrapperLabel').html()) +' GBP </p></div><div class="col-md-3 search_btn_wrapper">' +
				  '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][roomID]" value="'+dataReq['prices'][i]['room'].id+'"/>'+
				  '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][adult]" value="'+adult+'" />'+
				  '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][checkInDate]" value="'+checkInDate+'" />'+
				  '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][checkOutDate]" value="'+checkOutDate+'" />'+
				  '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][child]" value="'+child+'" />'+
				  '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][roomAmount]" value="'+roomAmount+'" />'+
				  '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][roomPriceT]" value="'+roomPrice+'" />'+
				  '<input type="hidden" name="reservation['+dataReq['prices'][i]['room'].id+'][hotel_name]" value="'+dataReq['prices'][i]['room'].hotel_name+'" />'+
				  '<span>No available Room</span>');


			  }

              // <input class="roomCounte" type="number" name="reservation['+dataReq['prices'][i]['room'].id+'][count]" min="0" disabled="disabled" max="'+numberOfe+'" value="1"/>



              //   }
              // });
              //selectRoomLink
               // dataReq['prices'][i]['room']['currency']
          total += dataReq['prices'][i]['price'];

               /*Select Room*/
               $('#selectRoomLink'+dataReq['prices'][i]['room'].id).click(function(){
               $('#totalPriceAmount').html(roomPrice+currencyCode );
              });
               /*Select Room*/
             });

             // for (var i = 1; i <= numberOfe; i++) {
             //   $('.room_counts').append('<option>'+i+'</option>');
             // }

          }

          $('.priceTable tfoot td').eq(1).html(total+" GBP");
       }
   });


     return false;
 });

});

$('.priceTable tbody').delegate('input[type="number"]','change',function(){

    var price = $(this).parent('.selectRoomBtnDesign').find('input[type="checkbox"]').data('price');
    var newPrice = price*$(this).val();
    $(this).parent('.selectRoomBtnDesign').find('input[type="checkbox"]').attr('data-price',newPrice);

    total();

});

$('.priceTable tbody').delegate('.checkedRoom','click',function(){

	  var totalRoom = $('#totalRoomWrapperLabel').html();

	  var totalChecked = $('.selectRoomBtnDesign.active').length;

	  console.log();
	  console.log(totalRoom);

	  if(totalChecked == 1){


        $('.priceTable tbody').find('.selectRoomBtnDesign').removeClass('active');
        $('.priceTable tbody').find('input:radio').attr('disabled','disabled');
        $('.priceTable tbody').find('input:radio').prop('checked',false);
        $('.priceTable tbody').find('input:radio').removeAttr('checked');
        $('#room1').val('0');
        $('#hotel1').val('0');

        $(this).parent('.selectRoomBtnDesign').addClass('active');
        $(this).find('input:radio').removeAttr('disabled');
        $(this).parent('.selectRoomBtnDesign').find('.roomCounte').removeAttr('disabled');
        $(this).find('input:radio').prop('checked',true);
        $(this).find('input:radio').attr('checked','checked');
        $('#room1').val($(this).parent('.selectRoomBtnDesign').find('.roomTitle').val());
        $('#hotel1').val($(this).parent('.selectRoomBtnDesign').find('.hotelTitle').val());
		$('#checkedHotelName').html($(this).parent('.selectRoomBtnDesign ').find('.hotelTitle').val());
		$('#checkedRoomName').html($(this).parent('.selectRoomBtnDesign ').find('.roomTitle').val());
		$('#checkedHotelNameInput').val($(this).parent('.selectRoomBtnDesign ').find('.hotelTitle').val());
		$('#checkedRoomNameInput').val($(this).parent('.selectRoomBtnDesign ').find('.roomTitle').val());


        total();

	  }else{

      if($(this).find('input:radio').is(':checked') == true){

        $(this).parent('.selectRoomBtnDesign').removeClass('active');
        $(this).find('input:radio').attr('disabled','disabled');
        $(this).parent('.selectRoomBtnDesign').find('.roomCounte').attr('disabled','disabled');
        $(this).find('input:radio').prop('checked',false);
        $(this).find('input:radio').removeAttr('checked');
        $('#room1').val($(this).parent('.selectRoomBtnDesign').find('.roomTitle').val());
        $('#hotel1').val($(this).parent('.selectRoomBtnDesign').find('.hotelTitle').val());
		$('#checkedHotelName').html($(this).parent('.selectRoomBtnDesign ').find('.hotelTitle').val());
		$('#checkedRoomName').html($(this).parent('.selectRoomBtnDesign ').find('.roomTitle').val());
		$('#checkedHotelNameInput').val($(this).parent('.selectRoomBtnDesign ').find('.hotelTitle').val());
		$('#checkedRoomNameInput').val($(this).parent('.selectRoomBtnDesign ').find('.roomTitle').val());



      }else{

        $(this).parent('.selectRoomBtnDesign').addClass('active');
        $(this).find('input:radio').removeAttr('disabled');
        $(this).parent('.selectRoomBtnDesign').find('.roomCounte').removeAttr('disabled');
        $(this).find('input:radio').prop('checked',true);
        $(this).find('input:radio').attr('checked','checked');
        $('#room1').val($(this).parent('.selectRoomBtnDesign').find('.roomTitle').val());
        $('#hotel1').val($(this).parent('.selectRoomBtnDesign').find('.hotelTitle').val());
		$('#checkedHotelName').html($(this).parent('.selectRoomBtnDesign ').find('.hotelTitle').val());
		$('#checkedRoomName').html($(this).parent('.selectRoomBtnDesign ').find('.roomTitle').val());
		$('#checkedHotelNameInput').val($(this).parent('.selectRoomBtnDesign ').find('.hotelTitle').val());
		$('#checkedRoomNameInput').val($(this).parent('.selectRoomBtnDesign ').find('.roomTitle').val());


      }

      total();

    }


});

function total(){

    var totalPrice = 0;

    $('.priceTable tbody input[type="radio"]:checked').each(function(){

        var roomCountNumber = $(this).parents('.selectRoomBtnDesign').find('.roomCounte').val();
        totalPrice += $(this).data('price');
        //console.log(roomCountNumber);

        $('#totalPriceAmountLabel').text(totalPrice+ ' ' + 'GBP');
        $('#totalPriceAmountLabelStep3').text(totalPrice+ ' ' + 'GBP');
        $('#toplam_para').val(totalPrice);
        $('#amount').val(totalPrice);
        $('#totalPriceAmount').val(totalPrice);

    });


}


 /*Step 3*/
    $('#btnStep2').click(function(){

		var form = $("#reservationFrom");
	   form.validate({
		 errorPlacement: function errorPlacement(error, element) { element.before(error); },
		 rules: {
			 confirm: {
				 equalTo: "#totalRoomWrapper",
				 equalTo: "#totalAdultWrapper",
				 equalTo: "#totalChildWrapper",
				 equalTo: "#totalPriceAmount",
			 }
		 }
	   });

	   form.validate().settings.ignore = ":disabled,:hidden";

     if($('.selectRoomBtnDesign').hasClass('active') == false){

         alert('Please select room type');

         e.preventDefault();

         return false;

     }

     $( ".next" ).trigger( "click" );//to next tab

    });
  /*Step 3*/
 /*Step 4*/
    $('#btnStep3').click(function(e){

        if(!$('input[name="paxNameSurname"]').val()){
          alert('Please fill Name & Surname');
          e.preventDefault();
          return false;
        }

        if(!$('input[name="paxEmail"]').val()){
          alert('Please fill E-Mail');
          e.preventDefault();
          return false;
        }

        if(!$('input[name="paxPhone"]').val()){
          alert('Please fill Phone');
          e.preventDefault();
          return false;
        }

        if(!$('input[name="paxAddress"]').val()){
          alert('Please fill Address');
          e.preventDefault();
          return false;
        }

        if(!$('input[name="paxPostalCode"]').val()){
          alert('Please fill PostalCode');
          e.preventDefault();
          return false;
        }

        if(!$('input[name="paxCountry"]').val()){
          alert('Please fill Country & City');
          e.preventDefault();
          return false;
        }

        $( ".next" ).trigger( "click" );//to next tab

    });
  /*Step 4*/




 $('#prevbtn').click(function(){

   if($('.menu-ul li').eq(0).hasClass('active') == true){

      return false;

   }

   $( ".prev" ).trigger( "click" );

 });



  function acdiv(i){
            // alert(i);
            var bb=i+"a";
            document.getElementById(i).style.display="block" ;
            document.getElementById(bb).innerHTML='<a href=\"Javascript:null(0)\" class=\"metin_mavi\" onClick=\"kapadiv('+i+')\"><b>Price List</a></b>' ;
        }

        function kapadiv(ii){
            var ia=ii+"a";
            document.getElementById(ii).style.display="none" ;
            document.getElementById(ia).innerHTML='<a href=\"Javascript:null(0)\" class=\"metin_mavi\" onClick=\"acdiv('+ii+')\"><b>Price  </b>  </a>' ;

        }

        function SayiKontrol(e) {
            olay = document.all ? window.event : e;
            tus = document.all ? olay.keyCode : olay.which;
            if(tus<48||tus>57) {
                if(document.all) { olay.returnValue = false; } else { olay.preventDefault(); }
            }
        }

        function findObj(n, d) { //v4.0
            var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
                d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
            if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
            for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
            if(!x && document.getElementById) x=document.getElementById(n); return x;
        }
 function XIDHesapla(){
            var simdi = new Date();
            var yil = new String(simdi.getFullYear());
            yil = yil.slice(2, 4);
            var ay = new String(simdi.getMonth()+1);
            if (ay.length == 1) ay = "0"+ay;
            var gun = new String(simdi.getDate());
            if (gun.length == 1) gun = "0"+gun;
            var sa = new String(simdi.getHours());
            if (sa.length == 1) sa = "0"+sa;
            var dk = new String(simdi.getMinutes());
            if (dk.length == 1) dk = "0"+dk;
            var sn = new String(simdi.getSeconds());
            if (sn.length == 1) sn = "0"+sn;

            findObj("XID").value = "YKB_00000000"
            +yil+ay+gun+sa+dk+sn;
        }

        jQuery(function(){
            XIDHesapla();
        });
