var twitterFeed;

$(document).ready(function() { 
    
    $('#specialProductContainer, #mostPopularContainer, .browseList, #pageMain').css({overflow: "visible"});
    $('#specialProductContainer, #mostPopularContainer').addClass('productRolloverList');
	$('#specialProductContainer ul li a.specialProductThumb, #mostPopularContainer ul li a.mostPopProductThumb').hover(function() {
	    thumbSrc = $('img', this).attr('src');
	    largeSrc = thumbSrc.replace(/product/, "product-large");
        $('.imageOverlay').stop();
        $(this).parent().css({overflow: "visible"});
        $(this).css({"z-index": "200"});
        buildOverlay($('img', this).attr('alt'), largeSrc, $(this).parent());
	}, function(){
	    $(this).css({"z-index": "90"});
	    $(this).parent().css({overflow: "hidden"});
	    removeOverlay($(this));
	});

    $('#homeSignNewsWrapper').hover(function() {
        $('.rolloverInner').stop(true, true);
        $('.newsSignUp .rolloverInner').css({width: '135px', height: '27px', zIndex: '200'});
        $('.newsSignUp .rolloverInner').animate({opacity: 1.0}, 100, "swing", function() {
            $('#page').mousemove(function(e){
                $('.newsSignUp .rolloverInner').css({top: e.pageY-30+'px', left: e.pageX+40+'px'});
            }); 
        });
    }, function() {
        $('.newsSignUp .rolloverInner').animate({opacity: 0.0}, 300, "swing", function() {
            $('.newsSignUp .rolloverInner').css({top: '-200px', left: '0px'});
        });
    });
    
    /* $('#signInRollBtn').hover(function() {
        $('.rolloverInner').stop(true, true);
        $('.signIn .rolloverInner').css({width: '186px', height: '63px', top: '-200px', zIndex: '200'});
        $('.signIn .rolloverInner').animate({opacity: 1.0}, 100, "swing", function() {
            $('#header').mousemove(function(e){
                $('.signIn .rolloverInner').css({top: e.pageY-73+'px', left: e.pageX+40+'px'});
            }); 
        });
    }, function() {
        $('.signIn .rolloverInner').animate({opacity: 0.0}, 300, "swing",function() {
            $('.signIn .rolloverInner').css({top: '-200px', left: '0px'});
        });
    }); */
});

function buildOverlay(imageTitle, imageRef, element) {
    $('.imageOverlayWrapper').remove();
    element.append($('<div class="imageOverlayWrapper"><div class="imageOverlayContainer"><div class="imageOverlay"><div class="imageOverlayImage"><img src="" alt=""/></div><div class="imageOverlayTitle"></div></div></div></div>'));
    $('.imageOverlayTitle').html(imageTitle);
    $('.imageOverlayImage img').attr('alt', imageTitle);
    $('.imageOverlay').css({top: "-50px"});
    $('.imageOverlay').css({left: "-290px"});
    $('.imageOverlay').css({"line-height": "14px"});
    $('.imageOverlayImage img').attr('src', imageRef).load(function() {
        $('.imageOverlay').animate({opacity: 1.0}, {queue:false, duration:100})
            .animate({left: "-295px"}, 300, "swing");
    });
}

function removeOverlay(element) {
    $('.imageOverlay').animate({left: "-300px"}, {queue:false, duration:300})
    .animate({opacity: 0.0}, 300, "swing", function() {
        $('.imageOverlayWrapper').remove();
    });
}


