$(document).ready(function() {
	
	// so the page is usable with JS disabled
	// otherwise the bottom content goes over the main content
	$("#content").css("margin-bottom", "0px");
	$("#social-networks").css("top", "450px").css("display", "none");



	// BOOKMARK HOVER FUNCTION
	//$("#bookmark").jBrowserBookmark();
	
	
	/*
	$("#bookmark").hover(function() {
		$("#social-networks").stop().fadeTo(500, 1.0);
	}, function() {
		$("#social-networks").stop().fadeTo(500, 0.0, function() {
			$("#social-networks").hide();
		});
	});
	
	$("#social-networks").hover(function() {
		$("#social-networks").stop().fadeTo(500, 1.0);
	}, function() {
		$("#social-networks").stop().fadeTo(300, 0.0, function() {
			$("#social-networks").hide();
		});		
	});
	*/
	
	
	
	
	// HIDE BUTTONS
	
	$(".hide-button").click(function () {
		var id = $(this).attr("id");
		var suffix = id.substring(5);
		$("#content-"+suffix).slideToggle(500);						   
		if ($("#hide-"+suffix).text() == "HIDE") {
			$("#hide-"+suffix).text("[+]");	
		} else {
			$("#hide-"+suffix).text("HIDE");	
		}
	});
	
	
	
	
	// BOTTOM CONTENT

	if ($.browser.msie && $.browser.version=="6.0") {
		// don't hide the bottom
		$('#main-wrapper').css({'height' : '100%'});
		$('#content-bottom-wrapper').css({'position' : 'absolute', 'left' : 0, 'bottom' : 0});
	}
	
	// ACTIVATE THIS IF THE BAR SHOULD BE SHOWN ON PAGE LOAD & CLICKED TO HIDE/SHOW
	
	$("#content-bottom").show();
	setTimeout(function() {
		$("#content-bottom").slideToggle(500);
		}, 2000)
	;	
	
	$("#content-bottom-button").click(function() { 
	$("#content-bottom").slideToggle(500, function() {
			if ($("#content-bottom").css("display") == "none") {
				$("#content-bottom-button").text('[+] Enjoy a drink on us...');
			} else {
				$("#content-bottom-button").text('[-] Hide...');
			}
		}
		);
	});
	
	// ACTIVATE THIS IF THE BAR SHOULD BE HIDDEN ON PAGE LOAD & CLICKED TO OPEN
	
	/*$("#content-bottom-button").click(function() { */
	/*	$("#content-bottom").slideToggle(500, function() {
			if ($("#content-bottom").css("display") == "none") {
				$("#content-bottom-button").text('[+] Enjoy a drink on us...');
			} else {
				$("#content-bottom-button").text('[-] Hide...');
			}
		}
		);
	});*/
	
	/*$("#content-bottom").hide();
	$("#content-bottom").delay(1250).slideToggle(500, function() {
		if ($("#content-bottom").css("display") == "none") {
			$("#content-bottom-button").text('[+] Enjoy a drink on us...');
		} else {
			$("#content-bottom-button").text('[-] Hide...');
		}
	}
	);*/
	
	
	
	
	
	// ANIMATION on LINKS
	
	$("input.submit").addClass("button-fade");
	
	$("a").each(function() {
		var c = $(this).children("img");
		var n = $(this).parent()[0].tagName;
		if ((c.size() == 0) && (n != "LI")) {
			$(this).addClass("button-fade");
		} else {
			$(this).children("img").addClass("button-fade");
		}
	});
	
	$(".button-fade").hover(function() {
		$(this).stop().fadeTo(400, 0.7);
	}, function() {
		$(this).stop().fadeTo(400, 1.0);
	});
	
	$("#nav li a").mouseout(function() {
		$(this).stop().fadeTo(100, 0.7, function() {
			$(this).fadeTo(800, 1.0, function() {
				 if ($.browser.msie) this.style.removeAttribute('filter');
			});
		});
	});
	
	// RESIZABLE BACKGROUND
	$("#full-screen-image").fullSizeImage({ 
		 repositionImage : true,
		 offset : "215,0",
		 position : "fixed"
	});
	
	
	$('#full-screen-image img:not(":first")').hide();
    var count=0;
    var countImages = $('#full-screen-image img').size();

    if(countImages>1){
        setInterval(nextImage,4000); //The number here dictates the length of time between the animation
    }

    function nextImage() {
        $('#full-screen-image img:eq('+count+')').fadeOut(1500); //Length of FadeOut transition
        if(count<countImages-1){
            count++;
        } else {
           	count=0;
        }
       $('#full-screen-image img:eq('+count+')').fadeIn(1500); //Length of FadeIn transition
    }	
	
});


