var App = {};

App.init = function ()
{
	// Extending case insensitive selector Contains:
	jQuery.extend (jQuery.expr[':'], { Contains: "jQuery (a).text ().toUpperCase ().indexOf (m[3].toUpperCase ()) >= 0" })
	//
	this.setAjaxLoader ();
	//this.setCocanSkin  ();
}

App.updateSkin = function ()
{	
	var xPos = Math.floor ($j('#content').position ().left) - 420;
	$j('#bg-cocan').css ('background-position', xPos + 'px 0px');
	
	xPos = Math.floor ($j('#content').position ().left) + 570;
	$j('#mascote').css ('left', xPos + 'px');
	
	var yPos = Math.floor ($j('body').height ());
	$j('#mascote').css ('height', yPos + 'px');
	$j('#mascote').css ('background-position', '0px ' + (yPos - 310) + 'px');
}

App.setCocanSkin = function ()
{	
	var bgCocan = '<div id="bg-cocan"></div>';
	$j('#wrapper').before (bgCocan);
	
	var mascote = '<div id="mascote"></div>';
	$j('#wrapper').before (mascote);
	
	$j(window).resize (this.updateSkin);
	this.updateSkin ();
	
	$j('#mascote').ajaxComplete (this.updateSkin);
}

App.setAjaxLoader = function ()
{
	$j('#ajax-loader').ajaxStart    (function () { $j(this).show () } );
	$j('#ajax-loader').ajaxComplete (function () { $j(this).hide () } );
}
//
$j(function ($j) { App.init () } );