
	// JavaScript Document
	// EXPLORER! +++++++++++++++++++++++++++++++++++++++++++
	
	var navegador;
	
	function getInternetExplorerVersion() {
	
		// Returns the version of Internet Explorer or a -1
		// (indicating the use of another browser).
		
	  var rv = -1; // Return value assumes failure.
	  
	  if (navigator.appName == 'Microsoft Internet Explorer')
	  {
		var ua = navigator.userAgent;
		var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
		  rv = parseFloat( RegExp.$1 );
	  }
	  return rv;
	}
		
	function checkVersion() {
		
	 // var msg = "You're not using Internet Explorer.";
	  var ver = getInternetExplorerVersion();
	
	  /*if ( ver > -1 )
	  {
		if ( ver >= 8.0 ) 
		  msg = "You're using a recent copy of Internet Explorer."
		else
		  msg = "You should upgrade your copy of Internet Explorer.";
	  }*/
	  
	  navegador = ver;
	  
	  //alert( msg );
	  
	}

	//Flooooat!
	
	function mueveCosasDo (elemento) {
	
		var mitop = $('#'+elemento).css('top').substring(0,$('#'+elemento).css('top').indexOf('p'));
		var marea = Math.floor(Math.random()*20) + 20;
		
		//if (Math.random() < 0.5) marea = -marea;
			
		var tiempo = 4*1000;//(Math.floor(Math.random()*3) + 3) * 1000;
		
		$('#'+elemento).animate({
		
			top:Number(mitop) + marea
				
		}, {
			
			duration: tiempo,
			specialEasing: {top: 'easeInOutCubic'},
			queue: false,
			complete:function () {
			
				mueveCosasUp(mitop, marea, tiempo, elemento);
					
			}
			
		});
		
		
	}
	
	function mueveCosasUp (mitop, marea, tiempo, elemento) {
				
		$('#'+elemento).animate({
		
			top:Number(mitop)
				
		}, {
			
			duration: tiempo,
			specialEasing: {top: 'easeInOutCubic'},
			queue: false,
			complete:function () {
			
				mueveCosasDo (elemento);
					
			}
			
		});
		
	}
	
	//Como una ola!
	
	function pasaOlas () {
		
		$('#ola0').css({backgroundPosition:'0 0'});
		$('#ola1').css({backgroundPosition:'0 0'});
		
		$('#olaTrans').css({backgroundPosition:'0 0'});
		
		$('#ola0').animate({
			backgroundPosition:'-518px 0'
		}, {
			duration: 12*1000,
			specialEasing: {backgroundPosition: 'linear'},
			queue: false
		});
		
		$('#ola1').animate({
			backgroundPosition:'518px 0'
		}, {
			duration: 12*1000,
			specialEasing: {backgroundPosition: 'linear'},
			queue: false
		});
		
		$('#olaTrans').animate({
			backgroundPosition:'518px 0'
		}, {
			duration: 12*1000,
			specialEasing: {backgroundPosition: 'linear'},
			queue: false,
			complete:pasaOlas	
		});
		
	}

