$(document).ready(function(){

	var URL = window.location.host;
	
	$('#cloud_link_img').css({opacity: 0});
	$('#cloud_link_img').hide();
	$('#soa_link_img').css({opacity: 0});
	$('#soa_link_img').hide();
	
	// soa
	if(URL.indexOf("cloud") != -1){
		$('#soa_link_box').css({opacity: 0.5});
		$('#soa_link_box').addClass("cursor_pointer")
		$("#soa_link_box").hoverIntent({
            sensitivity: 2,
            interval: 150,
            over: function(){linkOn('soa');},
            timeout: 1000,
            out: function(){linkOff('soa');}
         });
	}
	
	// cloud	
	else {
		$('#cloud_link_box').css({opacity: 0.5});
		$('#cloud_link_box').addClass("cursor_pointer");
		$('#cloud_link_box').hoverIntent({
            sensitivity:2,
            interval: 150,
            over: function(){linkOn('cloud');},
            timeout: 1000,
            out: function(){linkOff('cloud');}
         });
	}
		
//Superfish menu
$("ul.sf-menu").supersubs().superfish(
{
            delay:       1000,                          // one second delay on mouseout
            animation:   {opacity:'show'},  						// fade-in and slide-down animation
            speed:       'normal',                      // faster animation speed
            autoArrows:  false,                         // disable generation of arrow mark-up
            dropShadows: false                          // disable drop shadows
        }
);

//Toggle functions
 $("#toggle-all").toggle(
                    function(){
                         $(".excerpt").hide('slow');
			 $("#toggle").attr("class","show-all");
                    }, function() {
                         $(".excerpt").show('slow');
			 $("#toggle").attr("class","hide-all");
                    });

$(".hide-excerpt").click(function (event) {
	event.preventDefault();
      $(this).parents(".excerpt").hide("normal");
    });

$(".view-excerpt").click(function (event) {
	event.preventDefault();
      $(this).parents(".headline").next(".excerpt").toggle("normal");
    });

});
 
function linkOn(linkName) {
	$('#' + linkName + '_link_box').animate({width: "+=60px"}, 400);
	$('#' + linkName + '_link_box').animate({opacity: 1}, 400);
	$('#' + linkName + '_link_pre').animate({opacity: 0}, 1000);
	$('#' + linkName + '_link_pre').hide();
	$('#' + linkName + '_link_img').show();
	$('#' + linkName + '_link_img').animate({opacity: 1}, 1000);
	$('#' + linkName + '_link_img').addClass("cursor_pointer");
}
 
function linkOff(linkName) {
	$('#' + linkName + '_link_img').animate({opacity: 0}, 1000); 
	$('#' + linkName + '_link_box').animate({width: "-=60px"}, 400); 
	$('#' + linkName + '_link_img').hide();
	$('#' + linkName + '_link_pre').show();
	$('#' + linkName + '_link_pre').animate({opacity: 1}, 1000); 
	$('#' + linkName + '_link_img').removeClass("cursor_pointer");
	$('#' + linkName + '_link_box').animate({opacity: 0.5}, 700);
}
