var homecontent2_hidden = true;

function swapImages(){
  var active = jQuery('#slider .active');
  var next = (jQuery('#slider .active').next().length > 0) ? jQuery('#slider .active').next() : jQuery('#slider div:first');
  active.fadeOut(function(){
	active.removeClass('active');
	next.fadeIn().addClass('active');
	return false;
  });
  return false;
}
//setInterval('swapImages()', 4000);





function showTab(id){
	for(var i=1;i<4;i++){
		$("#tabs-"+i).removeClass('activetab');
		$("#tabContent_"+i).removeClass('active');
		$("#tabContent_"+i).css('display','none');
	}
	$("#tabs-"+id).addClass('activetab');
	$("#tabContent_"+id).addClass('active');
	$("#tabContent_"+id).css('display','block');
}

var viewedAllProducts = false;
function viewAllProducts(time){
	if(!time) time=500;
	if(!viewedAllProducts){
		$("#allProducts").animate({
				height: 'toggle' /* Set new height */
			}, time,function(){
				viewedAllProducts = true;
				$('#viewArrow').attr('src','/images/view_all_arrow.png');
			});
		
	}else{
		$("#allProducts").animate({
				height: 'toggle' /* Set new height */
			}, time,function(){
				viewedAllProducts = false;
				$('#viewArrow').attr('src','/images/view_all_arrow_close.png');
			});
	}
}

$(document).ready(function(){
	$(".shareThis a").css("color","#808080");
	viewAllProducts(1);
	var current = parseInt($('#homecontent2').css('height'));
	/*$('#homecontent2').attr("box_h", current+(current*.60)+'px');
	$('#homecontent2').attr("box_w", $('#homecontent2').css('width'));
	alert($('#homecontent2').css('display'));
	$('#homecontent2').css('height','0px');
	$('#homecontent2').css('display','block');
	$('#homecontent2').css('overflow','hidden');
	*/
	//$("#homecontent2").animate({height: 'toggle'}, 40);
	
	/* var ht = parseInt($('.content21').css('height'));
	$('.content21').attr("box_h", ht+(ht*.20)+'px');
			
	$('.content21').css('height','0px');
	$('.content21').css('display','block');
	$('.content21').css('overflow','hidden'); */
	
	//colorbox
	$(".videoLink1").colorbox({width:"685px", inline:true, href:"#bbdirect_videos1"});
	$(".videoLink2").colorbox({width:"685px", inline:true, href:"#bbdirect_videos2"});
	$(".videoLink3").colorbox({width:"685px", inline:true, href:"#bbdirect_videos3"});
	$(".videoLink4").colorbox({width:"685px", inline:true, href:"#bbdirect_videos4"});
	$(".videoLink5").colorbox({width:"685px", inline:true, href:"#bbdirect_videos5"});
	$(".videoLink6").colorbox({width:"685px", inline:true, href:"#bbdirect_videos6"});
	$(".videoLink7").colorbox({width:"685px", inline:true, href:"#bbdirect_videos7"});
	$(".videoLink8").colorbox({width:"685px", inline:true, href:"#bbdirect_videos8"});
	$(".videoLink9").colorbox({width:"685px", inline:true, href:"#bbdirect_videos9"});
	$(".videoLink10").colorbox({width:"685px", inline:true, href:"#bbdirect_videos10"});
	
	$("p").each(function(){
	var $this = $(this);
	if ($this.text() == " " || $this.text() == "&nbsp;" || $this.text() == "" || $this.text() == " &nbsp; "){
			$this.remove();
		}
	});
	
	$('.readMoreForContent2').click(function(e){
		e.preventDefault();
		var curimg  = $('.readMoreForContent2 img').attr('src');
		$('#homecontent2').slideToggle('slow',function() {
			if(homecontent2_hidden) {
				$('.readMoreForContent2 img').attr('src','/images/readmore_arrow_open.png');
				homecontent2_hidden = false;
			} else {
				$('.readMoreForContent2 img').attr('src','/images/readmore_arrow.jpg');
				homecontent2_hidden = true;
			}
			
		});
	}); 
});

function positionPromotion(){
	var pLeft = parseInt($('#promotion').css('left'));
	var wW = $(window).width();
	if(wW<1214)
		$('#promotion').css('left',1114);
	else{
		$('#promotion').css('left',wW-131+'px');
	}
}
setInterval ( "positionPromotion()", 500 );


/*function showContent2(){
	if(homecontent2_hidden){
		/*$("#homecontent2").css('overflow','auto');
		$("#homecontent2").css('display','inline');
		var open_height = $("#homecontent2").attr("box_h");
		$("#homecontent2").animate({height: parseInt(open_height)+'px'}, 440);
		
		$("#homecontent2").animate({height: 'toggle'}, 440);
		homecontent2_hidden = false;
		$('.readMoreForContent2 img').attr('src','/images/readmore_arrow_open.png');
	}else{
		//$("#homecontent2").animate({height:'0px'},440);
		$("#homecontent2").animate({height: 'toggle'}, 40);
		homecontent2_hidden=true;
		$('.readMoreForContent2 img').attr('src','/images/readmore_arrow.jpg');
	}
}*/

var tab=new Array();
tab[0] = false;
tab[1] = false;
tab[2] = false;
tab[3] = false;

//don't overuse animate, if the intention is to slide a content down..try using slideDown and slideUp
//animate is pretty slow that sometimes it doesn't work
function toggleTab(id){
	if(tab[id] == false){
//		$('.content2'+id).css('overflow','auto');
		//var open_height = $('.content2'+id).attr("box_h");
		// $('.content2'+id).animate({height: open_height}, 440);
		$('.content2'+id).slideDown(440);
		$('#tabContent_'+id+' img').attr('src','/images/readmore_arrow_open.png');
		tab[id] = true;
	}else{
		// $('.content2'+id).animate({height: '0px'}, 440);
		$('.content2'+id).slideUp(440);
		$('#tabContent_'+id+' img').attr('src','/images/readmore_arrow.jpg');
		tab[id] = false;
	}
}

function toggleContent22(){
	if(tab[2] != false) return;
	var ht = parseInt($('.content22').css('height'));
	$('.content22').attr("box_h", ht+(ht*.20)+'px');

	/* $('.content22').css('height','0px');
	$('.content22').css('display','block');
	$('.content22').css('overflow','hidden'); */
	//tab[2] = true;
}
function toggleContent23(){
	if(tab[3] != false) return;
	var ht = parseInt($('.content23').css('height'));
	
	$('.content23').attr("box_h", ht+(ht*.20)+'px');
	
	/* $('.content23').css('height','0px');
	$('.content23').css('display','block');
	$('.content23').css('overflow','hidden'); */
	//tab[3] = true;
}
	
