$(document).ready(function() {

	/* PNGFIX
	 
	Correctly handle PNG transparency in Win IE 5.5 & 6.
	http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006.
	
	Use in <HEAD> with DEFER keyword wrapped in conditional comments:
	<!--[if lt IE 7]>
	<script defer type="text/javascript" src="pngfix.js"></script>
	<![endif]-->
	
	*/
	
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	
	if ((version >= 5.5) && (document.body.filters)) 
	{
	   for(var i=0; i<document.images.length; i++)
	   {
		  var img = document.images[i]
		  var imgName = img.src.toUpperCase()
		  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		  {
			 var imgID = (img.id) ? "id='" + img.id + "' " : ""
			 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			 var imgStyle = "display:inline-block;" + img.style.cssText 
			 if (img.align == "left") imgStyle = "float:left;" + imgStyle
			 if (img.align == "right") imgStyle = "float:right;" + imgStyle
			 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			 var strNewHTML = "<span " + imgID + imgClass + imgTitle
			 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			 img.outerHTML = strNewHTML
			 i = i-1
		  }
	   }
	}

	
	// ANIMACION NUBES		
	$('#nivel0201').pan({fps: 30, speed: 0.4, dir: 'left', depth: 30});
	$('#nivel0202').pan({fps: 30, speed: 0.4, dir: 'left', depth: 30});
	$('#nivel0203').pan({fps: 30, speed: 0.4, dir: 'left', depth: 30});
		
	$('#nivel0101').pan({fps: 30, speed: 0, dir: 'left', depth: 10});
	$('#nivel0102').pan({fps: 30, speed: 0, dir: 'left', depth: 10});
	$('#nivel0103').pan({fps: 30, speed: 0, dir: 'left', depth: 10});
		
	$('#nivel0101, #nivel0102, #nivel0103, #nivel0201, #nivel0202, #nivel0203').spRelSpeed(1.5);
	
	//ANIMACION POSTS
	$('.animado').css({ marginTop: '-2000px' });
	$('.stage').css({ bottom: '-2000px' });
	//$('.imagen').css({ opacity: '0' });
	
	//Animación
	$('.animado').animate({ marginTop: '20px',}, 'slow', function (){});
	$('.stage').css({ opacity: 0});
	$('.stage').animate({ opacity: 1, bottom: '0'}, 'slow');
	
	//Boton Salir
	$('.salirNext').click(function() {
		$('.animado').animate({ marginTop: '-2000px',}, 'fast');
		$('.stage').animate({ opacity: 0}, 'fast');
	});
	
	//Boton Salir
	$('.salirPrev').click(function() {
		$('.animado').animate({ marginTop: '2000px',}, 'fast');
		$('.stage').animate({ opacity: 0}, 'fast');
	});


	//COLAPSAR MENU
	animatedcollapse.addDiv('proyectos', 'fade=0,speed=400,group=srv,hide=1')
	animatedcollapse.addDiv('info', 'fade=0,speed=400,group=srv,hide=1')

	animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted
			//$: Access to jQuery
			//divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID
			//state: "block" or "none", depending on state
	}

	animatedcollapse.init()
	
	// SLIDER PROYECTOS
	$(".slidetabs").tabs(".images > div.panel", {
	
		// enable "cross-fading" effect
			effect: 'fade',
			fadeInSpeed: 800,
			fadeOutSpeed: 800,
			rotate: true
		// use the slideshow plugin. It accepts its own configuration
		}).slideshow({
			autoplay: false,
			clickable:false
	});


	// TOOLTIPS
	$(".facebook, .twitter").tooltip({offset: [30, 2],  effect: 'slide', position: 'bottom center',});
	$(".facebookpage, .twitterpage").tooltip({ effect: 'slide', position: 'top center',});

	// AMPLIA FOTO PROYECTO
	$(".fullsize").fancybox({
		'opacity'		: true,
		'overlayShow'	: false,
		'width'			: '50%',
		'height'		: '50%',
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
		
	});
/*
	// INICIAR MAPA
	$(function(){
		$('.mapa').mobilymap({
			position: 'center',
			popupClass: 'bubble',
			markerClass: 'point',
			popup: false,
			cookies: true,
			caption: false,
			setCenter: true,
			navigation: true,
			navSpeed: 1000,
			navBtnClass: 'navBtn',
			outsideButtons: '.map_buttons a',
			onMarkerClick: function(){},
			onPopupClose: function(){},
			onMapLoad: function(){}
		});
	});

*/
	

});
