

$(window).load(function(){ 

 //$('#loading').css("visibility", "hidden");		
  //$('#fondo').fadeIn(2000);
	
		$("#mailing").hover(function(){
		$(this).css('background' , 'url(assets/templates/ijj/images/MailOver.gif)');
	}, function(){
		$(this).css('background' ,  'url(assets/templates/ijj/images/Mail.gif)');
	});
	
	$("#home").hover(function(){
		$(this).css('background' ,  'url(assets/templates/ijj/images/HomeOver.gif)');
	}, function(){
		$(this).css('background' ,  'url(assets/templates/ijj/images/Home.gif)');
	});
	
	$("#paginainicio").hover(function(){
		$(this).css('background' ,  'url(assets/templates/ijj/images/MakeHomePageOver.gif)');
	}, function(){
		$(this).css('background' ,  'url(assets/templates/ijj/images/MakeHomePage.gif)');
	});
	
	$("#pictureGalleryPrev").hover(function(){
		$(this).css('background' ,  'url(assets/templates/ijj/images/MiniGaleriaLeftOver.gif)');
	}, function(){
		$(this).css('background' ,  'url(assets/templates/ijj/images/MiniGaleriaLeft.gif)');
	});
	
	$("#pictureGalleryNext").hover(function(){
		$(this).css('background' ,  'url(assets/templates/ijj/images/MiniGaleriaRightOver.gif)');
	}, function(){
		$(this).css('background' ,  'url(assets/templates/ijj/images/MiniGaleriaRight.gif)');
	});
	
	$("#i").hover(function(){
		$(this).find('img').attr('src' ,  'assets/templates/ijj/images/iOver.png');
	}, function(){
		$(this).find('img').attr('src' , 'assets/templates/ijj/images/i.png');
	});


	$("#pictureSlider").jCarouselLite({
    btnNext: "#pictureGalleryNext",
    btnPrev: "#pictureGalleryPrev", 
		visible: 5,
		scroll: 5,
		speed: 1000
		
});

$('#headingsDataUl').bxSlider({
	    mode: 'fade',
	    speed: 1000,
	    pause: 5000,
	    auto: true,
		controls: false,
	    auto_direction: 'right',
	    width: 643,
	    wrapper_class: 'headings'
	});
	
	$('.socialNetworks').hover(function(){
		$(this).animate({"margin-right" : "-10px"}, "fast" );

	}, function(){
			$(this).animate({"margin-right" : "0px"}, "fast" );
	});

	

	$('li.menuLevel1').hover(
		function(e) {
		$(this).find('.itemContent.menuLevel1').find('a').animate({"color": "#FFFFFF", "margin-left" : "20px"}, 200
		);
		$(this).find('.itemBackground.menuLevel1').show("slide", {direction: "left"}, 200);
   },function(e){
   $(this).find('.itemBackground.menuLevel1').hide("slide", {direction: "left"}, 200);
	 $(this).find('.itemContent.menuLevel1').find('a').animate({"color": "#000000", "margin-left" : "10px"}, 200);
	 //$(this).children('ul > .menuLevel2 > .itemBackground').css({"display" : "none" });
   });
   
   $('li.menuLevel2').hover(function(e) {
		$(this).find('.itemBackground.menuLevel2').show("slide", {direction: "left"}, 200);
		$(this).find('.itemContent.menuLevel2').find('a').animate({"margin-left" : "30px"});

   },function(){
		$(this).find('.itemBackground.menuLevel2').hide("slide", {direction: "left"}, 200);

		$(this).find('.itemContent.menuLevel2').find('a').animate({"margin-left" : "20px"});
   });

	 $('li.menuLevel3').hover(function(e) {
		$(this).children('.itemBackground.menuLevel3').show("slide", {direction: "left"}, 200);
		$(this).find('.itemContent.menuLevel3').find('a').animate({"margin-left" : "20px"}, 200);
		e.stopPropagation();
   },function(){
	
		$(this).find('.itemBackground.menuLevel3').hide("slide", {direction: "left"}, 200);

		$(this).find('.itemContent.menuLevel3').find('a').animate({"margin-left" : "10px"}, 200);
		e.stopPropagation();
		
   });
	 
	 
	
	$('li.menuLevel1:has(ul)').click( function(e) {
		var position = $(this).position();
		
		$(this).addClass("menuSelected");
		$(this).siblings().css("visibility", "hidden");

		$('.menuBack').css("display" ,  "inline");
		$('.menuBack').position({my: "left top", at: "left top", of: ".menuSelected", offset: "10, -19"});
		$(this).children("ul").show("slide", {direction: "left"}, 300);
		$(this).find('ul > .menuLevel2 > .itemContent > a').css({ "font-weight" : "normal" });
	});
	
	$('li.menuLevel2:has(ul)').click( function(e) {
		var position = $(this).position();
			
		$('.menuBackExtra').css("display" ,  "inline");
		$(this).find("ul").clone(true).appendTo("#menuExtra").addClass("tertiaryMenuActive").css("position", "absolute").css("top", "20px");
		
		$("#menuExtra").show();
		//$(".tertiaryMenuActive").show("slide", {direction: "left"}, 300);
		$(".tertiaryMenuActive").fadeIn(300);
		$('.tertiaryMenuActive > li.menuLevel3 > .menuContent > a').css({ "font-weight" : "normal" });
	});
	
	
	
	$('#menu li ul li').click(function(e) {
		e.stopPropagation();
	});
	

	$('.menuBack').hover( function(){
		$('.backArrow').css("display", "inline");
	}, function(){
				$('.backArrow').css("display", "none");
	});
	
	$('.menuBackExtra').hover( function(e){
		$('.backArrow').css("display", "inline");
				e.stopPropagation();
	}, function(e){
				$('.backArrow').css("display", "none");
						e.stopPropagation();
	});
	
	
	$('.menuBack').click( function(){
		$('#menu > .menuSelected >  ul').css("display", "none");
		$(this).css("display", "none");
		$("#menu > li:not(.menuSelected)").css("visibility", "visible");
		$("#menu").find(".menuSelected").removeClass("menuSelected");
	});
	
	
	$('.menuBackExtra').click( function(e){
	//$(".tertiaryMenuActive").hide("slide", {direction: "left"}, 300);
	//$("#menuExtra").hide("slide", {direction: "left"}, 200);
	$("#menuExtra").fadeOut(300);
		$('.tertiaryMenuActive').detach();
				e.stopPropagation();
		//$("#menuExtra").hide();
	});
	
	$("#featured").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 4000, false);  
	
	$("#headingsList li a").click(function() {

		if ($(this).prev(".headingsListArrow").hasClass("arrowclicked") )
		{
			 $(this).prev(".headingsListArrow").removeClass("arrowclicked");
			 $(this).prev(".headingsListArrow").animate({"left":"-216px" });
			 $("#featured").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 4000, false);  
		}
		else
		{
		   $(this).parent().parent().find("li .arrowclicked").removeClass("arrowclicked").animate({"left":"-216px" });
		
		   
			 $(this).prev(".headingsListArrow").addClass("arrowclicked");
			 $(this).prev(".headingsListArrow").animate({"left" : "-31px" });
			 $(this).parent().removeClass("ui-tabs-selected");
		}
		
	});
	
	$('#topBannersTab').hover(function () {
		$('#topBanners').animate({'top': '0'}, 200);
	}, function() {});
	
		$('#topBanners').hover(function () {
	}, function() {
		$('#topBanners').animate({'top': '-74px'}, 200);
	});
	
	$('.pictureGalleryItem').hover(function(e) {
	e.preventDefault();
	 $(this).animate({"opacity": "0.50"}, 200);
	 $('#pictureGalleryTextTitle').text($(this).find('img').attr('title'));
	 $('#pictureGalleryTextDescription').text($(this).find('img').attr('alt'));
	 $('#pictureGalleryText').css("display", "block");
	} , function (){
	$(this).animate({"opacity": "1"}, 200);
	 $('#pictureGalleryTextTitle').text('');
	 $('#pictureGalleryTextDescription').text('');
	 $('#pictureGalleryText').css("display", "none");
	});
	
	
	
	
	$('.pollresults_choices ul li:nth-child(1) .easypoll_result .easypoll_bar .easypoll_inner').addClass('poll_result_bar1');
	$('.pollresults_choices ul li:nth-child(2) .easypoll_result .easypoll_bar .easypoll_inner').addClass('poll_result_bar2');
	$('.pollresults_choices ul li:nth-child(3) .easypoll_result .easypoll_bar .easypoll_inner').addClass('poll_result_bar3');
	$('.pollresults_choices ul li:nth-child(4) .easypoll_result .easypoll_bar .easypoll_inner').addClass('poll_result_bar4');
	$('.pollresults_choices ul li:nth-child(5) .easypoll_result .easypoll_bar .easypoll_inner').addClass('poll_result_bar5');
	
	$('.pollvotes li:nth-child(1)').addClass('polloption1');
	$('.pollvotes li:nth-child(2)').addClass('polloption2');
	$('.pollvotes li:nth-child(3)').addClass('polloption3');
	$('.pollvotes li:nth-child(4)').addClass('polloption4');
	$('.pollvotes li:nth-child(5)').addClass('polloption5');	
	
	$('#linkInformate').fancybox({
		'overlayColor' : '#000000', 
		'overlayOpacity' : 0.7
	});
	
	$("#footerContactForm").fancybox({
				'autoScale'		: false,
				'width'				: 360, 
				'height'			: 480, 	
				'title'				: 'Contacto',
				'type'				: 'iframe',
				'overlayColor' : '#000000', 
				'overlayOpacity' : 0.7
			});

	
	//$("#directory").treeview();

