function links(){

    $("a").hover(function(){
        $(this).stop().animate({color:"#195f61"},300);  
    },function(){
        $(this).stop().animate({color:"#35a4a8"},300);  
    });

    $("a.link-intro").hover(function(){
        $(this).stop().animate({marginLeft:"5px"},300);  
    },function(){
        $(this).stop().animate({marginLeft:"0"},300);  
    });

    $("a.link-arrow").hover(function(){
        $(this).stop().animate({marginLeft:"10px",color:"#195f61"},300);  
    },function(){
        $(this).stop().animate({marginLeft:"0",color:"#35a4a8"},300);  
    });

    $(".postmetadata a").hover(function(){
        $(this).stop().animate({color:"#f3b50c"},300);  
    },function(){
        $(this).stop().animate({color:"#9e7e29"},300);  
    });

    $("#sidebar a").hover(function(){
        $(this).stop().animate({color:"#215f0c"},300);  
    },function(){
        $(this).stop().animate({color:"#34bb04"},300);  
    });

    $("#footer a").hover(function(){
        $(this).stop().animate({color:"#ffffff"},300);  
    },function(){
        $(this).stop().animate({color:"#cec2b6"},300);  
    });

}



function slideshowModules() {

    $("#home-intro .slideshow").cycle({
    	fx: 'fade', 
	    timeout: 2000,
    	speed: 500 
	});

	$("#m-work-taw .photo-content").cycle({ 
	    timeout: 0, 
	    fx: "scrollHorz", 
	    speed: 300, 
	    prev: "#m-work-taw .prev",
	    next: "#m-work-taw .next"
	 });
	
	$("#m-work-dsc .photo-content").cycle({ 
	    timeout: 0, 
	    fx: "scrollHorz", 
	    speed: 300, 
	    prev: "#m-work-dsc .prev",
	    next: "#m-work-dsc .next"
	});

	$("#m-work-atp .photo-content").cycle({ 
	    timeout: 0, 
	    fx: "scrollHorz", 
	    speed: 300, 
	    prev: "#m-work-atp .prev",
	    next: "#m-work-atp .next"
	});

	$("#m-work-g2g .photo-content").cycle({ 
	    timeout: 0, 
	    fx: "scrollHorz", 
	    speed: 300, 
	    prev: "#m-work-g2g .prev",
	    next: "#m-work-g2g .next"
	});

	$("#m-work-crn .photo-content").cycle({ 
	    timeout: 0, 
	    fx: "scrollHorz", 
	    speed: 300, 
	    prev: "#m-work-crn .prev",
	    next: "#m-work-crn .next"
	});
	
	$("#m-work-apt .photo-content").cycle({ 
	    timeout: 0, 
	    fx: "scrollHorz", 
	    speed: 300, 
	    prev: "#m-work-apt .prev",
	    next: "#m-work-apt .next"
	});
	
	$("#m-work-ksp .photo-content").cycle({ 
	    timeout: 0, 
	    fx: "scrollHorz", 
	    speed: 300, 
	    prev: "#m-work-ksp .prev",
	    next: "#m-work-ksp .next"
	 });

	$("#m-work-tro .photo-content").cycle({ 
	    timeout: 0, 
	    fx: "scrollHorz", 
	    speed: 300, 
	    prev: "#m-work-tro .prev",
	    next: "#m-work-tro .next"
	 });

	$("#m-work-msc .photo-content").cycle({ 
	    timeout: 0, 
	    fx: "scrollHorz", 
	    speed: 300, 
	    prev: "#m-work-msc .prev",
	    next: "#m-work-msc .next"
	 });

	$("#m-work-bch .photo-content").cycle({ 
	    timeout: 0, 
	    fx: "scrollHorz", 
	    speed: 300, 
	    prev: "#m-work-bch .prev",
	    next: "#m-work-bch .next"
	 });

}



function randomBG() {
	
	var images = ["home-intro-bg-01.jpg", "home-intro-bg-02.jpg", "home-intro-bg-03.jpg", "home-intro-bg-04.jpg", "home-intro-bg-05.jpg"];
	$("#footer-home").css({'background-image':'url(/_images/' + images[Math.floor(Math.random() * images.length)] + ')'});
	
}



/*******

	***	Link Fader by Cedric Dugas   ***
	*** Http://www.position-absolute.com ***
	
	You can use and modify this script for any project you want, 
	but please leave this comment as credit.
	
	With this script you can have beautiful fade in and fade out hover link.
	
	Just add the class linkFader at your <a> tag and it will fade, 
	user with javascript disable will still have the css hover.

	This script only work if you use the image replacement technique as it take 
	the background image of the <a> tag and play with the background position.
	
*****/

hoverOpacity = {
	init : function(){
		$('a.linkFader').css({
			position:"relative",
			backgroundPosition:"0px 0px",
			cursor:"pointer"
		})
		$('a.linkFader').each(function(){
			
			spanFader = document.createElement('span');
			myBG = $(this).css("background-image")
			
			$(this).append(spanFader);
		
			myBG = $(this).css("background-image")
			spanWidth =  $(this).css("width")
			spanHeight =  $(this).css("height")
				
			$(this).find("span").css({
				backgroundImage:myBG,
				backgroundPosition:"bottom right",
				position:"absolute",
				display:"block",
				cursor:"pointer",
				top:"0px",
				left:"0px",
				width:spanWidth,
				height:spanHeight,
				opacity:0,
				visibility:"visible"
			})
		})
		$("a.linkFader").hover(function () {
			$(this).find("span").stop()
			$(this).find("span:not(:animated)").animate({opacity: 1},100)
		},
		function () {
			$(this).find("span").animate({opacity: 0},100)
		});
	}
}



function smoothScroll() {

    $('a.link-scroll[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},500);
                return false;
            }
        }
    });

}



function portfolio() {
			
	$("#m-work h2 a.toggle").click(function(event) {
		//var target = $(this).attr("href");
		//$(this).parent().siblings(".gallery").load(target);	
		$(this).parent().siblings(".gallery").toggle("blind",1000);
		$(this).parent().toggleClass("selected");
		return false;
	});

	$("#m-work a.link-showall").click(function() {
		//$(this).text($(this).text() == 'Minimize all' ? 'Expand all' : 'Minimize all');
		$(this).parents().find(".gallery").show("blind",1000);
		$(this).parents().find("h2").addClass("selected");
		return false;
	});

	$("#m-work a.link-hideall").click(function() {
		//$(this).text($(this).text() == 'Minimize all' ? 'Expand all' : 'Minimize all');
		$(this).parents().find(".gallery").hide("blind",1000);
		$(this).parents().find("h2").removeClass("selected");
		return false;
	});
	
	$("#m-work-msc a.link-arrow").hide();

}



/*
function tooltip() {

	$(".photo-content img").mousemove(function(e){
		var getCaption = $(this).attr("alt");
		var caption = $(this).parent().siblings(".caption");
		caption.css({
		    left:e.pageX,
		    top:e.pageY,
		})
		caption.show().html(getCaption);
    },function(){
		$(this).parent().siblings(".caption").hide();
    });

}
*/



$(document).ready(function() {

	links();
	slideshowModules();
	randomBG();
	hoverOpacity.init();
	smoothScroll();
	portfolio();	
		
});
