
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0; }

function ClearSearch()
{
if (searchbox.q.value == 'Search Whitworth')
	{
		searchbox.q.value = '';
	}
}

function ClearSearch(control, textvalue)
{
if (control.value == textvalue)
	{
		control.value = '';
	}
}


function ClearSearch2(boxtext)
{
if (searchbox2.q.value == boxtext)
	{
		searchbox2.q.value = '';
	}
}
function ChangeColor(button,color) 
{
button.style.backgroundColor = color;

return true;
} 





//



$(function(){
	if ($('#featureMain .slide').size() > 1) {
		// Create slideshow
		$("#featureMain").slideshow({ autoRun:true, video:V, callback:function(slide){stopVideo(slide); resetSlide(slide);} });
	}

});


var V = { state:null };
// Automatically called by video when state changes
function getUpdate(type, pr1, pr2, swf) {
	if (type == 'state') { V.state = pr1; }
}

// This is mostly for IE
function stopVideo(slide) {
	//If a video has been playing, stop it
	if (slide.find(".paneVideo").css('display') == "block") {
		slide.find(".paneVideo .video").html("");
	}	
}

function resetSlide(slide) {
	if (slide.get(0).id == "OneQuestion" || slide.get(0).id == "Why Whitworth" || slide.get(0).id == "Campus Tour" || slide.get(0).id == "Student Profiles" || slide.get(0).id == "Student Profiles") {
		slide.find(".paneLead").show();
		slide.find(".paneVideo").hide();
	}
}

(function($) {
	$.fn.slideshow = function(options) {
		var defaults = { 
			nav:"> .navSlides", 
			autoRun:false, 
			interval:8000, 
			video:{state:null}, 
			callback:null 
		};
	  // Extend our default options with those provided.
	  var options = $.extend(defaults, options);
		var w = this.width();
		var nav = $("<ul></ul>").appendTo(this.find(options.nav));
		var container = this.find(".slides");
		var slides = this.find(".slide");
		var activeSlide = 0;
		var slideInterval;
		// Set up auto run, if enabled
		if (options.autoRun && !(/iPhone/i.test(navigator.userAgent))) {
			var progressBar = createProgressBar();
			startAutoRun();
			this.hover(stopAutoRun, function(){ slideInterval = setTimeout(startAutoRun, 2000) });
		}
		// Set container width to sum of slide widths, plus a little extra
		container.width((w * slides.length) + 4);
		
		// Create Navigation
		createNavItem("prev", "Previous").click(function(){
			slidePrev(); return false; 
		});
		slides.each(function(i) {
			createNavItem("", i + 1).click(function(){ 
				slideTo(i); return false; 
			});
		});
		createNavItem("next", "Next").click(function(){
			slideNext(); return false;
		});

		// Activate first item by default
		activateSlide(1);
		hilightNav(1);
		
		// Functions
		function createNavItem(className, text) {
			return $("<li><a href='#'>"+text+"</a></li>").addClass(className).appendTo(nav);
		}		
		function slideTo(id) {
			if (options.callback != null) { options.callback.call(this, slides.eq(activeSlide)); };
			slides.removeClass("active");
			activeSlide = id;
			hilightNav(id + 1);
			container.animate({left:(-w * id)}, 300, "linear", function(){ activateSlide(id+1); });
		}		
		function slideNext() {
			slideTo((activeSlide + 1) % slides.length);
		}		
		function slidePrev() {
			slideTo((activeSlide + (slides.length-1)) % slides.length);
		}
		function hilightNav(id) {
			nav.find("li").removeClass("active");
			nav.find(":nth-child("+(id+1)+")").addClass("active");
		}		
		function startAutoRun() {
			// Prevent auto-run if a video pane is active
			if (slides.eq(activeSlide).find(".paneVideo").css('display') == "block") return false;
			
			runProgressBar();
			slideInterval = setInterval(function(){ runProgressBar(); }, options.interval);
		}		
		function stopAutoRun() {
			clearInterval(slideInterval);
			resetProgressBar();
		}		
		function createProgressBar() {
			return $("<div class='progressBar'><div class='bar'></div></div>").insertAfter(nav);
		}		
		function runProgressBar() {
			progressBar.find(".bar").animate({width:100}, (options.interval-1000), "linear", function(){ progressBar.find(".bar").width(0); slideNext(); });
		}		
		function resetProgressBar() {
			progressBar.find(".bar").stop().width(0);
		}		
		function activateSlide(id) {
			slides.eq(id-1).addClass("active");
		}
	};
})(jQuery);



var theImages = new Array() 
theImages[0] = '/~Images/homepage/1.jpg'
theImages[1] = '/~Images/homepage/2.jpg'
theImages[2] = '/~Images/homepage/3.jpg'
theImages[3] = '/~Images/homepage/4.jpg'
theImages[4] = '/~Images/homepage/5.jpg'
theImages[5] = '/~Images/homepage/6.jpg'
theImages[6] = '/~Images/homepage/7.jpg'
theImages[7] = '/~Images/homepage/8.jpg'
theImages[8] = '/~Images/homepage/9.jpg'
theImages[9] = '/~Images/homepage/10.jpg'
theImages[10] = '/~Images/homepage/11.jpg'
theImages[11] = '/~Images/homepage/12.jpg'

var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'" alt="Why Whitworth">');
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


// JCarousel - http://sorgalla.com/jcarousel/
function scrollercarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
    jQuery('#scrollercarousel').jcarousel({
        vertical: true,
		auto: 0,
        wrap: 'last',
		scroll: 3,
        initCallback: scrollercarousel_initCallback
    });
});


// Clear default form field values on focus - KGB 2008
	function resetField(field, reset) {
		var vd = field.defaultValue;
		if (field.value == (reset ? "" : vd)) {
			field.value = reset ? vd : "";
		}
	}



	function newWindow2(windowName){
	var activityWindow = window.open(windowName, "", "width=690, height=400")
	activityWindow.focus() }
