//in use? remove after transfer
$(document).ready(function(){   
	$(".fade").fadeTo("slow", 0.3);   
	$(".fade").hover(function(){   
		$(this).fadeTo("fast", 1.0);   
	},function(){   
	$(this).fadeTo("slow", 0.7);   
	});   
});  
// in use?? remove after transfer
$(document).ready(function(){   
	$(".fademenu").fadeTo("slow", 0.1);   
	$(".fademenu").hover(function(){   
		$(this).fadeTo("fast", 0.3);   
	},function(){ $(this).fadeTo("slow", 0.1);   
	});   
});
//Tooltips
$(document).ready(function(){	
	$("a").easyTooltip();
	$("a#textIntro").easyTooltip({
		tooltipId: "easyTooltip2",
		content: '<p>click to read our story</p>'});
	$("a#photoAlbum").easyTooltip({
		tooltipId: "easyTooltip2",
		content: '<p>click to view our Picture gallery</p>'});
	$("a#textAnimals").easyTooltip({
		tooltipId: "easyTooltip2",
		content: '<p>click to read about the animals in Australia</p>'});
	$("a#googleMap").easyTooltip({
		tooltipId: "easyTooltip2",
		content: '<p>click for our route and waypoints</p>'});
	$("a#textExperience").easyTooltip({
		tooltipId: "easyTooltip2",
		content: '<p>click to read about our experiences</p>'});
	$("a#ourJourneys").easyTooltip({
		tooltipId: "easyTooltip2",
		content: '<p>click to see Our Journeys</p>'});
	$("a#textDutch").easyTooltip({
		tooltipId: "easyTooltip2",
		content: '<p>klik voor tips in het Nederlands</p>'});
	$("a#textEnglish").easyTooltip({
		tooltipId: "easyTooltip2",
		content: '<p>click for English help</p>'});
	
});

// shadow around images
$(document).ready(function(){ $(".shadow img").load(function() 
	{
	$(this).wrap(function(){
      return '<span class="image-wrap ' + $(this).attr('class') + '" style="position:relative; display:inline-block; background:url(' + $(this).attr('src') + ') no-repeat center center; width: ' + $(this).width() + 'px; height: ' + $(this).height() + 'px;" />';
    });
    $(this).css("opacity","0");
  });

});

//headertext
$(document).ready(function(){
$("#header_text_main").FontEffect({outline:true,gradient:true,gradientColor:"#959496", gradientPosition:20,gradientSteps:30});
$("#header_text_sub").FontEffect({outline:true,gradient:true,gradientColor:"#959496", gradientPosition:10,gradientSteps:20});
$("#header_photo").FontEffect({outline:true,gradient:true,gradientColor:"#959496", gradientPosition:20,gradientSteps:30});
$("#header_travel").FontEffect({outline:true,gradient:true,gradientColor:"#959496", gradientPosition:20,gradientSteps:30});
$("#header_map").FontEffect({outline:true,gradient:true,gradientColor:"#959496", gradientPosition:20,gradientSteps:30});
$("#twitter_follow1").FontEffect({outline: true});
$("#twitter_follow2").FontEffect({outline: true});
$("#new_follow1").FontEffect({outline: true});
$("#new_follow2").FontEffect({outline: true});
$("#sites").FontEffect({outline: true});
$("#pages").FontEffect({outline: true});
$("#menus").FontEffect({outline: true});
$("#goto").FontEffect({outline: true});
$("#messages").FontEffect({outline: true});
$("#circled1").FontEffect({outline: true,outlineColor1:"#000"});
$("#circled2").FontEffect({outline: true,outlineColor1:"#000"});
$("#circled3").FontEffect({outline: true,outlineColor1:"#000"});
$("#circled4").FontEffect({outline: true,outlineColor1:"#000"});
$("#circled5").FontEffect({outline: true,outlineColor1:"#000"});
$("#circled6").FontEffect({outline: true,outlineColor1:"#000"});
$("#circled7").FontEffect({outline: true,outlineColor1:"#000"});
});

