// JavaScript Document

// Navigasjonsmeny
sfHover = function(){
    var sfEls = document.getElementById("Navigation").getElementsByTagName("LI");
    for (var i = 0; i < sfEls.length; i++) {
        sfEls[i].onmouseover = function(){
            this.className += " sfhover";
        }
        sfEls[i].onmouseout = function(){
            this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
        }
    }
}
if (window.attachEvent) 
    window.attachEvent("onload", sfHover);


$(document).ready(function(){

// Keywords show/hide
	var keyH = $('#keywords').height() ;
	var keyHT = keyH + 14 ;
	keyHT = keyHT * '-1'
    $('#keywords').css({
        'margin-top': keyHT
    });

    $('a#keywords-t').click(function(){
    var topp = $('#keywords').css('marginTop');
		if (topp == '0px'){
		$('#keywords').animate({
                marginTop: keyHT
            }, 500);
		}
		else {
			$('#keywords').animate({
				marginTop: '0px'
			}, 500);
		}
	});
    $('a#keywords-hide').click(function(){
        $('#keywords').animate({
            marginTop: keyHT
        }, 500);
    });
    
// Sky-animation
    $('#Sky').animate({
        left: '0px'
    }, 70000, function(){
        $(this).animate({
            opacity: '0'
        }, 3000)
    });

// Google show-hide
    $('#Search').hover(function(){
        $('#Google').show();
    }, function(){
        $('#Google').hide();
    });
    
// Klikk utenfor div: http://www.webdeveloper.com/forum/showthread.php?t=85564

//Navigasjon-knapper
	var path = location.href ;
	var relPath = path.replace('http://g-sun2009.localhost', '')
	var relPath = relPath.replace('http://g-sun.no', '');
	var path2 = 'http://g-sun.no' + relPath;
	if (path.match('/en/')){
	var home = '/en/index.php'}
	else {
	var home = '/index.php'	};

	var here = $('#Navigation li a[href="'+relPath+'"]')
	|| $('#Navigation li a[href="'+path2+'"]');
	if (relPath=='/'){
		here = $('#Navigation li a:first')
	}

	var aUp = here.parents('li:eq(1)').find("a:first").not('a[href="#"]')
	var Up = aUp.attr('href') || home;
	if (aUp.hasClass('frame')){
		Up = Up.replace('http://g-sun.no', '')
		Up = "/frame.php?page=" + Up;
		}
	$('img#Up').parent().attr("href", Up);

	var aForw1 = here.parent().find("li a:first").eq(0);
	var aForw2 = here.parents().next('li').find("a:first").eq(0);
	if (aForw1.length == '1'){
		var aForw = aForw1
	} else{
	var aForw = aForw2;
	};
	var Forward = aForw.attr('href') || home;
	if (aForw.hasClass('frame')){
		Forward = "/frame.php?page=" + Forward;
		}
	$('img#Forward').parent().attr("href", Forward);

//breadcrumb
	var BrCu = here.parents('li').find("a:first").not('a[href="/index.php"]').not('a[href="/en/index.php"]');
	var BText = "";
	for (i=3; i>=0; i--){
	if (BrCu[i] != undefined){
	BText = BText + ' &gt; ' + '<a href="' + BrCu[i] + '">' + BrCu.eq(i).html() + '</a>';
	}}
	$('#breadcrumb span.ins').html(BText);
	
	$('#breadcrumb, #nKnapper, #Navigation').hover(function(){
		$('#breadcrumb').stop().animate({
		opacity: '1',
		}, 100)
    }, function(){
		$('#breadcrumb').animate({
		opacity: '0',
		}, 2000)
	});
	
// test
	somecode = ""
});

