﻿if (!Array.prototype.map) {
	Array.prototype.map = function(fun, thisp) {
		/// <summary>
		///	Creates a new array with the results of calling a provided function on every element in this array.
		/// </summary>
		/// <param name="fun" type="Function" optional="false">Function that produces an element of the new Array from an element of the current one.</param>
		/// <param name="thisp" optional="true">Object to use as this when executing fun.</param>
		var len = this.length;
		if (typeof fun != "function")
			throw new TypeError();

		var res = new Array(len);
		var thisp = arguments[1];
		for (var i = 0; i < len; i++)
			if (i in this)
			res[i] = fun.call(thisp, this[i], i, this);

		return res;
	};
}

if (!window.console) {
	window.console = function() { };

	window.console.log = function() {
		var value = "";
		for (var i = 0; i < arguments.length; i++) {
			value += arguments[0].toString()

			if (i != (arguments.length - 1))
				value += " ## ";
		}
		//alert(value);
	};

	window.console.info = function() {
		var value = "";
		for (var i = 0; i < arguments.length; i++) {
			value += arguments[0].toString()

			if (i != (arguments.length - 1))
				value += " ## ";
		}
		alert(value);
	};

	window.console.warn = function() {
		var value = "";
		for (var i = 0; i < arguments.length; i++) {
			value += arguments[0].toString()

			if (i != (arguments.length - 1))
				value += " ## ";
		}
		alert(value);
	};
}

if (!window.fireunit) {
	window.fireunit = function() { };

	window.fireunit.ok = function(test, message) {
	};

	window.fireunit.compare = function(expression1, expression2, message) {
	};

	window.fireunit.reCompare = function(regEx, expression, message) {
	};

	window.fireunit.testDone = function() {
	};

	window.fireunit.mouseDown = function(domElement) {
	};

	window.fireunit.click = function(domElement) {
	};

	window.fireunit.focus = function(domElement) {
	};

	window.fireunit.key = function(domElement, key) {

	};
}

window.entry = function() {
	var _sectionCode = (typeof r_section == "undefined" ? "home" : r_section.Code);
	var _pageCode = (typeof r_page == "undefined" ? null : r_page.Code);
	return {
		facilities: /facilities/.test(_sectionCode),
		apartments: /apartments/.test(_sectionCode),
		visit: /visit/.test(_sectionCode),
		team: /team/.test(_sectionCode),
		contact: /contact/.test(_sectionCode),
		video: /video/.test(_sectionCode),
		home: /home/.test(_sectionCode),
		travel: /travel/.test(_sectionCode),
		plans: /plans/.test(_sectionCode),
		section: _sectionCode,
		page: _pageCode
	};
} ();

// Analytics
var logEvent = function(event, section, page) {
	pageTracker._trackPageview("/" + event + "/" + section + (page ? "/" + page : ""));
};