//--Baas interactive--//

var $j = jQuery.noConflict();

    $j(function () {
        $j('.bubbleInfo').each(function () {
            var distance = 75;
            var time = 250;
            var hideDelay = 500;

            var hideDelayTimer = null;

            var beingShown = false;
            var shown = false;
            var trigger = $j('.trigger', this);
            var info = $j('.popup', this).css('opacity', 0);


            $j([trigger.get(0), info.get(0)]).mouseover(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                if (beingShown || shown) {
                    // don't trigger the animation again
                    return;
                } else {
                    // reset position of info box
                    beingShown = true;

                    info.css({
                        top: 110,
                        left: 197,
                        display: 'block'
                    }).animate({
                        left: '-=' + distance + 'px',
                        opacity: 1
                    }, time, 'swing', function() {
                        beingShown = false;
                        shown = true;
                    });
                }

                return false;
            }).mouseout(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                hideDelayTimer = setTimeout(function () {
                    hideDelayTimer = null;
                    info.animate({
                        opacity: 0
                    }, time, 'swing', function () {
                        shown = false;
                        info.css('display', 'none');
                    });

                }, hideDelay);

                return false;
            });
        });
    });
    




//fancy inline ajax content
$j(document).ready(function(){
        $j("a#inline").fancybox({
            'frameWidth': 1000,
            'frameHeight': 600
        });

        $j("a#inline2").fancybox({
            'frameWidth': 1000,
            'frameHeight': 130
        });

//opacity home featured
$j("#home_excerpt, #featured_work_img").css("opacity", 0.9);


//corner on blocks	
		$j("#homepage li, .home_featured, #respond, .thread-even, .thread-alt, .thumb_work, div.pro-player-container, .work_featured, .blog_front_left, .blog_front_right").corner("5px");
		
//fading flickr images
		$j(".footer_flickr").fadeTo("slow", 0.4); // This sets the opacity of the thumbs to fade down to 30% when the page loads
		$j(".footer_flickr").hover(function(){
		$j(this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
		  },function(){
		$j(this).fadeTo("slow", 0.4);
		 // This should set the opacity back to 30% on mouseout
							   	});
//fading background
		$j("#homepage li, .thumb_work").hover(function () {
			$j(this).animate({
			backgroundColor: "#e4e4e4"
		  }, 200 );
		  },
		  function () {
			$j(this).animate({
			backgroundColor: "#fff"
		  }, 200 );      }
		);

//sliding panel latest posts		  
		//Get the height of the first item
		$j('#mask').css({'height':$j('#panel-1').height()});	
		
		//Calculate the total width - sum of all sub-panels width
		//Width is generated according to the width of #mask * total of sub-panels
		$j('#panel').width(parseInt($j('#mask').width() * $j('#panel div').length));
		
		//Set the sub-panel width according to the #mask width (width of #mask and sub-panel must be same)
		$j('#panel div').width($j('#mask').width());
		
		//Get all the links with rel as panel
		$j('a[rel=panel]').click(function () {
	
		//Get the height of the sub-panel
		var panelheight = $j($j(this).attr('href')).height();
		
		//Set class for the selected item
		$j('a[rel=panel]').removeClass('selected');
		$j(this).addClass('selected');
		
		//Resize the height
		$j('#mask').animate({'height':panelheight},{queue:false, duration:500});			
		
		//Scroll to the correct panel, the panel id is grabbed from the href attribute of the anchor
		$j('#mask').scrollTo($j(this).attr('href'), 800);		
		
		//Discard the link default behavior
		return false;
		});

//recent work sliding panel
		$j('#loopedSlider').loopedSlider();
		
		$j(".innerSearch input.searchField ").focus(function () {$j(".innerSearch").css("backgroundPosition","0 -30px");});
		$j(".innerSearch input.searchField ").blur(function () {$j(".innerSearch").css("backgroundPosition","0 0");});
		
		$j("input.inputfc").focus(function () {$j(this).parent("p.inputfc").css("backgroundPosition","0 -30px");});
		$j("input.inputfc").blur(function () {$j(this).parent("p.inputfc").css("backgroundPosition","0 0");});
		
		$j("input.big_inputfc").focus(function () {$j(this).parent("p.big_inputfc").css("backgroundPosition","0 -60px");});
		$j("input.big_inputfc").blur(function () {$j(this).parent("p.big_inputfc").css("backgroundPosition","0 0");});
		
		$j(".comment_form form textarea").focus(function () {$j("#div_ctextarea").css("backgroundPosition","0 -119px");});
		$j(".comment_form form textarea").blur(function () {$j("#div_ctextarea").css("backgroundPosition","0 0");});
		
		$j("input.submitComment").hover(function () {$j(this).css("backgroundPosition","0 -31px");},function () {$j(this).css("backgroundPosition","0 0");});
		
		$j("a.sideImgHolder span").hover(function () {$j(this).css("backgroundPosition","0 0");},function () {$j(this).css("backgroundPosition","0 -105px");});
		
		$j(".flickerizedImgs a").prepend("<span></span>");
		$j(".flickerizedImgs a span").hover(function () {$j(this).css("backgroundPosition","0 -101px");},function () {$j(this).css("backgroundPosition","0 0");});
		
		$j("textarea").css("resize","none")
		 
		 $j(function(){
			$j('.flickerizedImgs a').click(function(){
			window.open(this.href);
			return false;
			});
		});
		

	}); 

