$(document).ready(function(){

    $(".projSlide > li > img.color").load(function(){
        $(this).fadeTo("fast",0.0001);
    });
    
    var projSlide = $(".projSlide");
	var indexSecond = $("#index-second");
    var overLay = $("#overlay");
    var leftEle = $("#left");
    var rightEle = $("#right");
    var bottomLeft = $("#bottomLeft");
    var bottomRight = $("#bottomRight");


    projSlide.children("li").children(".color").fadeTo("fast",0.01);
	
	
    indexSecond.jCarouselLite({btnNext: ".next",btnPrev:".prev"});
	
	$(window).resize(function() {
		if($.browser.msie){
			width = ($('body').width()-900)/2;
		}else{
			width = ($('body').width()-898)/2;
		}
		overLay.css("height", $(window).height());
		leftEle.css({width:width});
		bottomLeft.css({width:width-3});
		rightEle.css({width:width});
		bottomRight.css({width:width});
	});
	if($.browser.msie){
		width = ($('body').width()-900)/2;
	}else{
		width = ($('body').width()-898)/2;
	}
	height = $('.projSlide').height();
	overLay.css("height", $(document).height());  
	leftEle.css({width:width,height:height});
	rightEle.css({width:width,height:height});
    function fadeOutBW(){
        var colFade = $(this);
        var bwFade = $(this).siblings(".bw");
        leftEle.animate({ height:355},{queue:false});
        rightEle.animate({ height:355},{queue:false});
        bwFade.fadeTo("fast",0.001);
        indexSecond.css({overflow: "visible"}).stop().animate({ height:355});
        colFade.css({cursor:"pointer"}).fadeTo("fast",1.0);
        overLay.fadeIn("fast");
    }


    function fadeInBW(){
        //$(".hoverSide").stop().animate({height:250});
        var bwFade = $(this).siblings(".bw");
        var colFade = $(this);
        indexSecond.css({overflow:"hidden"}).stop().animate({height:250},"fast");
        leftEle.stop().animate({height:250},"fast");
        rightEle.stop().animate({ height:250},"fast");
        bwFade.fadeTo("fast",1.0);
        colFade.css({cursor:"auto"}).fadeTo("fast",0.001);
        overLay.delay(100).fadeOut();
    }

	function fadeOutSide(){
		$(this).animate({opacity:0.001},"fast");
        
	}
	function fadeInSide(){
		$(this).animate({opacity:1.0},"fast");
	}
	var centerHoverConfig = {
		interval:80,
		timeout:30,
		over: fadeOutBW,
		out: fadeInBW
	}

	var sideHoverConfig = {
		interval:80,
		timeout:30,
		over: fadeOutSide,
		out: fadeInSide
	}
	$(".color").click(function(){
		window.location = "/project/" + $(this).attr("rel");
	});
	
	
	$(".projSlide > li > img ").hoverIntent(centerHoverConfig);
	$(".sideHover").hoverIntent(sideHoverConfig);


$(function(){
    $(".next").mouseover(function() { 
            var src = $(this).attr("src");
            var replaced = "/deka/images/arrowright-hover.png";
            $(this).attr("src", replaced);
        }).mouseout(function() {
            var src = $(this).attr("src");
            var replaced = "/deka/images/arrowright.png";
            $(this).attr("src", replaced);
        });
});
  
$(function(){
    $(".prev").mouseover(function() { 
            var src = $(this).attr("src");
            var replaced = "/deka/images/arrowleft-hover.png";
            $(this).attr("src", replaced);
        }).mouseout(function() {
            var src = $(this).attr("src");
            var replaced = "/deka/images/arrowleft.png";
            $(this).attr("src", replaced);
        });
});
$(function(){
    $(".b1").mouseover(function() { 
            var src = $(this).attr("src");
            var replaced = "/deka/images/hovers/facebook-hover.jpg";
            $(this).attr("src", replaced);
        }).mouseout(function() {
            var src = $(this).attr("src");
            var replaced = "/deka/images/hovers/facebook.jpg";
            $(this).attr("src", replaced);
        });
});

$(function(){
    $(".b2").mouseover(function() { 
            var src = $(this).attr("src");
            var replaced = "/deka/images/hovers/rapid-growth-hover.jpg";
            $(this).attr("src", replaced);
        }).mouseout(function() {
            var src = $(this).attr("src");
            var replaced = "/deka/images/hovers/rapid-growth.jpg";
            $(this).attr("src", replaced);
        });
});

$(function(){
    $(".b3").mouseover(function() { 
            var src = $(this).attr("src");
            var replaced = "/deka/images/hovers/srs-hover.jpg";
            $(this).attr("src", replaced);
        }).mouseout(function() {
            var src = $(this).attr("src");
            var replaced = "/deka/images/hovers/srs.jpg";
            $(this).attr("src", replaced);
        });
});


});