$("a[rel=fancybox]").fancybox({
   'titlePosition' 		: 'inside',
   'overlayColor' : '#000000', 
   'overlayOpacity' : 0.7

});


$("a[rel=fancybox-video]").each(function(){
	$(this).append($('<img src ="'+$.jYoutube($(this).attr('href'))+ '" class="youtubeThumbnail" />'));
});

$("a[rel=fancybox-video]").click(function() {
	$.fancybox({
	'overlayColor' : '#000000', 
   'overlayOpacity' : '0.7',
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'		: 480,
			'height'		: 385,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

	return false;
});
		
	/*$("a[href^='mailto:']").each(function() {
	  var email = $(this).attr('href').replace("mailto:", "");
		$(this).attr('id', email);
		//$(this).attr('href', 'http://www.kraftlogic.com/ijjweb/index.php?id=144&correo=' + this.email);
		$(this).removeAttr('href');
		});*/
	
	
	$(".popupContacto").click(function (e) {
	
	//$('#ContactForm #correo').attr('value', this.href.replace("mailto:", ""));
	
	e.preventDefault();
	
	$.fancybox({
		'overlayColor' : '#000000', 
		'overlayOpacity' : 0.7,
		'href'			: 'index.php?id=144&correo=' + this.href.replace("mailto:", ""),
		'autoScale'		: false,
		'width'				: 360, 
		'height'			: 360,
		'type'				: 'iframe',
		'title'			: this.title,
		'titleShow'		: 'true',
		'titlePosition': 'outside'
		
	});
	
});


	
});









