/*
 *	@author: Mircea Zetea
 *	@package: SkyPointe
 *	@description: website concept
 *	@requires: jQuery javascript library
*/
	//homepage banner effects
	var index = 1;
	var stop = false;
	
	$("#slidesContainer").ready( function(){
		changeSlides();
	});
	
	function changeSlides()
	{
		$(".topBanner").fadeOut("slow");
		$("#banner_" + index).ready( function(){
			var previous = index - 1;
			$("#banner_" + index).fadeIn("slow");
			$("#control_" + index).css({border:"#fff solid 1px",width:"8px",height:"8px"});
			$("#control_" + previous).css({border:"none",width:"10px",height:"10px"});
		});
		
		if(!document.getElementById("banner_"+index))
		{
			index = 1;
			$("#banner_" + index).fadeIn("slow");
			$("#control_" + index).css({border:"#fff solid 1px",width:"8px",height:"8px"});
			index++;
		}
		else
			index++;
		if(!stop)
			setTimeout("changeSlides()",3500);
	}
	
	$("#slideControls").ready( function(){
		$(".controls").click( function(){
			$(".controls").css({border:"none",width:"10px",height:"10px"});
			$("#" + this.id).css({border:"#fff solid 1px",width:"8px",height:"8px"});
			var searchString = this.id
			var number = searchString.substring(searchString.indexOf("_") + 1);
			$("#banner_" + index).ready( function(){
				$("#banner_" + index).fadeOut("slow");
				index = number;
				$("#banner_" + index).fadeIn("slow");
				stop = true;
				return false;
			});
			return false;
		});
	});
	//end homepage banner effects
	
	//start clean newssubscription input
	$("#enterEmail").ready( function(){
		$("#enterEmail").click( function(){
			this.value = "";
 		});
	});
	
	//start gallery controlls
	$(".thumbs").ready( function(){
		$(".thumbs").click( function(){
			var largeImageSource = $("#" + this.id).attr("href");
			$(".thumbs > img").css({border:"none"});
			//$("#" + this.id + " > img").css({border:"#532F19 solid 1px"});
			$("#largeImage").attr({src:largeImageSource});
			return false;
		});
	});
	var nextId = 6;
	var firstId = 1;
	$("#next").ready( function(){
		$("#next").click( function(e){
			var totalThumbs = parseInt(document.getElementById("totalThumbs").value)
			if(totalThumbs > 5)
			{
				var nextThumb = "thumb_" + nextId
				if(document.getElementById(nextThumb))
				{
					$("#thumb_" + firstId).hide();
					$("#thumb_" + nextId).show();
					firstId++;
					nextId++;
				}	
			}
			return false;
		});
	});
	$("#prev").ready( function(){
		$("#prev").click( function(e){
			if(firstId >= 1)
			{
				firstId--;
				$("#thumb_" + firstId).show();
				nextId--;
			}
			return false;
		});
	});