// JavaScript Document

// jCarousel

function dekodujAdres(_obj, _sep, _pre, _post){
	if(_obj){
		var _emil=_obj.href.substr(7);
		var _emil2='';
		_sep=_sep.split('').reverse().join('');
		_pre=_pre.substr(_sep.length);
		eval('_pre=String.fromCharCode('+_pre.split(_sep).join()+');');
		_post=_post.substr(_sep.length);
		eval('_post=String.fromCharCode('+_post.split(_sep).join()+');');
		_emil=_emil.substr(_sep.length);
		eval('_emil=String.fromCharCode('+_emil.split(_sep).join()+');');
		_emil2=_emil.substr(_emil.lastIndexOf('.'));
		_emil=_emil.substr(0, _emil.lastIndexOf('.'));
		_emil=_pre.replace('[0-9]', '7')+_emil+_post.replace('[a-z]', 'x');
		_emil=_emil.replace(eval('/'+_pre+'(.)'+_post+'/g'), '$1');
		location.href='mailto:'+_emil+_emil2;
		return false;
	}
	return true;
}

function mycarousel_initCallback(carousel)
{
	
    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });


    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};



jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        auto: 5,
        wrap: 'last',
		visible: 1,
		scroll: 1,
        initCallback: mycarousel_initCallback
    });
});


// end jCarousel


$(document).ready(function(){
	
	//lngBar
	$('div.languageBar div.lng ul#other').hide();

	$('div.languageBar div.lng ul li#current').click(function(){
		//document.getElementById('current').style.display = 'none';
		$('ul#other').toggle('fast');
		return false;
	});
	
	
	
	$('div.languageBar div.lng ul li').mouseover(function(){
		$(this).animate({backgroundColor: '#f3f3f3' }, 10);
		return false;
	});
	
	$('div.languageBar div.lng ul li').mouseout(function(){
		$(this).animate({backgroundColor: '#fdfdfc' }, 10);
		return false;
	});
	
});

function rozwin(id) {
	$("#"+id).slideToggle(200);
}

function pobierzDane (plik, id, kotwica) {
	$("#loading").ajaxStart(function(){    
		$(this).show();  
	});
	$("#loading").ajaxStop(function(){    
		$(this).hide();  
	});
	$.ajax({
   type: "POST",
   url: plik,
   cache: false,
   data: "id="+id,
   success: function(html){
	 $("#loadContent").html(html);
//	 tb_init("a.thickbox, area.thickbox, input.thickbox");
	 document.location.href="#"+kotwica;
   }
 });
}

/* subMenu */
$(document).ready(function(){

//	$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*) 
	$("ul.subnav li a").addClass('sub');
	$("ul.topnav li a").mouseover(function() { //When trigger is clicked...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});

});

