function show_player_promo(){
	var content = '<div id="pp_holder"><div id="pp"> \
		<div id="pp_top">DO IT FOR THE FAME!<a href="#" class="pp_close">Close</a></div> \
		<div id="pp_contenth"><div id="pp_content"></div></div> \
	</div></div>';
	$('#wrap').prepend(content);
	$('#pp_content').load('include/player_promo.inc.php',function(){
		$('#form_player_promo').submit(function(){
			var my_form = document.form_player_promo;
			var error = 0;
			$('input#pp_name').removeClass('err');
			$('input#pp_phone').removeClass('err');
			$('input#pp_email').removeClass('err');
			if ($('input#pp_name').val()==''){
				$('input#pp_name').addClass('err');
				error = 1;
			}
			if ($('input#pp_email').val()=='' && $('input#pp_phone').val()==''){
				$('input#pp_email').addClass('err');
				$('input#pp_phone').addClass('err');
				error = 1;			
			}
			if (error==0){
				$('#pp_content').fadeOut(function(){
					$('#pp_contenth').addClass('loader');
					var inputs = [];
					$(':input', my_form).each(function() {
						inputs.push(this.name + '=' + encodeURIComponent(this.value));
					})  
					jQuery.ajax({
						data: inputs.join('&'),
						url: 'scripts/scr_player_promo.php',
						timeout: 5000,
						error: function() {
							$('#pp_content').html('<div id="pp_confirm"><p>Your request could not be processed.<br />Please try again later.</p><div id="btn_pp_confirm" class="cbutton"><div class="cbuttons">&nbsp;</div><a class="cbuttonc pp_close" href="#">Close</a></div></div>');
							$('#pp_contenth').removeClass('loader');
							$('#pp_content').fadeIn(function(){
							
							});
						},
						success: function(r) { 
							switch(r){
								case "1":
									$('#pp_content').html('<div id="pp_confirm"><p>Your request was sent.<br />Thank you!</p><div id="btn_pp_confirm" class="cbutton"><div class="cbuttons">&nbsp;</div><a class="cbuttonc pp_close" href="#">Close</a></div></div>');
									$('#pp_contenth').removeClass('loader');
									$('#pp_content').fadeIn(function(){
									
									});
									break;
								default:
									$('#pp_content').html('<div id="pp_confirm"><p>Your request could not be processed.<br />Please try again later.</p><div id="btn_pp_confirm" class="cbutton"><div class="cbuttons">&nbsp;</div><a class="cbuttonc pp_close" href="#">Close</a></div></div>');
									$('#pp_contenth').removeClass('loader');
									$('#pp_content').fadeIn(function(){
									
									});
									break;
							}
						}
					});
				});
			}
			return false;
		});
		$('#pp_holder').css({'visibility':'hidden','display':'block'});
		var ch = parseInt($('#pp').height());
		$('#pp_holder').css('height',$('#wrap').height());
		$('#pp').css({'margin-top':'-'+(ch/2)+'px'});
		$('#pp_holder').css({'display':'none','visibility':'visible'});
		$('#pp_holder').show();	
	});
}

function show_announcement(title,content){
	var ann_close = '<a href="#" class="ann_close">Close</a>';
	var ann_top = '<div id="ann_top">'+decodeURIComponent(title)+ann_close+'</div>';
	var action = '<div id="alert_actionh" style="width:65px;"><div class="cbutton"><div class="cbuttons">&nbsp;</div><a class="cbuttonc ann_close" href="#">Close</a></div></div>';
	var ann = '<div id="ann_holder"><div id="ann"> \
		'+ann_top+' \
		<div id="ann_content">'+decodeURIComponent(content)+'</div> \
		<div id="ann_action">'+action+'</div> \
	</div></div>';
	$('#wrap').prepend(ann);
	$('#ann_holder').css({'visibility':'hidden','display':'block'});
	var ch = parseInt($('#ann').height());
	$('#ann_holder').css('height',$('#wrap').height());
	$('#ann').css({'margin-top':'-'+(ch/2)+'px'});
	$('#ann_holder').css({'display':'none','visibility':'visible'});
	$('#ann_holder').show();
}

