$(document).ready(function() {		
	
	//GENERAL BITS AND BODS TO REST STYLES ETC
	
	//remove sitemap link for browsers with scripting
	$('.siteMap').css({display: 'none'});
	
	//Set original search result opacity
	$('#livesearch').css({opacity: 0.8});
	
	//add search feature
	$('#search form').css({display: 'inline'});
	
	//LIVE SEARCH SPECIFICS
	
	//set the oppacity of the searchLink class, this class is on the search result links and unless there are search results there is nothing to pin the oppacity too,
	//which is why I have waited until the hover is called to do so
	$("#livesearch").hover(function(){
		//set the livesearch back to 100% otherwise it can cause the searchlink end oppacity to be 80% of 80% e.g. compounds 
		//annimate the fade up
		$("#livesearch").animate({opacity: 0.9}, 300);
		$("a.searchLink").animate({opacity: 1}, 300);
		},
    function(){
		//annimate the fade down
		$("a.searchLink").animate({opacity: 0.8}, 300);
		$("#livesearch").css({opacity: 0.8});
		
   });	

	//SLIDESHOW SPECIFICS
	//append or add the form for browsers with scripting	
	$('ul.slideshow') .append('<li><a href="links.html"><img src="images/logos/ABC.jpg" width="149" height="99" alt="ABC - Australian Broadcasting Commission" /></a></li> 							 <li><a href="links.html"><img src="images/logos/Aust-Govt-FaCSIA.gif" width="149" height="99" alt="Australian Government Department of Families, Community Services and Indigenous Affairs" /></a></li>             <li><a href="links.html"><img src="images/logos/Australian-Government.gif" width="149" height="99" alt="Australian Government" /></a></li>             <li><a href="links.html"><img src="images/logos/BCCLogo.gif" width="149" height="99" alt="Burnie City Council" /></a></li>             <li><a href="links.html"><img src="images/logos/Chac.gif" width="149" height="99" alt="Chircular Head Aboriginal Corp." /></a></li>             <li><a href="links.html"><img src="images/logos/DOTARS_inline-logo.gif" width="149" height="99" alt="Australian Government Department of Transport and Regional Services" /></a></li>             <li><a href="links.html"><img src="images/logos/FostersLogo.gif" width="149" height="99" alt="Fosters Group"/></a></li>             <li><a href="links.html"><img src="images/logos/FYA.gif" width="149" height="99" alt="The Foundation for Young Australians"/></a></li>             <li><a href="links.html"><img src="images/logos/Headway.gif" width="149" height="99" alt="Headway North West Inc" /></a></li>             <li><a href="links.html"><img src="images/logos/Lighthouse-Film-Soc-Logo.jpg" width="149" height="99" alt="Lighthouse Film Scociety" /></a></li>             <li><a href="links.html"><img src="images/logos/LOGO-AGs-Crime-Prev.jpg" width="149" height="99" alt="National Community Crime Prevention Programme" /></a></li>             <li><a href="links.html"><img src="images/logos/NWRSS.gif" width="149" height="99" alt="North West Regional Support Services Inc" /></a></li>             <li><a href="links.html"><img src="images/logos/ozco-horiz.gif" width="149" height="99" alt="Australian Government Australia Council for the Arts" /></a></li>             <li><a href="links.html"><img src="images/logos/raf_logo.gif" width="149" height="99" alt="Australian Government Regional Arts Fund" /></a></li>             <li><a href="links.html"><img src="images/logos/SA_black_mac.gif" width="149" height="99" alt="Australian Government Screen Australia" /></a></li>            <li><a href="links.html"><img src="images/logos/STas_VertW.gif" width="149" height="99" alt="Screen Tasmania - Tasmania Explore the posibilities" /></a></li>             <li><a href="links.html"><img src="images/logos/TasGov_Vert-NS.gif" width="149" height="99" alt="Tasmanian Government" /></a></li>             <li><a href="links.html"><img src="images/logos/tcf-logo.gif" width="149" height="99" alt="Tasmanian Community Fund" /></a></li>             <li><a href="links.html"><img src="images/logos/TRA-Logo.gif" width="149" height="99" alt="Tasmanian Regional Arts" /></a></li>             <li><a href="links.html"><img src="images/logos/Triple_J_TV.gif" width="149" height="99" alt="Tripple J TV" /></a></li>             <li><a href="links.html"><img src="images/logos/Wynyard-Council.gif" width="149" height="99" alt="Waratah Wynyard Council" /></a></li>');


});


$(document).ready(function() {		
	
	//Execute the slideShow, set 4 seconds for each images
	slideShow(4000);

});

function slideShow(speed) {


	//append a LI item to the UL list for displaying caption<div class="slideshow-caption-container"><h3></h3><p></p></div>
	$('ul.slideshow').append('<li id="slideshow-caption" class="caption"></li>');

	//Set the opacity of all images to 0
	$('ul.slideshow li').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('ul.slideshow li:first').css({opacity: 1.0});
	
	//Call the gallery function to run the slideshow	
	var timer = setInterval('gallery()',speed);
	
	//pause the slideshow on mouse over
	$('ul.slideshow').hover(
		function () {
			clearInterval(timer);	
		}, 	
		function () {
			timer = setInterval('gallery()',speed);			
		}
	);
	
}

function gallery() {


	//if no IMGs have the show class, grab the first image
	var current = ($('ul.slideshow li.show')?  $('ul.slideshow li.show') : $('#ul.slideshow li:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().attr('id') == 'slideshow-caption')? $('ul.slideshow li:first') :current.next()) : $('ul.slideshow li:first'));
		
	//Get next image caption
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);
	
	//Hide the current image
	current.animate({opacity: 0.0}, 1000).removeClass('show');

}

// Code for the TOOL TIP pop-up 
$(document).ready(function(){
						   
  $(".toolTip").each(function(){
		var t;
		var isanimated = false;
		var isvisible = false;
		var popup = $(".floatingpanel",this);
		$(this).mouseover(function(){
			if (t) clearTimeout(t);
			if (!isvisible && !isanimated){
				isanimated = true;
				popup.css({opacity:0,display:"block",marginTop:0}).animate({marginTop:"1em",opacity:0.8},0, function(){isanimated=false;isvisible=true;});
			} else {
				return;
			}
		}).mouseout(function(){
			if (t) clearTimeout(t);
			if (!isanimated && isvisible){
				t = setTimeout(function(){isanimated=true;popup.animate({marginTop:"1em",opacity:0},400, function(){popup.css({display:"none"});isvisible=false;isanimated=false;});}, 200);
			} else {
				return;
			}
		});
	});
});