/*********************************************
HOME...
*********************************************/

	function eventosHome () {
				
		$('#logo2DDepotOver').mouseenter(			
			function(){
				//$(this).css({'cursor':'pointer'});
				$('#logo2DDepotOjazos').css({'visibility':'visible'});
			}
		);
		
		$('#logo2DDepotOver').mouseleave( 
			function(){
				//$(this).css({'cursor':'default'});
				$('#logo2DDepotOjazos').css({'visibility':'hidden'});
			}
		);
		
		//randomiza separadores...
		//$('.waveUnder').css({'background-position':''+ (Math.random()*250 + 250) + 'px 0'});
	
	
		$('.homeBTPlay, .gameBTPlay').mouseenter(			
			function(){
				
				$(this).css({'cursor':'pointer'});
				
				$(this).find('.homeBTPlayON').css({'visibility':'visible'});				
				
				if (navegador == -1) {
				
					$(this).find('.homeBTPlayON').css({'opacity':'0'});
					$(this).find('.homeBTPlayON').animate({
						opacity: 1
					}, {
						duration: 250,
						queue: false
					});	
					
				}
				
			}
		);
		
		$('.homeBTPlay, .gameBTPlay').mouseleave( 
			function(){
				
				$(this).css({'cursor':'default'});
				
				if (navegador == -1) {
					
					$(this).find('.homeBTPlayON').animate({
						opacity: 0
					}, {
						duration: 250,
						queue: false,
						complete: function () {
							
							$(this).find('.homeBTPlayON').css({'opacity':'0'});
							$(this).find('.homeBTPlayON').css({'visibility':'hidden'});	
							
						}
					});
					
				} else {
					
					$(this).find('.homeBTPlayON').css({'visibility':'hidden'});	
				
				}
				
			}
		);
		
		//nav superior
		
		/*$('#homeNavGame').mouseenter(			
			function(){
				$(this).css({'cursor':'pointer'});
				//$('#logo2DDepotOjazos').css({'visibility':'visible'});
			}
		);
		
		$('#homeNavGame').mouseleave( 
			function(){
				$(this).css({'cursor':'default'});
				//$('#logo2DDepotOjazos').css({'visibility':'hidden'});
			}
		);
		*/
		
		$('#homeNavBlog').mouseenter(			
			function(){
				$(this).css({'cursor':'pointer'});
				//$('#logo2DDepotOjazos').css({'visibility':'visible'});
			}
		);
		
		$('#homeNavBlog').mouseleave( 
			function(){
				$(this).css({'cursor':'default'});
				//$('#logo2DDepotOjazos').css({'visibility':'hidden'});
			}
		);
		
		$('#homeNavBlog').click(
			function() {
		  		window.location = "http://www.2ddepot.com/blog/";
			}
		);

	}

/*********************************************
HOME...
*********************************************/

	function eventosHeader () {
				
		/*$('.pageBack').mouseenter(			
			function(){
				$(this).css({'cursor':'pointer'});
			}
		);
		
		$('.pageBack').mouseleave( 
			function(){
				$(this).css({'cursor':'default'});
			}
		);
		
		$('#target').click(function() {
  			alert('Handler for .click() called.');
		});*/
		//randomiza separadores...
		//$('.waveUnder').css({'background-position':''+ (Math.random()*250 + 250) + 'px 0'});
	
	}

