//Checks to see if current user is using iphone/ipad/ipod
function iphoneCheck(){
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
		iphone=true;
	}
	else{
		iphone=false;
	}
}
// helper for setUpScrollPanes() function renables the up arrow if the user clicks down or content is above it.
function rebindUpArrow(selector) {
	selector.find('.nav_arrow_up').bind('mousedown', function(e) {
		e.preventDefault();
		if($j(this).hasClass('customer')){
			$j('#hsb_brand_sect_customer .nav_arrow_up').trigger('mousedown');
	}
	selector.find('.nav_arrow_down').removeClass('nav_arrow_down_disabled');
	var scrollObject =selector.find('.hsb_brand_sect_body_scroller');
	var scrollHeight = scrollObject.height();
	var contentHeight = scrollObject.find('.hsb_brand_sect_content').height();
	var thisObject = $j(this);
	var scrollerInterval = setInterval(function(){
	var scrollVar = scrollObject.scrollTop();
	if(scrollVar== 0){
		selector.find('.nav_arrow_up').addClass('nav_arrow_up_disabled')
		clearInterval(scrollerInterval);
		scrollObject.stop(true);
		thisObject.unbind('mouseup');
	}
	scrollObject.animate({'scrollTop' : '-=' + 5}, 1);
	}, 1);
	thisObject.bind('mouseup mouseleave', function(e) {
		if($j(this).hasClass('customer')){
		$j('#hsb_brand_sect_customer .nav_arrow_up').trigger('mouseup');
	}
	clearInterval(scrollerInterval);
	scrollObject.stop(true);
	thisObject.unbind('mouseup mouseleave');
	});
	return false;
	});
}
// helper for setUpScrollPanes() function renables the down arrow if the user clicks down or content is below it.
function rebindDownArrow(selector) {
	selector.find('.nav_arrow_down').bind('mousedown', function(e) {
		e.preventDefault();
		if($j(this).hasClass('customer')){
			$j('#hsb_brand_sect_customer .nav_arrow_down').trigger('mousedown');
	}
	selector.find('.nav_arrow_up').removeClass('nav_arrow_up_disabled');
	var scrollObject =selector.find('.hsb_brand_sect_body_scroller');
	var scrollHeight = scrollObject.height();
	var contentHeight = scrollObject.find('.hsb_brand_sect_content').height();
	var thisObject = $j(this);
	var scrollerInterval = setInterval(function(){
	var scrollVar = scrollObject.scrollTop();
	if(scrollHeight+scrollVar == contentHeight){
		selector.find('.nav_arrow_down').addClass('nav_arrow_down_disabled')
		clearInterval(scrollerInterval);
		scrollObject.stop(true);
		thisObject.unbind('mouseup mouseleave');
	}
	scrollObject.animate({'scrollTop' : '+=' + 5}, 1);
	}, 1);
	thisObject.bind('mouseup mouseleave', function(e) {
		if($j(this).hasClass('customer')){
		$j('#hsb_brand_sect_customer .nav_arrow_down').trigger('mouseup');
	}
	clearInterval(scrollerInterval);
	scrollObject.stop(true);
	thisObject.unbind('mouseup');
	});
	return false;
	});
}

//Sets up scroll panes on any module that requires scrolling page content. Takes height of container and amount of elements to generate pages.
function setUpScrollPanes() {
$j('.hsb_brand_sect_body_scroller').each(function(){
$j(this).scrollTop(0);
});
var contentScroller = $j('.hsb_brand_sect_body_scroller', '#hsb_content');
$j('.content_module', '#hsb_content').each(function() {
rebindDownArrow($j(this));
rebindUpArrow($j(this))
});
var disableArrows = contentScroller.filter(function() {
var height=$j(this).find('.hsb_brand_sect_content').height();
var content_height =$j('.hsb_brand_sect_content').find('.btn_215_100_left').height();
var defaul_scroll_height  = content_height * 2;
if(defaul_scroll_height < height) {
return false;
} else {
return true;
}
}).parent().parent();

$j(disableArrows).find('.nav_arrow_down').addClass('nav_arrow_down_disabled').unbind('mousedown');
$j(disableArrows).find('.nav_arrow_up').addClass('nav_arrow_up_disabled').unbind('mousedown');
$j('.nav_arrow_up', '#hsb_content').addClass('nav_arrow_up_disabled').data('active', false);
}