function show_alert(type,content,action){
	var alert_close = '<a href="#" class="alert_close">Close</a>';
	if (type=='login') alert_top = '<div id="alert_top">Login required'+alert_close+'</div>';
	if (type=='alert') alert_top = '<div id="alert_top">Alert'+alert_close+'</div>';
	if (type=='info') alert_top = '<div id="alert_top">Info'+alert_close+'</div>';
	if (type=='login'){
		content = 'Du musst angemeldet sein, um diese Funktion zu nutzen.<br />Melde dich an oder klicke auf die Register Site.';
		action = '<div id="alert_actionh" style="width:145px;"><div class="cbutton"><div class="cbuttons">&nbsp;</div><a class="cbuttonc" href="login.html">Login</a></div> <div class="cbutton"><div class="cbuttons">&nbsp;</div><a class="cbuttonc" href="register/">Register</a></div></div>';	
	}
	if (action==0) action = '<div id="alert_actionh" style="width:65px;"><div class="cbutton"><div class="cbuttons">&nbsp;</div><a class="cbuttonc alert_close" href="#">Close</a></div></div>';
	var alert = '<div id="alert_holder"><div id="alert"> \
		'+alert_top+' \
		<div id="alert_content">'+content+'</div> \
		<div id="alert_action">'+action+'</div> \
	</div></div>';
	$('#wrap').prepend(alert);
	$('#alert_holder').css('height',$('#wrap').height());
	$('#alert_holder').show();
}

function open_uploader(){
	$('body').prepend('<div id="uploader_holder"><div id="uploader"></div></div>');
	var ch = parseInt($('#wrap').height());
	var wh = parseInt($(window).height());
	var scrollTop = $(window).scrollTop();
	if (ch>wh){
		$('#uploader_holder').height(ch+'px');
	}
	var bh = 391;
	var pos_top = (wh-bh)/2;
	if (pos_top<50) pos_top = 50;
	$('#uploader').css('top',(pos_top+scrollTop)+'px');
}

function close_uploader(){
	$('#uploader_holder').hide().remove();
}

var activity = 0;
var home_games_navr_count = 1;
var home_headline = 0;
var home_headline_sel = 1;
var home_headline_count = 0;
var home_player = 0;
var gallery = 0;
var calendar = 0;
var players = 0;
var news_content_visible = 0;
var press_content_visible = 0;

function load_headline(elem,id,hr){
	if (home_headline==0){
		home_headline = 1;
		var my_id = id;
		var my_link = elem;
		$('#headline .headline_holder').addClass('loader');
		$('#headline_nav_list a').removeClass('sel');
		$('#headline .headline_content').fadeOut(function(){
			$('#headline .headline_content').load('include/home_headline.inc.php',{id:my_id,hr:hr},function(){
				$('#headline .headline_holder').removeClass('loader');
				$('#headline .headline_content').fadeIn(function(){
					$(my_link).addClass('sel');
					home_headline_sel = parseInt($(my_link).parent().attr('id').replace('hh_',''));
					home_headline = 0;
				});
			
			});
		});
	}		
}

function next_headline(){
	var ne = home_headline_sel+1;
	var next_elem = (ne<=home_headline_count)?ne:1;
	var elem = $('#hh_'+next_elem).children('a');
	var id = elem.attr('id').replace('hbuzz_','');
	load_headline(elem,id,1);
}

function start_autoplay(){
	stop_autoplay();
	timerID = setInterval("next_headline();",7000);
}

function stop_autoplay(){
	if(typeof(timerID) !== 'undefined'){
		clearInterval(timerID);
	}
}

