var IE = document.all ? true:false;
var altoWin = window.screen.height;
var anchoWin = window.screen.width;

function slideSwitch(id,titulo) {
    
    var active = $('#slideshow DIV.active2');

    var sombra = $('.sombra');

    if(sombra && sombra.css('opacity') < 1.0){
    	sombra.animate({opacity: 1.0});
    }

    if ( active.length == 0 ) active = $('#slideshow DIV:last');

    var next = id===undefined ? active.next().length ? active.next()
        : '' : $("#"+id);
    
    var prev = id===undefined ? active.prev().length ? active.prev()
        : $('#slideshow DIV:last') : $("#"+id);

    active.addClass('last-active2');

    if(next && next.is('div')){
	    
	    next.css({opacity: 0.0})
	        .addClass('active2')
	        .animate({opacity: 1.0}, tiempo2, function() {
	            active.removeClass('active2 last-active2');
	        });
        }
}

function slideGal(id, titulo) {

    if(IE){ // si es IE

	    $('#slideshow').animate({ filter: 'alpha(opacity=0)'}, 300, function(){
	            $('#slideshow div.active').removeClass('active last-active');
	            $("#"+id).addClass('active');
	            $('#menu-seccion a').addClass('acc');
	            $('#'+id+' .titulo').html(titulo);
	            $('#'+id+' .titulo').width($("#"+id+" img").width());
	        });
	       

	    $('#slideshow').animate({ filter: 'none'}, 300);
	    	
	 }else{ // si no es IE

	    if(!($('#'+id).hasClass('active'))){

		    $('#menu-seccion a.acc').removeClass('acc');

		    var shdw = $('#slideshow div.active img').css('-moz-box-shadow');

		    $('#slideshow div.active img').css('-moz-box-shadow','none');

		    $('#slideshow').animate({opacity: 0.0}, 300, function() {
		            $('#slideshow div.active').removeClass('active last-active');
		            $("#"+id).addClass('active');
		            $('#slideshow div.active img').css('-moz-box-shadow',shdw);
		            $('#menu-seccion a').addClass('acc');
		            $('#'+id+' .titulo').html(titulo);
		            $('#'+id+' .titulo').width($("#"+id+" img").width());
		        });

		    $('#slideshow').animate({opacity: 1.0});

	    }
    } // termina "si no es IE".
}

function acomodo(){
	
	var altoImg = IE ? document.documentElement.clientHeight : window.innerHeight;
	var anchoImg = IE ? document.documentElement.clientWidth : window.innerWidth;

	if(anchoWin > 1023 && altoWin > 767){
	 		
		$("#back img").height(altoImg);

		if($("#back img").height() < 570){
			$("#back img").height(570);
			$("body").css({ overflowY: 'auto' });
		}
		if($("#back img").height() > 700){

			$("#back img").attr('src','http://www.marianakirby.com/home/img/1600x906.jpg');
			$("#margen").height(altoImg*0.24);
						$("#menu-seccion").css({ marginTop: '55px'});
		}else{
			$("#back img").attr('src','http://www.marianakirby.com/home/img/1600x756.jpg');
			$("#margen").height(altoImg*0.16);
			if($("#margen").height() < 80){ $("#margen").height(80); }
						$("#slideshow").css({ marginTop: '40px'});
			$(".sombra").css({ top: '40px'});
			$("#menu-seccion").css({ marginTop: '0px'});
					}

	}else{
	 		
	 	$("#back img").width(990);
	 	$("#back img").height(590);
	 	$("#margen").height(($("#back").height())*0.16);
	}

	$('#back img').css({ visibility: 'visible'});

}

function mouseHover(enlace){
	
	mid = enlace;
	mid = mid.replace("m","i");

	slideGal(mid, $('#'+enlace).html());
}

$(function(){
	
	acomodo();
	$('#menu-seccion a').addClass('acc');


$('#main').css({ visibility: 'visible'});
$('body').css({ background: 'none'});
$("#slideshow").show();

});

$(window).resize(function() { acomodo();});
