// JavaScript Document
var loadDone = false;
jQuery.noConflict();
var $j = jQuery;

$j(document).ready(function() {

    $j(".fs_list a").click(function(event){
	fillContent(this);
    });


    $j("#fiesta_close").click(function() {
         //$j('#mask').fadeTo("slow", 0.0);
         $j('#mask').fadeOut(500);
        $j('#dialog').hide();
    });
    
});

function fillContent(item)
{
	var imagepath = 'img/characters/';
	var charactername = item.rel;
	var characterimage = imagepath+charactername+'_form_img.png';
                switch (charactername) {
                      case "jaeger":
                        $j("#characterimage").attr("src", characterimage);
                        $j("#characterimage").css({'width' : '447',  'height' : '518'});
                        $j("#characterimage").removeClass('charakterimage').addClass('jaeger_position');
                        break;
                      case "priester":
                        $j("#characterimage").attr("src", characterimage);
                        $j("#characterimage").css({'width' : '299',  'height' : '572'});
                        $j("#characterimage").removeClass('charakterimage').addClass('priester_position');
                        break;
                      case "krieger":
                        $j("#characterimage").attr("src", characterimage);
                        $j("#characterimage").css({'width' : '332',  'height' : '583'});
                        $j("#characterimage").removeClass('charakterimage').addClass('krieger_position');
                        break;
                      case "magier":
                         $j("#characterimage").attr("src", characterimage);
                         $j("#characterimage").css({'width' : '414',  'height' : '528'});
                         $j("#characterimage").removeClass('charakterimage').addClass('magier_position');
                        break;
                      default:
                         $j("#characterimage").attr("src", characterimage);
                         $j("#characterimage").css({'width' : '414',  'height' : '528'});
                         $j("#characterimage").removeClass('charakterimage').addClass('magier_position');
                        break;
                    }


	formAndGameinfoPopup();
}

function formAndGameinfoPopup()
{
    if(!loadDone) {
        //loadDone = true;
        var id = "#dialog";  
   
      //Get the screen height and width  
        var maskHeight = $j(document).height();
        var maskWidth = $j(window).width();
      
        //Set height and width to mask to fill up the whole screen  
        $j('#mask').css({'width':maskWidth,'height':maskHeight});
          
        //transition effect       
        //$j('#mask').css('display','block');
        $j('#mask').fadeIn(500);
        $j('#mask').fadeTo("slow", 0.8);

      
        //Get the window height and width  
        var winH = $j(window).height();
        var winW = $j(window).width();
                
        //Set the popup window to center  
        $j(id).css('top',  winH/2-$j(id).height()/2);
        $j(id).css('left', winW/2-$j(id).width()/2);
		
		
        //transition effect  
        $j(id).fadeIn(1000);

        return true;
    }
} 

