///////////////////////////////////////////////
//
//  Copyright 2012 David Gross
//  Not for distribution of modification of any kind without explicit written permission!
//
//  Functions to ease C++/JS information exchanging
//




function unpack32(s,os){
	return ((s.charCodeAt(os+0))<<24)|((s.charCodeAt(os+1))<<16)|((s.charCodeAt(os+2))<<8 )|((s.charCodeAt(os+3))<<0 );
}

function unpack16(s,os){
	return ((s.charCodeAt(os+0))<<8 )|((s.charCodeAt(os+1))<<0 );
}
function unpack8(s,os){
	return (s.charCodeAt(os)+0);
}
function unpack16b(s,os){
	return ((s.charCodeAt(os+1))<<8 )|((s.charCodeAt(os+0))<<0 );
}

function pack32(v){
	return String.fromCharCode(((v>>24)&255))+String.fromCharCode(((v>>16)&255))+String.fromCharCode(((v>>8 )&255))+String.fromCharCode(((v>>0 )&255));
}
//var bsix=window.atob("AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==");

function pack16(vv){
	return String.fromCharCode((vv>>8)&255)+String.fromCharCode(vv&255);
}
function packmessage(m,s){
	if(s.length){
		s=window.btoa(s);
	}
	return pack16(m)+s;
}