/* (c) 2006-7 Ghost(TM) Inc. (http://G.ho.st/home) . All rights reserved.
G.ho.st licenses this software to you under the terms of the 
Common Public License Version 1.0 http://www.opensource.org/licenses/cpl.php 
*/

/**====================================================================================== **
/*  File: loginRegistrationJS.js   				    		                              **
/*  Creator: Rami khalyleh                                                                **
/*  Create date: 2009-02-24                                                               **
/*  Authors: Rami khalyleh,...                                                            **
/*  Contains some Js methods to embed the login/registration canvas                       **
/**====================================================================================== */

	// Getting the Parameters from the URL
	var language = "en";
	var email = "";
	var signiture = "";
	var referral = "";
	var referrerUrl = "";
	var promotionCode = "";
	var ghaction = null;
	var ghostId = "";
	var vcWinRef = null;
	var errCode = ""; // Maybe we have an error comes by redirecting to home page.
	var rememberedOpen = getRememberedOpenVCOptions(); // Getting the saved value of the open radio buttons in the login section.
	var isMouseOverDeleteCookie = false;
	
	var vcParams = document.location.search.substring(1);
	var viewedFileId = '';
	//Constants
	var GHOST_REMEMEBER_ID_COOKIE = 'ghostcookieRememberID_';
	var GHOST_REMEMEBER_PASSWORD_COOKIE = 'ghostcookieRememberPassword_';
	var GHOST_REMEMBER_PASSWORD_CLIKED_FLG = 'rememberedPasswordClickedTmp_';
	if (vcParams){
	
		vcParams = vcParams.split('&');
		
		for (var i = 0 ; i < vcParams.length ; i++){
			
			var param = vcParams[i]
			
			if (param){
				
				var paramNameAndValue = param.split('=');
				
				if (paramNameAndValue.length > 1){
					
					var paramName = paramNameAndValue[0];

					var paramValue = paramNameAndValue[1];
					
					if( paramName == 'action'){
						ghaction = paramValue;
					}else
					if( paramName == 'referral'){
						referral = paramValue;
					}else
					if( paramName == 'referrerUrl' ||  paramName == 'promotionURL' ||  paramName == 'promotionUrl' ||  paramName == 'referrerTag'){
						referrerUrl = paramValue;
					}else
					if( paramName == 'promotionCode'){
						promotionCode = paramValue;
					}else
					if( paramName == 'email'){
						email = paramValue;
					}else
					if( paramName == 'signature'){
						signiture = paramValue;
					}else
					if( paramName == 'language'){
						language = paramValue;
					}else
					if( paramName == 'code'){
						ghaction = 'loginWithError';
						errCode = paramValue;
					}else
					if( paramName == 'ghostId'){
						ghostId = paramValue;
					}

				}else{
					//Direct login
 					doDirectLogin(paramNameAndValue[0]);
				}
			}		
		}
	}
		
	// Do loading the login canvas, this method called from onload event of the page that contains the login section which is the main.jsp page.
	function doLoadLoginRegSection(){
		if (ghaction){
			doOpenLoginRegSection(ghaction);
		}
		lzCanvasRuntimeVersion = 8 * 1;
	
		if (lzCanvasRuntimeVersion == 6) {
			lzCanvasRuntimeVersion = 6.65;
		}
		var wmode = 'window';
		var rememberedPsdClicked = getCookie(GHOST_REMEMBER_PASSWORD_CLIKED_FLG + ghostId);
		lz.embed.swf({url: getCDNURL(xmlDoc, callingURL) + '/lps/workspace/VC/client/homePageLoginNReg/GhLoginRegCanvas.lzx?lzt=swf&lzr=swf9&VCURL=' + VCURL + '&revision=' + server_revision + '&browserName=' + browserName + '&ghaction=' + ghaction +'&referral=' + referral + '&referrerUrl=' + referrerUrl + '&promotionCode=' + promotionCode + '&email=' +email+ '&signiture=' + signiture + '&language=' + language + '&rememberedOpen=' + rememberedOpen + '&errCode=' + errCode + '&ghostId=' + ghostId  + '&rPsdClicked=' + rememberedPsdClicked, bgcolor: '#000000', width: '100%', height: '100%', id: 'lzLoginRegApp', accessible: 'false' , wmode : wmode, appenddivid: 'tdLoginReg'}, lzCanvasRuntimeVersion);
		lz.embed.lzLoginRegApp.onload = function loaded() {
			//Turn off the waiting indicator.
			document.getElementById('tdLoginRegWaitingInd').style.display = 'none';
			
			// After 3 second, start loading the second canvas which is the desktop canvas.
			setTimeout("doCacheDesktopCanvas()", 3000);// After 3 sec, start download the desktop canvas to caching it in the browser.
		}

		// Getting the remembered user Ids and password 	
		doAddTheRememberCookies();
		
		getSSLCertificate();
	}
	// Returning the ghaction which is the action that we need to execute.
	function getGhaction(){return ghaction;}

	// Returning the ghostId.
	function getGhostId(){return ghostId;}
	
	// This method is responsible to open the login section according the required section (login/registration)
	function doOpenLoginRegSection(sec){
		if (sec) ghaction = sec;
		var logRegTd = document.getElementById('htmlLoginRegSec');
		
		if (!cookieEnabled) return; // Checking the cookie if its enabled, this variable is 
		if (logRegTd){
			if (lz.embed.lzLoginRegApp && lz.embed.lzLoginRegApp.loaded && ghaction){
				logRegTd.style.display = 'none';
				document.getElementById('tdLoginRegWaitingInd').style.display = 'none';
				document.getElementById('tdLoginReg').style.visibility = 'visible';
				if (ghaction == 'registration' || ghaction == 'invitation'){
					lz.embed.lzLoginRegApp.callMethod('doOpenRegistrationForm(\'' + ghaction + '\')');
				}else
				if (ghaction == 'login'){
					lz.embed.lzLoginRegApp.callMethod('doOpenLoginForm()');
				}else
				if (ghaction == 'loginWithRememberId' && ghostId){
					lz.embed.lzLoginRegApp.callMethod('doSetUserId(\'' + ghostId + '\')');
				}else
				if (ghaction == 'loginWithError'){
					doShowLoginErrorMessage(ghostId, errCode);
				}
			}else
			if (ghaction){
				logRegTd.style.display = 'none';
				document.getElementById('tdLoginRegWaitingInd').style.display = '';
			}
		}
		setFlashFocus();
	}

	// Closing teh login section by hiding it and then show the html section.
	function doCloseLoginRegSection(){
		document.getElementById('htmlLoginRegSec').style.display = '';
	}
	
	// Generating the remembered cookies on the main page
	function doAddTheRememberCookies(){
		var rUserCookie = getRememberUserCookies(3); // Getting the latest 3 remembered cookies. 
		var cookiesTbl = '<div id="rememberUsersDiv" style="overflow: hidden;height: 83px;width: 100%;"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>';
		for (var i = 0 ; i < rUserCookie.length ; i++){
			var userCookie = rUserCookie[i];
			var userId = userCookie.substring(userCookie.indexOf('<user>') + 6 , userCookie.indexOf('</user>'));
			var type = getRememberedCookieType(userCookie);
			
			cookiesTbl += '<td align="center" width="'+(100/rUserCookie.length)+'%">' + getRememberedCookieBlock(type, userId) + '</td>'
		}
  		cookiesTbl += '</tr></table></div>';
  		document.getElementById('rememberedUserCookies').innerHTML = cookiesTbl;
	}

	// Getting the remembered users type, if its remember userId or remember password.  
	function getRememberedCookieType(userCookie){
		return userCookie.substring(userCookie.indexOf('<type>') + 6 , userCookie.indexOf('</type>'))
	}
	
	// Implementing the HTML code of the remembered cookies, including the user avatar and his user id.(to be embeded in and HTML page).
	function getRememberedCookieBlock(type, userId){
		var bgImg = '/icons/rem_user_up.png';
		var overImg = '/icons/rem_user_over.png';
		var upImg = '/icons/rem_user_up.png';
		var downImg = '/icons/rem_user_down.png';
		
		if ( isIE && getBrowserVersion() <= 6 ){
			bgImg = '/icons/rem_user_up.gif';
			overImg = '/icons/rem_user_over.gif';
			upImg = '/icons/rem_user_up.gif';
			downImg = '/icons/rem_user_down.gif';
		}
		
	return '<table width="80" height="80" border="0" cellspacing="0" cellpadding="0"> ' +
				'<tr>' +
				'	<td height="55" align="center">' +
				'		<object style="z-index:1px" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="55" height="55" id="avatar" align="middle">' +
				'			<param name="allowScriptAccess" value="sameDomain" />' +
				'			<param name="allowFullScreen" value="false" />' +
				'			<param name="movie" value="' + VCURL + '/vcweb/users/avatar?username=' + userId.toLowerCase() + '"/>' +
				'			<param name="quality" value="high" />' +
				'			<param name="wmode" value="transparent" />' +
				'			<param name="bgcolor" value="#ffffff" />' +
				'			<embed src="' + VCURL + '/vcweb/users/avatar?username=' + userId.toLowerCase() + '" quality="high" wmode="transparent" bgcolor="#ffffff" width="55" height="55" name="avatar" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
				'		</object>' +
				'	</td>' +
				'</tr>' +
				'<tr>' +
				'	<td class="RedirectPagesText" align="center"><a href="JavaScript:void(0);" onClick="doLogin(\'' + type + '\',\'' + userId + '\', \'_self\')" style="cursor:hand;" class="RedirectPagesText">' + userId + '</a></td>' +
				'</tr>' +
			'</table>' +
			'<div id="avatarCover' + userId + '" style="background-image: url(\'' + bgImg + '\');z-index:10px;position: relative;height: 80px;width: 80px;top: -80px;left: 0px;right:0px;bottom:0px;cursor: pointer" onclick="doLogin(\'' + type + '\',\'' + userId + '\', \'' + (rememberedOpen == 'true'? '_top' : '_self') + '\')" onmouseover="doChangeElRes(this, \'' + overImg + '\',\'over\',\'' + userId + '\');" onmouseout="doChangeElRes(this, \'' + upImg + '\',\'out\',\'' + userId + '\');" onmousedown="doChangeElRes(this, \'' + downImg + '\',\'down\',\'' + userId + '\');" onmouseup="doChangeElRes(this,\'' + overImg + '\',\'up\',\'' + userId + '\');"></div>' +
			'<img id="cookieDeleteIcn' + userId + '" src="/icons/remove_button_over.png" style="visibility:hidden;z-index: 20px;position: relative; height: 12px; width: 12px;left:45px;top:-160; cursor: pointer" onclick="doDeleteRememberedCookie(\'' + type + '\',\'' + userId + '\')" onmouseover="doMouseOverCookieDeleteIcon(this,\'over\',\'' + userId + '\');" onmouseout="doMouseOverCookieDeleteIcon(this,\'out\',\'' + userId + '\');"/>'; 
	}
	
	function doLogin(type, userId, position){
		if (type == GHOST_REMEMEBER_PASSWORD_COOKIE){
			// Adding a temporary flag to know in the vc.html that the direct login comes from clicks on remembered password cookie.   
			addCookie(GHOST_REMEMBER_PASSWORD_CLIKED_FLG + userId, userId, 300000); // Will be deleted after 5 minute.
			if (position == '_self'){
				var desktopRef = window.open('/vc.html?' + userId + getAdditionalParametersToVC(), position, null, true);
				return true;
			}else{
				var desktopPopupRef = window.open('/vc.html?' + userId + '&isPopup=true' + getAdditionalParametersToVC(), '', getScreenMaxmSize(), true);
				if (desktopPopupRef) return true;
				return false;
			}	
		}else
		if (type == GHOST_REMEMEBER_ID_COOKIE){
			ghostId = userId;
			ghaction = 'loginWithRememberId';
			doOpenLoginRegSection('loginWithRememberId');
		}
	}
	
	function doClosePopup(userId){
		vcWinRef.close();
	}
	
	function setFlashFocus(){
		var logCan = document.getElementById("lzLoginRegApp");
		if (logCan){
			logCan.focus();
		}
	}
	
	// Openning the G.ho.st Lite
	function doOpenGhostLite(position){
		if (position == '_self'){
			var desktopRef = window.open(VCURL + '/m', position, null, true);
		}else{
			var desktopPopupRef = window.open(VCURL + '/m', '', getScreenMaxSize(), true);
		}
	}
	
	function doOpenDesktopCanvas(userId, position){
		if (position == '_self'){
			var desktopRef = window.open(VCURL + '/vc.html?ghostId=' + userId + getAdditionalParametersToVC(), position, null, true);
		}else{
			vcWinRef = window.open(VCURL + '/vc.html?ghostId=' + userId + '&isPopup=true' +  getAdditionalParametersToVC(), '', getScreenMaxSize(), true);
		}
	return (!vcWinRef ? false : true); // In a popup case if there is a popup blocker
	}
	
	// Needed parameters that we need to pass them to the vc
	function getAdditionalParametersToVC(){
		var pars = '';
		if (referral) pars += '&referral=' + referral;	
		
		if (referrerUrl) pars += '&referrerUrl=' + referrerUrl;	
		
		if (promotionCode) pars += '&promotionCode=' + promotionCode;	

		if (!(language.toLowerCase() =='en' || language.toLowerCase() =='english') ) pars += '&language=' + language;  // Passing the language if not the default(english) as a parameter to the desktop canvas 
		
		if (viewedFileId && viewedFileId != '') pars += '&fileId=' + viewedFileId;
	return pars;	
	}
	
	// Called from laszlo after got a valid response from the server for the authentication request.
	function doPopupLogin(userId){
		//loggedInPopupsArr.push(userId);
		if (vcWinRef){
			vcWinRef.doLogin(userId);			
		}
	}
	
	function getSSLCertificate(){
		var onepixImg = document.getElementById("onepixImg");
		onepixImg.src = getSecureURL(xmlDoc, callingURL) + "/onepix.gif";
	}
	
	// Getting the remembered user cookies, by passing how many cookies we need to retrieve.
	function getRememberUserCookies(latestNum){
		var cookiesArrays= document.cookie.split(';');
		var allCookies = new Array();
		var result = new Array();

		for(var i = 0 ; i < cookiesArrays.length ; i++){
			if(cookiesArrays[i].indexOf("ghostcookieRemember") != -1){
				allCookies.push(cookiesArrays[i]);
			}
		}
		
		allCookies.sort(sortAccordingDate);
		
		if (latestNum > allCookies.length) latestNum = allCookies.length;
		
		for (var j = 0 ; j < latestNum ; j++){
			result.push(allCookies[j])
		}
	return result;
	}
	// Sorting the cookies according they time.
	function sortAccordingDate(a, b){
		var datea = doFormatDate(a.substring(a.indexOf('<time>') + 6 , a.indexOf('</time>')));
		var dateb = doFormatDate(b.substring(b.indexOf('<time>') + 6 , b.indexOf('</time>')));
		if (isIE){
			return (dateb < datea ? -1 : 1);
		}
	return (dateb > datea ? -1 : 1);
	}
	
	// Formatting the cookies date, to do the sorting for it.
	function doFormatDate(strFullDate){
		if (isIE){ // Workaround solution for formatting th cookies date before compare they dates
			var strDatePArr = strFullDate.split('T');
			var strDate = strDatePArr[0].replace('-','/');
			var strTime = strDatePArr[1].split('.')[0];
			var timeArr = strTime.split(':'); 
			var cDate = new Date(strDate);
			cDate.setHours(timeArr[0])
			cDate.setMinutes(timeArr[1])
			cDate.setSeconds(timeArr[2])
			return cDate;
		}else{
			return new Date(strFullDate);		
		}
	}
	
	// To adding new remember user cookie.
	function doAddRememberIDCookie(cookieName, cookieValue, expInMills, userId){
		//try to delete remember password cookie if its exist. if there is a remember id then it will do an override.
		if (cookieName.indexOf(GHOST_REMEMEBER_ID_COOKIE) != -1 && getCookie(GHOST_REMEMEBER_PASSWORD_COOKIE + userId)){
			lz.embed.lzLoginRegApp.callMethod('lgn.cookieManager.deleteCookie(\'' + userId + '\')');
		}
		addCookie(cookieName, cookieValue, expInMills , null, null);
	}
	
	function addRememberedIdCookie(userId){
		var cookieName = "ghostcookieRememberID_" + userId.toLowerCase();
		var cookieValue = "<ghostCookie userId='" + userId + "'><type>ghostcookieRememberID_</type><user>" + userId + "</user><time>" + (new Date()) + "</time></ghostCookie>";
		addCookie(cookieName, cookieValue, 1000000000000 , null, null);
	}
	

	// Direct login
	function doDirectLogin(userId){
		ghostId = userId;
		//Getting the user settings.(open in the same window OR in new window)
		var userCookieType = doGetUserRememberedCookie(userId);
		if (userCookieType){
			var result = doLogin(userCookieType, userId, (rememberedOpen == 'true'? '_top' : '_self'));
			// Checking if we success to open the window.
			if (!result && userCookieType != '_self'){
				doLogin(userCookieType, userId, '_self');
			}
		}else{
			// Not remembered, we opening the login with the userId
			doLogin(GHOST_REMEMEBER_ID_COOKIE, userId, '');
		}
	}
	
	// Getting the type of user remember. (Password/userID) 
	function doGetUserRememberedCookie(userId){
		if (getCookie(GHOST_REMEMEBER_PASSWORD_COOKIE + userId)){
			return GHOST_REMEMEBER_PASSWORD_COOKIE;
		}else
		if (getCookie(GHOST_REMEMEBER_ID_COOKIE + userId)){
			return GHOST_REMEMEBER_ID_COOKIE;
		}else{
			return null;
		}
	}

	// Its in common.js, but we used this in the direct login, so, the common.js still not loaded
	function getCookie (cookieName) {
	  var cookie = document.cookie.match ('(^|;) ?' + cookieName + '=([^;]*)(;|$)');
	  if (cookie){
	    return ( unescape ( cookie[2] ) );
	  } else {
	    return null;
	  }
	}
	// Deleting the rememebered user Id.
	function doHandleCreateRmrPswdCookie(userId){
		// Deleting the remember user Id if exist.
		doDeleteCookie(GHOST_REMEMEBER_ID_COOKIE + userId.toLowerCase());
		// Adding a cookie as a flag to indicate that we creating a rememeber password cookie, this will removed once the desktop loaded.
		if (rememberedOpen == 'false'){ //In thesame window		
			addCookie('rememberPasswordTmp_' + userId, userId, 1000000000000);
		}
	}
	// Keep the user choice, if he select to open the VC in new/same window.
	function doSetUserOption(userOption){
		var cookieName = "ghostRememberedUserOpenedOption";
		var str = '<ghostOpenOption>' + userOption + '</ghostOpenOption>';
		rememberedOpen = userOption;
		// Deleting the remember user Id if exist.
		deleteCookie(cookieName);
		// Adding a cookie as a flag to indicate that we creating a rememeber password cookie, this will removed once the desktop loaded.
		addCookie(cookieName , str, 1000000000000);
	}
	// Deleting the cookies
	function doDeleteCookie(cookieName){
		if (getCookie(cookieName)){
			addCookie(cookieName, '', -10 , null, null);
			deleteCookie(cookieName); // for ensure that the cookie is deleted. TODO: Need checking to know why this method is not working.
		}
	}
	
	// Embeding the desktop canvas, as caching, in this case we will benefit from the browser caching if the browser has completed download the desktop canvas, So, we open the desktop canvas, the browser will get it from the browser cache.
	function doCacheDesktopCanvas(){
		if (document.getElementById('desktopCanvasCache')){
			lz.embed.swf({url: getCDNURL(xmlDoc, callingURL) + '/lps/workspace/VC/client/welcomei.lzx?revision='+server_revision+'&debug=false&version=' + version + '&browserName=' + browserName +'&VCURL=' + VCURL + '&isTesting=false&referral=' + referral + '&isWin='+isWin + '&language=' + language + '&isNormalLogin=true&lzt=swf&lzr=swf9', bgcolor: '#ffffff', width: '0', height: '0', id: 'lzDesktopApp', accessible: 'false' , wmode : 'window', appenddivid: 'desktopCanvasCache'}, 9);			
		}
	}
	
	//Getting the user setting. (Open in the same window OR in new window).
	function getRememberedOpenVCOptions(){
		var rememberedCk = getCookie('ghostRememberedUserOpenedOption');
		if (rememberedCk){
			return rememberedCk.substring('<ghostOpenOption>'.length, rememberedCk.indexOf('</ghostOpenOption>') );
		}
	return '';			
	}
	// For the animation of the user remembered cookies(Avatars). 
	function doChangeElRes(el, strUrl, mEffect, userId){
		el.style.background = "url('" + strUrl + "')";
		if (mEffect == 'over'){
			document.getElementById('cookieDeleteIcn' + userId).style.visibility = "visible"; 
		}else
		if (mEffect == 'out'){
			setTimeout("doHideCookieDeleteIcon('" + userId + "')", 200); 
		}
	}
	
	// To hide the remembered user delete button
	function doHideCookieDeleteIcon(userId){
		if (!isMouseOverDeleteCookie){
			document.getElementById('cookieDeleteIcn' + userId).style.visibility = "hidden";
		}
	}
	
	// The mouse over the remembered delete cookies 
	function doMouseOverCookieDeleteIcon(el, mEffect, userId){
		isMouseOverDeleteCookie = false;
		if (mEffect == 'over'){
			isMouseOverDeleteCookie = true;
		}else
		if (mEffect == 'out'){
			doHideCookieDeleteIcon(userId);
		}
	}
	
	// Viewing the error message in the login section
	function doShowLoginErrorMessage(userId, msg){
		var isRemClicked = getCookie(GHOST_REMEMBER_PASSWORD_CLIKED_FLG + userId); 
		doOpenLoginRegSection('login');
		lz.embed.lzLoginRegApp.callMethod('lgn.showLoginErrorMessage(\'' + userId + '\',\'' + msg + '\',\'' + isRemClicked + '\')');
	}
	
	//Deleting the remember user cookies.
	function doDeleteRememberedCookie(type, userId){
		isMouseOverDeleteCookie = false;
		if (type == GHOST_REMEMEBER_ID_COOKIE){ // Delete the remember user Id, just call the addCookie method with previous date.
			doDeleteCookie(GHOST_REMEMEBER_ID_COOKIE + userId.toLowerCase());
			doRefreshRemUsersCookies();
		}else
		if (type == GHOST_REMEMEBER_PASSWORD_COOKIE){
			lz.embed.lzLoginRegApp.callMethod('lgn.cookieManager.deleteCookie(\'' + userId + '\')');
		}
		doHideCookieDeleteIcon(userId); // White requesting in delete the remember password case
	}
	
	// Refreshing the remembered cookies that are appeared on the home page.
	function doRefreshRemUsersCookies(){
		document.getElementById('rememberedUserCookies').removeChild(document.getElementById('rememberUsersDiv'));
		doAddTheRememberCookies();
	}
	function doDeleteRememberedPassword(userId){
		doDeleteCookie(GHOST_REMEMEBER_PASSWORD_COOKIE + userId.toLowerCase());
		setTimeout("doRefreshRemUsersCookies()", 1000); // TODO: workaround because sometimes the response from server to delete the rem. cookies takes some times to do. 
	}
	
	// NOTE: This method is aleady implemented in the homePageUtils.js, BUT we need it here for the direct login, because in direct login the homePageUtils.js file is still not loaded, because we checking the direct login before the home page loaded.
	function getScreenMaxmSize() {
		var xMax;
		var yMax;
	
		if (typeof(screen.availWidth) == 'number') {
			xMax = screen.availWidth;
			yMax = screen.availHeight;
		} else if (typeof(screen.width) == 'number') {
			xMax = screen.width;
			yMax = screen.height;
		} else if (typeof(window.outerWidth) == 'number') {
			xMax = window.outerWidth;
			yMax = window.outerHeight;
		} else if (document.documentElement
				&& (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
			xMax = document.documentElement.clientWidth;
			yMax = document.documentElement.clientHeight;
		} else if (document.body
				&& (document.body.clientWidth || document.body.clientHeight)) {
			xMax = document.body.clientWidth;
			yMax = document.body.clientHeight;
		} else {
			xMax = 640;
			yMax = 480;
		}
		var isMac = (navigator.appVersion.indexOf("Mac") != -1) ? true : false;
		if (isMac)
			yMax = yMax - 20;
	
		return "minimizable=no, width="
				+ xMax
				+ ", height="
				+ yMax
				+ ", resizable=no,"
				+ " fullscreen=yes, titlebar=no, directories=no, channelmode=no, scrollbars=no,"
				+ " status=no, toolbar=no, menubar=no, location=no";
	}
	
	// Send a google track. (Goals)
	function doGoogleGoalTrack(goal,step){
		pageTracker._trackPageview('/' + goal + '/' + step);
	}
	
	//Getting where the login registration section is embeded. ex. in the home page, in the splash page,... 
	function getLoginRegLocation(){return pageName;}
	
	function doDeleteRememberedPsdFlag(userId){
		addCookie(GHOST_REMEMBER_PASSWORD_CLIKED_FLG + userId, '', -10 , null, null);
	}