
function g_DecodeBase64(sInputRaw)
{

	var sOutput = "";
	var sBase64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

	// Strip invalid chars
	var sInput = sInputRaw.replace(/[^A-Za-z0-9\+\/\=]/g, "");

	var iInputLength = sInput.length;

	// We need at least 4 characters and the string must be in parts of 4
	if ( iInputLength >= 4 && iInputLength % 4 == 0 )
	{
		var i = 0;

		var c1, c2, c3 = "";
		var e1, e2, e3, e4 = "";

		do
		{
			e1 = sBase64Chars.indexOf(sInput.charAt(i++));
			e2 = sBase64Chars.indexOf(sInput.charAt(i++));
			e3 = sBase64Chars.indexOf(sInput.charAt(i++));
			e4 = sBase64Chars.indexOf(sInput.charAt(i++));

			c1 = ( e1 << 2 ) | ( e2 >> 4 );
			c2 = ( ( e2 & 15 ) << 4 ) | ( e3 >> 2 );
			c3 = ( ( e3 & 3 ) << 6 ) | e4;

			sOutput = sOutput + String.fromCharCode(c1);

			if ( e3 != 64 ) sOutput = sOutput + String.fromCharCode(c2);
			if ( e4 != 64 ) sOutput = sOutput + String.fromCharCode(c3);

		} while ( i < iInputLength );
	}

	return sOutput;
}


function g_EmProtection(sInput64, sStyle)
{

	var sOutput = "";
	var sEm = g_DecodeBase64(sInput64);

	sOutput += "<" + "a" + " h" + "ref=\"";
	sOutput += "m" + "ail" + "to" + ":";
	sOutput += sEm;
	sOutput += "\"";

	if ( sStyle.length > 0 )
		sOutput += " style=\"" + sStyle + "\"";

	sOutput += ">" + sEm;
	sOutput += "</" + "a>";

	return sOutput;
}

function g_openWindow(sURL, sName, iWidth, iHeight, sResizable, sStatus)
{

	var sOptions = '';
	sOptions += 'toolbar=0,location=0,directories=0,menubar=0';
	sOptions += ',status=' + sStatus + ',scrollbars=' + sResizable +',resizable='  + sResizable;
	sOptions += ',width=' + iWidth + ',height=' + iHeight;

	var objWin = window.open(sURL, sName, sOptions);
	if (objWin != null)
	  {
		objWin.moveTo((screen.width-iWidth)/2,(screen.height-iHeight)/2);
		objWin.focus();
	  }
}
