var box_pos;
var uefa_box_slide;
var selected_club;

function uefa2009_clubs_show()
{
    close_banner();
    win_width = window.getSize()['size']['x'];
    box_pos = (win_width / 2) - 310; 
    
    mbox_open(620, 800, true, box_pos, 50);
    pre_fullscreen();

    new Ajax('/bin/uefa2009/presentation.php', {
	     method: 'get',
	     encoding: 'utf-8',
	     update: $('MBOX_window'),
	     evalScripts: true,
	     onComplete: function() {
    		var imgpath = '/static/slo/main/img/box/central/uefa2009/logos/';
    	
    	    uefa_box_slide = new Fx.Slide('black_box');
    	    uefa_box_slide.hide();
    		
    	 	$$('.club_set_logos a img').addEvents({
    	 		'mouseover': function() { 
    	 			imgsrc = this.src.split('/');
    	 			fname = imgsrc[imgsrc.length-1];
    	 			this.src = imgpath + 'small/' + fname;
    	 			
    	 			$('caption_content').innerHTML = this.getAttribute('alt');
    	 			$('caption').setStyle('display', 'block');

    	 			cap_width = $('caption').getSize()['size']['x'];
    	 			$('caption_arrow').setStyle('width', cap_width);

    	 			$('caption').setStyles({
    	 				'top': this.getPosition()['y'] - 32 - 50,
    	 				'left': this.getPosition()['x'] - (cap_width/2) + 20 - box_pos
    	 			});
    	 			
    	 			// alert(this.getAttribute('alt'));
    	 		},
    	 		'mouseout': function() {
    	 			if (selected_club != this.id) {
	    	 			imgsrc = this.src.split('/');
	    	 			fname = imgsrc[imgsrc.length-1];
	    	 			this.src = imgpath + 'gray/' + fname;
    	 			}
    	 			
    	 			$('caption').setStyles({
    	 				'display': 'none'
    	 			});
    	 		},
    	 		'click': function(e) {
    	 			// reset previous selected icon
    	 			if (selected_club) {
    	 				imgsrc = $(selected_club).src.split('/');
	    	 			fname = imgsrc[imgsrc.length-1];
	    	 			$(selected_club).src = imgpath + 'gray/' + fname;
    	 			}
    	 			
    	 			// hide caption
    	 			$('caption').setStyle('display', 'none');
    	 			
    	 			// set image
    	 			imgsrc = this.src.split('/');
    	 			fname = imgsrc[imgsrc.length-1];
    	 			this.src = imgpath + 'small/' + fname;
    	 			
    	 			// set title
    	 			$('title_text').innerHTML = this.getAttribute('alt');
    	 			
    	 			// set title image
    	 			$('title_image').src = imgpath + 'small/' + fname;
    	 			
    	 			// set selected club global var
    	 			selected_club = this.id;
    	 			
    	 			//
    	 			e = new Event(e);
    	 			$('data_content').innerHTML = '';
    	 			$('loading').setStyle('display', 'block');
    	 			load_club_data(this.id);
    	 			e.stop();
    	 		}
    	 	});
    	 }
	}).request();
}

function uefa2009_content_show(content_id)
{
    close_banner();
    win_width = window.getSize()['size']['x'];
    box_pos = (win_width / 2) - 310;
    
    mbox_open(620, 800, true, box_pos, 50);
    pre_fullscreen();

    new Ajax('/bin/uefa2009/static_content.php', {
	     method: 'get',
	     encoding: 'utf-8',
	     data: { content: content_id },
	     update: $('MBOX_window'),
	     evalScripts: true,
	     onComplete: function() {
    	 }
	}).request();
}

function load_club_data(club_id) {
	new Ajax('/bin/uefa2009/club_data.php', {
	     method: 'get',
	     data: { club: club_id },
	     encoding: 'utf-8',
	     evalScripts: true,
	     onComplete: function(data) {
	    	 $('data_content').innerHTML = data;
	    	 $('loading').setStyle('display', 'none');
	    	 uefa_box_slide.slideIn();
   	 	 }
	}).request();
}
