var scrollerOptions = {
	autoScroll: "onstart",
	autoScrollDirection: "left",
	autoScrollStep: 1,
	autoScrollInterval: 3,
	startAtElementId: "startDiv",
	visibleHotSpots: "always",
	hotSpotsVisibleTime: 5
};

$(document).ready(function(){
	$("#slider").easySlider();
	
	if(typeof $('#scroller').smoothDivScroll == 'function'){
		$("#scroller").smoothDivScroll(scrollerOptions);
		
		$("#scroller .scrollableArea img").mouseover(function(){
			img = $(this);
			
			url = img.attr("src").split("/");
			file = url[url.length-1];
			ext = file.split(".")[1];
			newurl = '';
			
			if (ext == "png"){
				for (i=0;i<url.length-1;i++){
					if (url[i].length == 0)
						continue;
						
					newurl += url[i]+"/";
				}
				newurl += 'over/';
				
				img.attr('src',newurl+file);
			}
		}).mouseout(function(){
			img = $(this);
			src = img.attr("src").replace("/over","");
			img.attr("src",src);
		});
	}
	

	$(".artistOverview a").hover(function(){
		tip = $(this).find('.tip');
		tip.show(); //Show tooltip
	}, function() {
		tip.hide(); //Hide tooltip		  
	}).mousemove(function(e) {
		var mousex = e.pageX + 20; //Get X coodrinates
		var mousey = e.pageY + 20; //Get Y coordinates
		var tipWidth = tip.width(); //Find width of tooltip
		var tipHeight = tip.height(); //Find height of tooltip
		
		//Distance of element from the right edge of viewport
		var tipVisX = $(window).width() - (mousex + tipWidth);
		//Distance of element from the bottom of viewport
		var tipVisY = $(window).height() - (mousey + tipHeight);
		  
		if ( tipVisX < 20 ) { //If tooltip exceeds the X coordinate of viewport
			mousex = e.pageX - tipWidth - 20;
		} if ( tipVisY < 20 ) { //If tooltip exceeds the Y coordinate of viewport
			mousey = e.pageY - tipHeight - 20;
		} 
		tip.css({  top: mousey, left: mousex });
	});
});

/* Mail obfuscator */

// Email.js version 5
var tld_ = new Array()
tld_[0] = "nl";
tld_[1] = "com";
tld_[2] = "net";
var topDom_ = 13;
var m_ = "mailto:";
var a_ = "@";
var d_ = ".";

function mail(name, dom, tl)
{
	var s = e(name,dom,tl);
	document.write(s);
}
function mail2(name, dom, tl, params, display)
{
	document.write('<a href="'+m_+e(name,dom,tl)+'">'+e(name,dom,tl)+'</a>');
}
function e(name, dom, tl)
{
	var s = name+a_;
	if (tl!=-2)
	{
		s+= dom;
		if (tl>=0)
			s+= d_+tld_[tl];
	}
	else
		s+= swapper(dom);
	return s;
}
function swapper(d)
{
	var s = "";
	for (var i=0; i<d.length; i+=2)
		if (i+1==d.length)
			s+= d.charAt(i)
		else
			s+= d.charAt(i+1)+d.charAt(i);
	return s.replace(/\?/g,'.');
}
