<!-- Dynamic ASCII, Hex and Unicode Converter (Javascript) is Copyright 2009 My-i-p.com -->

function sync1a() {
document.form_hexc.hex.scrollTop = document.form_hexc.ascii.scrollTop;}
function sync1b() {
document.form_hexc.unicode.scrollTop = document.form_hexc.ascii.scrollTop;}
function sync2a() {
document.form_hexc.ascii.scrollTop = document.form_hexc.hex.scrollTop;}
function sync2b() {
document.form_hexc.unicode.scrollTop = document.form_hexc.hex.scrollTop;}
function sync3a() {
document.form_hexc.ascii.scrollTop = document.form_hexc.unicode.scrollTop;}
function sync3b() {
document.form_hexc.hex.scrollTop = document.form_hexc.unicode.scrollTop;}

function cleartext(){
document.form_hexc.ascii.value = '';
document.form_hexc.hex.value = '';
document.form_hexc.unicode.value = '';}

function expand(){
var hgt = document.form_hexc.size.rows;
hgt = hgt + 5;
document.form_hexc.size.rows = hgt;}
function contract(){
var hgt = document.form_hexc.size.rows;
hgt = hgt - 5;
document.form_hexc.size.rows = hgt;}

function box_size(){
if (document.form_hexc.new_line.checked == true) document.form_hexc.hex.rows = '6';
if (document.form_hexc.new_line.checked == false) document.form_hexc.hex.rows = '1';
if (document.form_hexc.new_line.checked == true) document.form_hexc.unicode.rows = '6';
if (document.form_hexc.new_line.checked == false) document.form_hexc.unicode.rows = '1';}

function ascii_box(){
if (document.form_hexc.new_line.checked == false){
ascii_input = document.form_hexc.ascii.value;
ascii_input = ascii_input.replace(/\r/g,'');
var hex_out = new Array();
var uni_out = new Array();
for (var x = 0; x < ascii_input.length; x++){
var car = ascii_input.charCodeAt(x); hex_out[x] = '%' + car.toString(16); uni_out[x] = '&#' + car + ';';}
hex_out = hex_out.join('');
uni_out = uni_out.join('');
document.form_hexc.hex.value = hex_out;
document.form_hexc.unicode.value = uni_out;}
if (document.form_hexc.new_line.checked == true){
ascii_input = document.form_hexc.ascii.value;
ascii_input = ascii_input.replace(/\r/g,'');
ascii_input = ascii_input.split('\n');
var hex_out = new Array();
var uni_out = new Array();
for (var s = 0; s < ascii_input.length; s++){
var hex_cars = new Array();
var uni_cars = new Array();
for (var x = 0; x < ascii_input[s].length; x++){
var car = ascii_input[s].charCodeAt(x); hex_cars[x] = '%' + car.toString(16); uni_cars[x] = '&#' + car + ';';}
hex_cars = hex_cars.join(''); hex_out[s] = hex_cars; uni_cars = uni_cars.join(''); uni_out[s] = uni_cars;}
hex_out = hex_out.join('\n');
uni_out = uni_out.join('\n');
document.form_hexc.hex.value  = hex_out;
document.form_hexc.unicode.value  = uni_out;}}

function hex_box(){
if (document.form_hexc.new_line.checked == false){
hex_input = document.form_hexc.hex.value.toLowerCase().replace(/\r/g,'').replace(/\n/g,'');
ascii_out = unescape(hex_input);
uni_out = new Array();
for (var x = 0; x < ascii_out.length; x++){
var car = ascii_out.charCodeAt(x); uni_out[x] = '&#' + car + ';';}
uni_out = uni_out.join('');
document.form_hexc.ascii.value = ascii_out.replace(/%a/g,'\n');
document.form_hexc.unicode.value = uni_out.replace(/&#37;&#97;/g,'&#10;');}
if (document.form_hexc.new_line.checked == true){
hex_input = document.form_hexc.hex.value.replace(/\r/g,'').replace(/%a/g,'\n');
ascii_out = unescape(hex_input);
ascii_out2 = ascii_out.split('\n');
uni_out = new Array();
for (var s = 0; s < ascii_out2.length; s++){
var uni_cars = new Array();
ascii_out3 = ascii_out2[s];
ascii_out3 = ascii_out3;
for (var x = 0; x < ascii_out3.length; x++){
var car = ascii_out3.charCodeAt(x); uni_cars[x] = '&#' + car + ';';}
uni_cars = uni_cars.join(''); uni_out[s] = uni_cars;}
uni_out = uni_out.join('\n');
document.form_hexc.ascii.value = ascii_out;
document.form_hexc.unicode.value = uni_out}}

function unicode_box(){
if (document.form_hexc.new_line.checked == false){
uni_input = document.form_hexc.unicode.value.replace(/\r/g,'').replace(/\n/g,'');
uni_input = uni_input.split('&#').join('');
uni_input = uni_input.split(';');
var ascii_out = new Array();
var hex_out = new Array();
for (var x = 0; x < uni_input.length-1; x++){
var parsed = parseInt(uni_input[x]); ascii_out[x] = String.fromCharCode(parsed); hex_out[x] = '%' + parsed.toString(16);}
ascii_out = ascii_out.join('');
hex_out = hex_out.join('');
document.form_hexc.ascii.value = ascii_out;
document.form_hexc.hex.value = hex_out;}
if (document.form_hexc.new_line.checked == true){
uni_input = document.form_hexc.unicode.value;
uni_input = uni_input.split('&#').join('').replace(/\r/g,'');
uni_input = uni_input.split('\n');
var parsed_out = new Array();
var parsed_hex_out = new Array();
for (var s = 0; s < uni_input.length; s++){
var uni_input3 = new Array();
var hex_out = new Array();
uni_input2 = uni_input[s].split(';');
for (var x = 0; x < uni_input2.length-1; x++){
var parsed = parseInt(uni_input2[x]); uni_input3[x] = String.fromCharCode(parsed); hex_out[x] = '%' + parsed.toString(16);}
ascii_out = uni_input3.join('');  parsed_out[s] = ascii_out; parsed_hex_out[s] = hex_out.join('');}
ascii_out2 = parsed_out.join('\n');
hex_out2 = parsed_hex_out.join('\n');
document.form_hexc.ascii.value = ascii_out2;
document.form_hexc.hex.value = hex_out2;}}

function SelectAll(id) {
document.getElementById(id).focus();
document.getElementById(id).select();}
