/**
 * X3 CMS - A smart Content Management System
 *
 * @author		Paolo Certo
 * @copyright	(c) 2010-2011 CBlu.net di Paolo Certo
 * @license		http://www.gnu.org/licenses/agpl.htm
 * @package		X3CMS
 */
 
// external links
$(function() {
    $('a[href^=http]').not('.no_target').click( function() {
        window.open(this.href);
        return false;
    });
});

// preload images
$.fn.preload = function() {
    this.each(function(){
        $('<img/>')[0].src = this;
    });
}

$(document).ready(function() {
	
	if ($("#antispam").length > 0) {
		$('#antispam').remove();
    }
    $('a[href^=http]').not('.no_target').addClass('blank');
	$('<img/>').preload();
	
	fixedMenu();
	recaptcha();
	$("#content").css("width", $("#content ul:first").width() + "px");
	
	$('a.zoom').attr({'rel': 'prettyPhoto'});
	$("a[rel^='prettyPhoto']").prettyPhoto({
		theme: 'facebook', /* pp_default, light_rounded / dark_rounded / light_square / dark_square / facebook */
		social_tools:''});
});

var loading = '<img id="loader" src="' + root + '/files/files/spinner.gif" alt="loading..." />',
	c = 0,	// reload captcha
	recaptcha = function() {
		$('#reload_captcha').click(function() {
			c = c + 1;
			var src = $('#reload_captcha').attr('href');
			d = new Date();
			$("#captcha_img").attr("src", src + '/' + c + '?' + d.getTime());
			return false;
		});
	},
	fixedMenu = function(){
		$('#nav ul').css({display: 'none'}); // Opera Fix
		$('#nav li').hover(
			function(){
				$(this).find('ul:first').css({visibility: 'visible',display: 'none'}).show(400);
			},function(){
				$(this).find('ul:first').css({visibility: 'hidden'});
			}
		);
	}

