$(document).ready(function(){
var count=0; // to count blank fields

/*------------validation function-----------------*/
$(".submit_btn").click(function(event){
//fetching radio button by name
	var radio_check = $('.rad');
	
	//fetching all inputs with same class name text_field and an html tag textarea 
	var input_field = $('.text_field');
	var text_area = $('textarea');
	
	//validating radio button
	if(radio_check[0].checked== false && radio_check[1].checked== false){
	 var y = 0;
	}
	else{
	 var y = 1; 
	}
	
	//for loop to count blank inputs 
	for(var i=input_field.length;i>count;i--){
	if(input_field[i-1].value==''|| text_area.value=='')
		{
			count = count + 1;
		    
		}
	else{			
			count = 0;
		}
	}
	
	//Notifying validation 
		if(count!=0||y==0){
		
			alert("*All Fields are mandatory*");
			event.preventDefault();	
			}
			else{			
				return true;
			}
});

/*---------------------------------------------------------*/

//Function runs on NEXT button click for First step
	$(".next_btn").click(function(){ 
	var x = document.getElementById('service_id').value;
	
    if (x == null || x == "") {
        alert("Please Select Service And Serivce Provider And click on Show Available buttom");
        return false;
    }
	else {

	$(this).parent().next().fadeIn('slow');
	$(this).parent().css({'display':'none'});
//Adding class active to show steps forward;
	$('.active').next().addClass('active');
	$('.act').next().addClass('act');
	}
	});
	

		
	$(".free").click(function(){ 

var y	=	$(this).children().val();
$("#free_value").val(y);

	});
	
	

	
/*---------------------------------------------------------*/	
	
//Function runs on NEXT button click for Second 2 step
	
	$(".next_btn1").click(function(){ 
	var x1 = document.getElementById('free_value').value;
	
    if (x1 == null || x1 == "") {
        alert("Please Select Date And Time");
        return false;
    }
	else {
								  
								  
								  
								  //Function runs on NEXT button click 
	$(this).parent().next().fadeIn('slow');
	$(this).parent().css({'display':'none'});
//Adding class active to show steps forward;
	$('.active').next().addClass('active');
	$('.act').next().addClass('act');
	
	//history.pushState(null, "A new title!", "?done")
	
	}
	});
	
	
/*---------------------------------------------------------*/	




/*---------------------------------------------------------*/	


$(".free1").click(function(){ 
						  
								  
	
	$('.app_monthly_schedule_wrapper').css({'width':'48%','margin-right':'2%'});

	
	function getUrlVars()
    {
	
	var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
	}
	var me = getUrlVars()["app_service_id"];
	//alert(me);
	
	
	});
	



/*---------------------------------------------------------*/	
	
	
	
	
	
	
	
	
	
	
	
/*---------------------------------------------------------*/	
	 //Function runs on PREVIOUS button click 
	
	$(".pre_btn").click(function(){           
	$(this).parent().prev().fadeIn('slow');
	$(this).parent().css({'display':'none'});
//Removing class active to show steps backward;
	$('.active:last').removeClass('active');
	});
	
//validating all input and textarea fields	
	$(".submit_btn").click(function(e){	
	if($('input').val()=="" || $('textarea').val()==""){	
			alert("*All Fields are mandatory*");
			return false;
		}
		else{
			return true;
		}
	});
});

 
//$script .= "history.pushState(null, 'A new title!', '?app_service_id='+selected_service);";
$(document).ready(function(){
	$("#tabs li").click(function() {
		//	First remove class "active" from currently active tab
		$("#tabs li").removeClass('current');

		//	Now add class "active" to the selected/clicked tab
		$(this).addClass("current");

		//	Hide all tab content
		$(".tab_content").hide();

		//	Here we get the href value of the selected tab
		var selected_tab = $(this).find("a").attr("href");
    
		//	Show the selected tab content
		$(selected_tab).fadeIn();

		//	At the end, we add return false so that the click on the link is not executed
		return false;
	});
});
/* ]]> */






  $(document).ready(function() { 
      $('.app_select_services').change(function() { 
	  
	  
        $.blockUI({ overlayCSS: { backgroundColor: '#9ACAF5' } }); 
 
        setTimeout($.unblockUI, 20000); 
    }); 
}); 
  
  
  
  
  $(document).ready(function() { 
      $('.app_select_workers').change(function() { 
	  
	  
        $.blockUI({ overlayCSS: { backgroundColor: '#9ACAF5' } }); 
 
        setTimeout($.unblockUI, 20000); 
    }); 
}); 
  
  
  
  
  
   $(document).ready(function() { 
      $('.next_month').click(function() { 
	  
	  
        $.blockUI({ overlayCSS: { backgroundColor: '#9ACAF5' } }); 
 
        setTimeout($.unblockUI, 20000); 
    }); 
}); 
    
  
   $(document).ready(function() { 
      $('.previous_month').click(function() { 
	  
	  
        $.blockUI({ overlayCSS: { backgroundColor: '#9ACAF5' } }); 
 
        setTimeout($.unblockUI, 20000); 
    }); 
}); 
    



