


$(document).ready(function(){
    
	
	//menu elemek effektje
		$('#menu_top a').blend(300);
		
        
 	initLoginBox();	//belépéshez / kilépéshez    
        
	
	$("#koncert_next").jqrotate(-5);	
	$("#koncert_next-wrap").jqrotate(-2);
			
		
		
});


function initForumLinks() {
	
	
	
	$('.outer_html').fancybox({
        'type'          :   'iframe', 
        'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200,
        'titleShow'     :   'true',
        'showCloseButton':  'true',
        'scrolling'     :   'auto',
        'autoDimensions':   'true',            
        'width'         :   '80%',
        'height'        :   '80%',
        'enableEscapeButton': 'true' 
    }                
); 
	
}

function initLoginBox() {
	
	
	$('#login_login_nick').example('Név');
	$('#login_login_password').example('Jelszó');
	$('#login #login_submit').click(function(){			
		logIn();			
	});
	

	$('#logged_in #login_submit').click(function(){			
		logOut();			
	});
}


function logIn() {
	
	$('#login').submit();
	return true;
	
	$('#fader_login').fadeOut('slow', function(){
		
		$.ajax({
			   type: "POST",
			   url: "/user/login",
			   data: $('#login').serialize(),
			   success: function(msg){
						$('#fader_login').fadeIn('slow', function(){});	
						$('#fader_login').html(msg);									
						initLoginBox();
					
			   }
			 });
		
	});
	
}


function logOut() {
	
	$('#logged_in').submit();
	return true;
	
	
	$('#fader_login').fadeOut('slow', function(){
		
		$.ajax({
			   type: "POST",
			   url: "/user/logout",
			   data: $('#login').serialize(),
			   success: function(msg){
						$('#fader_login').fadeIn('slow', function(){});	
						$('#fader_login').html(msg);									
						initLoginBox();
					
			   }
			 });
		
	});		
		
}






/**
 * 	egy adott div-et kinyit, bezar animalva
 * 
 * 
 * @param id
 * @return
 */
function openClose(id) {
	
   if( $('#'+id).hasClass('active') ) {
	
        $('#'+id).slideUp('slow', function() {
            // Animation complete.            
          });
        $('#'+id).removeClass('active')
        
        
    } else {        
        
        $('#'+id).slideDown('slow', function() {
            // Animation complete.            
          });
        $('#'+id).addClass('active')
       	
    }
}

function closeElement(id) {
	
	$('#'+id).slideUp('slow', function() {
        // Animation complete.            
      });
    $('#'+id).removeClass('active')
	
}

function openElement(id) {
	
	$('#'+id).slideDown('slow', function() {
        // Animation complete.            
      });
    $('#'+id).addClass('active')
    
}




/* debug */
function debug(text, indent){
    var eol = '<br />';
    pre = '';
    var i = 0;
    if(indent) {
        for(i = 0; i < indent; i++) {
            pre += '&nbsp;&nbsp;&nbsp;';
        }
    }
    text = pre + text;
    $('#debugbar .content').append(text+eol);
    return true;
} 


