$(function(){
//*************************************************( Jacob's Liquid Scroller )***>	   
var number = $("#partners").css('left');
var distance = parseFloat(number)
var autoscrollv = true;
var scrolling = false;
var container = $("#partcon").width()
var maxscroll = 0;

autoScroll();

function maxScroll(){
	container = $("#partcon").width()
	maxscroll = 1970 - container;
};

function autoScroll(){
	maxScroll();
	number = $("#partners").css('left');
	distance = parseFloat(number);
	if (autoscrollv == true && distance <= 0 && distance >= maxscroll * -1) {$("#partners").animate({"left":  "-=1px"}, 1, function(){ autoScroll();
		});
	}; 
};
    $("#Right").mousedown(function(){ 
		autoscrollv = false;
        	scrolling = true; 
       			startScrollingright($("#partners"), "-=10px");
	}).mouseup(function(){ 
		scrolling = false; 
	});
	$("#Left").mousedown(function(){ 
		autoscrollv = false;
        	scrolling = true; 
        		startScrollingleft($("#partners"), "+=10px"); 
	}).mouseup(function(){ 
        scrolling = false; 
    }); 
	
function startScrollingleft(obj, param) {
maxScroll();
number = $("#partners").css('left');
distance = parseFloat(number);
if (distance <= 0){
	if (!scrolling) {obj.stop();
		} else { obj.animate({"left": param}, 1, function(){ if (scrolling) { startScrollingleft(obj, param);
		} });
	}; 
};
};

function startScrollingright(obj, param) {
number = $("#partners").css('left');
distance = parseFloat(number);
maxScroll();
if (distance >= maxscroll * -1){
	if (!scrolling) {obj.stop();
		} else { obj.animate({"left": param}, 1, function(){ if (scrolling) { startScrollingright(obj, param);
		} });
	};
};
};

//*************************************************( Jacob's Sweet SUBNAV )***>

var t1state = 0;
var t2state = 0;
var t3state = 0;
var t4state = 0;

$('#toggle1').click(function() {
  if(t1state == 0){
  $('#cont1').slideDown('fast', function() {
    $("#toggle1 img").attr("src", "images/down.gif");
		t1state = 1;
  });
  }else{
	$('#cont1').slideUp('fast', function() {});
	$("#toggle1 img").attr("src", "images/out.gif");
		t1state = 0;
  }
});

$('#toggle2').click(function() {
  if(t2state == 0){
  $('#cont2').slideDown('fast', function() {
    $("#toggle2 img").attr("src", "images/down.gif");
		t2state = 1;
  });
  }else{
	$('#cont2').slideUp('fast', function() {});
	$("#toggle2 img").attr("src", "images/out.gif");
		t2state = 0;
  }
});

$('#toggle3').click(function() {
  if(t3state == 0){
  $('#cont3').slideDown('fast', function() {
    $("#toggle3 img").attr("src", "images/down.gif");
		t3state = 1;
  });
  }else{
	$('#cont3').slideUp('fast', function() {});
	$("#toggle3 img").attr("src", "images/out.gif");
		t3state = 0;
  }
});

$('#toggle4').click(function() {
  if(t4state == 0){
  $('#cont4').slideDown('fast', function() {
    $("#toggle4 img").attr("src", "images/down.gif");
		t4state = 1;
  });
  }else{
	$('#cont4').slideUp('fast', function() {});
	$("#toggle4 img").attr("src", "images/out.gif");
		t4state = 0;
  }
});
//*************************************************( Jacob's Liquid Scroller Patch 1.0 )***>

$(function () {  $('#Left').hover(function () {    this.src = 'images/larrow.png';  }, function () {    this.src = 'images/larrow-mo.png';  });});

$(function () {  $('#Right').hover(function () {    this.src = 'images/rarrow.png';  }, function () {    this.src = 'images/rarrow-mo.png';  });});

//*************************************************( Jacob's Liquid Scroller Patch 1.1 )***>

function checker(){
	window.setInterval(function(){number = $("#partners").css('left');distance = parseFloat(number);maxScroll();
	if (distance * -1 -20 > maxscroll){
		$("#partners").css('left', maxscroll * -1 - 10 + "px");
	};
	},1); 
};

checker();

});


