﻿jQuery = jQuery.noConflict();
function getURLParameter (name) {
 return decodeURI((RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]);
}

var ta=new Array();
ta=[
'9:00-9:45x0', 
'9:00-9:45x1', 
'9:45-10:15x0', 
'9:45-10:15x1', 
'10:15-11:00x0', 
'10:15-11:00x1', 
'11:45-12:30x0', 
'11:45-12:30x1', 
'13:30-14:15x0', 
'13:30-14:15x1', 
'14:15-15:00x0', 
'14:15-15:00x1', 
'15:00-15:45x0', 
'15:00-15:45x1'
];
jQuery(document).ready(function($) {
//alert(getURLParameter('task'));
$("#date").focusout(function(){
if($(this).val()!='' || getURLParameter('task')!='edit'){
$.getJSON("/components/com_hello/gate.php",
  {
    action: "busylist",
    date:$(this).val()
  },
  function(data) {
    $.each(data, function(i,item){
      $('select[name]="datestream" option').each(function() {
    if ( $(this).val() == item )
       $(this).remove();
});
    });
  });
  

}
if($("#date").val()!=''){
$.getJSON("/components/com_hello/gate.php",
  {
    action: "is_closed",
    date:$("#date").val()
  },
  function(data) {
    $.each(data, function(i,item){
	//alert(item);
	if(item.status=='closed')alert('День '+item.date+' закрыт для потока '+(parseInt(item.stream)+1)+"\nВыберите другой день!");
    });
  });
}
});


});
