/**
 * Switch between open and closed state in cisviewer.
 *
 * @param string $id
 * @return void
 */
function switchDisplay(id) {

	var img = document.getElementById('image_' + id);
	var content = document.getElementById('container_' + id);
	var path = 'typo3conf/ext/cis_viewer/';
	
	if (img.src.indexOf('arrow_1.gif')!=-1)  {
		img.src = path + 'arrow_2.gif';
		content.style.display = 'block';
	} else {
		img.src = path + 'arrow_1.gif';
		content.style.display = 'none';
	}
}


/**
 * Loop form and toggle all checkboxes on/off
 *
 * @param object $f Reference to form object
 * @param boolean $state State of reference checkbox (true/false)
 * @return void
 */
 function toggleSelect(f,state) {
 		
		//loop form 	
 		for(i=0; i < f.elements.length; i++) {
 			
 			el = f.elements[i];	//reference to element
 			
 			//set found checkbox to reference state
 			if (el.type == 'checkbox') {
 				el.checked = state;
 			} 
 		}
	}
	
	
/**
 * Loop group and toggle all checkboxes on/off
 *
 * @param object $f Reference to form object
 * @param boolean $state State of reference checkbox (true/false)
 * @return void
 */
 function toggleGroupedSelect(name,state) {
 		
 		f = document.forms[0];
 		
		//loop form 	
 		for(i=0; i < f.elements.length; i++) {
 			
 			el = f.elements[i];	//reference to element
 			
 			
 			//set found checkbox to reference state
 			switch(name) {
 				case 'brand':
		 			if (el.type == 'checkbox' && el.name == name + '[]') {
		 				el.checked = state;
		 			} 
 				break;

 				case 'data':
		 			if (el.type == 'checkbox' && (el.name == 'family_data[]' || el.name == 'model_data[]')) {
		 				el.checked = state;
		 			} 
 				break;

 				
 				
 			}
 		}

		//toggle a-tag
		if (state) {
			document.getElementById(name + '_ON').style.display = 'none';
			document.getElementById(name + '_OFF').style.display = 'inline';
		} else {
			document.getElementById(name + '_ON').style.display = 'inline';
			document.getElementById(name + '_OFF').style.display = 'none';
		}
	}
	

/**
 * Tests if the submit-button for the SearchResultControlPanel should activate
 * Not if headers or spacers
 *
 * @return boolean
 */
 function testSubmit() {
 	
 	var sV = document.getElementById('selectedSearchResultDisplay').value;

 	if (sV.substr(0,6) == 'spacer') {
 		return false;	
 	} else {
 		return true;
	}
 	
 	
 } 
