// JavaScript Document
//alert('good');
var st;

var news_item=1;
var selected_slide =1;
var thumbs = '';
var i;
var continue_check = 'yes'
var clicked = 'no'
var photo = new Array();
var news_text = new Array();
var link_text = new Array();
var button_text = new Array();
var button_slide = new Array();
var selected_slide = 1;


// # for first and last slides. This is the starting and ending to the slide show in case you want to skip beginning or ending slides
var first = 1;
var last = 8;


////
//Easy edits guide & examples
//
//Slide speed(in miliseconds make sure to end with ;)
//  var slide_speed = 5000;
//
//Slides- Make sure to enclose each edit after the = in ' ' and end with ; 
//  photo[#] = 'the image source for slide #';
//  news_text[#] = 'the news article for slide #';  
//  link_text[#] = 'the 'Read more' link for slide #';
//
//Buttons- Make sure they follow order, text & slides match up [#]. Buttons will be inserted in to table as the are read in (top down order of [#]
//   button_text[#] = 'What you want the button to say'
//   button_slide[#] = 'The slide # you want the button to go to'  previous/next are respective functions
////

////
//Speed of slides
////
var slide_speed = 7000;

////
//Link text (Read More...)
////
short_link = 'Read More...';

////
//Picture source
//   You can change, add, & manage pictures in the news folder by using joomla administrator media manager. 
//   Just make sure that the source and names match. Use 'none' for no image
////
photo[1] = '/images/news/withhelpadiploma.jpg';
photo[2] = '/images/news/storiesfromthesystem.png';
photo[3] = '/images/news/boyce.gif';
photo[4] = '/images/news/scholarshipsoffered.jpg';
photo[5] = '/images/news/fostercarenumbersdown.jpg';
photo[6] = '/images/news/fosterchildrenbegintransition.jpg';
photo[7] = '/images/news/salutetograds.jpg';
photo[8] = '/images/news/ordinaryamericans.jpg';
////
//Text to go with picture. 
//  Best not to use ' or " (unless in html)
//  for single quote '  use html code   &#39; 
//  for double quote "  use html code &quot;
////
news_text[1] = 'With a Little Help, a Diploma';

news_text[2] = 'Stories from the System';

news_text[3] = 'Orlando Magic Executive goes from Foster Care in Independence to White House';

news_text[4] = 'Scholarships Offered by the University of Phoenix';

news_text[5] = 'Foster Care Numbers Drop as States Add Preventative Services';

news_text[6] = 'Foster Children Begin Transition';

news_text[7] = 'On Foster Youth Success Stories: Salute to Grads Who Defied the Odds';

news_text[8] = 'Ordinary Americans Make a Difference in the Lives of Former Foster care Children';




////
//Links
////
link_text[1] = '/index.php/news/78-news/148-with-a-little-help-a-diploma-';
link_text[2] = '/index.php/news/78-news/147-stories-from-the-system';
link_text[3] = '/index.php/news/78-news/146-orlando-magic-executive-goes-from-foster-care-in-independence-to-white-house';
link_text[4] = '/index.php/news/78-news/145-scholarships-offered-by-the-university-of-phoenix';
link_text[5] = '/index.php/news/78-news/141-foster-care-numbers-drop';
link_text[6] = '/index.php/news/78-news/142-foster-children-begin-transition';
link_text[7] = '/index.php/news/78-news/143-on-foster-youth-success-stories-salute-to-grads-who-defied-the-odds';
link_text[8] = '/index.php/news/71-urgent/144-ordinary-americans-make-a-difference-in-the-lives-of-former-foster-care-children';
////
//Be careful below
////


//preload our images to an array
var image_array = new Array();

for (i = 1; i < photo.length;i++)
{
image_array[i] = new Image();
image_array[i].src = photo[i];
};





