

	var colorSelItem = '#B0C4DE'	// #B0C4DE;#F0F0F0;#FF8C00;#FFCC8E;#F4F7FB
	var commingFrom;

///\brief Script Loaded by the templates conectall and diagrams
	function showSectionIndex( sectionId, lng) {
	
		var theSpan = document.getElementById( "cnf_" + sectionId );
		
		if ( ( theSpan.style.display == 'none' ) && ( theSpan.innerHTML.indexOf( 'table' ) == -1 ) ) 
		{
			_req = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject( "Microsoft.XMLHTTP" );
			_req.open( "GET", "/tutorials/connectivity/diagrams/aspx/getSectionIndex.asp?sId=" + sectionId + "&l=" + lng);
			_req.onreadystatechange = function() {
										if ( _req.readyState == 4 ) {
											theSpan.innerHTML 	  = _req.responseText;
											theSpan.style.display = "block";
											_req 				  = null;
										}
									  }
			_req.send( null );
		}
		else if ( ( theSpan.style.display == 'none' ) && ( theSpan.innerHTML.indexOf( 'table' ) != -1 ) ) 
			theSpan.style.display = "block" 
		else if ( theSpan.style.display == 'block' ) 
			theSpan.style.display = 'none';
	}
	
	
	
	
	function updateComponentType( action, minVal, maxVal, cmpId, theValues ) {
	
		var theCounter 	 = document.getElementById( 'counter' + cmpId );
		var theValue     = parseInt( theCounter.innerHTML, 10 );
		var theComponent = document.getElementById( 'chk_' + cmpId );
		var aValues 	 = theValues.split( "," )
		
		// Update the text in the counter
		switch ( action ) 
		{ 
			case "+" : 
				theCounter.innerHTML = theValue == maxVal ? String( theValue ) : String( theValue + 1 );
				break; 
			case "-" : 
				theCounter.innerHTML = theValue == minVal ? String( theValue ) : String( theValue - 1 );
		} 
		
		// Update the value of the hidden control with the component selected
		theComponent.value = aValues[ parseInt( theCounter.innerHTML ) - 1 ];
		// Automatically mark the checkbox as checked
		theComponent.checked = true;
	}
	

	function selectElem( theId, theValues ){
	
		var theChkBox = document.getElementById( 'chk_' + theId );
		
		// In case of components with sub-components -> update the value of the checkbox using the value displayed in the counter
		if ( ( theChkBox.checked ) && ( theValues != '' ) ) {
			if ( theValues == 'DVDRSL' ) {
				// Special case for the DVDR with SmartLink control
				if ( document.getElementById( 'chk_DVDRSL' ).checked )
					theCheckBox.value = '';
			} else {
				var theCounter 	= document.getElementById( 'counter' + theId );
				var aValues 	= theValues.split( "," )
				theChkBox.value = aValues[ parseInt( theCounter.innerHTML ) - 1 ];
			}
		}
	}
	

	function selectDVDRSL() {
		if ( document.getElementById( 'chk_DVDRSL' ).checked ) {
			var theChkDVDR = document.getElementById( 'chk_DVDR' );
			theChkDVDR.checked	= true;
			theChkDVDR.value	= '';
		} else {
			var theChkDVDR = document.getElementById( 'chk_DVDR' );
			if ( theChkDVDR.checked ) 
				theChkDVDR.value	= 'DVDR';
		}	
	}
	
	
	function showDiagram( lng ) {
	
		var chkComponents = '';
		var diagramPage   = 'connection.aspx?l=' + lng;
		if ( commingFrom ) diagramPage += '&ct=' + commingFrom;

		// Retrieve all the components selected and concatenate them with a comma
	    var l = document.getElementsByTagName( "input" ).length;
	    for( var i = 0; i < l; i++ ) 
	      with( document.getElementsByTagName( "input" )[i] )
			if ( ( type == "checkbox" ) && ( checked == true ) && ( value != '' ) )
				chkComponents += "," + value;
		chkComponents = chkComponents.substr( 1 )	// Just to remove the 1st comma
		
		// Create the REQUEST object and make the call
		_req = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject( "Microsoft.XMLHTTP" );
		
		_req.open( "GET", "getDiagram.asp?chkComponents=" + chkComponents );
		_req.onreadystatechange = function() {
									if ( _req.readyState == 4 ) {
										// Parameters to track whether a diagram was found or not
										var diagramFound = ( _req.responseText != '' ? ( '&fd=' + chkComponents ) : ( '&nf=' + chkComponents ) );  
										document.location = diagramPage + '&d=' + _req.responseText + diagramFound;
										_req = null;
									}
								  }
		_req.send( null );
	}	

	function showDiagramId( site, id) {
		var url = 'connection.aspx?site=' + site + '&d=' + id;
		document.location = url;
	}

	
	function divOnMouseOver( theId ) {
	
		var theDiv  = document.getElementById( 'div_' + theId );
		var theCell = document.getElementById( 'td_' + theId );
		
		theDiv.style.backgroundColor = '#FFCC8E'; 	//#FDFAE8; #FF8C00
		theDiv.style.cursor			 = 'pointer'
		theCell.className 			 = 'cnn_cell_hover';
	}

	
	function divOnMouseOut( theId ){
	
		var theDiv    = document.getElementById( 'div_' + theId );
		var theChkBox = document.getElementById( 'chk_' + theId );
		var theCell   = document.getElementById( 'td_' + theId );
		
		theDiv.style.backgroundColor = theChkBox.checked ? colorSelItem : '#FFFFFF';
		theCell.className = 'cnn_cell';
	}

	
	function resetChkboxes() {
	
	    var l = document.getElementsByTagName( "input" ).length;

	    for( var i = 0; i < l; i++ ) 
	      with( document.getElementsByTagName( "input" )[i] )
			if( type == "checkbox" ) 
				checked = false;
	}

	
	function checkSelectedComponents( lng ) {
	
		var totalSelected = 0;
		var l = document.getElementsByTagName( "input" ).length;

		for( var i = 0; i < l; i++ ) 
	      with( document.getElementsByTagName( "input" )[i] )
			if( ( type == "checkbox" ) && ( checked == true ) && ( value != '' ) )
				totalSelected++;

		if ( totalSelected >= 2 ) 
			showDiagram( lng );
	}

