function encrypt(data) {
	var result = "";
	for(i = 0; i < data.length; i++) {
		var hexCode = data.charCodeAt(i).toString(16);
		if (hexCode.length == 1) {
			hexCode = "0" + hexCode;
		}
		result += hexCode;
	}
	return result;
}

function getClientWindow(str_windowURL) {

	var isReferrerValid = (typeof referrer != "undefined") && referrer;
	if(isReferrerValid) {
		str_windowURL += "&y=" + referrer;
	}

	var int_windowWidth = 1015;
	var int_windowHeight = 550;
	var int_windowLeft = (screen.width - int_windowWidth) / 2;
	var int_windowTop = (screen.height - int_windowHeight) / 2;
	var str_windowName = location.hostname.replace(/\./g,"_");
	str_windowName = str_windowName.replace(/-/g,"_");
	var str_windowProperties = 'height=' + int_windowHeight + ', width=' + int_windowWidth + ', top=' + int_windowTop + ', left=' + int_windowLeft + ', scrollbars=0, resizable=0, menubar=0, toolbar=0, location=0, statusbar=0, fullscreen=0';
	var obj_window = window.open(str_windowURL, str_windowName, str_windowProperties);
	if (window.focus && obj_window!=null) {
		obj_window.focus();
	}
	return obj_window;
}

function openClient(str_windowURL) {
	getClientWindow(str_windowURL);
}

function openMiniSkinClient(hostUrl, pdcUid, param) {
	if (!hostUrl) {
		hostUrl = location.hostname;
	}
	var url = "http://lobby.gioconlineitalia.it/connector/client/lobby/client.aspx?x=" + encrypt(hostUrl);
	if (pdcUid) {
		url += "&y=" + encrypt(pdcUid);
	}
	if (param) {
		url += "&p=" + param;
	}
	
	openClient(url);
}












