jQuery(function($) {
	$('#bcr_packshots_1').hover(
      function(){$('#bcr_packshots').css('background-position','0 -347px');}, 
      function(){$('#bcr_packshots').css('background-position','0 0');}
    );
	$('#bcr_packshots_2').hover(
      function(){$('#bcr_packshots').css('background-position','0 -694px');}, 
      function(){$('#bcr_packshots').css('background-position','0 0');}
    );
	$('#bcr_packshots_1,#bcr_packshots_2').click(function(){
    	this.target = '_blank';
  	}).add('a[rel=external],#bcr_visit a').click(function(){
    	bcrStopVid();
  	});
  	$('#bcr_blog_rotator a').live('click',function(){
		this.target = '_blank';
  		bcrStopVid();
	});
	$('#bcr_visit a').click(function(){
		var win_width = screen.width;
  		var win_height = screen.height;
  		var win_top = 0;
  		var win_left = 0;
		window.open($(this).attr('href'),'jandj_'+Math.floor(Math.random()*11),'fullscreen=yes,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+win_width+',height='+win_height+',top='+win_top+',left='+win_left);
		return false;
	});
	$('#bcr_slider_vertical').slider({
		orientation: 'vertical',
		min: -100,
		max: 0,
		change: handleChange,
        slide: handleSlide
	});
	$('.bcr_tweet').tweet({
		username: 'julieandjulia',
        count: 5,
        loading_text: 'loading tweets...'
	});
	var bcr_blog = '';
	$.get('JJ_Blogs.xml',{},function(xml){
		$('item',xml).each(function(i){
			var url = $(this).find('outboundURL').text();
			var base = $(this).find('txtDisplay').text().replace('<font color="ffffff" size="15">','').replace('</font>','');
			var clean = base.toLowerCase().replace(/\s/g,'').replace('{','').replace('}','').replace('-','');
			bcr_blog += '<p><a class="'+clean+'_button promotion" href="'+url+'">'+base+'</a></p>';
		});
		$('.bcr_pad').append(bcr_blog).cycle({
			fx: 'scrollHorz',
    		prev:   '#bcr_prev', 
    		next:   '#bcr_next', 
    		timeout: 0 
		}).css('display','block');
	});
});
function handleChange(e, ui)
{
    var maxScroll = $("#bcr_scroller").attr("scrollHeight") - $("#bcr_scroller").height();
    $("#bcr_scroller").animate({ scrollTop: -ui.value * (maxScroll / 100)}, 1000);
}
function handleSlide(e, ui)
{
    var maxScroll = $("#bcr_scroller").attr("scrollHeight") - $("#bcr_scroller").height();
    $("#bcr_scroller").attr({ scrollTop: -ui.value * (maxScroll / 100)   });
}
function bcrStopVid()
{
	var obj = swfobject.getObjectById('bcr_swf');
	if (obj) { obj.stopVideo(null); }
}