if(self!=top)document.images?top.location.replace(window.location.href):(top.location.href=window.location.href);

GV={
	lang:$('body').hasClass('lang-en')?'en':'no',
	tip:$('<div id="tip"></div>').appendTo(document.body),
	layer:$('<div id="layer"></div>').appendTo(document.body),
	dotip:function(e,t){
		if(GV.tipped!=(t=e.type=='mouseleave'?'':e.target.alt))GV.tip.html(GV.tipped=t||'')[t?'show':'hide']();
		if(GV.tipped)GV.tip.css({top:e.pageY+15,left:e.pageX+15});
	},
	accordination:function(s){
		$(this).addClass('cur').animate({paddingTop:5,paddingBottom:5,fontSize:'16px'},s=200).next().slideDown(s).parent()
		.find('dt.cur').not(this).animate({paddingTop:0,paddingBottom:0,fontSize:'12px'},s).removeClass('cur').next().slideUp(s);
	},
	lightbox:function(e,el,p){
		GV.layer.html('<img alt="" />'+(el=$(this)).attr('alt')+'<span>'+(p=el.parent()).attr('rel')+'</span>');
		return !GV.layer.find('img').attr('src',p.attr('href')).css('opacity',0).fadeTo(300,1).parent().show(); //maxheight this //keypress
	},
	pointer:function(e,t){
		if(e.type=='click'){
			if((t=GV.tipped.charAt(0))==Texts[GV.lang][1][0])return GV.tip.hide()&&GV.layer.hide();
			var n=t==Texts[GV.lang][2][0],from=$('div.thumbs a[href='+GV.layer.find('img').attr('src')+']:eq(0)'),to=from[n?'next':'prev']();
			GV.lightbox.call((to.length?to:from.parent().children(n?'a:first-child':'a:last-child')).children()[0]);
		}
		else{
			var w=GV.layer.width()/3,t=Texts[GV.lang][e.pageX<w?0:(e.pageX>(w+w)?2:1)];
			if(GV.tipped!=t)GV.tip.html(GV.tipped=t).show();
			GV.tip.css({top:e.pageY+15,left:e.pageX+15});
		}
	}
}

Texts={
	en:['&laquo; previous','close viewer','next &raquo;'],
	no:['&laquo; forrige','lukk visning','neste &raquo;']
}

$('body').addClass('js').find('dt:not(.cur)').live('click',GV.accordination);
$('div.thumbs').bind('mousemove mouseleave',GV.dotip);//.find('a').each(function(i,el){new Image().src=el.href});
$(document.getElementById('page-'+String(window.location.hash).replace('#',''))||'dt').eq(0).click();
$('#cont a[href*=://]').live('click',function(){window.open(this.href);return false});
$('div.thumbs img').live('click',GV.lightbox);
$('#search input').focus();
GV.layer.bind('mousemove click',GV.pointer);