var $j = jQuery.noConflict();
	
// Se ejecuta en el document.onload de todas las paginas de la administracion.
// Se usa el jQuery.ready para llamar a esta funcion asi que si queremos usar el ready
// de jQuery tendremos que extender este metodo.
$j.xpressReady = function() { }	
     
// Use jQuery via $j(...)
// Se pueden anidar tantos ready como se quiera.
$j(document).ready(function(){
	
	$j.xpressReady();
	
});

$j.fn.anchorAnimate = function(settings) {

	settings = $j.extend({
		speed : 1100
	}, settings);	
	
	return this.each(function(){
		var caller = this;		
		
		if (!$j(caller).hasClass('xpress_anchor_noanimate')) {
			$j(caller).click(function (event) {	
				event.preventDefault();
				var locationHref = window.location.href;
				var elementClick = $j(caller).attr("href");
				
				var destination = $j(elementClick).offset().top;
				$j("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
					window.location.hash = elementClick
				});
				return false;
			});
		}
	})
}

var iframeMode = 1;

$j.fn.iframeAutoHeight = function (options) {
	// set default option values
	var options = $j.extend({
		heightOffset: 0
	}, options);

	// iterate over the matched elements passed to the plugin
	$j(this).each(function () {
		// Check if browser is Opera or Safari(Webkit so Chrome as well)
		if ($j.browser.safari || $j.browser.opera) {
			// Start timer when loaded.
			$j(this).load(function () {
				var iframe = this;
				var delayedResize = function () {
					resizeHeight(iframe);
				};
				setTimeout(delayedResize, 0);
			});
			$j(window).resize(function () {
				var iframe = document.getElementById('if_we');
				var delayedResize = function () {
					resizeHeight(iframe);
				};
				setTimeout(delayedResize, 0);
			});

			// Safari and Opera need a kick-start.
			var source = $j(this).attr('src');
			$j(this).attr('src', '');
			$j(this).attr('src', source);
		}
		else {
			// For other browsers.
			$j(this).load(function () {
				resizeHeight(this);
			});
		}

		// resizeHeight
		function resizeHeight(iframe) {
			var newHeight = $j(window).height();
		    if (iframeMode == 1) {
			    // Set inline style to equal the body height of the iframed content plus a little
				try {
					newHeight = iframe.contentWindow.document.body.offsetHeight + options.heightOffset;
					if (newHeight <= options.heightOffset) {
						if (iframe.contentWindow.document.getElementById('page')) {
							newHeight = iframe.contentWindow.document.getElementById('page').offsetHeight + options.heightOffset;
						}
					}
				} catch (e) { }
			} else {
	            newHeight = $j(window).height() - 40;
			}
			
			iframe.style.height = newHeight + 'px';
		}

	}); // end
}

// cargar parametros de la URL
$j.urlParam = function(name) {
	var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(document.location.href);
	if (results != null && results.length > 1)
		return results[1];
	else
		return null;
}

