function SupProposeGame() {
	
	this.pwd = undefined;
	
	this.getProposedGame = function(url) {
		var B = Prototype.Browser;
		var tmp = new Dialog.Box('sg_prop_game', B.IE); //show overaly only if not IE
		
		//if ($('sg_msg_login') !== undefined) 		$('sg_msg_login').hide();
		if ($('sg_prop_content') !== undefined) 	$('sg_prop_content').hide();
		if ($('sg_prop_game') !== undefined) 		$('sg_prop_game').show();
		if ($('sg_loader') !== undefined) 			$('sg_loader').show();
		//make ajax request for open game
    	var myAjax = new Ajax.Request(url, {method: "get", onComplete: this.sg_c});
    	try {
    		pageTracker._trackPageview("/join_game_funnel/show_playnow.html");
    	} catch(err) {}
	}
	
	this.sg_c = function(res) {	
		$('sg_loader').hide();		
		$('sg_loader_symbol').hide();
		$('sg_prop_content').update(res.responseText).show();
	}
	
	this.respondToClick = function(event) {
	    var e = document.getElementById('sg_playnow_link_100');
	    if (e === undefined || e === null || e.value === undefined || e.value.length < 1) {
	    	return false;
	    }
	    else {
	  	    eval(e.value);
	    }
	}
	
	this.getRegScreen= function(url) {
		$('sg_prop_content').hide();
		$('sg_loader_symbol').show();		
		$('sg_loader').show();
		url = url + '&type=100';
		var myAajx = new Ajax.Request(url, {method: 'get', onComplete: this.sg_show});
	}
		
	this.sg_show= function(res) {
		//$('debug').update(res.responseText);
		evalScript(res.responseText);
		$('sg_loader').hide();
		$('sg_loader_symbol').hide();
		//$('sg_msg_login').show();
		$('sg_prop_content').update(res.responseText).show();
	}
	
	this.closePopup= function() {
		$('sg_prop_game').hide();
		//$('sg_msg_login').hide();
	}

	/**
	 *  Leere Dialogbox
	 */
	this.showEmpty = function() {
		new Dialog.Box('sg_prop_game');
		//$('sg_msg_login').hide();
		$('sg_prop_content').hide();
		$('sg_prop_game').show();
	}
	
	this.setMode = function(mode_p) {
		this.mode = mode_p;
	}
	
	this.setPwd = function(pwd_p) {
		this.pwd = pwd_p;
	}
	
	/**
	 * Password AJAX call for checking password and logging in user
	 */
	this.checkPw = function (id) {
		var url = 'index.php';
	    var command = 'eID=create&a=pw&';//TODO +lang;
		var pw = $('game_password_'+id).value;
		prop.setPwd(pw);
		command += '&pw='+pw;
		command += '&id='+id;
	    var myAjax = new Ajax.Request(url, {method: 'get', parameters: command, onComplete: this.pwC});
	}
	
	/**
	 * Callback for the password check. 
	 * JSON string with
	 * 		error --> display error
	 *   register --> correct password, user not logged in -> display registration screen
	 *    success --> logged in user, submit game registration data
	 */
	this.pwC = function (res) {
		//$('debug').update(res.responseText);
		//return;
		var r = eval('(' + res.responseText + ')');
		if (r.error !== undefined) {
		  $('sg_wrong_pw_'+r.error).appear({duration: 0.2}).highlight({ endcolor: '#d3cdbf' });
		  prop.setPwd(undefined);		  
		}
		else if (r.register !== undefined){ //not logged in, nu aber quick registeren / einloggen
			prop.showEmpty();
			prop.getRegScreen(r.register);
		} else if (r.success) {
			//TODO display forward link
			//alert (r.success);
			location.href = r.success;
		} else {
			//ignore error
		}

	}

}
/**
 * CJC
 * All that is included in the parameter "scripts" is going to be executed.
 * We use this function for the namechecker. We send in the parameter the declaration of
 * SupAjaxFactory callback and request objects so we can use them later.
 * to check the user name.
 * @param scripts 
 * @return
 */
function evalScript(scripts)
{	try
	{	if(scripts != '')	
		{	var script = "";
			scripts = scripts.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){
	       	                         if (scripts !== null) script += arguments[1] + '\n';
 	        	                        return '';});
			if(script) (window.execScript) ? window.execScript(script) : window.setTimeout(script, 0);
		}
		return false;
	}
	catch(e)
	{	errorrep("evalScript",e)
	}
}