//The main slider function that calls itself every slide_speed seconds
function slider(selected_slide)
{clicked='no';
thumbs = '';
//continue_check to see if we are mousing over
if (continue_check == 'yes'){lol = selected_slide;

    for (i = 1; i < photo.length;i++)
    {if (i == selected_slide){thumbs = thumbs+'<div id="div_highlight" onClick="click_slide('+i+')"><img class="image_thumb" src="'+photo[i]+'" onMouseOver="stop_slide('+i+')" onMouseOut="continue_slide()"></div>';}
    else{
            
        thumbs = thumbs+'<div class="div_thumb" onClick="click_slide('+i+')"><img class="image_thumb" src="'+photo[i]+'" onMouseOver="stop_slide('+i+')" onMouseOut="continue_slide()"></div>';
    };

    document.getElementById("thumb_box").innerHTML= thumbs 
};

//create photo + news header div + and link
//this will be inserted after photo
html_header = '<div id="news_header"><b><a href='+link_text[lol]+ '>'+news_text[lol] +'</a></b></div>';
html_photo = '<a href="'+link_text[lol]+'"><img class="image_news" src="'+photo[lol]+'"></a>';

first_html = html_photo+html_header;


document.getElementById("photo_box").innerHTML= first_html;

continue_check == 'yes'
//Timer call
if (continue_check == 'yes'){
	news_item = news_item + 1;
	if (news_item >= photo.length){
		news_item = first;
		};
	
};
};
st = setTimeout('slider(news_item)', slide_speed);
};

//Mouse on
function stop_slide(selected_slide){//alert('mouse on');

continue_check = 'no';show_stop(selected_slide);};

//mouse on
function show_stop(slide){
html_header = '<div id="news_header"><b><a href='+link_text[slide]+ '>'+news_text[slide] +'</a></b></div>';
html_photo = '<a href="'+link_text[slide]+'"><img class="image_news" src="'+photo[slide]+'"></a>';

first_html = html_photo+html_header;


document.getElementById("photo_box").innerHTML= first_html
if (slide == (news_item-1)){}
else{if (clicked=='yes'){}
else{
document.getElementById("div_highlight").id="div_thumb";}
};
};

//Mouse off
function continue_slide(){
continue_check = 'yes';show_slide((news_item -1));};

//mouse off
function show_slide(slide){

if (clicked != 'yes'){
continue_check='yes';
if (slide==0){slide = last}
html_header = '<div id="news_header"><b><a href='+link_text[slide]+ '>'+news_text[slide] +'</a></b></div>';
html_photo = '<a href="'+link_text[slide]+'"><img class="image_news" src="'+photo[slide]+'"></a>';

first_html = html_photo+html_header;
//news_and_more = '<div id="news_header"><b><a href='+link_text[slide]+ '>'+news_text[slide] +'</a></b></div>';
document.getElementById("photo_box").innerHTML= first_html//'<a href="'+link_text[slide]+'"><img class="image_news" src="'+photo[slide]+'"></a>'+news_and_more;
if (document.getElementById("div_thumb")){
document.getElementById("div_thumb").id="div_highlight"};
continue_check ='yes';
    };
if (clicked=='yes'){//alert('click');
select_div(slide+1);}
};

function click_slide(slide){clicked='yes';if (slide == news_item){select_div(slide)};
news_item = slide;//select_div(slide);
};


function select_div(slide){//alert('redraw');
thumbs = '';


    for (i = 1; i < photo.length;i++)
    {if (i == slide){thumbs = thumbs+'<div id="div_highlight" onClick="click_slide('+i+')"><img class="image_thumb" src="'+photo[i]+'"   onMouseOver="stop_slide('+i+')" onMouseOut="continue_slide()"></div>';
    html_header = '<div id="news_header"><b><a href='+link_text[slide]+ '>'+news_text[slide] +'</a></b></div>';
    html_photo = '<a href="'+link_text[slide]+'"><img class="image_news" src="'+photo[slide]+'"></a>';

    first_html = html_photo+html_header;


document.getElementById("photo_box").innerHTML= first_html}
    else{
            
        thumbs = thumbs+'<div class="div_thumb" onClick="click_slide('+i+')"><img class="image_thumb" src="'+photo[i]+'" onMouseOver="stop_slide('+i+')" onMouseOut="continue_slide()"></div>';
    };

    document.getElementById("thumb_box").innerHTML= thumbs ;
   
};
};
