function preloadImages(seccion) {
		
	var directory = 'http://www.notonlywebs.com/newnow/';
	var ruta = '';	
	ruta = 'img/home/';
	
	var pic1 = new Image();	
	pic1.src = directory+ruta+'fondocentral.png';	
	ruta = 'img/socialmedia/';	
	var pic2 = new Image();	
	pic2.src = directory+ruta+'bdsocial.png';	
	ruta = 'img/servicios/';	
	var pic3 = new Image();	
	pic3.src = directory+ruta+'bgservicios.png';	
	ruta = 'img/productos/';	
	var pic4 = new Image();	
	pic4.src = directory+ruta+'bgproductos.png';	
	ruta = 'img/portfolio/';	
	var pic5 = new Image();	
	pic5.src = directory+ruta+'bgportfolio.png';	
	ruta = 'img/contacto/';
	var pic6 = new Image();
	pic6.src = directory+ruta+'bgcontacto.png';

}

function initSection(section) {
	
	switch(section) {
		
			case 'portfolio':
				jQuery('#mycarousel').jcarousel({
					visible: 4,
					scroll: 4,					
					//wrap: "last",
					animation: "slow"
					
				});
				$('#mycarousel li').mouseover(function(){
					$(this).fadeTo("fast",1);									
				});
				$('#mycarousel li').mouseout(function(){
					$(this).fadeTo("slow",0.6);									
				});
				
				mostrarPortfolio('panasonic');
				
			break;		
			
	}
	
	$('#contenido_central_lateral').load('includes/barraLateral.html',function(){
		initSectionCommon();																		   
	});
}

function initSectionCommon() {
	initTooltips();
	//initFades();
	cargarCuadros();
	eJobForm();
}

function initLinks() {
	
	$('.modal').each(function(){
		
		direccion = $(this).attr('href');			
			
		$(this).attr('target','_self');
		$(this).addClass('iframe');				
				$(this).fancybox({
					overlayShow: true,
					autoDimensions: false,
					width: 0.9*screen.width,
					height: 0.8*screen.height
		});	  	
	});
}

function eJobForm() {
	
	$('#eJobForm').each(function(){
		
		direccion = $(this).attr('href');			
			
		$(this).attr('target','_self');
		$(this).addClass('iframe');				
				$(this).fancybox({
					overlayShow: true,
					autoDimensions: false,
					width: 670,
					height: 590
		});	  	
	});
	
	$('#eJobForm2').each(function(){
		
		direccion = $(this).attr('href');			
			
		$(this).attr('target','_self');
		$(this).addClass('iframe');				
				$(this).fancybox({
					overlayShow: true,
					autoDimensions: false,
					width: 670,
					height: 590
		});	  	
	});
}


function initTooltips() {
		$('a.tooltip_social').qtip({
		   content: $(this).title,
		   position: {
			  corner: {
				 target: 'bottomMiddle',
				 tooltip: 'topMiddle'
			  }
   		   },
		   style: { 			  
			  padding: 5,
			  background: '#FEFEFE',
			  color: '#666666',
			  textAlign: 'center',
			  border: {
				 width: 1,
				 radius: 3,
				 color: '#EC0275'
			  },
			  tip: 'topMiddle'  
		   }

		});
}

function initFades() {
	$('.fade').hover(function() {
   		 $(this).fadeTo("fast", 0.95);
  	}, function() {
    	$(this).fadeTo("slow", 1);
 	 });
}

function cargarCuadros() {
	
	var uno=randomNumberFooter();
	var dos = (uno+1)%10;
	var tres = (dos+1)%10;
	var cuatro = (tres+1)%10;
	
	$('#footer_cuadro_1').load('includes/footer_cuadros/'+uno+'.html');	
	$('#footer_cuadro_2').load('includes/footer_cuadros/'+dos+'.html');	
	$('#footer_cuadro_3').load('includes/footer_cuadros/'+tres+'.html');		
	$('#footer_cuadro_4').load('includes/footer_cuadros/'+cuatro+'.html');
	
}