$(document).ready(function(){

	$('#btn_player_promo a').live('click',function(){
		show_player_promo();
		return false;
	});

	if ($('#headline').length>0){
		var count = $('#headline_nav_list ul li').size();
		home_headline_count = count;
		if (count>1){
			start_autoplay();
			$('#headline').live('mouseover',function(){
				stop_autoplay();
			});
	
			$('#headline').live('mouseout',function(){
				start_autoplay();
			});
		}		
	}

	$('div.player_profile_photos div.ppp_action a').live('click',function(){
		var what = $(this).attr('id').split('_');
		var action = what[0];
		var id = what[1];
		var player = $('.player_profile_photos ul').attr('id').replace('player_','');
		switch(action){
			case 'edit':{
				return true;
				break;
			}
			case 'first':{
				$.post('scripts/scr_player_photo_first.php',{player:player,id:id},function(data){
					window.location.reload();
				});
				return false;
				break;
			}
			case 'delete':{
				if (confirm('Are you sure you want to delete the selected photo?')){
					$.post('scripts/scr_player_photo_delete.php',{player:player,id:id},function(data){
						window.location.reload();
					});
				}
				return false;
				break;
			}
			case 'adelete':{
				if (confirm('Are you sure you want to delete the selected album?\nAll photos in this album will be also deleted!')){
					$.post('scripts/scr_player_album_delete.php',{player:player,id:id},function(data){
						window.location.reload();
					});
				}
				return false;
				break;
			}
			default:{
				return false;
				break;
			}
		}
	});

	$('#award_add').live('click',function(){
		var id = $('#award_holder').children().size()/2;
		$('#award_holder').append('<div class="fi"><label>Date</label><input type="text" name="award_date'+(id+1)+'" id="award_date'+(id+1)+'" value="dd/mm/jjjj" onblur="if(this.value == \'\') {this.value = \'dd/mm/jjjj\';}" onfocus="if(this.value == \'dd/mm/jjjj\') {this.value = \'\';}" /></div><div class="fi"><label>Award</label><input type="text" name="award_award'+(id+1)+'" id="award_award'+(id+1)+'" /></div>');
		$('#aw_count').val(id+1);
		return false;
	});

	$('#pclub_add').live('click',function(){
		var id = $('#pclub_holder').children().size()/2;
		$('#pclub_holder').append('<div class="fi"><label>Between</label><input type="text" name="pclubs_date'+(id+1)+'" id="pclubs_date'+(id+1)+'" value="jjjj - jjjj" onblur="if(this.value == \'\') {this.value = \'jjjj - jjjj\';}" onfocus="if(this.value == \'jjjj - jjjj\') {this.value = \'\';}" /></div><div class="fi"><label>Club</label><input type="text" name="pclubs_club'+(id+1)+'" id="pclubs_club'+(id+1)+'" /></div>');
		$('#pc_count').val(id+1);
		return false;
	});

	$('a.btn_b_photo').live('click',function(){
		$('#buzz_uphoto_w').val($('#uimg_width').val());
		$('#buzz_uphoto_h').val($('#uimg_height').val());
		$('#buzz_uphoto_x1').val($('#uimg_x1').val());
		$('#buzz_uphoto_y1').val($('#uimg_y1').val());
		$('#buzz_uphoto_x2').val($('#uimg_x2').val());
		$('#buzz_uphoto_y2').val($('#uimg_y2').val());
		close_uploader();
		return false;
	});

	$('a.btn_p_photo').live('click',function(){
		$('#pphoto_photo_w').val($('#uimg_width').val());
		$('#pphoto_photo_h').val($('#uimg_height').val());
		$('#pphoto_photo_x1').val($('#uimg_x1').val());
		$('#pphoto_photo_y1').val($('#uimg_y1').val());
		$('#pphoto_photo_x2').val($('#uimg_x2').val());
		$('#pphoto_photo_y2').val($('#uimg_y2').val());
		close_uploader();
		return false;
	});

	$('a.btn_n_photo').live('click',function(){
		$('#news_photo_w').val($('#uimg_width').val());
		$('#news_photo_h').val($('#uimg_height').val());
		$('#news_photo_x1').val($('#uimg_x1').val());
		$('#news_photo_y1').val($('#uimg_y1').val());
		$('#news_photo_x2').val($('#uimg_x2').val());
		$('#news_photo_y2').val($('#uimg_y2').val());
		close_uploader();
		return false;
	});

	$('input#pint_title').focus(function() {
		if (press_content_visible==0){
			$('#profile_press_add_content').slideDown(function(){
				press_content_visible = 1;
			});
		}
	});

	$('input#news_title').focus(function() {
		if (news_content_visible==0){
			$('#profile_news_add_content').slideDown(function(){
				news_content_visible = 1;
				$("#news_content").wysiwyg({
					css : 'http://www.yabazz.com/css/wysiwyg.css',
				    controls: {
						justifyFull   : { visible : false },
						subscript   : { visible : false },
						superscript : { visible : false },
						undo : { visible : false },
						redo : { visible : false },
						insertHorizontalRule : { visible : false },
						h1 : { visible : false },
						h2 : { visible : false },
						h3 : { visible : false },
						h1mozilla : { visible : false },
						h2mozilla : { visible : false },
						h3mozilla : { visible : false },
						separator04 : { visible : false },
						separator09 : { visible : false },
						insertImage : { visible : false },
						insertTable : { visible : false }
					}	
				});
			});
		}
	});
	
	$('#form_player_news_cancel').live('click',function(){
		$('#profile_news_add_content').slideUp(function(){
			news_content_visible = 0;
			$('#news_content').wysiwyg('destroy');
			$('#news_title').removeClass('err');
			$('input#news_title').val('');
			$('textarea#news_content').val('');
		});
	});

	$('#form_player_press_cancel').live('click',function(){
		$('#profile_press_add_content').slideUp(function(){
			press_content_visible = 0;
			$('#pint_title').removeClass('err');
			$('input#pint_title').val('');
			$('textarea#pint_short').val('');
			$('input#pint_url').val('http://');
		});
	});

	$('#form_buzz_editor_cancel').live('click',function(){
		$('#buzz_editor_holder').hide().remove();
	});

	$('a.alert_close').live('click',function(){
		$('#alert_holder').hide().remove();
		return false;
	});

	$('a.ann_close').live('click',function(){
		$('#ann_holder').hide().remove();
		return false;
	});

	$('.pp_close').live('click',function(){
		$('#pp_holder').hide().remove();
		return false;
	});

	$('#ym_login').live('click',function(){
		$('#header_login').toggle();
		return false;
	});

	$.extend($.fn.jScrollPane.defaults, {showArrows:true,arrowSize:10,animateTo:true});

	$('.scrollbars').jScrollPane();

	$('#btn_write_buzz, a.buzz_edit').live('click',function(){
		if ($(this).hasClass('rl')){
			show_alert('login','','');
		}
		else{
			var id = '';
			if ($(this).hasClass('buzz_edit')){
				id = $(this).attr('id').replace('buzz_','');
			}
			$('#wrap').prepend('<div id="buzz_editor_holder"><div id="buzz_editor"><div id="buzz_editor_content"></div></div></div>');
			$('#buzz_editor_holder').css('height',$('#wrap').height());
			$('#buzz_editor').addClass('loader');
			$('#buzz_editor_holder').show();
			$('#buzz_editor_content').load('include/buzz_editor.inc.php',{id:id},function(){
				$('#buzz_editor').removeClass('loader');	
				$('#buzz_editor_content').fadeIn(function(){
					$("#buzz_buzz").wysiwyg({
						css : 'http://www.yabazz.com/css/wysiwyg.css',
					    controls: {
							justifyFull   : { visible : false },
							subscript   : { visible : false },
							superscript : { visible : false },
							undo : { visible : false },
							redo : { visible : false },
							insertHorizontalRule : { visible : false },
							h1 : { visible : false },
							h2 : { visible : false },
							h3 : { visible : false },
							h1mozilla : { visible : false },
							h2mozilla : { visible : false },
							h3mozilla : { visible : false },
							separator04 : { visible : false },
							separator09 : { visible : false },
							insertImage : { visible : false },
							insertTable : { visible : false }
						}	
					});
				});
			});
		}
		return false;
	});

	$('#players_top a').live('click',function(){
		if (players==0){
			players = 1;
			var what = $('#players').attr('class').split('_');
			var script = '';
			var id = '';
			var team_info = $(this).attr('id').split('_');
			var team = '';
			var team_no = '';
			switch(what[0]){
				case 'game':{
					script = 'include/players.inc.php';
					id = $('#players').attr('class').replace('game_','')
					team = team_info[1];
					break;
				}
				case 'player':{
					script = 'include/team.inc.php';
					id = $('#players').attr('class').replace('player_','')
					team = team_info[1];
					team_no = team_info[2];
					break;
				}
				default:{
					break;
				}
			}
			$('#players_top a').removeClass('sel');
			$(this).addClass('sel');
			$('#players_holder').addClass('loader2');
			$('#players_content').fadeOut(function(){
				$('#players_content').load(script,{id:id,team:team,team_no:team_no},function(){
					$('#players_holder').removeClass('loader2');
					$('#players_content').fadeIn(function(){
						$('#players_content').jScrollPane({maintainPosition:false});
						players = 0;
					});
				});
			});	
		}
		return false;
	});

	$('.calendar_top a').live('click',function(){
		if (calendar==0){
			calendar = 1;
			var type = $('div.calendar').attr('id').replace('cal_','');
			var date = $(this).attr('class').replace('cal_','').split('_');
			var month = date[0];
			var year = date[1];
			var cr = 1;
			var ch = $('.calendar_dates ul').outerHeight();
			$('.calendar_dates').css({'height':ch+'px'});
			$('.calendar_dates').addClass('loader2');
			$('.calendar_dates ul').fadeOut(function(){
				$('.calendar_dates').load('include/calendar.inc.php',{type:type,month:month,year:year,cr:cr},function(){
					$('.calendar_dates ul').css({'visibility':'hidden','display':'block'});
					var new_ch = $('.calendar_dates ul').outerHeight();
					$('.calendar_dates').animate({'height':new_ch+'px'},function(){
						$('.calendar_dates ul').css({'display':'none','visibility':'visible'});
						$('.calendar_dates ul').fadeIn(function(){
							calendar = 0;
						});
					});
					
				
				});
			});
		}
		return false;
	});

	$('#galleryl_nav .cbutton a, #galleryl_tlist a, #galleryl_content a').live('click',function(){
		if (gallery==0){
			gallery = 1;
			var what = $('#galleryl').attr('class').split('_');
			switch(what[0]){
				case 'game':{
					script = 'include/galleryl_game.inc.php';
					what = $('#galleryl').attr('class').replace('game_','');
					break;
				}
				case 'player':{
					script = 'include/galleryl_player.inc.php';
					what = $('#galleryl').attr('class').replace('player_','');
					break;
				}
				default:{
					break;
				}
			}
			var photo = $(this).attr('id').replace('photo_','');
			if (photo=='') photo = $(this).attr('class').replace('photo_','');
			var pr = 1;
			var ch = $('#galleryl_content').height();
			$('#galleryl_content').css({'height':ch+'px'});
			$('#galleryl_cphoto').fadeOut(function(){
				$('#galleryl_content').addClass('loader');
				$('#galleryl_info strong').fadeOut(function(){
					$.post(script,{what:what,pid:photo,pr:pr},function(data){
						var info = data.split('|');
						var info_src = info[0];
						var info_pos = info[1];
						var info_count = info[2];
						var info_prev_id = info[3];
						var info_prev_url = decodeURIComponent(info[4].replace(/\+/g,  " "));
						var info_next_id = info[5];
						var info_next_url = decodeURIComponent(info[6].replace(/\+/g,  " "));
						var info_photo_url = decodeURIComponent(info[7].replace(/\+/g,  " "));
						var info_photo_info = decodeURIComponent(info[8].replace(/\+/g,  " ")); 
						var info_photo_height = info[9]; 
						$('#galleryl_count strong').html(info_pos);
						$('#galleryl_info strong').html(info_photo_info);
						$('#galleryl_nav a.nav_prev').attr('id','photo_'+info_prev_id);
						$('#galleryl_nav a.nav_next').attr('id','photo_'+info_next_id);
						$('#galleryl_nav a.nav_prev').attr('href',info_prev_url);
						$('#galleryl_nav a.nav_next').attr('href',info_next_url);			
						$('#galleryl_cphoto').html('<a href="'+info_next_url+'" class="photo_'+info_next_id+'"></a>');
						$(new Image()).attr('src',info_src+'?random='+(new Date()).getTime()).load(function(){
//						$(new Image()).attr('src',info_src).load(function(){
							$('#galleryl_cphoto a').html(this);	
							$('#galleryl_content').animate({'height':info_photo_height+'px'},function(){
								$('#galleryl_content').removeClass('loader');
								$('#galleryl_cphoto').fadeIn(function(){
									$('#galleryl_info strong').fadeIn(function(){
										gallery = 0;
									});
								});
							});
						}).attr('src',info_src)	
					});
				
				});
			});
		}
		return false;
	});

	$('#btn_player_follow a').live('click',function(){
		if ($(this).hasClass('rl')){
			show_alert('login','','');
		}
		else{
			var my_id = $(this).attr('id').replace('follow_','');
			var my_elem = $(this);
			$.post('scripts/scr_player_follow.php',{id:my_id},function(data){
				var msg = 'Follow';
				if (data==1) msg = 'Unfollow';
				my_elem.html(msg);
			});
		}	
		return false;
	});

	$('#gallery_nav_left a').live('click',function(){
		if ($(this).hasClass('rl')){
			show_alert('login','','');
			return false;
		}
		else{
			if (gallery==0){
				return true;
			}
			else{
				return false;
			}
		}
	});

	$('#gallery_nav_right a').live('click',function(){
		if (gallery==0){
			gallery = 1;
			var game = $('#gallery').attr('class').replace('game_','');
			var photo = $(this).attr('id').replace('photo_','');
			var pr = 1;
			var elem1 = "gallery_photo1";
			var elem2 = "gallery_photo2";
			if ($("#gallery_photo2").is(":hidden")){
				elem1 = "gallery_photo2";
				elem2 = "gallery_photo1";
			}
			$("#"+elem2).css({"z-index":50});
			$("#"+elem1).css({"z-index":100});
			$('#gallery_nav_info em').fadeOut(function(){
				$('#gallery_nav_info').addClass('loader2');
				$.post('include/gallery_game.inc.php',{game:game,id:photo,pr:pr},function(data){
					var info = data.split('|');
					var info_src = info[0];
					var info_pos = info[1];
					var info_count = info[2];
					var info_prev_id = info[3];
					var info_prev_url = decodeURIComponent(info[4].replace(/\+/g,  " "));
					var info_next_id = info[5];
					var info_next_url = decodeURIComponent(info[6].replace(/\+/g,  " "));
					var info_photo_url = decodeURIComponent(info[7].replace(/\+/g,  " "));
					$('#gallery_nav_info em').html('Bilder '+info_pos+' von '+info_count);
					$('#gallery_nav_right a.nav_prev').attr('id','photo_'+info_prev_id);
					$('#gallery_nav_right a.nav_next').attr('id','photo_'+info_next_id);
					$('#gallery_nav_right a.nav_prev').attr('href',info_prev_url);
					$('#gallery_nav_right a.nav_next').attr('href',info_next_url);			
					$('#gallery_nav_left a').attr('href',info_photo_url);			
					$(new Image()).attr('src',info_src+'?random='+(new Date()).getTime()).load(function(){
//					$(new Image()).attr('src',info_src).load(function(){
						$('#'+elem1).html(this);
						$("#"+elem1).fadeIn(800,function(){
							$("#"+elem2).css({"display":"none"});
							$('#gallery_nav_info').removeClass('loader2');
							$('#gallery_nav_info em').fadeIn(function(){
								gallery = 0;
							});
						});
					}).attr('src', info_src);		
				});
			});
		}
		return false;
	});

	$('a.share_like').live('click',function(){
		if ($(this).hasClass('rl')){
			show_alert('login','','');
		}
		else{
			if (!$(this).children('span').hasClass('liked')){
				var what = $(this).attr('id').split('_');
				var script = '';
				var id = '';
				switch(what[0]){
					case 'gamel':{
						script = 'scripts/scr_game_like.php';
						id = $(this).attr('id').replace('gamel_','');
						break;
					}
					case 'buzzl':{
						script = 'scripts/scr_buzz_like.php';
						id = $(this).attr('id').replace('buzzl_','');
						break;
					}
					case 'pnewsl':{
						script = 'scripts/scr_player_news_like.php';
						id = $(this).attr('id').replace('pnewsl_','');
						break;
					}
					default:{
						break;
					}
				}
				$(this).children('span').fadeOut(function(){
					$(this).addClass('liked');
					$(this).html('Danke!');
					$(this).fadeIn(function(){
						$.post(script,{id:id},function(){
						});
					});
				});
			}
		}
		return false;		
	});

	$('#next_games_list a.game_vote, #next_games_vote a').live('click',function(){
		if ($(this).hasClass('rl')){
			show_alert('login','','');
		}
		else{
			if (!$(this).hasClass('voted')){
				$(this).addClass('voted');
				var game = $(this).attr('id').replace('gvote_','');
				var content = $(this).children('em');
				$(content).fadeOut(function(){
					$(content).html('Danke!');
					$(content).fadeIn(function(){
						$.post('scripts/scr_game_vote.php',{game:game},function(){
						
						});
					});			
				});
			}
		}
		return false;
	})

	$('#form_login_btn').live('click',function(){
		$('#form_login').submit();
		return false;
	});

	$('#next_games_nav_list ul li a').live('click',function(){
		if (home_headline==0){
			home_headline = 1;
			var my_id = $(this).attr('id').replace('hgame_','');
			var my_link = $(this);
			var hr = 1;
			$('#headline_game .headline_holder').addClass('loader');
			$('#next_games_nav_list a').removeClass('sel');
			$('#headline_game .headline_content').fadeOut(function(){
				$('#headline_game .headline_content').load('include/next_games_headline.inc.php',{id:my_id,hr:hr},function(){
					$('#headline_game .headline_holder').removeClass('loader');
					$('#headline_game .headline_content').fadeIn(function(){
						$(my_link).addClass('sel');
						home_headline = 0;
					});
				
				});
			});
		}
		return false;
	});

	$('#headline_nav_list ul li a').live('click',function(){
		var my_id = $(this).attr('id').replace('hbuzz_','');
		load_headline($(this),my_id,1);
		return false;
	});

	$('#home_player_nav_list ul li a').live('click',function(){
		if (home_player==0){
			home_player = 1;
			var ch = $('#home_player_content').outerHeight();
			var my_id = $(this).attr('id').replace('hplayer_','');
			var pr = 1;
			$('#home_player_contenth').css({'height':ch+'px'});
			$('#home_player_contenth').addClass('loader2');
			$('#home_player_content').fadeOut(function(){
				$('#home_player_content').load('include/home_player.inc.php',{id:my_id,pr:pr},function(){
					$('#home_player_contenth').removeClass('loader');
					$('#home_player_content').css({'visibility':'hidden','display':'block'});
					ch = $('#home_player_content').outerHeight();
					$('#home_player_contenth').animate({'height':ch+'px'},function(){
						$('#home_player_content').css({'display':'none','visibility':'visible'});
						$('#home_player_content').fadeIn(function(){
							home_player = 0;
						});				
					});
					
				});
						
			});
		}
		return false;
	});
	
	$('#galleryl_tleft a').live('click',function(){
		if (activity==0){
			activity = 1;
			var count = $('#galleryl_tlist ul li').size();
			var pos = $('#galleryl_tlist ul').css('left').replace('px','');
			var left_count = -pos/150;
			if (left_count>4) left_count = 4;
			if (left_count>0){
				$('#galleryl_tlist ul').animate({'left':'+='+(left_count*150)+'px'},function(){
					activity = 0;
				});
			}
			else{
				activity = 0;
			}
		}
		return false;
	});
	$('#galleryl_tright a').live('click',function(){
		if (activity==0){
			activity = 1;
			var count = $('#galleryl_tlist ul li').size();
			var pos = $('#galleryl_tlist ul').css('left').replace('px','');
			var right_count = count + pos/150 - 4;
			if (right_count>4) right_count = 4;
			if (right_count>0){
				$('#galleryl_tlist ul').animate({'left':'-='+(right_count*150)+'px'},function(){
					activity = 0;
				});
			}
			else{
				activity = 0;
			}
		}
		return false;
	});

	$('#home_games_nav_list ul li a.nav_prev').live('click',function(){
		if (activity==0){
			activity = 1;
			var count = $('#home_games_holderc ul li').size();
			var pos = $('#home_games_holderc ul').css('left').replace('px','');
			var left_count = -pos/160;
			if (left_count>4) left_count = 4;
			if (left_count>0){
				$('#home_games_holderc ul').animate({'left':'+='+(left_count*160)+'px'},function(){
					home_games_navr_count--;
					var current_count = $('#home_games_navr strong').html().split('/');
					var new_count = home_games_navr_count+'/'+current_count[1];
					$('#home_games_navr strong').html(new_count);
					activity = 0;
				});
			}
			else{
				activity = 0;
			}
		}
		return false;
	});

	$('#home_games_nav_list ul li a.nav_next').live('click',function(){
		if (activity==0){
			activity = 1;
			var count = $('#home_games_holderc ul li').size();
			var pos = $('#home_games_holderc ul').css('left').replace('px','');
			var right_count = count + pos/160 - 4;
			if (right_count>4) right_count = 4;
			if (right_count>0){
				$('#home_games_holderc ul').animate({'left':'-='+(right_count*160)+'px'},function(){
					home_games_navr_count++;
					var current_count = $('#home_games_navr strong').html().split('/');
					var new_count = home_games_navr_count+'/'+current_count[1];
					$('#home_games_navr strong').html(new_count);
					activity = 0;
				});
			}
			else{
				activity = 0;
			}
		}
		return false;
	});
	
	if ($('#home_games').length>0){
		$('strong.game_photo').addClass('loader1');
		$('strong.game_photo').each(function(){
			var src = $(this).children('em').html();
			var parent = $(this);
			var img = new Image();
			$(img).load(function (){
				$(this).hide();
				$(parent).html(this);
				$(parent).removeClass('loader1');
				$(this).fadeIn();
			}).error(function () {

			}).attr('src', src);
		});		
	}
	
	$('#form_player_photo_cancel').live('click',function(){
		var album = $('#pphoto_albums').val();
		document.location.href='profile.html?show=photos&album='+album;
		return false;
	});
	
	$('#form_player_album_cancel').live('click',function(){
		document.location.href='profile.html?show=photos';
		return false;
	});

	$('.buzzc_delete').live('click',function(){
		if (confirm('Are you sure ?')){
			var id = $(this).attr('id').replace('buzzc_','');
			$.post('scripts/scr_buzz_commentd.php',{id:id},function(){
				window.location.reload();
			});
		}
		return false;
	});

	$('.gamec_delete').live('click',function(){
		if (confirm('Are you sure ?')){
			var id = $(this).attr('id').replace('gamec_','');
			$.post('scripts/scr_game_commentd.php',{id:id},function(){
				window.location.reload();
			});
		}
		return false;
	});

	$('.pnewsc_delete').live('click',function(){
		if (confirm('Are you sure ?')){
			var id = $(this).attr('id').replace('pnewsc_','');
			$.post('scripts/scr_player_news_commentd.php',{id:id},function(){
				window.location.reload();
			});
		}
		return false;
	});

	$('.buzz_delete').live('click',function(){
		if (confirm('Are you sure ?')){
			var id = $(this).attr('id').replace('buzz_','');
			$.post('scripts/scr_buzz_delete.php',{id:id},function(){
				window.location.reload();
			});
		}
		return false;
	});
	$('.pnews_delete').live('click',function(){
		if (confirm('Are you sure ?')){
			var id = $(this).attr('id').replace('pnews_','');
			$.post('scripts/scr_player_news_delete.php',{id:id},function(){
				window.location.reload();
			});
		}
		return false;
	});
});