//Browser adaption
$(document).ready(function(){
$().browserSizr({containerDiv: 'body',lower1024: 'on',over1024: 'off'});});

// Show button Hide Menu
$(document).ready(function(){
$("#sub-left").click(function(){$("#left").slideToggle();var el = $("#shText");var state = $("#shText").html();state = (state == 'Show Menu' ? '<span id="shText">Hide Menu </span>' : '<span id="shText">Show Menu</span>');el.replaceWith(state);$("#menus").redrawFE() });}); 

//Scrolling menu
$(document).ready(function(){	
total = $('#innerContainer li').length;
$totalImgs = $('#innerContainer li');
thumbHeight = 0;
for (x=0; x<total; x++) {thumbHeight = thumbHeight + 20;}
$('#innerContainer')	.css({height: thumbHeight + 'px'});
$('#slideUp')			.hover(function(e){
$('#innerContainer')	.stop();
posTop = -parseInt($('#innerContainer').css("top"))
speed = (posTop) * 10;
slideTop = thumbHeight - 100;
$('#innerContainer')	.animate({"top": "0px"}, speed)
$('#slideUp')			.css({"background": "url(http://data.delosgaia.nl/resources2/circular_single/arrow-up-hover.png) no-repeat"})
},function(){
$('#innerContainer')	.stop();
$('#slideUp')			.css({"background": "url(http://data.delosgaia.nl/resources2/circular_single/arrow-up.png) no-repeat"})
});
$('#slideDown')			.hover(function(e){
posTop = parseInt($('#innerContainer').css("top"))
speed = (thumbHeight + posTop) * 10;
slideTop = thumbHeight - 100;
$('#innerContainer')		.stop();
$('#innerContainer')		.animate({"top": -slideTop + "px"}, speed)
$('#slideDown')				.css({"background": "url(http://data.delosgaia.nl/resources2/circular_single/arrow-down-hover.png) no-repeat"})
$('#slideUp')				.css({"background": "url(http://data.delosgaia.nl/resources2/circular_single/arrow-up.png) no-repeat"})
},function(){
$('#innerContainer')		.stop();
$('#slideDown')				.css({"background": "url(http://data.delosgaia.nl/resources2/circular_single/arrow-down.png) no-repeat"})
});
})

//New Window link
$(document).ready(function() {
    $('a[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });
});

//codaSlider
$().ready(function() {$('#coda-slider-1').codaSlider({autoSlide: false, autoSlideInterval: 10000});});
$().ready(function() {$('#coda-slider-2').codaSlider({autoSlide: false, autoSlideInterval: 1000000});});

//Twitter
$(document).ready(function(){
    // Get latest 6 tweets by jQueryHowto
    $.jTwitter('delosgaia', 10, function(data){
        $('#posts').empty();
        $.each(data, function(i, post){
            $('#posts').append(
                '<div class="post">'
                + '<div class="txt">'
                + '<p>'
                + relativeTime(post.created_at)
                + '<br />'
                + post.text
                + '</p>'
                +' </div>'
                +'</div>'
            );
        });
    });
});
function relativeTime(pastTime)
{	
	var origStamp = Date.parse(pastTime);
	var curDate = new Date();
	var currentStamp = curDate.getTime();
	
	var difference = parseInt((currentStamp - origStamp)/1000);

	if(difference < 0) return false;

	if(difference <= 5)				return "Just now";
	if(difference <= 20)			return "Seconds ago";
	if(difference <= 60)			return "A minute ago";
	if(difference < 3600)			return parseInt(difference/60)+" minutes ago";
	if(difference <= 1.5*3600) 		return "One hour ago";
	if(difference < 23.5*3600)		return Math.round(difference/3600)+" hours ago";
	if(difference < 1.5*24*3600)	return "One day ago";
	
	var dateArr = pastTime.split(' ');
	return dateArr[2]+' '+dateArr[1]+' '+dateArr[3]+(dateArr[5]!=curDate.getFullYear()?' '+dateArr[5]:'');
}

