/*
* PK base Javascript Class
*
* @author		Frédéric Trudeau <ftrudeau@prospek.ca>
* @author		Sylvain Hovington <sylvain@prospek.ca>
* @author		Stéphane Taurand <stephane@prospek.ca>
* @copyright	Copyright (c) 2009 Prospek Inc. All rights reserved.
* @uses			jQuery 1.3.2
* @version		1.1 (custom for avunet project)
*/

"use strict";

var date = new Date();

var PK = {

	/**
	* Default configuration
	*
	* @property PK.CFG
	* @type Object
	* @static
	*/
	CFG : {
		//language : 'fr_CA',
		cdsActive : false,
		cdsCurrentHostIndex	: 0,
		cdsHostCount : 0,
		protocol : (("https:" === document.location.protocol) ? "https://" : "http://")
	},


	/*
	* Initialize ze thing.
	*
	* @author		Frédéric Trudeau <ftrudeau@prospek.ca>
	* @copyright	Copyright (c) 2009 Prospek Inc. All rights reserved.
	*/
	init: function (config, debug)
	{
		if (typeof debug !== false && typeof debug === "object")
		{
			PK.CONSOLE = debug;
		}


		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Check for configuration
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

		// console.log("[init] START : Configuration check", "time");
		if (typeof config === undefined)
		{
			alert('PK class needs minimal configuration to run');
			return;
		}

		if (typeof config !== 'object')
		{
			alert('PK class configuration needs to be an object');
			return;
		}

		this.CFG = config;

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Check for jQuery, which must be loaded
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

		if (typeof jQuery === undefined)
		{
			alert('jQuery is needed by PK class');
			return;
		}


		////////////////////////
		// INITIALIZE METHOD //
		//////////////////////
		if (typeof this[this.CFG.initMethod] === 'function')
		{
			this[this.CFG.initMethod]();
		}
		else
		{
			alert("[init] Cannot initialize method '" + this.CFG.initMethod + "' (does it exists ?)");
		}

	},

	/*
	*	1 action for dessine moi un voyage project
	*/
	defaultMethod: function()
	{
		this.last();
	},

	////////////////////////////
	// BEGIN PRIVATE METHODS //
	//////////////////////////

	/*
	* Stuff to do last
	*
	* @author		Frédéric Trudeau <ftrudeau@prospek.ca>
	* @copyright	Copyright (c) 2009 Prospek Inc. All rights reserved.
	*/
	last: function ()
	{
		// Detect browser and if IE dont touch cufon opacity
		if (navigator.appName!="Microsoft Internet Explorer")
		{
			// Display cufon elements by changing opacity back to 1
			jQuery(".font_eaves,.font_styl,.font_eaves_scaps").animate
			(
				{opacity: 1},
				1000,
				"easeInOutExpo"
			);

		}
		else
		{
			// Display cufon elements by changing opacity back to 1
			jQuery(".font_eaves,.font_styl,.font_eaves_scaps").animate(1000).css({visibility: "visible"});
		}


	}

};

/*
* Initialize PK Class on document ready
*
* @author		Frédéric Trudeau <ftrudeau@prospek.ca>
* @author		Stéphane Taurand <stephane@prospek.ca>
* @copyright	Copyright (c) 2009 Prospek Inc. All rights reserved.
* @see	http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx#tip25
*/

jQuery
(
	function ()
	{
		if (typeof(cfg) === undefined)
		{
			cfg = {};
		}

		if (typeof(cfg.debug) !== undefined && cfg.debug === true)
		{
			PK.init(cfg, D);
		}
		else
		{
			PK.init(cfg);
		}
	}
);
