$(document).ready(function(){
						   
// ChillTip Version 1.0 - add class="chillTip" and title="This is a Chilltip" tag to img,a,span attributes. 
						   
$('a[title]').mouseover(function(){								  
	$('body').append('<div class="title"></div>');
	var title = $(this).attr("title");
	$('.title').append('<p>' + title + '</p>');
	// Change the value below to change opacity of the ChillTip from 0-100 or 0.0-1.0
	$('.title').css("filter:","alpha(opacity=85)").css("-moz-opacity","0.85").css("-khtml-opacity", "0.85").css("opacity", "0.85");  
	$('.title').fadeIn(500);  //ChillTip fade in time (recommended 500ms)
	this.tip = this.title;
	this.title = "";
	});

$('a[title]').mousemove(function(e){
	var border_top = $(window).scrollTop(),border_right = $(window).width(),offset = 15,left_pos,top_pos;
    if(	border_right - (offset *2) >= $('.title').width() + e.pageX){left_pos = e.pageX + offset;}
	else{left_pos = border_right - $('.title').width() - offset;}
	if(border_top + (offset *2 ) >= e.pageY - $('.title').height()){top_pos = border_top + offset;}
	else{top_pos = e.pageY-$('.title').height( )- offset;}	
	$('.title').css({left:left_pos, top:top_pos});
	});

$('a[title]').mouseout(function(){
	$('.title').remove();
	this.title = this.tip;
	});
		
function initAds() {
	if($('body').hasClass('bransch-selected')) {
		showRandomAdInCategory('#bransch-ads');
	} else if($('body').hasClass('process-selected')) {
		showRandomAdInCategory('#process-ads');
	} else if($('body').hasClass('prenumerera-selected')) {
		showRandomAdInCategory('#prenumeration-ads');
	} else {
		showRandomAdInCategory('#default-ads');
	}
}
function showRandomAdInCategory(ad_cat) {
	var adcount = $(ad_cat + ' li').length;
	var randomad = Math.floor(Math.random()*adcount + 1);
	$(ad_cat + ' li:nth-child(' + randomad + ')').fadeIn('slow');	
}
initAds();
});






