there_are_any_optionen = false;
there_are_any_tarife = false;


function dq_update_selection_indicators() {	
	if (document.getElementById) {
		there_are_any_unchecked_ones = false;		
		for (var j = 0; j < document.vertrag.elements.length; j++) {
						
			if( document.vertrag.elements[j].id.substr( 0, 3 ) == 'sg_') {
				if (document.vertrag.elements[j].checked == false) {
					there_are_any_unchecked_ones = true;					
				}
				
				lineid = document.getElementById('line'+ document.vertrag.elements[j].id.substr(3));			
				picid = document.getElementById('pic_'+ document.vertrag.elements[j].id.substr(3));			

				if (document.vertrag.elements[j].checked) {				
					lineid.className = 'td_select';
					if(picid) {					
						picid.src = pic_ordner+'icon_ja_vertrag.gif';					
					}
				}else{
					lineid.className = 'td_leer';
					if(picid) {
						picid.src = pic_ordner+'icon_vertrag.gif';
					}
					
				}				
			}
		}		
	}
}

function dq_del_checkbox() {	
	for (var j = 0; j < document.vertrag.elements.length; j++) {
		if( document.vertrag.elements[j].id.substr( 0, 4 ) == 'sg_2') {
			if (document.vertrag.elements[j].checked == true) {
				document.vertrag.elements[j].checked = false;
				picid = document.getElementById('pic_'+ document.vertrag.elements[j].id.substr(3));	
				picid.src = pic_ordner+'icon_vertrag.gif';		
				
				lineid = document.getElementById('line'+ document.vertrag.elements[j].id.substr(3));	
				lineid.className = 'td_leer';
			}								
		}
	}
}

function dq_select_line(snmp_query_id, snmp_index, update) {
	
	if (document.getElementById) {	
		msgid = document.getElementById('sg_' + snmp_query_id + '_' + snmp_index);	
		lineid = document.getElementById('line'+ snmp_query_id + '_' + snmp_index);	
		if (!update) msgid.checked = !msgid.checked;	
		
		dq_update_selection_indicators();
	}	
}

function dq_update_optionen(optionen) {	
	if(!there_are_any_optionen) {
		there_are_any_optionen = optionen;
		Effect.BlindDown(optionen);		
	}
	else{
		
		if(there_are_any_optionen!=optionen) {
			Effect.BlindUp(there_are_any_optionen);
			Effect.BlindDown(optionen);
			there_are_any_optionen = optionen;
			dq_del_checkbox();
		}		
		else {
			if(there_are_any_optionen) {
				Effect.BlindUp(there_are_any_optionen);
				there_are_any_optionen = false;					
			}		
		}
	}
}

function dq_show_tarife(tarife) {	
	if(!there_are_any_tarife) {
		there_are_any_tarife = tarife;
		Effect.BlindDown('tast_'+tarife);		
		lineid = document.getElementById('head_'+tarife);			
		lineid.className = 'td_select';		
	}
	else{
		if(there_are_any_tarife!=tarife) {
			Effect.BlindUp('tast_'+there_are_any_tarife);
			
			lineid = document.getElementById('head_'+there_are_any_tarife);			
			lineid.className = 'td_mittel';
			
			Effect.BlindDown('tast_'+tarife);
			lineid = document.getElementById('head_'+tarife);			
			lineid.className = 'td_select';
			
			there_are_any_tarife = tarife;
			
			if(there_are_any_optionen) {
				Effect.BlindUp(there_are_any_optionen);
				there_are_any_optionen = false;
				dq_del_checkbox();
			}		
		}		
	}
	
}
