/* SENIORPORTEN */
$(function() {

$('A.bilde').click(function() {	
var src = $('.'+$(this).children('IMG').attr('class')+'.usynlig').attr('src');
var lbwidth = $('.'+$(this).children('IMG').attr('class')+'.usynlig').width() +20;
var lbheight = $('.'+$(this).children('IMG').attr('class')+'.usynlig').height() +2;
createLightBox(src, lbwidth, lbheight);
});
	
});

function createLightBox(src, lbwidth, lbheight) {
var adjustwidth = (lbwidth + 20);
	if ($('#lbdiv').length == 0) {
		$('<div id="lbouter"><div id="lbhead"><a id="close"><img src="/_public/Seniorporten/bilder/hvitt_kryss.png" alt="lukk vindu"/></a></div><div id="lbdiv"><div id="lbinner"><img src="' +src+ '"/></div></div></div><div id="lbcover"></div>').appendTo('BODY');
	}
	var bgHeight = $(document).height();
	if ($(window).height() > bgHeight) { bgHeight = $(window).height(); }
	var left = ($(window).width() - lbwidth) / 2;
	var top = ($(window).height() - lbheight) / 2 + $(window).scrollTop();
	$('#lbcover').css({ position: 'absolute', left: 0, top: 0, right: 0, bottom: 0, width: '100%', height: bgHeight+'px', zIndex: 1000, background: '#000', opacity: 0.2 });
	$('#lbouter').css({ position: 'absolute', left: left+'px', top: top+'px', width: lbwidth+'px', height: lbheight+'px', zIndex: 1001 });
	$('#lbhead').css({ position: 'relative', width: adjustwidth+'px', height: '35px', background: '#fa9d11', zIndex: '1002' });
	$('#lbdiv').css({ position: 'absolute', left: 0, top: 0, background: '#fff', width: lbwidth+'px', height: lbheight+'px', padding: '44px 0px 16px 20px' });
	$('#lbinner').css({ height: '100%', overflowY: 'auto', paddingRight: '0px' });
	$('#close').css({ position: 'absolute', top: '10px', right: 0, width: '60px', height: '20px', zIndex: 1002, cursor: 'pointer', textDecoration: 'underline', textAlign: 'center', color: '#fff' });
	$('#close').click(function() {
		$('#lbouter').remove();
		$('#lbcover').remove();
	});
	$('#lbdiv').dropShadow();
	$('#lbouter').draggable({ handle: '#lbinner' });
}

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