// JavaScript Document

$(document).ready(function() {

//Make the heights of the feature panel and the individual testimonies equal

    $("#testimonials div div").equalHeights();  
	
	$("#thumbnails li").click(function() {  //When you click a thumbnail
	
	$("#thumbnails li").stop().animate({opacity:'0.6'}, 'slow');   //Change all thumbnails to half transparent except for the one you just clicked
	$("#thumbnails li").removeClass('active');
	$(this).stop().animate({opacity:'1'}, 'slow')
	$(this).addClass('active');
    
    return false;
	});
	

    $("#s1").click(function() {      //When you click the thumbnail
      	$(".slider").animate({      //Animate the slider
            right: "0px"
        }, 450, 'easeInCubic');
		$(".toptext").fadeOut("fast");    //Fade all text out then fade the selected text in
        $("#txt1").fadeIn("fast");
		
        return false;
    });

    $("#s2").click(function() {

      
        $(".slider").animate({
            right: "259px"           //This setting is how much it should move to the right. Thus, if you change the image/viewport size, you would need to change this. (And the rest of course.)
        }, 450, 'easeInCubic');
		$(".toptext").fadeOut("fast");
        $("#txt2").fadeIn("slow");
        
        return false;
    });

    $("#s3").click(function() {

       
        $(".slider").animate({
            right: "518px"
        }, 450, 'easeInCubic');
		$(".toptext").fadeOut("fast");
        $("#txt3").fadeIn("slow");
        
        return false;
    });

    $("#s4").click(function() {

      
        $(".slider").animate({
            right: "777px"
        }, 450, 'easeInCubic');
		$(".toptext").fadeOut("fast");
        $("#txt4").fadeIn("slow");
       
        return false;
    });
	

    $("#v1").click(function() {
      	$(".slider").animate({
            right: "0px"
        }, 450, 'easeInCubic');
		$(".toptext").fadeOut("fast");
        $("#txt1").fadeIn("fast");
		
        return false;
    });

    $("#v2").click(function() {

      
        $(".slider").animate({
            right: "501px"
        }, 450, 'easeInCubic');
		$(".toptext").fadeOut("fast");
        $("#txt2").fadeIn("slow");
        
        return false;
    });

    $("#v3").click(function() {

       
        $(".slider").animate({
            right: "1002px"
        }, 450, 'easeInCubic');
		$(".toptext").fadeOut("fast");
        $("#txt3").fadeIn("slow");
        
        return false;
    });

    $("#v4").click(function() {

      
        $(".slider").animate({
            right: "1503px"
        }, 450, 'easeInCubic');
		$(".toptext").fadeOut("fast");
        $("#txt4").fadeIn("slow");
       
        return false;
    });
	
	

    $("#hptestimonials, #testimonials").cycle({ //Cycles the testimonials. Feel free to check the help file for more info. 
        timeout: 8000
    });
	

$("#arrowbutton").click(function(){

	if($('#arrowbutton').is('.up'))   //When arrow is clicked, slide up/down, change direction of arrow accordingly. 
	
	{
		$("#slidemenu").stop().animate({ top: '-180px'}, 'slow', 'easeInBack');
		$("#slidemenu ul li").stop().animate({opacity:'0.5'}, 'slow');
		$(this).css('background-image', 'url(images/arrowup.png)');
		$(this).removeClass('up');
		$(this).addClass('done');
	
	}		
		
	else {
	
	$("#slidemenu").stop().animate({ top: '-395px'}, 'slow', 'easeOutBack');	
		$("#slidemenu ul li").stop().animate({opacity:'1'}, 'slow');		
		$(this).css("background-image", "url(images/arrow.png)");
		$(this).addClass('up');
	}
		
		
		
});

$("#slidemenu ul li").hover(function() {


	$(this).stop().animate({opacity:'1'}, 'fast');

	}, function () {
	
		if($('#arrowbutton').is('.up'))
		
		{}
		
		else {

	$(this).stop().animate({opacity:'0.5'}, 'slow');
	}

	});
	

$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)

	$("ul li span").click(function() { //When trigger is clicked...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click


		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
			
		});
return false;
		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
			
			
	});
	
	$("#featuresmenu li.feat").hover(function() {

	$(this).stop().animate({marginLeft:'20px'}, 'fast');

	}, function () {	
		
	$(this).stop().animate({marginLeft:'0px'}, 'slow');
	}

);

	$("#features a").hover(function() {

	$(this).stop().animate({marginLeft:'123px'}, 'fast');

	}, function () {	
		
	$(this).stop().animate({marginLeft:'0px'}, 'slow');
	}

);





$('img#totop').hover(function() {    //Creates a tooltip. 

	$('.tooltip').stop().animate({opacity: "show", top: "20px"}, "slow");
		}
		
	, function() {
	
	$('.tooltip').stop().animate({opacity: "hide", top: "-80px"}, "fast");
	
});

 $("#twitter").tweet({
            username: "crazyclouds",  //Change this. 
            join_text: "auto",
            avatar_size: 48,
            count: 1,
            auto_join_text_default: "I said,",
            auto_join_text_ed: "I",
            auto_join_text_ing: "I was",
            auto_join_text_reply: "I replied to",
            auto_join_text_url: "I was checking out",
            loading_text: "loading tweets..."
        });

		$('#slider_frontpage').anythingSlider({
   easing: "swing",                // Anything other than "linear" or "swing" requires the easing plugin
   autoPlay: true,                 // This turns off the entire FUNCTIONALITY, not just if it starts running or not
   startStopped: false,            // If autoPlay is on, this can force it to start stopped
   delay: 6000,                    // How long between slide transitions in AutoPlay mode
   animationTime: 500,             // How long the slide transition takes
   hashTags: true,                 // Should links change the hashtag in the URL?
   buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
   pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
   startText: " ",             // Start text
   stopText: " ",               // Stop text
   navigationFormatter: null       // Advanced Use: details below
})

});