/*
Copyright (c) 2011 Mediasparx (http://www.mediasparx.com)
Notes: Teaser
*/

var timerid;

function teaser(container) {

	$(container).each(function() {

		// Flytt ankerbilde
		$(container).find('.listRow').each(function(index) {
			$(this).find(".AnchorImageBox").prependTo(this);
		});

		// Legg P på tekst
		$(container).find('.listSummary').each(function(index) {
			$(this).wrapInner('<p></p>');
		});

		// Klikkbar på hover
		$(this).find(".listRow a").append('<span></span>');

		// Hover effekt
		$(this).find(".listRow").hover(function()
		{
			$(this).closest('.listRow').find(".listSummary").stop().animate({ top: "0px" }, 400 );
		}
		, function()
		{
			$(this).closest('.listRow').find(".listSummary").stop().animate({ top: "144px" }, 300 );
		});

	});

}

function teaserthumb(container) {

	$(container).each(function() {

		// Flytt ankerbilde
		$(container).find('.listRow').each(function(index) {
			$(this).find(".AnchorImageBox").prependTo(this);
		});

		// Fjern tekst
		$(container).find('.listSummary').each(function(index) {
			$(this).remove();
		});

		// Endre linker til hovedside
/*		$(container).find('a').each(function(index) {
			var link = $(this).attr("href");
			var position = link.lastIndexOf("/")
			var link = link.substring(0,position);
			$(this).attr("href", link );
		}); */


	});

}

// Startup
$(function() {

	teaser(".teaser");
	teaserthumb(".teaserthumb");

});
