function onPageLoad()
{
	$("a.fancybox").fancybox({
 		'zoomOpacity' : true,
 		'overlayShow' : false,
 		'zoomSpeedIn' : 500,
 		'zoomSpeedOut' : 500
		}); 


		$('#scroller_container').scrollTo(0);
		var scrollCurrentElement = 0;
		var scrollElementMax = $('#scroller').children().length-3;
 		$("#popup_scroll_right").click(function() {
	 		if (scrollCurrentElement+3 >= scrollElementMax) {
 				scrollCurrentElement = scrollElementMax;
	 		} else {
	 			scrollCurrentElement += 3;
	 		}
 			var target = $('.popupElement:eq('+(scrollCurrentElement)+')'); 
 			$('#scroller_container').scrollTo(target, 400, { easing:'easeInOutSine' });
 		});
 		$("#popup_scroll_left").click(function() {
	 		if (scrollCurrentElement-3 <= 0) {
 				scrollCurrentElement = 0;
 				target = 0;
	 		} else {
	 			scrollCurrentElement -= 3;
	 			target = $('.popupElement:eq('+(scrollCurrentElement)+')'); 
	 		}	 			
 			$('#scroller_container').scrollTo(target, 400, { easing:'easeInOutSine' });
 		});	 
 		$("#popup_scroll_right").hover(
 		 		function(){$(this).attr("src","/layout/carusel_right_mouseover.gif")},
 		 		function(){$(this).attr("src", "/layout/carusel_right.gif")}	 		 		
 		);	
 		$("#popup_scroll_left").hover(
 		 		function(){$(this).attr("src","/layout/carusel_left_mouseover.gif")},
 		 		function(){$(this).attr("src", "/layout/carusel_left.gif")}	 		 		
 		);	
 		
 		$("#sp_twitter").click(function() {
 			top.location.href = "http://twitter.com/home?status="+top.location.href;
 		}).css('cursor','pointer');
 		$("#sp_wykop").click(function() {
 			top.location.href = "http://www.wykop.pl/dodaj?url="+top.location.href;
 		}).css('cursor','pointer');
 		$("#sp_facebook").click(function() {
 			top.location.href = "http://www.facebook.com/share.php?u="+top.location.href;
 		}).css('cursor','pointer');
 		$("#sp_delicious").click(function() {
 			top.location.href = "http://del.icio.us/post?url="+top.location.href;
 		}).css('cursor','pointer');		
 		$("#sp_blip").click(function() {
 			top.location.href = "http://blip.pl/dashboard?body="+top.location.href;
 		}).css('cursor','pointer');		 		
}

function contactFormSubmit()
{
	$('.invisible').hide();
	
	if ($("#imie").val()=='') {
		$("#sp_imie").show();
		return false;
	}
	
	if (echeck($("#e-mail").val())==false) {
		$("#sp_e-mail").show();
		return false;
	}
	
	if ($("#temat").val()=='') {
		$("#sp_temat").show();
		return false;
	}	
	
	if ($("#txt").val()=='') {
		$("#sp_txt").show();
		return false;
	}
	
	document.forms.kontakt.action = '/info/send';
	document.forms.kontakt.submit();
}

function echeck(str) {

    var at="@"
    var dot="."
    var lat=str.indexOf(at)
    var lstr=str.length
    var ldot=str.indexOf(dot)
    if (str.indexOf(at)==-1){
       return false
    }

    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
       return false
    }

    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
        return false
    }

     if (str.indexOf(at,(lat+1))!=-1){
        return false
     }

     if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
        return false
     }

     if (str.indexOf(dot,(lat+2))==-1){
        return false
     }

     if (str.indexOf(" ")!=-1){
        return false
     }

     return true
}

