function parseParams(params)
{
	var	strIn = "31,31,75,4800,1,1,1,0,1,0,0";
	var	m = 0, j = 0;
	for( var k = 0; k < strIn.length; k++ )
		if (strIn.charAt(k) == ",")	{
			params[j++] = parseInt(strIn.substring(m,k));
			m = k + 1;
		}
	
	if(k > m)
		params[j] = parseInt(strIn.substring(m,k));
}

function deleteNode(nodeId)
{
	var node = document.getElementById(nodeId);
	var parent = node.parentNode;
	parent.removeChild(node);
}

function totalParams()
{
	return 11;
}

function adjust_image_colors()
{
	var Params = new Array( totalParams() );
	parseParams( Params );
	var	color_types = Params[0];
	if(((color_types & 2) == 0)||((color_types & 4) == 0))		{
		deleteNode("HalftonesOn");
		deleteNode("HalftonesOn1");
		deleteNode("HalftonesOn21");
	}
	if(((color_types & 8) == 0)||((color_types & 16) == 0))		{
		deleteNode("ColorOn");
		deleteNode("ColorOn2");
		deleteNode("ColorOn3");
		deleteNode("ColorOn4");
	}	
	if(((color_types & 1) == 0)||((color_types & 2) == 0))	{
		deleteNode("Lineart");
	}
	
	if(((color_types & 8) == 0)||((color_types & 16) == 0)||((color_types & 4) == 0))		{
		deleteNode("ColorHT");
		deleteNode("ColorHT1");	
	}
}

function apply_filters()
{
	var Params = new Array( totalParams() );
	parseParams( Params );
	
	var	color_types = Params[0];
	
	if(((color_types & 8) == 0)||((color_types & 16) == 0)||((color_types & 4) == 0))		{
		deleteNode("ColorHT");
		deleteNode("ColorHT1");			
	}
	
	if (!(((color_types & 8) == 0)&&((color_types & 16) == 0)))		{
		deleteNode("ColorMode");
		deleteNode("Lineart");
	}
	else
	{
		if (!((color_types & 4) == 0))
		{		
			deleteNode("Lineart");
		}
		else
			deleteNode("ColorMode");
	}
}

function channel_list()
{
	var Params = new Array( totalParams() );
	parseParams( Params );
	
	var	color_types = Params[0];
	
	if(((color_types & 2) == 0)||((color_types & 4) == 0))		{
		deleteNode("HalftonesOn");			
	}
	if(((color_types & 8) == 0)||((color_types & 16) == 0))		{	
		deleteNode("ColorOn");			
	}	
	if(((color_types & 1) == 0)||((color_types & 2) == 0))	{
		deleteNode("Lineart");	
	}
	
	if(((color_types & 8) == 0)||((color_types & 16) == 0)||((color_types & 4) == 0))		{
		deleteNode("ColorHT");					
	}	
}

function color_type()
{
	var Params = new Array( totalParams() );
	parseParams( Params );


	var	color_types = Params[0];
	
	if((color_types & 1) == 0)	{
		deleteNode("Lineart");					
		deleteNode("LineartDesc");					
	}
	if((color_types & 2) == 0)	{
		deleteNode("Halftone");					
		deleteNode("HalftoneDesc");					
	}
	if((color_types & 4) == 0)	{
		deleteNode("Gray");					
		deleteNode("GrayDesc");					
	}
	if((color_types & 8) == 0)	{
		deleteNode("Color256");					
		deleteNode("Color256Desc");					
	}
	if((color_types & 16) == 0)	{
		deleteNode("ColorTrue");					
		deleteNode("ColorTrueDesc");					
	}
}
function color_management()
{
	var Params = new Array( totalParams() );
	parseParams( Params );


	var	color_management = Params[4];
	
	if(color_management == 1)	{
		deleteNode("AltDescription");									
	}else{
	deleteNode("MainDescription");
	}
}
function histogram()
{
	var Params = new Array( totalParams() );
	parseParams( Params );


	var	value = Params[5];
	
	if(value == 1)	{
		deleteNode("AltDescription");	
	}else {
		deleteNode("MainDescription");
	}
}
function customize_scan_settings()
{
	var Params = new Array( totalParams() );
	parseParams(Params);

	var	color_types = Params[0];

	if((color_types & 1) == 0)	{
		deleteNode("Lineart");					
	}
	
	if((color_types & 2) == 0)	{
		deleteNode("Halftone");					
	}
	
	if((color_types & 4) == 0)	{
		deleteNode("Gray");					
	}
	
	if((color_types & 8) == 0)	{
		deleteNode("Color256");					
	}
	if((color_types & 16) == 0)	{
		deleteNode("ColorTrue");					
	}
}

function document_source()
{
	var Params = new Array( totalParams() );
	parseParams( Params );

	var	feeder_types = Params[1];
	
	if((feeder_types & 1) == 0)	{
		deleteNode("ADF");					
		deleteNode("ADF1");					
	}
	if((feeder_types & 2) == 0)	{
		deleteNode("Flatbed");					
		deleteNode("flatbed1");							
	}
	if((feeder_types & 4) == 0)	{
		deleteNode("Auto");										
	}	
	if(((feeder_types & 1) == 0)||((feeder_types & 2) == 0)){
		deleteNode("AdfFlat");					
		deleteNode("Select");							
	}
	
	if(((feeder_types & 8) == 0)||((feeder_types & 16) == 0)){
		deleteNode("ADF_duplex");					
	}
}

