$(document).ready(function () {

	$('.link_month').click(function() {

		$('.kalender_val').html('<center><br><img src="images/loading.gif"></center>');

		var name = $(this).attr('name');

		var date = name.split("-");

		var last_month = parseInt(date[1]) - 1;
		if(last_month == 0){
			last_month = 12;
			last_year = parseInt(date[0]) - 1;
		}else{
			last_year = date[0];
		}

		var next_month = parseInt(date[1]) + 1;

		if(next_month == 13){
			next_month = 1;
			next_year = parseInt(date[0]) + 1;
		}else{
			next_year = date[0];
		}

		$('.kal_last').attr('name', last_year+"-"+last_month);
		$('.kal_next').attr('name', next_year+"-"+next_month);

		var teamID = $('#teamID').val();

		$.get("ajax/calender.php",{ year: date[0], month: date[1], teamID: teamID }, function(data){

			var value = data.split("///");
   			$('.kalender_val').html(value[1]);
			$('.kalender_header').html(value[0]);
  		});

		return false;
	});

	$('#teamsel').change(function() {
		link = $('#teamsel').val();
		location.href=link;
	});

	$('.image').click(function() {

		var id = $(this).attr('id');

		$('.image_'+id).hide();	

	});

	$('.image_close').click(function() {

		var id = $(this).attr('id');

		$('.image_'+id).hide();	

	});

	$('.showPlayerInfo').click( function() {
		var id = $(this).attr('id');
		var teamID = $('#teamID').attr('value');

		$.get("ajax/getPlayerInfo.php",{ id: id, teamID: teamID }, function(data){
			$('#small_info').html(data);
			$('#small_info').show();
		});
	});
});

function nyttFonster(minsajt, namnet, bredd, hojd, scroll) { 
  var venster = (screen.width - bredd) / 2; 
  var uppifroon = (screen.height - hojd) / 2; 
  hurdant = 'width='+bredd+',height='+hojd+',top='+uppifroon+',left='+venster+',scrollbars='+scroll+',resizable' 
  win = window.open(minsajt, namnet, hurdant) 
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } 
} 



function visa(id) { 
  if(document.getElementById) { var obj = document.getElementById(id); } 
  else 
    if(document.all){ var obj = document.all(id); } 
    if(obj.style.display == 'none'){ obj.style.display = ''; } 
    else { obj.style.display = 'none'; } 
}	
