// JavaScript Document

$(function(){
					
										//$('#slideOne').slidePulpo();  
					ubicarFlecha()
					
					$(window).resize(ubicarFlecha);
					
					$("#slideOne").wslide({		
						width:395,
						height:235,
						horiz: true
					})
					
					$("#razones").wslide({
								width: 417,
								height: 243,
								horiz: true,
								autoStartTime : 3000
						});
									
					/* $('#razones').slidePulpo({
											 	autoPlay:false
											 }); */
					
					serialize();
					
					$('.animate').hover(function(){
							 $(this).animate({ marginTop: "-5px" }, 100)
					},function(){
							$(this).animate({ marginTop: "-0px" }, 200)
					})
					
					
					$('#prev').click(function(){
						actual = visible();
						Cantidad = $('#app_home li').length;
						prevObj = (actual-1);
						
						if (actual==0) {
							$('#li_0').fadeOut(200,function(){
								$('#li_'+(Cantidad-1)).fadeIn(500);
							})
							return false;
						}
						
						if (actual > 0){
							$('#li_'+actual).fadeOut(200,function(){
								$('#li_'+prevObj).fadeIn(500);
							})
						}
						
						//$('#prev').attr('href','#');
						
					})
					$('#next').click(function(){
						actual = visible();
						Cantidad = $('#app_home li').length;
						nextObj = (actual+1);
						
						if (actual==(Cantidad-1)) {
							$('#li_'+(Cantidad-1)).fadeOut(200,function(){
								$('#li_0').fadeIn(500);
							})	
							return false;
						}
						
						if (actual < (Cantidad-1)){
							$('#li_'+actual).fadeOut(200,function(){
								$('#li_'+nextObj).fadeIn(500);
							})
						}
						//$('#next').attr('href','#');
					})
					
					
					
					
				})
				
				
				function visible(){
					var ele;
					$('#app_home li').each(function(){
						if ($(this).is(':visible')){
							ele = $(this).attr('id');
							ids = ele.split('li_')
							
						}
					})
					
					return parseInt(ids[1]); ;
				}
				
				function serialize(){
					var i = 0;
					$('#app_home li').each(function(){
							$(this).attr('id','li_'+i);
							i++;
					})
				}
				
				function ubicarFlecha(){
					var Ww = $(window).width();
					var Wb = $('#box3D').width();
					
					var result  = ((Ww-Wb)/2)
					$('.flecha').css('width',(parseInt(result)-10));
				}