﻿

function Stewdio(){}


function histoFaceRead()
{
	histoFaceReset( false );
	var histoText = document.getElementById( "input" ).value;
	document.getElementById( "downloadFalse" ).style.display = "none";
	document.getElementById( "downloadReady" ).style.display = "block";
	var parent = document.getElementById( "downloadImage" );
	var child  = document.createElement( "img" );
	child.setAttribute( "src", "http://www.stewdio.org/histoface/lib/tool.stegalevel.php?src=http%3A%2F%2Fwww.stewdio.org%2Fhistoface%2Flib%2Ftool.histoface.php%3Ftxt%3D"+ histoText );
//	child.setAttribute( "src", "http://www.stewdio.org/histoface/BETA/lib/tool.stegalevel.php?src=http%3A%2F%2Fwww.stewdio.org%2Fhistoface%2FBETA%2Flib%2Ftool.histoface.php%3Ftxt%3D"+ histoText );
	parent.appendChild( child );

	/*
	var histoText = document.getElementById( "input" ).value;
	var parent = document.getElementById( "levelsHistogram" );
	var child = document.createElement( "img" );
	child.setAttribute( "src", "lib/tool.histoface.php?txt="+ histoText );
	child.setAttribute( "id" , "histoFaceImage" );
	parent.appendChild( child );
	*/
};


function histoFaceReset( full )
{
	if( full )
	{
		document.getElementById( "input" ).value = "";
		document.getElementById( "downloadFalse" ).style.display = "block";
		document.getElementById( "downloadReady" ).style.display = "none";
	};
	var parent = document.getElementById( "downloadImage" );
	while( parent.hasChildNodes() )
	{
    	parent.removeChild( parent.lastChild );
	};
};


function reset()
{
	var display = document.getElementById( "display" );
	while( display.hasChildNodes() )
	{
		display.removeChild( display.lastChild );
	};
};


function update()
{
	reset();
	var display = document.getElementById( "display" );
	var input = document.getElementById( "input" ).value;
	for( var i = 0; i < input.length; i ++ )
	{
		var chr = input[i].toUpperCase();
		var ord = chr.charCodeAt();
		if( ( ord == 32 ) ||
			( ord >  47 && ord < 58 ) ||
			( ord >  64 && ord < 91 ) )
		{
			var img = document.createElement( "img" );
			img.setAttribute( "src", "med/HistoFace/0" + ord + ".png" );
			display.appendChild( img );
		};
	};
	var img = document.createElement( "img" );
	img.setAttribute( "src", "med/HistoFace/004.png" );
	img.style.marginLeft = "-1px";
	display.appendChild( img );
};


function look()
{
	inputNew = document.getElementById( "input" ).value;
	if( inputNew != inputOld )
	{
		inputOld = inputNew;
		update();
	};
};
var lookInterval = window.setInterval( "look()", 100 );
var inputOld = "";
var inputNew = "";



