// JavaScript Document

title = new Array(10);
title[1] = "Sandy in the Pen Pals Program, all the way on the left.";
title[2] = "Sandy with her guardian, Mr. Frank Commins.";
title[3] = "Good girl, Sandy!";
title[4] = "Sandy with Mr. Larry Carson, coordinator of the Marin Humane Society Pen Pals Program.";
title[5] = "Sandy with the author, Dr. Nancy Kay.";
title[6] = "Cover girl!";
title[7] = "Watching over her garden.";
title[8] = "At home in San Rafael, California.";

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function previousPic(src) {
	var MAX = 8;
	var splitURL1 = src.split("sandy"); // Gets pic number after "sandy"
	var splitURL2 = splitURL1[1].split("."); //Gets pic number before ".jpg"
	var picNumber = splitURL2[0];
	if (picNumber > 1)
		picNumber--;
	else
		picNumber=MAX;
	var url = "Images/sandy" + picNumber + ".jpg";
	document.sandy.src = url;
	document.getElementById('caption').innerHTML = title[picNumber];
}

function nextPic(src) {
	var MAX = 8;
	var splitURL1 = src.split("sandy"); // Gets pic number after "sandy"
	var splitURL2 = splitURL1[1].split("."); //Gets pic number before ".jpg"
	var picNumber = splitURL2[0];
	if (picNumber < MAX)
		picNumber++;
	else
		picNumber=1;
	var url = "Images/sandy" + picNumber + ".jpg";
	document.sandy.src = url;
	document.getElementById('caption').innerHTML = title[picNumber];
}

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function inputClick(input) {
	if (input.value == input.alt) {
		input.value = '';	
	}
}

function inputClickOff(input) {
	if (input.value == '') {
		input.value = input.alt;	
	}
}

function onCatChange() {
	var dropdown = document.getElementById("cat");
	if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
		location.href = "http://speakingforspot.com/blog/?cat="+dropdown.options[dropdown.selectedIndex].value;
	}
}
