//Specify the slider's slide speed (larger is slower)

var numSlides = 13;
var lastSlide = numSlides - 1;

var slidespeed = 3;
var slidesteps = 126 / slidespeed;

var hex = 255;

var sideImgOpac = 35;

window.onload = PageLoad;

var index = new Array(15, 13, 14, 3, 2, 1, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12);

var textFading = false;
var opacChanging = false;
var leftSliding = false;
var rightSliding = false;

var opacStart = 0;
    var opacEnd = 100;
    var speed = 5;      //Change speed to control fading speed - larger number means slower
    var timer = 0;

var slides = new Array();
slides[1] = "images/portfolio/Image08_thumb.jpg";
slides[0] = "images/portfolio/Image02_thumb.jpg";
slides[2] = "images/portfolio/Image03_thumb.jpg";
slides[3] = "images/portfolio/Image04_thumb.jpg";
slides[4] = "images/portfolio/Image05_thumb.jpg";
slides[5] = "images/portfolio/Image06_thumb.jpg";
slides[6] = "images/portfolio/Image07_thumb.jpg";
slides[7] = "images/portfolio/Image01_thumb.jpg";
slides[8] = "images/portfolio/Image09_thumb.jpg";
slides[9] = "images/portfolio/AP_thumb.png";
slides[10] = "images/portfolio/DECO_thumb.png";
slides[11] = "images/portfolio/GPA_thumb.png";
slides[12] = "images/portfolio/TwoFish_thumb.png";
slides[13] = "images/portfolio/Image10_thumb.png";
slides[14] = "images/portfolio/Image11_thumb.png";
slides[15] = "images/portfolio/Image12_thumb.png";

var bigImages = new Array();
bigImages[1] = 'images/portfolio/Image08_main.jpg';
bigImages[0] = 'images/portfolio/Image02_main.jpg';
bigImages[2] = 'images/portfolio/Image03_main.jpg';
bigImages[3] = 'images/portfolio/Image04_main.jpg';
bigImages[4] = 'images/portfolio/Image05_main.jpg';
bigImages[5] = 'images/portfolio/Image06_main.jpg';
bigImages[6] = 'images/portfolio/Image07_main.jpg';
bigImages[7] = 'images/portfolio/Image01_main.jpg';
bigImages[8] = 'images/portfolio/Image09_main.jpg';
bigImages[9] = 'images/portfolio/AP_main.png';
bigImages[10] = 'images/portfolio/DECO_main.png';
bigImages[11] = 'images/portfolio/GPA_main.png';
bigImages[12] = 'images/portfolio/TwoFish_main.png';
bigImages[13] = 'images/portfolio/Image10_main.jpg';
bigImages[14] = 'images/portfolio/Image11_main.jpg';
bigImages[15] = 'images/portfolio/Image12_main.jpg';

var txtArray = new Array();
txtArray[0] = "<b>FOSA (Fairfield Outreach and Sponsorship Association)</b> is a non-profit outreach sponsorship group which supports a children\'s center in Zimbabwe, Africa. The organization had an existing Web site but desired an improved design along with several other additional points of functionality. The new site features an online donation form, detailed information about the children and staff, and a more user-friendly system for supporting children.<p><p><a target='_blank' href=\"http://\www.fosakids.org\">Visit The FOSA Site</a>";
txtArray[1] = "<b>The Masters Study</b> The Master’s Study is a classical home school program located on the north side of Indianapolis, Indiana that studies the liberal arts from a historically Christian perspective. The new site features a complete redesign with fresh colors as well as bringing a more personal feel to the site with prominent pictures of the students.<p><p><a target='_blank' href=\"http://www.themastersstudy.org/index.html\">Visit The Master's Study Site</a>";
txtArray[2] = "<b>Families Preventing Birth Defects</b> is a non-profit organization which seeks to notify individuals of birth defects and methods of prevention. Last summer, the organization lacked a Web presence so the project objective was to create an online location for information about birth defects to be made public. The Families Preventing Birth Defects site was the first project completed by the Fellows.<p><p><a target='_blank' href=\"http://fpbd.org\">Visit The FPBD Site</a>";
txtArray[3] = "<b>Indiana Crop Improvement Association</b> is an organization that performs quality assurance, lab testing, and field services for customers in the seed, grain, food, and related industries.  The company was searching for a new and improved site which would display updated content in a more organized and visually appealing format. The site also contains more information about their products for user viewing. The main objective of the site was to improve the marketing aspect of the business with information more readily available for users.<p><p>Indiana Crop Site Coming Soon!";
txtArray[4] = "<b>Trash Talk</b> is a business which circulates newsletters around the country that inform adults and children of waste management and recycling. The project was a redesign of the former Trash Talk site and included added functionality such as newsletter samples to the site.<p><p><a target='_blank' href=\"http://trashtalk.com\">Visit The Trash Talk Site</a>";
txtArray[5] = "<b>The Summit Academy</b>, a school located in Indianapolis, seeks to teach its students through a classical education.  The school had been utilizing their existing site for several years but desired a better marketing tool for prospective students and their families.  The objective of the project was to create a site for Summit which is more visually appealing and user-friendly.   <p><p><a target='_blank' href=\"http://thesummitacademy.com\">Visit The Summit Academy Site</a>";
txtArray[6] = "<b>Environmental Water Solutiosn</b> Environmental Water Solutions is a small business that specializes in the sale of water treatment systems such as water softeners and water conditioning systems.  They are a locally owned and operated company that provides sales, installation, and service of these systems.  Previously, the company was without a Web presence so a simple, clean, and professional site where they could direct their clients was desired.     <p><p><a target='_blank' href=\"http://ewstreatment.com\">Visit The Environmental Water Solutions Site</a>";
txtArray[7] = "<b>Benjamin Hunter</b> was elected to the Indianapolis City/County Council last November and was seeking a new site which would display the purpose of his term in office was well as key issues he is seeking to address. The site also includes a spreadsheet for users to submit their complaints and concerns for Ben's notification. The main purpose of the site is to keep Indiana residents informed about key government issues throughout Ben\'s term in office.<p><p><a target='_blank' href=\"http://\www.benjaminhunter.org/main/index.html\">Visit Benjamin Hunter's Site</a>";
txtArray[8] = "<b>The Ambassador House and Gardens, Inc</b> is an organization dedicated to the preservation and restoration of the Ambassador House and Gardens in the Fishers area.  The goal of the Ambassador House organization is to create an educational center and museum that serves as a way for visitors to learn about the history of Fishers.  The house was seeking a Web site to inform readers about the restoration work on their historic landmark. <p><p><a target='_blank' href=\"http://\www.ambassadorhouse.org/\">Visit The Ambassador House and Gardens, Inc Site</a>";
txtArray[9] = "Coming Soon";
txtArray[10] = "Coming Soon";
txtArray[11] = "Coming Soon";
txtArray[12] = "Coming Soon";
function CacheImage(ImageSource)
{
	var ImageObject = new Image();
	ImageObject.src = ImageSource;
}

