/*!
 * (c) 2010 Robert Wetzlmayr (http://wetzlmayr.at/)
 */
function mycarousel_initCallback(carousel)
{
    carousel.buttonNext.hover(
		function() {
			carousel.startAuto(.5, "next");
		},
		function() {
			carousel.stopAuto();
		}
	);

    carousel.buttonPrev.hover(
		function() {
			carousel.startAuto(.5, "prev");
		},
		function() {
			carousel.stopAuto();
		}
	);
};

var touchstrip = {
	initialize : function () {
		var t = "fast";
		try {
			var c = $('#carousel').jcarousel;
		} 
		catch(e) {
		}
		$("#touch-top").mouseenter(function() {rolldown($("#strip"), t)});
		$("#frame").add(".browse").mouseenter(function() {rollup($("#strip"), t);});
	}
}

var touchmenu = {
	initialize : function () {
		var t = "fast";
		$("#touch-bottom").mouseenter(function() {springup($("#menu"), t)});
		$("#frame").add(".browse").mouseenter(function() {springdown($("#menu"), t)});
	}
}

var slideitems = {
	initialize : function () {
		$("#slideitems li a").hover(function(event){
			var menu = "#menu-" + $(this).attr("rel");
			if (event.type == "mouseenter") {
				$(menu).wrap("<strong>");
			} else {
				$(menu).unwrap();
			}
		});
	}
}

var figure = {
	initialize : function () {
		$("#theimage").hide();
		$("#figcaption").hide();
		$("#theimage").resize(function() {$("#figure").width($(this).width());});
		$("#theimage").load(function() {$(this).resize();$(this).show();$("#figcaption").fadeIn('fast');});
		$("#theimage").jmc_resizr({
			cropType : 'full',
			binding : {
				vertical : 'center',
				horizontal : 'center'
			},
			followBrowserSize :  true,
			parentElement : $('#frame')
		});
	}
}
var motion = {
	initialize : function () {
		$("#thevideo").hide();
		$("#figcaption").hide();
		$("#thevideo").resize(function() {$("#figure").width($(this).width());});
		$("#thevideo").load(function() {$(this).resize();$(this).show();$("#figcaption").fadeIn('fast');});
		$("#thevideo").jmc_resizr({
			cropType : 'full',
			binding : {
				vertical : 'center',
				horizontal : 'center'
			},
			followBrowserSize :  true,
			parentElement : $('#frame')
		});
	}
}


function rollup(el, t) {
	el.stop(true, true).animate(
		{top : -el.outerHeight()},
		{
			duration : t,
			complete : function() {
				el.addClass("hidden");
			}
		}
	);
}

function rolldown(el, t) {
	el.stop(true, true).animate(
		{top : 0},
		{
			duration : t,
			complete : function() {
				el.removeClass("hidden");
			}
		}
	);
}

function springdown(el, t) {
	el.stop(true, true).animate(
		{bottom : -el.outerHeight()},
		{
			duration : t,
			complete : function() {
				el.addClass("hidden");
			}
		}
	);
}

function springup(el, t) {
	el.stop(true, true).animate(
		{bottom : 0},
		{
			duration : t,
			complete : function() {
				el.removeClass("hidden");
			}
		}
	);
}

$(document).ready( function() {
	if ($("body").hasClass("maximize")) {
		window.moveTo(0,0);
		window.resizeTo(screen.availWidth,screen.availHeight);
	}
	$("body").addClass("js");
    $("#theimage").removeAttr("width");
    $("#theimage").removeAttr("height");
	behaviour.initialize();
});