function how_to_adjust_scan_settings()
{
	var Params = new Array( totalParams() );
	parseParams( Params );

	var	feeder_types = Params[1];
	
	if(((feeder_types & 1) == 0))	{
		deleteNode("ADF");					
	}
	
	if(((feeder_types & 2) == 0))	{
		deleteNode("Flatbed");					
	}
	if(((feeder_types & 1) == 0)||((feeder_types & 2) == 0)){
		deleteNode("ADFflat");					
	}
}

function How_To_Scan_a_Whole_Page()
{
	var Params = new Array( totalParams() );
	parseParams( Params );

	var	color_types = Params[0];

	if((color_types & 1) == 0)	{
		deleteNode("Lineart");					
	}
	if((color_types & 2) == 0)	{
		deleteNode("Halftone");					
	}
	if((color_types & 4) == 0)	{
		deleteNode("Gray");					
	}
	if((color_types & 8) == 0)	{
		deleteNode("Color256");					
	}
	if((color_types & 16) == 0)	{
		deleteNode("ColorTrue");					
	}
	if(((color_types & 8) == 0)||((color_types & 16) == 0)||((color_types & 4) == 0))		{
		deleteNode("ColorHT");					
	}
	if(!((color_types & 8) == 0)||((color_types & 16) == 0)||((color_types & 4) == 0))		{
		deleteNode("NoColorHT");					
	}

}

function Information_Pane()
{
	var Params = new Array( totalParams() );
	parseParams( Params );
	var	color_types = Params[0];
	
	if(((color_types & 8) == 0)||((color_types & 16) == 0)||((color_types & 2) == 0)||((color_types & 4) == 0))		{
		deleteNode("ColorHT");					
	}
	
	var	feeder_types = Params[1];
	if ((feeder_types == 1) || (feeder_types == 2) || (feeder_types == 4) || (feeder_types == 8) || (feeder_types == 16))
	{		
		DocSourceSelect.removeNode(true);
	}
}


function resolution() {
	var Params = new Array( totalParams() );

	parseParams( Params );
	
	var	min_res = Params[2];
	var	max_res = Params[3];
	document.getElementById("MinRes").innerHTML = min_res + " ";
	document.getElementById("MaxRes").innerHTML = max_res;
}

function Scan_Image()
{
	var Params = new Array( totalParams() );
	parseParams( Params );

	var	feeder_types = Params[1];
	
	if((feeder_types & 1) == 0)	{
		deleteNode("ADF");					
	}
}

function Select_color_channel()
{
	var Params = new Array( totalParams() );
	parseParams( Params );


	var	color_types = Params[0];
	
	if(((color_types & 8) == 0)||((color_types & 16) == 0))		{
		deleteNode("ColorOn");					
		deleteNode("ColorOn1");					
		deleteNode("ColorOn2");					
		deleteNode("ColorOn3");					
		deleteNode("ColorOn4");
	}	
	
	
	if(((color_types & 8) == 0)||((color_types & 16) == 0)||((color_types & 4) == 0))		{
		deleteNode("ColorHT");					
		deleteNode("ColorHT1");									
	}
}

function Setting_Preferences()
{
	var Params = new Array( totalParams() );
	parseParams( Params );

	var	hide_network = (Params[6] == 0);
	
	if (hide_network)	{
		deleteNode("Network");					
	}
	
	var	hide_authentication = (Params[8] == 0);
	var	hide_startfromscanner = (Params[9] == 0);	
	
	if(hide_authentication) {
		deleteNode("Authentication");
	}	
	
	if(hide_startfromscanner) {
		deleteNode("StartFromScanner");
	}
}

function Preference_Authentication()
{
	var Params = new Array( totalParams() );
	parseParams( Params );

	var	show_authentication = (Params[8] != 0);

	if( show_authentication)	{
		deleteNode("AltDescription"); 
	}
	else	{
		deleteNode("MainDescription");
	}
}

function Preference_Options()
{
	var Params = new Array( totalParams() );
	parseParams( Params );

	var	hide_startfromscanner = (Params[9] == 0);
	
	if(hide_startfromscanner) {
		deleteNode("StartFromScanner");
	}
	
	var     hide_autostartfirstpage = (Params[10] == 0);
	
	if (hide_autostartfirstpage) { 
		deleteNode("AutoStartFirstPage");
	}
}

function Options_Panel()
{
	var Params = new Array( totalParams() );
	parseParams( Params );

	var	hide_color_match = ( Params[4] == 0 );
	var	hide_histogram = ( Params[5] == 0 );

	if( hide_color_match )	{
		deleteNode("ColorMatch1");
		deleteNode("ColorMatch2");
	}
	if(	hide_histogram ){
		deleteNode("Histogram1");
		deleteNode("Histogram2");
	}
}
