

function checkSearchField(obj) {
	var elem;
	if (obj.value == 'num') {
		if ((elem = document.getElementById('num_search'))) elem.style.display='block';
		if ((elem = document.getElementById('reg_search'))) elem.style.display='none';
		if ((elem = document.getElementById('search_query'))) elem.value='';
	} else {
		if ((elem = document.getElementById('num_search'))) elem.style.display='none';
		if ((elem = document.getElementById('reg_search'))) elem.style.display='block';
		if ((elem = document.getElementById('search_from'))) elem.value='';
		if ((elem = document.getElementById('search_to'))) elem.value='';
	}
}


function openNew(obj, width, height, titul) {
	var newwin = window.open('/images/spacer.gif', 'Information', 'toolbar=0,status=0,menubar=0,scrollbars=0,resizable=1,width=' + width + ',height=' + height);
	newwin.document.open();
	newwin.document.write('<html><head><title>'+ titul + '</title></head>');
 	newwin.document.write('<body style="margin-left:0; margin-right:0; margin-top:0; margin-bottom:0;padding-top:0; padding-left:0; padding-right:0; padding-bottom:0;"><a href="javascript:void(0)" onClick="window.close()"><img src="' + obj + '" border="0" alt="Скрыть"/></a></body></html>');
 	newwin.document.close();
	newwin.focus();
}

function showChannelsList(list_nom){
	var ul=null,divs=null;
	if(obj=document.getElementById('channels_list')){
	 	
		
		 divs=obj.getElementsByTagName('div');
		 
				
		
		 for (i=0; i<obj.childNodes.length; i++) {
				if(obj.childNodes[i].nodeName=="UL"){
				   ul=obj.childNodes[i];
				}				
				
		 }
		 if(!ul) return;
		 
		 
		 
		 
		 
		 if(obj=ul.getElementsByTagName('ul')){
		 	
		 	for(i=0; i<obj.length; i++){
		 		
		 		 if(obj[i].id=='channel_list_'+list_nom){
		 		 	
		 		 	obj[i].style.display='block';
		 		 }
		 		  else{
		 		    obj[i].style.display='none';
		 		  }
		 	}
		 			 		
		 }	
		 	
		

		 
		 		 	
	}		
 }
	

function showProgramm(nom){
	if((nom<1)||(nom>7)) return;
	
	for(var i=1;i<=7;i++){
		
		if(obj=document.getElementById('programm_'+i))
			obj.style.display='none';
		if(obj=document.getElementById('calendar_day_'+i)){
			obj.className='enable';
			obj.onmouseout=function(){this.className='enable'};
			obj.onmouseover=function(){this.className='selected'};
			
		}
			
			
			
			
	}
	
	if(obj=document.getElementById('programm_'+nom)){
			obj.style.display='block';
	}
	
	if(obj=document.getElementById('calendar_day_'+nom)){
				obj.className='current';
				obj.onmouseout=null;
				obj.onmouseover=null;
	}
	
	
}


function selectedChannels(id,checked){
	resetGlobalChannelsSelect();
	if(obj=document.getElementById(id)){
		
		if(checkbox=obj.getElementsByTagName('INPUT')){
		 	
		 	for(i=0; i<checkbox.length; i++){
		 		if(checkbox[i].getAttribute('type')=='checkbox'){
		 		 if(checked==true)
		 		 			checkbox[i].checked=true;
		 		  else
		 		  			checkbox[i].checked=false;
		 			
		 		}		 		
		 		 
		 	}
		}
		
	}
	
}

function selectedChannelsGroup(group_nom,checked){
	
	resetGlobalChannelsSelect();
	var selected=true;
	if(obj=document.getElementById('channel_list_'+group_nom)){
				
		if(checkbox=obj.getElementsByTagName('INPUT')){
		 	
		 	for(i=0; i<checkbox.length; i++){
		 		if(checkbox[i].getAttribute('type')=='checkbox'){
		 			if(checkbox[i].checked!=true){
		 				selected=false;
		 				break;
		 			}
		 		 
		 		}
			}	
	  }	
		if(obj=document.getElementById('channel_list_name_'+group_nom)){
				if(checkbox=obj.getElementsByTagName('INPUT'))
					if(selected)
						checkbox[0].checked=true;
					else
						checkbox[0].checked=false;
			}
					
	}
	
}


function selectAllChannels(checked){
	
	
	if(obj=document.getElementById('channels_list')){
		if(checkbox=obj.getElementsByTagName('INPUT')){
			for(i=0; i<checkbox.length; i++){
		 		if(checkbox[i].getAttribute('type')=='checkbox'){
		 			 	checkbox[i].checked=checked;	
		 		}
			}
		}
	}
	
}
	
function resetGlobalChannelsSelect(){
	
	if(obj=document.getElementById('select_all_channels')){
		 obj.checked=false;		
	}
	
}



function showTeleprogramm(){
	
	if(obj=document.getElementById('teleprogram_filter_form')){
		obj.submit();
	}
	
	
}



 function notify(channel_id){
 	
 	
 		setTimeout(function(){notify(channel_id);},5000);
		
 		if(do_notifier){
 			try{
 			//  serverRequest('GET',"/notify.php?c="+channel_id,new Array(),null,null,null);
 			} catch(e){}
 			
 		}
	  
 	
 }
