// JavaScript Document
$(window).load(function(){
	if(getCookie("photoSlide")=="ocultar"){
		$("#media").hide();
		$("#top").height(80);
		$("#top").css({'margin-bottom': '5px'});
		$("#media").empty();
		$("#mostrar").show();
		$("#ocultar").hide();
	}else{
		$("#media").load("slider.php");
		$("#media").show();
		$("#top").height(300);
		$("#top").css({'margin-bottom': '115px'});
		$("#mostrar").hide();
		$("#ocultar").show();
	}
	var photoSlide=getCookie("photoSlide");
  	if (photoSlide==null || photoSlide==""){
		setCookie("photoSlide","mostrar",7);
	}
});
$(document).ready(function(e) {
		
		$("#mostrar").click(function(){
			mostrarPhotoSlide();
		});
		
});
function mostrarPhotoSlide(){
	$("#mostrar").fadeOut("slow",function(){
				$("#media").load("slider.php");
				$("#top").slideUp("slow",function(){
					$("#top").height(300);
					$("#top").css({'margin-bottom': '115px'});
					$("#top").slideDown("slow",function(){
						$("#media").slideDown("slow",function(){
							$("#ocultar").fadeIn("slow");
							setCookie("photoSlide","mostrar",7);
						});
					});
				});
		
			});
}
function ocultarPhotoSlide(){
	$("#ocultar").fadeOut("slow",function(){
				$("#media").slideUp("slow",function(){
					$("#top").slideUp("slow",function(){
						$("#top").height(80);
						$("#top").css({'margin-bottom': '5px'});
						$("#top").slideDown("slow",function(){
							$("#mostrar").fadeIn("slow");
							$("#media").empty();
							setCookie("photoSlide","ocultar",7);
						});
					});
					
				});
			});
}
	var lastId=0;
	$(document).ready(function(e) {
        $(".lista").hide();
		
	});
	function cargarLista(id){
		$("#equipos"+lastId).slideUp("fast");
		$(".tipos"+lastId).css({background:'none',border:'none'});
		if(lastId!=id){
			$("#equipos"+id).slideDown("fast");
			$(".tipos"+id).css({background:'#5de920',border:'1px solid black'});
			lastId=id;
		}else{
			lastId=0;
		}
	}
	function cargarInfo(nid){
		$("#content").height($("#content").height());
		$("#info-pro").fadeOut("fast",function(){
			$(this).load("infoProyecto.php",{id:nid},function(){
				$(this).fadeIn("fast",function(){
					$(".obras").fadeOut("fast",function(){
						$(".proyectos").fadeIn("fast",function(){
							$("#content").css('height','auto');
						});
					});
				});
			});
		});
	};
	function cargarObras(npag){
		$("#content").height($("#content").height());
		$("#info-pro").fadeOut("fast",function(){
			$(this).load("obrasEjecutadas.php",{pag:npag},function(){
				$(this).fadeIn("fast",function(){
					$(".proyectos").fadeOut("fast",function(){
						$(".obras").fadeIn("fast",function(){
							$("#content").css('height','auto');
						});
					});
				});
			});
		});
	}
	$(document).ready(function(e) {
        $(".obras").hide();
    });
	function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}