function SetSliderHTML()
{
    var sliderHTML;
    var cross_slide = document.getElementById("slider");

    cross_slide.style.left = "-126px";
    
    sliderHTML = "<nobr>";
    for (i = 0; i < numSlides; i++) {
        sliderHTML += '<img id="thumb' + i + '" src="' + slides[index[i]] + '" border="0" />';
    }
    
    sliderHTML += "</nobr>";
    
    cross_slide.innerHTML = sliderHTML;
}

function PageLoad()
{
    SetSliderHTML();

    changeOpac(sideImgOpac, 'thumb1');
    changeOpac(100, 'thumb2');
    changeOpac(sideImgOpac, 'thumb3');

	for (i = 0; i < numSlides; i++) {
		CacheImage(bigImages[i]);
	}

    SetMainImage();
}

function FadeText()
{
    document.getElementById('txtbox').innerHTML = txtArray[index[2]];

    if(hex > 0) { //If color is not black yet
        hex -= 11; // increase color darkness
        document.getElementById('txtbox').style.color = "rgb("+hex+","+hex+","+hex+")";
        setTimeout("FadeText()", 20); 
    }
    else
	{
        hex=255 //reset hex value
		textFading = false;
	}
}

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 

    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
	if (opacity == opacEnd)
		opacChanging = false;
}

//Main Image and Text
function SetMainImage() {     
	timer = 0;
    changeOpac(50, 'bigimg');
    document.images['bigimg'].src = bigImages[index[2]];

    //determine the direction for the blending, if start and end are the same nothing happens 
    for(i = opacStart; i <= opacEnd; i++) { 
        setTimeout("changeOpac(" + i + ",'bigimg')",(timer * speed)); 
        timer++; 
    }
    
    FadeText();
} 

function MoveSlideLeft(index)
{
    var cross_slide = document.getElementById("slider");
    cross_slide.style.left=parseInt(cross_slide.style.left)-slidespeed+"px";
	if (index == (slidesteps - 1))
		leftSliding = false;
}

function SlideLeft()
{
	if (textFading == false && opacChanging == false && leftSliding == false && rightSliding == false)
	{

	textFading = true;
	opacChanging = true;
	leftSliding = true;
	
    var i = 0;
    var tmpIndex = index[0];

    SetSliderHTML();

    changeOpac(sideImgOpac, 'thumb1');
    changeOpac(sideImgOpac, 'thumb2');
    changeOpac(100, 'thumb3');
    changeOpac(sideImgOpac, 'thumb4');
    
    for (i = 0; i < slidesteps; i++) {
        lefttime=setTimeout("MoveSlideLeft(" + i + ")",20*i);
        if (i < lastSlide) {
            index[i] = index[i+1];
        }
    }
    
    index[lastSlide] = tmpIndex;
    
    SetMainImage();
	}
}

function MoveSlideRight(index)
{
    var cross_slide = document.getElementById("slider");
    cross_slide.style.left=parseInt(cross_slide.style.left)+slidespeed+"px";
	if (index == (slidesteps-1))
		rightSliding = false;
}

function SlideRight()
{
	if (textFading == false && opacChanging == false && leftSliding == false && rightSliding == false)
	{
	textFading = true;
	opacChanging = true;
	rightSliding = true;

    var i = 0;
    var tmpIndex = index[lastSlide];

    SetSliderHTML();

    changeOpac(sideImgOpac, 'thumb0');
    changeOpac(100, 'thumb1');
    changeOpac(sideImgOpac, 'thumb2');
    changeOpac(sideImgOpac, 'thumb3');

    for (i = 0; i < slidesteps; i++) {
        lefttime=setTimeout("MoveSlideRight(" + i + ")",20*i);
        if (i < lastSlide) {
            index[lastSlide-i] = index[lastSlide-1-i];
        }
    }
    
    index[0] = tmpIndex;
    
    SetMainImage();
	}
}