function randomNumberFooter() {
	return Math.floor(Math.random()*10);		
}

/////////////////////////////*SERVICIOS*///////////////////////////////////

function seleccionServicios(tipo) {
	
	switch(tipo) {
		
		case 'ecomunicacion':
			
			$('#eComunicacion').addClass('menu_servicios_selected');
			$('#comunicacion').removeClass('menu_servicios_selected');			
			$('#contenido_servicios02').fadeOut("fast",function(){
				$('#contenido_servicios02').load('includes/servicios/menu_ecomunciacion.html',function(){
					$('#contenido_servicios02').fadeIn("slow",function(){
						initMenuServiciosDerecha();
						initLinks();
					});				
				});													
			});
			
			$('#subtitulo').html('¿Qué podemos hacer online?');
			
		break;
		
		case 'comunicacion':
			
			$('#comunicacion').addClass('menu_servicios_selected');
			$('#eComunicacion').removeClass('menu_servicios_selected');
			$('#contenido_servicios02').fadeOut("fast",function(){
				$('#contenido_servicios02').load('includes/servicios/menu_comunciacion.html',function(){
					$('#contenido_servicios02').fadeIn("slow",function(){
						initMenuServiciosDerecha();
						initLinks();
					});				
				});													
			});
			$('#subtitulo').html('¿Qué podemos hacer offline?');
			
		break;		
	}			
}

function initMenuServiciosDerecha() {
	$('.menu_servicios_li').mouseover(function(){
		$(this).addClass('menu_servicios_li_roll');										   
	});	
	$('.menu_servicios_li').mouseout(function(){
		$(this).removeClass('menu_servicios_li_roll');										   
	});	
}

function showSeccion(init,object) {
	 
	 id = $(object).attr('id');
	 	 
	 $('.menu_servicios_li_in').removeClass('menu_servicios_li_in');
	 $('.contenido_seccion_servicios').each(function(){
			if($(this).is(":visible")) $(this).slideUp("normal");												 
	 });	 
	 
	 if ($("#menu_servicios_"+init).is(":hidden")) {
        $("#menu_servicios_"+init).slideDown("slow").show(function(){
			$(this).show();
		});
		
		$('#'+id).addClass('menu_servicios_li_in');		
		
      } else {
        $("#menu_servicios_"+init).slideUp("normal");
		$('.menu_servicios_li_in').removeClass('menu_servicios_li_in');
      }	
}

function mostrarFlujo() {
	$('<a href="img/servicios/flow.png"></a>').fancybox({
        overlayShow: true
    }).click();	
}

function mostrarNews(init) {
	$('<a href="img/portfolio/zooms/'+init+'"></a>').fancybox({
        overlayShow: true,
		autoScale: false
    }).click();	
}

function mostrarPortfolio(init) {
	
	$('#contenido_portfolio01').fadeOut("fast",function(){
			$('#contenido_portfolio01').load('includes/portfolio/'+init+'.html',function(){		
				$('#contenido_portfolio01').fadeIn("fast",function(){
					//Activar slideshow
					interval = setInterval( "slideSwitch()", 6000 );
					
					$('#slideshow img').mouseover(function(){
						clearInterval(interval);									   
					});
					$('#slideshow img').mouseout(function(){
						interval = setInterval( "slideSwitch()", 6000 );
					});
					$('#mycarousel li').click(function(){
						clearInterval(interval);	
					});
					initLinks();
				});		
			});													
	});
}

function seleccionProductos() {
	
				$('#contenido_productos02').load('includes/productos/menu_productos.html',function(){
					$('#contenido_productos02').fadeIn("slow",function(){
						initMenuServiciosDerecha();
					});				
				});			
	
}

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 900, function() {
            $active.removeClass('active last-active');
        });
}

function cerrarModal() { $.fancybox.close() }
