// page effects
$(document).ready(function(){
$('#banners img').fadeIn(1400);
$('#badges img').fadeIn(1400);
$('#catimg img').fadeIn(1400);
$('#profiles img').fadeIn(1400);
});

// newsscroll
$(document).ready(function(){
$('marquee').marquee().mouseover(function () {
  $(this).trigger('stop');
}).mouseout(function () {
  $(this).trigger('start');
});
});

// newsscroll tooltip
$(document).ready(function() { 
    $(".newstick").tooltip({
    position: "bottom left",
    offset: [10,150],
    delay: 120
	});
});

// schema tooltips
$(document).ready(function() { 
	// schema td tips
    $("table.schema td div.ttip").tooltip({
    slideInSpeed: 170,
    slideOutSpeed: 90, 
    position: "top left",
    offset: [40,275],
    delay: 40
	});
	// kalenderlänkar tips
	$("a.kalenderlank").tooltip({
	tip:"#kalendertip",
    slideInSpeed: 170,
    slideOutSpeed: 90, 
    position: "top left",
    offset: [5,265],
    delay: 40
	});
});

// alternate presentation boxes
$(document).ready(function(){
$('div.presentation div.right:odd').addClass("left");
$('div.presentation div.right:odd').removeClass("right");
});

// accordion
$(document).ready(function(){
		$myid = location.href.replace(/.*#/,'');
		$myacc = '#acc_'+$myid;
		$myindex = $("*").filter(".accitem").index( $($myacc)[0] );
	$("#accordion").tabs("#accordion div.accitem div.artikel", {tabs: 'h2.accordiontab', effect: 'fade', fadeInSpeed:400, initialIndex: $myindex});	
});

// scroll to
$(document).ready(function($){
	$.localScroll.hash({
		queue:true,
		duration:1000
	});

	$.localScroll({
		queue:true,
		duration:800,
		hash:false
	});
});

// banners slideshow
$(document).ready(function() {
	$("#banners").tabs("#banners > a", {
		tabs: 'img',
		onClick: null, 
		event: 'right-click',
		effect: 'fade',
		fadeInSpeed: 1500,
		fadeOutSpeed: 1500,
		rotate: true	
	}).slideshow({
	autoplay: true,
	interval: 5000
	});
});

// badges slideshow
$(document).ready(function() {
	$("#badges").tabs("#badges > a", {
		tabs: 'img',
		onClick: null, 
		event: 'right-click',
		effect: 'fade',
		fadeInSpeed: 1000,
		fadeOutSpeed: 1000,
		rotate: true	
	}).slideshow({
	autoplay: true,
	interval: 3000
	});
});

// profiles slideshow
$(document).ready(function() {
	$("#profiles").tabs("#profiles > a", {
		tabs: 'img:not(.overlay)',
		onClick: null, 
		event: 'right-click',
		effect: 'fade',
		fadeInSpeed: 1500,
		fadeOutSpeed: 1500,
		rotate: true	
	}).slideshow({
	autoplay: true,
	interval: 7000
	});
});

// ajax search
$(document).ready(function() {
	//init
		var SearchText ='';
		$("#search").val("vad söker du?");
		$("#search").css("color", "#999999");
	//input focus
		$("#search").focus(function() {
			if($("#search").val() == "vad söker du?") {
				$("#search").val("");
			}
			$("#search").css("color", "#000000");
		});	
	//acontent blur (not bloody working now is it..)
		$("div.col2 div.acontent").blur(function() {
			$("div.col2 div.acontent").slideUp();
			$("div.col2 div.content").slideDown();
		});
	//blur
		$("#search").blur(function() {
			if($("#search").val() == "") {
				$("#search").val("vad söker du?");
				$("#search").css("color", "#999999");
			}
		});
	//keydown
		$("#search").keydown(function(e) {
			if(e.which == 8) {
				SearchText = $("#search").val().substring(0, $("#search").val().length-1);
			}
			else {
				SearchText = $("#search").val() + String.fromCharCode(e.which);
			}
			$("div.col2 div.content").slideUp();
			$("div.col2 div.acontent").load("async.php", { search: SearchText});
			$("div.col2 div.acontent").slideDown();
		});
	//acontent mouseenter and focus
		$("div.col2 div.acontent").mouseenter(function() {
		$("#search").blur();
		var SearchTextArr = SearchText.split(' ');  
		$('.col2').highlight(SearchTextArr);
		});	
});

// ajax load calendar
function loadgcal(calurl,loadinto){
if(!loadinto) loadinto = "div.col2 div.content";
$(loadinto).load(calurl);
// $(loadinto).load(calurl + '&' + loadinto);
}

