﻿var i=1;

function gallery_pic()
{
	if(i>4)
	{ 
		$("div.image_list").animate({left: '0px' }, 1000);
		i=0;
	}else{ 
		$("div.image_list").animate({left: '-=184px' }, 1000);
		i++;
	}
	 setTimeout("gallery_pic()",6000);
}

function next(w)
{
	if(w>4)
	{ 
		apear();
		w=1;
	}else{ 
		setTimeout("dissapear("+w+")",0);
		$("li.on").removeClass('on').next('li').addClass('on');
		w++; 
	}
	if(w>5) setTimeout("next("+w+")",0);
	else setTimeout("next("+w+")",5000);
}

function dissapear(id) {
	$("div.pic ul li.news"+id).animate({ opacity: 1.0},10).animate({ opacity: 0.0},3000);
	$("#excerpt ul").animate({ top:"-=70"},3000);	
}

function apear() {
	$("#excerpt ul").animate({ top:"+=280"},1000);
	$("div.pic ul li.news1").animate({ opacity: 1.0},600);		
	$("div.pic ul li.news2").animate({ opacity: 1.0},10);		
	$("div.pic ul li.news3").animate({ opacity: 1.0},10);		
	$("div.pic ul li.news4").animate({ opacity: 1.0},10);		
	$("div.pic ul li.news5").animate({ opacity: 1.0},10);		
	$("ul#news_list li").removeClass('on');
	$("ul#news_list li:first").addClass('on');
}

function move_footer()
{
	$('div.slider div').marquee('pointer').mouseover(function () 
	{
		$(this).trigger('stop');
	}).mouseout(function () {
		$(this).trigger('start');	
	});
}

$(document).ready(function()
{		
 	$("a[rel=gallery]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	$("a#log_in").click(function(){ $("div#panel_login").animate({top: '100px' }, 200); });			
	// run	
 	setTimeout("next("+1+")",5000);	
 	setTimeout("gallery_pic()",4000);	
	move_footer();

	//marquee
	$("a.slide_right").click(function(){ $('div.pointer div').animate({left:"+=100px"},100);});	
	$("a.slide_left").click(function(){ $('div.pointer div').animate({left:"-=100px"},200);});	
	
	$("div.exercise a").mouseover(function(){ $(this).children('span').animate({top:"34px"},100);});		
	$("div.exercise a").mouseleave(function(){ $(this).children('span').animate({top:"0px"},100); });		

	$("a.left").click(function(){
		if(i>=1)
		{
			$("div.image_list").animate({left: '+=184px' }, 500);
			i--;
		}		
	});	
	
	$("a.right").click(function(){
		if(i<5)
		{
			$("div.image_list").animate({left: '-=184px' }, 500);
			i++;
		}		
	});			

	$("div#panel_login span img").click(function(){
		$("div#panel_login").animate({top: '-384px' }, 200);
	});	
	
     $("#add_comment").bbedit({
        highlight: true,
        enableSmileybar: false,
        tags: 'b,i,u,s,url'		
      });		
	  
    var f = $('<input type="submit" name="register" value="Rejestruj" class="add" />');
    $('p#button').append(f);	  
	
    var f = $('<input type="submit" name="przypomnienie" value="Przypomnij" class="add" />');
    $('p#button_przy').append(f);	  
	
	var z =$('#odp').attr("value");
	var a = 0;
	$('#sonda ul.list_probe input[type="checkbox"]').click(function(){
		if ($(this).attr('checked')) a++; else a--;
		if(a>=z) $('#sonda input[type="checkbox"]').attr('disabled', true);								
	});			
	
	$('#form').submit(function(){
		 $('#sonda input[type="checkbox"]').removeAttr('disabled');
	});	

		$('.result').click(function(){
			a=0;
			$('input[type="checkbox"]').removeAttr('disabled');
		});	
		
	flowplayer("player", "/layout/flowplayer-3.2.7.swf", {
    clip:  {
        autoPlay: false,
        autoBuffering: true
    }});	
});
