/* --- Rotating partner logos --- */

var rotation_speed = 4400;		// Milliseconds between auto-rotations

var rotation_timer = null;		// Rotation timer ID
var rotation_manuallystopped = false;	// Is timer manually stopped
var rotation_animating = false;	// Flag if rotating (to avoid overlapping)

// Partner logo auto-rotation
function startrotation(){
	$("#rotater-pause").removeClass("active"); // Unset paused image

	rotation_timer = window.setInterval('rotatepartners()', rotation_speed);
}
function stoprotation(){
	$("#rotater-pause").addClass("active"); // Set paused image

	window.clearInterval(rotation_timer);
	rotation_timer = null;
}
function rotatepartners() {
	$("#rotater-next").click();
}

// Page initilization
$(document).ready(function(){

	if (!document.getElementById("allpartners")) { return false; }

	// Firefox opacity fix
	if ($.browser.mozilla && parseInt(navigator.appVersion) == 5) {
		$("body").css("opacity", "0.9999");
	}

	// Add class for scripted interface
	$("#allpartners").addClass("scripted");

	// Pick randomize first item
	var numitems = $("#allpartners>.block").size();
	var randomstart = Math.floor(Math.random()*numitems);
	$("#allpartners>.block:not(:eq(" + randomstart + "))").hide();

	// Insert rotater triggers
	$("#allpartners").append('<div id="ctrls"><div id="back"><a href="#" id="rotater-back">&#60;</a></div><div id="next"><a href="#" id="rotater-next">&#62;</a></div></div>');

	// Start auto-rotate
	startrotation();

	// Rotator actions
	$("#rotater-back").click(function(){

		// Get current and next item
		var $current = $("#allpartners>.block:visible");
		var $next = $current.prev(".block");

		// Loop back to first
		if ($next.size() == 0) {
			$next = $("#allpartners>.block:last");
		}

		// Fade to next item
		if (!rotation_animating) {
			rotation_animating = true;
			$current.fadeOut(300, function(){
				$next.fadeIn(400, function(){
					rotation_animating = false;

					// IE7 fading bug
					if ($.browser.msie) { this.style.removeAttribute("filter"); }
				});
			});
		}

		return false;
	});

	$("#rotater-next").click(function(){

		// Get current and next item
		var $current = $("#allpartners>.block:visible");
		var $next = $current.next(".block");

		// Loop back to first
		if ($next.size() == 0) {
			$next = $("#allpartners>.block:first");
		}

		// Fade to next item
		if (!rotation_animating) {
			rotation_animating = true;
			$current.fadeOut(200, function(){
				$next.fadeIn(400, function(){
					rotation_animating = false;
				});
			});
		}

		return false;
	});

	$("#rotater-pause").click(function(){

		if (rotation_timer == null) {

			// Start timer
			rotation_manuallystopped = false;
			startrotation();

		} else {

			// Stop timer
			rotation_manuallystopped = true;
			stoprotation();

		}

		return false;
	});

	// Also pause on item hover
	$("#allpartners>.block").hover(function(){

		stoprotation();

	}, function(){
		// Only restart if not manually stopped
		if (!rotation_manuallystopped) {
			startrotation();
		}
	});

});





/*
	Share Our Strength Holiday scripts (utilizing jQuery 1.2.6)
	Developed by Saforian
*/

/* --- Initialize page --- */
$(document).ready(function(){


/*
this clears the value of prepopulated form fields as long as they have a class "swaptextbox"
*/

var swap_text_boxes = [];

function init_swap_text_boxes(){
  //Store the default value for each box
  $('input[type=text][value].swaptextbox').each(function() {
    swap_text_boxes[$(this).attr('id')] = $(this).attr('value');
  });
  //Add focus and blur events to set or clear the value
  $('input[type=text][value].swaptextbox').bind('focus', function() {
    if($(this).val() == swap_text_boxes[$(this).attr('id')]) {
      $(this).val('');
    }
  });
  $('input[type=text][value].swaptextbox').bind('blur', function() {
    if($(this).val() == '') {
      $(this).val(swap_text_boxes[$(this).attr('id')]);
    }
  });
} 

init_swap_text_boxes();

//onfocus="if(this.value=='your email address here'){this.value=''};" onblur="if(this.value==''){this.value='your email address here'};

$('#footbox').after('<div id="footbtm"></div>');



});
