$(document).ready(function() {
	
	$('#marquee').each(function(el){
		$(this).tabs({ fx: {opacity: 'toggle'} }).tabs('rotate', 10000);
		
		$(this).mouseover(function(){
			$(this).tabs('rotate', 0, false);
		});
		$(this).mouseout(function(){
			$(this).tabs({ fx: {opacity: 'toggle'} }).tabs('rotate', 10000);
		});
	});
	
	$('.open-window').each(function(el){
		var trigger = $(this);
		var target = $(this).next('.modal-window');
			target.jqm({
				overlay: 0,
				onShow: function(h) {
					h.w.css('opacity',1).fadeIn('fast');
					var topPos = $(window).scrollTop() + 50;
					h.w.css('top',topPos);
				},
				onHide: function(h) {
					h.w.fadeOut('fast',function() { 
					if(h.o) h.o.remove();
				});
				}
			});
			target.jqmAddTrigger(trigger);
		});
	
	if($('#open-project-slideshow').length > 0){
		var trigger = $('#open-project-slideshow');
		var target = $('#project-slideshow');
		target.jqm({
			overlay: 0,
			onShow: function(h) {
				h.w.css('opacity',1).fadeIn('fast');
				var topPos = $(window).scrollTop() + 50;
				h.w.css('top',topPos);
			},
			onHide: function(h) {
				h.w.fadeOut('fast',function() { 
				if(h.o) h.o.remove();
			});
			}
		});
		target.jqmAddTrigger(trigger);
		
		$('#slideshow-thumbs li').each(function(el){
			$(this).click(function(i){
				$(this).siblings().removeClass('current');
				$(this).addClass('current');
				$('#slideshow-image').html($(this).html());
			});
		});
	}
	
});

function spamBlock(a,b,c){
	if(c=="mail"){
		locationstring="mailto:"+a+"@"+b;
	} else {
		locationstring=a+b;
	}
	window.location=locationstring;
}

function externalLinks() {  
	if (!document.getElementsByTagName) return;  
	var anchors = document.getElementsByTagName("a");  
	for (var i=0; i<anchors.length; i++) {  
		var anchor = anchors[i];  
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
	}
}
window.onload = externalLinks;

