/********************************************************
 * @author matias
 * Basic Page loading strategy
 ********************************************************/
function MainStrategy() {
	this.checkSession = true;
	this.hasHeaders = true;
	this.currentPage = 'index.php';
}

MainStrategy.prototype.setCheckSession = function (value) {
	this.checkSession = value;
};

MainStrategy.prototype.getCheckSession = function () {
	return this.checkSession;
};

MainStrategy.prototype.setHasHeaders = function (value) {
	this.hasHeaders = value;
};

MainStrategy.prototype.getHasHeaders = function () {
	return this.hasHeaders;
};

MainStrategy.prototype.setCurrentPage = function (name) {
	this.currentPage = name;
};

MainStrategy.prototype.getCurrentPage = function () {
	return this.currentPage;
};

MainStrategy.prototype.init = function () {
	detectSafari();
	initMouseWheel();

	try {
		// Loads search dropdown
		//var oMainDropdown = new Dropdown('mainmenu_qwhere', '0');
		//oMainDropdown.loadFromTableSync('XSquareSearchCollections');
	} catch (e) {
		alert("Search dropdown initialization error");
	}

	var member_id = null;
	var memberurl = oEnviroment.getURLVariable('squareurl');

	var entry_id = oEnviroment.getURLVariable('entry');
	var section = oEnviroment.getURLVariable('section');
	var area  = oEnviroment.getURLVariable('area');

	if (entry_id == null) entry_id = 0;
	if (section != null) activeSection[PARAM_INDEX_SECTION] = section;
	if (area != null) activeSection[PARAM_INDEX_AREA] = area;

	if (memberurl == '') memberurl = null;
	if (memberurl === null) {
		member_id = oEnviroment.getURLVariable('member');
	} else {
		var uHelper = new UserHelper();
		// Call service (X1-001) to load member
		member_id = uHelper.getMemberByUrl(memberurl);
	}

	if (member_id == '') member_id = null;
	if (member_id === null) {

		activeSection[PARAM_INDEX_SECTION] = 'main';
		/*
		if (activeSection[PARAM_INDEX_SECTION] == 'members') {
		}
		*/
		// Loads welcome section
		welcome_refresh();
		hasWelcome = true;
	} else {
		// Loads member profile
		member_click(member_id, oEnviroment.getURLVariable('tab'));
	}

	if (activeSection[PARAM_INDEX_SECTION] == 'mysquare') {
		activeSection[PARAM_INDEX_SECTION] = 'main';
	}

	activeSection[PARAM_INDEX_TAG] = '';
	activeSection[PARAM_INDEX_CATEGORY] = 'CONTENT';
	activeSection[PARAM_INDEX_ENTRY_TYPE] = 0;

	showMainMenu();
	$("screenContainer").style.display = '';
	if (member_id === null) {
		//the last function is defined in com/square/presentation/showcontent.js :
		updateMenus();
		showContent(null, null, null, entry_id);
	}

	if (oEnviroment.isUserLogged()) {
		//$('txt_createblog').innerHTML = 'Upload your videos and photos!';
		checkPendingRequests();
		SessionScheduler();
	}

	loadBanner(activeSection[PARAM_INDEX_SECTION], "bannerAd", '');

};
