// JavaScript Document

$(document).ready(function(){
    $("#button1").click(function(){
		$(this).delay(1000,function(){
        $("#button1").attr('src', 'images/home-buttons/button1_over.png');
		$("#button2").attr('src', 'images/home-buttons/button2.png');
		$("#button3").attr('src', 'images/home-buttons/button3.png');
		$("#button4").attr('src', 'images/home-buttons/button4.png');
        $("#image2,#image3,#image4").fadeOut(750);
		$("#text2,#text3,#text4").fadeOut(750);
		});
		$(this).delay(2000,function(){
		$('#image1').fadeIn(750);
		$('#text1').fadeIn(750);
		});
	});
});

$(document).ready(function(){
    $("#button2").click(function(){
		$(this).delay(1000,function(){
		$("#button2").attr('src', 'images/home-buttons/button2_over.png');
		$("#button1").attr('src', 'images/home-buttons/button1.png');
		$("#button3").attr('src', 'images/home-buttons/button3.png');
		$("#button4").attr('src', 'images/home-buttons/button4.png');
        $("#image1,#image3,#image4").fadeOut(750);
		$("#text1,#text3,#text4").fadeOut(750);
		});
		$(this).delay(2000,function(){
		$('#image2').fadeIn(750);
		$('#text2').fadeIn(750);
		});
	});
});

$(document).ready(function(){
    $("#button3").click(function(){
		$(this).delay(1000,function(){
		$("#button3").attr('src', 'images/home-buttons/button3_over.png');
		$("#button2").attr('src', 'images/home-buttons/button2.png');
		$("#button1").attr('src', 'images/home-buttons/button1.png');
		$("#button4").attr('src', 'images/home-buttons/button4.png');
        $("#image2,#image1,#image4").fadeOut(750);
		$("#text2,#text1,#text4").fadeOut(750);
		});
		$(this).delay(2000,function(){
		$('#image3').fadeIn(750);
		$('#text3').fadeIn(750);
		});
	});
});

$(document).ready(function(){
    $("#button4").click(function(){
		$(this).delay(1000,function(){
		$("#button4").attr('src', 'images/home-buttons/button4_over.png');
		$("#button2").attr('src', 'images/home-buttons/button2.png');
		$("#button3").attr('src', 'images/home-buttons/button3.png');
		$("#button1").attr('src', 'images/home-buttons/button1.png');
        $("#image2,#image3,#image1").fadeOut(750);
		$("#text2,#text3,#text1").fadeOut(750);
		});
		$(this).delay(2000,function(){
		$('#image4').fadeIn(750);
		$('#text4').fadeIn(750);
		});
	});
});

$(document).ready(function(){ 
	$("#search-btn").click(function(){
		$(".search-panel").fadeIn(10);							
		$(".search-panel").css("height","34px");
		});
	});
$(document).ready(function(){
		$(".search-panel-close").click(function(){
		$(".search-panel").fadeOut(3000);
		});
	});

$(document).ready(function(){ 
	$(".LoginFormBox").click(function(){
		$(".login-panel").fadeIn(10);							
		$(".login-panel").css("height","24px");
		});
	});
$(document).ready(function(){
		$(".login-panel-close").click(function(){
		$(".login-panel").fadeOut(3000);
		});
	});

$(document).ready(function(){
	
	$(".accordion h2:first").addClass("active");
	$(".accordion p:not(:first)").hide();

	$(".accordion h2").click(function(){
		$(this).next("p").slideToggle("slow")
		.siblings("p:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h2").removeClass("active");
	});

});

$(function(){

    $("ul.dropdown li").hover(function(){
    
        $(this).addClass("hover");
        $('ul:first',this).css('visibility', 'visible');
    
    }, function(){
    
        $(this).removeClass("hover");
        $('ul:first',this).css('visibility', 'hidden');
    
    });
    
    $("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");

});

// Home Page Image

$(document).ready(function() {	
 
	//Show Banner
	$(".main_image .desc").show(); //Show Banner
	$(".main_image .block").animate({ opacity: 0.85 }, 1 ); //Set Opacity
 
	//Click and Hover events for thumbnail list
	$(".image_thumb ul li:first").addClass('active'); 
	$(".image_thumb ul li").click(function(){ 
		//Set Variables
		var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
		var imgDehref = $(this).find('a').attr("href"); //Get Main Image URL
		var imgDesc = $(this).find('.block').html(); 	//Get HTML of block
		var imgDescHeight = $(".main_image").find('.block').height();	//Calculate height of block	
		
		if ($(this).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			//Animate the Teaser				
			$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
				$(".main_image .block").html(imgDesc).animate({ opacity: 0.85,	marginBottom: "0" }, 250 );
				$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
			});
		}
		
		$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
		$(this).addClass('active');  //add class of 'active' on this list only
		return false;
		
	}) .hover(function(){
		$(this).addClass('hover');
		}, function() {
		$(this).removeClass('hover');
	});
			
	//Toggle Teaser
	$("a.collapse").click(function(){
		$(".main_image .block").slideToggle();
		$("a.collapse").toggleClass("show");
	});
	
});//Close Function

