$(document).ready(function(){

	// fadeout flash messages on click
	$('.cancel').click(function(){
		$(this).parent().fadeOut();
		return false;
	});

	// fade out good flash messages after 3 seconds
	$('.flash_good').animate({opacity: 1.0}, 3000).fadeOut();

	$('ul#links li a').click(function() {
		var html = $(this).parent().find('div').html();
		$('#content_inner.links div#linkdetail').html(html);
		return false;
	});
	
	var html = $('ul#links li:first-child a').parent().find('div').html();
	$('#content_inner.links div#linkdetail').html(html);
	
	$("#keywords").click(function() {
		if($(this).val() == "Enter keywords...") {
			$(this).val("");
		}
	});
	
	//screen image rotate
    $('.slideshow').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
	
	//social icon movement
	$('ul#social li a').hover(function()
		{ 
			/* mouseover */ 
			$(this).animate({marginTop: "-7px", paddingBottom:"22px"}, "fast");	
			$(this).parent().find('div').fadeTo("fast", 0.33);
		}, function(){ 
			/* mouseout */ 
			$(this).animate({marginTop: "0px", paddingBottom:"0px"}, "fast");	
			$(this).parent().find('div').fadeTo("fast", 1);			
		}
	);
	$("#service_content .desc").show(); //Show Banner
	$("#service_content .block").animate({ opacity: 0.85 }, 1 ); //Set Opacity
	
	//

	$("#services_links ul li:first").addClass('active'); //Add the active class (highlights the very first list item by default)
	$("#services_links 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 imgDesc = $(this).find('.block').html();  //Get HTML of the "block" container
    var imgDescHeight = $(".main_image").find('.block').height(); //Find the height of the "block"

    if ($(this).is(".active")) {  //If the list item is active/selected, then...
        return false; // Don't click through - Prevents repetitive animations on active/selected list-item
    } else { //If not active then...
        //Animate the Description
        $("#service_content .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() { //Pull the block down (negative bottom margin of its own height)
            $("#service_content .block").html(imgDesc).animate({ opacity: 0.85,  marginBottom: "0" }, 250 ); //swap the html of the block, then pull the block container back up and set opacity
            $("#service_content img").attr({ src: imgTitle , alt: imgAlt}); //Switch the main image (URL + alt tag)
        });
    }
    //Show active list-item
    $("#services_links ul li").removeClass('active'); //Remove class of 'active' on all list-items
    $(this).addClass('active');  //Add class of 'active' on the selected list
    return false;

}) .hover(function(){ //Hover effects on list-item
    $(this).addClass('hover'); //Add class "hover" on hover
    }, function() {
    $(this).removeClass('hover'); //Remove class "hover" on hover out
});
	//
	
	$("a.collapse").click(function(){
    $("#service_content .block").slideToggle(); //Toggle the description (slide up and down)
    $("a.collapse").toggleClass("show"); //Toggle the class name of "show" (the hide/show tab)
});
	
	
	
	
});
//////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	$(function(){
    $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
        && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                $('html,body').animate({scrollTop: targetOffset}, 1000);
                return false;
            }
        }
    });
});
	
	///////////////////////////////////////////////////////////////////////////////////////////
	
