var xypos = function(xy, wh) { return (xy) ? (xy - wh) / 2 : 0; }

var attr = function(x, y, w, h) {
	return 'menubar=no,toolbar=no,status=no,resizable=yes,width='+w+',height='+h+',left='+x+',top='+y;
}

var popup = function(q) {
	var w, h, x = xypos(screen.width, w = 600), y = xypos(screen.height, h = 430);
	var win = window.open('http://www.artists-connect.de/queue.php?q='+q, '_queue', attr(x, y, w, h)); win.focus(); return;
}

var magazine = function() {
	var w, h, x = xypos(screen.width, w = 1024), y = xypos(screen.height, h = 768);
	var win = window.open('http://www.artists-connect.de/magazine/magazine.html', '_magazine', attr(x, y, w, h)); win.focus(); return;
}

function gTranslate() { 
	new google.translate.TranslateElement({ includedLanguages: 'en,de,es' }); return;
}

function mailto(id) { popup(id); }

function v_height() {
	var h = $('#header').height(); var c = $('#content').height();
	var r = $('#right').height(); return (r > c) ? r + h : c + h;
}

$(document).ready(function() {
	var colors = new Array ('#b0b0b0', '#004466', '#999999', '#000088', '#0000cc', '#888888');
	
	if (!$.cookie('seed')) {
		var j = Math.floor( (6 - 1) * Math.random() ); $.cookie ('seed', j);
	} else { var j = $.cookie('seed'); }

	var i;
	$('.wp-tag-cloud a').each(function() {
		if (i == 1 || i == 4) { 
			var bold = 'bold'; 
			var space = '1px'
		}
		else {
			var bold = 'lighter';
			if (i == 3) 
				var space = '1.5px';
			else
				var space = '0.5px';
		} i = (j == 5) ? j = 0 : j++;
		$(this).css( 
			{ 
				'font-size' : 11+i+'pt', 
				'color' : colors[i], 
				'font-weight' : bold, 
				'letter-spacing' : space,
				'line-height' : i+j+16+'px'
			}
		);
	});
		
	$('#slideshow').cycle({
		fx: 'fade',	speedIn: 500, speedOut: 2500,
		before:  function (idx, slide) { $('#image-title').html('&nbsp;'); },
		after: function (idx, slide) { $('#image-title').html(slide.alt); }
	});

	$('#footer').css({ top: v_height()+52+'px' });
	$(window).resize(function(){ 
		$('#footer').css({ top: v_height()+52+'px' }); 
	});

	$('a[rel=on]').click(function(){
		$('#translate').attr({ src: 'http://translate.google.com/translate_a/element.js?cb=gTranslate' });
	});

	$('a[rel=uid]').click(function(){ 
		mailto( $(this).attr('class') );
	});

	$('a[rel=magazine]').click(function(){ 
		magazine();
	});

});