/*********************************************
SIDEBAR...
*********************************************/
		
	var categorias_abierto = false;
	var archivos_abierto = false;
	
	var archivos_altura;
	var categorias_altura;
	
	function eventosSidebar () {
				
		archivos_altura = $('#sidebarArchives').height() - 2;
		categorias_altura = $('#sidebarCategories').height() - 2;
		
		//cierra...
		
		$('#sidebarArchives').css("height",0);
		$('#sidebarCategories').css("height",0);
		
		$('#sidebarArchivesContent').css("margin-top",-archivos_altura);
		$('#sidebarCategoriesContent').css("margin-top",-categorias_altura);
		
		//handlers...
		
		//$('#sidebarArchivesPlus').click(abreCierra);
		//$('#sidebarCategoriesPlus').click(abreCierra);
		
		$('#sidebarArchivesPlus').mouseenter(abreSidebar);
		/*		
			function(){
				$(this).css({'cursor':'pointer'});
			}
		);*/
		
		$('#sidebarCategoriesPlus').mouseenter(abreSidebar);
		/*
		(			
			function(){
				$(this).css({'cursor':'pointer'});
			}
		);*/
		
		$('#sidebarContent').mouseleave(cierraSidebar);
		
		/*( 
			function(){
				$(this).css({'cursor':'default'});
			}
		);
		*/
		
		//$('#sidebar').mouseenter(cierraSidebar);
		
		/*( 
			function(){
				$(this).css({'cursor':'default'});
			}
		);*/
			
		
	
	}
	
	function abreSidebar (event) {
		
		$(this).css({'cursor':'pointer'});
		
		var objetivo;
		var altura;
		var posY;
		
		if (event.currentTarget.id == "sidebarArchivesPlus") {
			
			objetivo = "#sidebarArchives";
			
			archivos_abierto = true;
			altura = archivos_altura;
			posY = 0;
			
		} else {
		
			objetivo = "#sidebarCategories";
			
			categorias_abierto = true;
			altura = categorias_altura;
			posY = 0;
			
			
		}
		
		$(objetivo).stop(true,false);
		$(objetivo+'Content').stop(true,false);
				
		//ANIMA...
		
		$(objetivo).animate({
						height: altura,
					}, {
						duration: 1000,
						easing: 'easeInOutCubic',
						queue: false
					});
			
		$(objetivo+'Content').animate({
						'margin-top': posY,
					}, {
						duration: 1000,
						easing: 'easeInOutCubic',
						queue: false
					});
			
		
		//'sidebarArchives ' + $('#sidebarArchives').height());
		
	}
	
	function cierraSidebar (event) {
		
		$(this).css({'cursor':'default'});
		
		var objetivo;
		var altura;
		var posY;
		
		/*if (event.currentTarget.id == "sidebarArchivesPlus") {
			
			objetivo = "#sidebarArchives";
			
			archivos_abierto = false;
			altura = 0;
			posY = -archivos_altura;
			
		} else {
		
			objetivo = "#sidebarCategories";
			
			categorias_abierto = false;
			altura = 0;
			posY = -categorias_altura;
			
		}*/
			
		
		$("#sidebarArchives").stop(true,false);
		$("#sidebarArchivesContent").stop(true,false);
			
		$("#sidebarCategories").stop(true,false);
		$("#sidebarCategoriesContent").stop(true,false);
			
			
		//ANIMA...
		
		$("#sidebarArchives").animate({
						height: 0,
					}, {
						duration: 500,
						easing: 'easeInOutCubic',
						queue: false
					});
			
		$("#sidebarArchivesContent").animate({
						'margin-top': -archivos_altura,
					}, {
						duration: 500,
						easing: 'easeInOutCubic',
						queue: false
					});
					
			
		$("#sidebarCategories").animate({
						height: 0,
					}, {
						duration: 500,
						easing: 'easeInOutCubic',
						queue: false
					});
			
		$("#sidebarCategoriesContent").animate({
						'margin-top': -categorias_altura,
					}, {
						duration: 500,
						easing: 'easeInOutCubic',
						queue: false
					});
		
		
	}
	
	function abreCierra (event) {
		
		$(this).css({'cursor':'pointer'});
		
		var objetivo;
		var altura;
		var posY;
		
		if (event.currentTarget.id == "sidebarArchivesPlus") {
			
			objetivo = "#sidebarArchives";
			
			if (archivos_abierto) {
			
				archivos_abierto = false;
				altura = 0;
				posY = -archivos_altura;
						
			} else {
				
				archivos_abierto = true;
				altura = archivos_altura;
				posY = 0;
			}
			
		} else {
		
			objetivo = "#sidebarCategories";
			
			if (categorias_abierto) {
			
				categorias_abierto = false;
				altura = 0;
				posY = -categorias_altura;
				
			} else {
				
				categorias_abierto = true;
				altura = categorias_altura;
				posY = 0;
				
			}
			
		}
				
		//ANIMA...
		
		$(objetivo).animate({
						height: altura,
					}, {
						duration: 1000,
						easing: 'easeOutCubic',
						queue: false
					});
			
		$(objetivo+'Content').animate({
						'margin-top': posY,
					}, {
						duration: 1000,
						easing: 'easeOutCubic',
						queue: false
					});
			
		
		//'sidebarArchives ' + $('#sidebarArchives').height());
		
	}

